Browse Source

feat:[模板管理][hover画模态框demo]

master
luojie 2 days ago
parent
commit
4d467e9422
2 changed files with 174 additions and 6 deletions
  1. +161
    -2
      src/components/Template/HandleFormItem.vue
  2. +13
    -4
      src/components/Template/icons/Question.vue

+ 161
- 2
src/components/Template/HandleFormItem.vue View File

@ -34,11 +34,41 @@
<!-- qc才能操作 -->
<div class="handle-row" v-if="isShowHandle()">
<el-checkbox class="ml-5"></el-checkbox>
<Question class="handle-icon" :class="getQuestionColor()" />
<div @mouseenter="onMouseEnter" @mouseleave="onMouseLeave">
<Question class="handle-icon" :class="getQuestionColor()" />
</div>
<img v-if="getIsShowCopyIcon()" @click="onCopy" src="@/assets/images/copy-icon.svg" class="handle-icon"
alt="" />
<img src="@/assets/images/record-icon.svg" class="handle-icon" alt="" />
</div>
<!-- 修改记录模态框 -->
<div
v-if="showModal"
ref="modalRef"
class="modification-modal"
@mouseenter="onModalEnter"
@mouseleave="onModalLeave"
>
<div class="modal-content">
<h4>修改记录</h4>
<div class="records-list">
<div
v-for="(record, index) in modificationRecords"
:key="index"
class="record-item"
>
<p><strong>时间:</strong> {{ record.timestamp }}</p>
<p><strong>旧值:</strong> {{ record.oldValue }}</p>
<p><strong>新值:</strong> {{ record.newValue }}</p>
<hr v-if="index < modificationRecords.length - 1">
</div>
<div v-if="!modificationRecords || modificationRecords.length === 0" class="no-records">
暂无修改记录
</div>
</div>
</div>
</div>
</div>
</template>
@ -86,6 +116,24 @@ export default {
return {
inputValue: this.value,
oldValue: this.value, //
showModal: false, //
modificationRecords: [
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
{},
], //
modalTimer: null, //
isHoveringModal: false, //
isHoveringMain: false, //
}
},
watch: {
@ -99,6 +147,13 @@ export default {
},
methods: {
//
onHover() {
},
//
onLeave() {
},
getFillTypeStyle(type) {
const {fillType} = this.item;
const typeObj = {
@ -160,8 +215,9 @@ export default {
isShowHandle() {
const { fillType } = this.item;
const { templateStatus } = this.$store.state.template;
return true;
//qc
return (templateStatus === "qc" || templateStatus === "actFill") && fillType === "actFill";
// return (templateStatus === "qc" || templateStatus === "actFill") && fillType === "actFill";
},
//
getDisabled() {
@ -256,6 +312,20 @@ export default {
// console.error(':', error);
// }
//
const record = {
oldValue: this.oldValue,
newValue: this.inputValue,
timestamp: new Date().toLocaleString(), //
password: password ? '***' : '' //
};
// 20
if (this.modificationRecords.length >= 20) {
this.modificationRecords.shift(); //
}
this.modificationRecords.push(record);
//
this.$emit('modification-recorded', {
field: this.item.label || '',
@ -263,6 +333,48 @@ export default {
newValue: this.inputValue,
password: password
});
},
//
onMouseEnter(event) {
clearTimeout(this.modalTimer);
this.showModal = true;
// DOM
this.$nextTick(() => {
if (this.$refs.modalRef) {
const elementRect = event.target.getBoundingClientRect();
const modalEl = this.$refs.modalRef;
//
modalEl.style.left = elementRect.right + 5 + 'px'; // 5px
modalEl.style.top = elementRect.top + 'px';
}
});
},
//
onMouseLeave() {
//
this.modalTimer = setTimeout(() => {
if (!this.isHoveringModal) {
this.showModal = false;
}
}, 300);
},
//
onModalEnter() {
this.isHoveringModal = true;
clearTimeout(this.modalTimer);
},
//
onModalLeave() {
this.isHoveringModal = false;
this.modalTimer = setTimeout(() => {
this.showModal = false;
}, 300);
}
},
}
@ -418,6 +530,53 @@ export default {
}
}
.modification-modal {
position: fixed;
z-index: 9999;
background-color: rgba(0, 0, 0, 0.7);
border-radius: 4px;
padding: 10px;
color: white;
max-height: 300px;
min-width: 250px;
overflow: hidden;
pointer-events: auto;
}
.modification-modal .modal-content {
max-height: 280px;
overflow-y: auto;
padding-right: 5px;
}
.modification-modal .modal-content h4 {
margin: 0 0 10px 0;
font-size: 14px;
border-bottom: 1px solid #ccc;
padding-bottom: 5px;
}
.modification-modal .records-list {
font-size: 12px;
}
.modification-modal .record-item p {
margin: 5px 0;
word-break: break-all;
}
.modification-modal .record-item hr {
border: 0;
border-top: 1px solid #555;
margin: 8px 0;
}
.modification-modal .no-records {
text-align: center;
color: #aaa;
font-style: italic;
}
.clickable{
cursor: pointer;
width: auto;

+ 13
- 4
src/components/Template/icons/Question.vue View File

@ -1,7 +1,6 @@
<template>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
t="1767342719425" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
<svg @mouseenter="mouseenter" @mouseleave="mouseleave" t="1767342719425" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
fill="currentColor" p-id="1797" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200">
<path
d="M511.51393 63.894216c-114.5315 0-229.061976 43.508933-316.720432 131.167389-174.676321 174.676321-174.676321 458.764542 0 633.440863 87.658456 87.658456 202.188932 131.167389 316.720432 131.167389s229.062999-43.508933 316.720432-131.167389c174.676321-174.676321 174.676321-458.764542 0-633.440863C740.576929 107.403149 626.045429 63.894216 511.51393 63.894216zM511.51393 108.683305c52.466955 0 103.653755 10.237155 151.641699 29.432333 49.907667 20.475334 94.695732 49.907667 133.086088 88.937588 39.029922 38.390355 68.463278 83.179444 88.937588 133.086088 19.195178 47.987944 29.432333 99.174744 29.432333 151.641699s-10.237155 103.653755-29.432333 151.641699c-20.47431 49.907667-49.907667 94.695732-88.937588 133.086088-38.390355 39.029922-83.179444 68.463278-133.086088 88.937588-47.987944 19.195178-99.174744 29.432333-151.641699 29.432333-52.466955 0-103.653755-10.237155-151.641699-29.432333-49.907667-20.475334-94.695732-49.907667-133.086088-88.937588-39.029922-38.390355-68.463278-83.179444-88.937588-133.086088-19.195178-47.987944-29.432333-99.174744-29.432333-151.641699s10.237155-103.653755 29.432333-151.641699c20.475334-49.907667 49.907667-94.695732 88.937588-133.086088 38.390355-39.029922 83.179444-68.463278 133.086088-88.937588C407.860175 118.92046 459.046974 108.683305 511.51393 108.683305z"
@ -10,11 +9,21 @@
d="M511.51393 674.300456c-18.555611 0-34.55091 15.355733-34.55091 34.55091 0 18.555611 15.996322 33.911344 34.55091 33.911344 19.195178 0 34.55091-15.355733 34.55091-33.911344C546.065863 689.657212 530.709107 674.300456 511.51393 674.300456zM512.154519 280.799314c-42.2298 0-76.141144 10.877745-101.734032 33.911344-25.593911 22.394033-41.589211 55.026244-46.707788 97.895611l58.225099 7.0383c4.479011-31.991622 15.355733-55.665811 31.352055-70.381977 15.996322-15.355733 35.831067-22.394033 59.505255-22.394033 24.953322 0 46.068222 8.317433 63.343677 24.953322 16.635889 15.996322 24.953322 35.1915 24.953322 57.585533 0 11.517311-2.559289 23.034623-8.317433 33.271778-5.758144 10.237155-18.555611 23.674189-37.750789 40.949644-19.834744 17.275455-33.271778 30.072923-40.949644 39.029922-9.597589 12.156878-17.275455 24.313755-21.754466 36.470633-6.398734 15.996322-9.597589 35.1915-9.597589 56.945967l0.639566 17.275455 53.746088 0c0.639566-22.394033 1.919722-39.029922 4.479011-48.627511 3.198855-10.237155 7.0383-19.195178 12.796444-26.873044 5.758144-7.677866 17.275455-19.834744 35.831067-35.831067 26.873044-24.313755 45.428655-44.789089 55.026244-61.424978 8.958022-16.635889 14.0766-35.1915 14.0766-55.026244 0-34.55091-13.437034-63.984267-40.310078-88.298022C592.773651 292.956192 556.942585 280.799314 512.154519 280.799314z"
fill="currentColor" p-id="1799"></path>
</svg>
</template>
</template>
<script>
export default {
props: {
},
methods: {
mouseenter() {
this.$emit('mouseenter', true)
},
mouseleave() {
this.$emit('mouseleave', false)
}
}
}
</script>

Loading…
Cancel
Save