11 changed files with 270 additions and 77 deletions
-
23src/assets/scss/rq.scss
-
65src/main.js
-
63src/utils/highlight.js
-
15src/views/modules/sampleManagement/technicalSpecificationDetail/com_bm_customerInformation.vue
-
7src/views/modules/sampleManagement/technicalSpecificationDetail/com_bm_demoSlot.vue
-
4src/views/modules/sampleManagement/technicalSpecificationDetail/com_bm_inkMixing.vue
-
4src/views/modules/sampleManagement/technicalSpecificationDetail/com_bm_lamination.vue
-
4src/views/modules/sampleManagement/technicalSpecificationDetail/com_bm_prepress.vue
-
15src/views/modules/sampleManagement/technicalSpecificationDetail/com_bm_routing.vue
-
45src/views/modules/sampleManagement/technicalSpecificationDetail/com_tsd_basicInformation.vue
-
102src/views/modules/sys/dict-data-select-highlight.vue
@ -0,0 +1,63 @@ |
|||
export default { |
|||
bind(el) { |
|||
|
|||
// 获取所有子元素中的 input 和 el-select
|
|||
const inputs = el.querySelectorAll('input'); |
|||
const selects = el.querySelectorAll('.el-select'); |
|||
const textareas = el.querySelectorAll('textarea'); |
|||
|
|||
|
|||
// 处理所有的 input 元素
|
|||
inputs.forEach(inputEl => { |
|||
inputEl.dataset.originalValue = inputEl.value; |
|||
|
|||
inputEl.addEventListener('input', function() { |
|||
const isModified = inputEl.value !== inputEl.dataset.originalValue; |
|||
if (isModified) { |
|||
inputEl.classList.add('highlight'); |
|||
} else { |
|||
inputEl.classList.remove('highlight'); |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
// 处理所有的 textarea 元素
|
|||
textareas.forEach(textareaEl => { |
|||
textareaEl.dataset.originalValue = textareaEl.value; |
|||
|
|||
// 监听 input 事件
|
|||
textareaEl.addEventListener('input', function() { |
|||
const isModified = textareaEl.value !== textareaEl.dataset.originalValue; |
|||
if (isModified) { |
|||
textareaEl.classList.add('highlight'); |
|||
} else { |
|||
textareaEl.classList.remove('highlight'); |
|||
} |
|||
}); |
|||
|
|||
}); |
|||
|
|||
// 处理所有的 el-select 元素
|
|||
selects.forEach(selectEl => { |
|||
const selectComponent = selectEl.__vue__; |
|||
if (!selectComponent) { |
|||
console.warn('Element does not have a Vue instance attached.'); |
|||
return; |
|||
} |
|||
|
|||
selectEl.dataset.originalValue = selectComponent.value; |
|||
|
|||
selectComponent.$on('change', function(value) { |
|||
const selectInputEl = selectEl.querySelector('.el-input__inner'); |
|||
if (selectInputEl) { |
|||
const isModified = value !== selectEl.dataset.originalValue; |
|||
if (isModified) { |
|||
selectInputEl.classList.add('highlight'); |
|||
} else { |
|||
selectInputEl.classList.remove('highlight'); |
|||
} |
|||
} |
|||
}); |
|||
}); |
|||
} |
|||
}; |
|||
@ -0,0 +1,102 @@ |
|||
<template> |
|||
<div v-highlight-container> |
|||
<el-select v-bind="$attrs" v-on="$listeners" :value="value" style="width: 100%" @change="changeDictData"> |
|||
<el-option v-for="(item, index) in options" |
|||
:key="index" :label="item.dictLabel" |
|||
:value="item.dictValue" |
|||
:disabled="item.status === 'N' || disabledOptionsValue.includes(item.dictValue)"> |
|||
<slot :label="item.dictLabel" :value="item.dictValue"></slot> |
|||
</el-option> |
|||
</el-select> |
|||
</div> |
|||
</template> |
|||
<script> |
|||
import {selectDictDataList} from "../../../api/dict"; |
|||
export default { |
|||
name:'dictDataSelect', |
|||
model:{ |
|||
prop:'value', |
|||
event:'change' |
|||
}, |
|||
props:{ |
|||
dictType: { |
|||
type: String, |
|||
}, |
|||
dictTypeList:{ |
|||
type:Array, |
|||
default:()=>[], |
|||
}, |
|||
value:{ |
|||
required: true, |
|||
}, |
|||
useDefaultValue:{ |
|||
type:Boolean, |
|||
default:true, |
|||
}, |
|||
useSite:{ |
|||
type:Boolean, |
|||
default:true, |
|||
}, |
|||
disabledOptionsValue:{ |
|||
type:Array, |
|||
default:()=>[], |
|||
}, |
|||
site:{ |
|||
type:String, |
|||
default:undefined, |
|||
} |
|||
}, |
|||
data () { |
|||
return { |
|||
options: [] |
|||
} |
|||
}, |
|||
created () { |
|||
this.initOption() |
|||
}, |
|||
methods: { |
|||
dictDefaultValue(){ |
|||
// 当value值不存在 并且查询的下拉框存在默认值列,将value赋值为默认 |
|||
if (!this.value && this.options.length > 0){ |
|||
let find = this.options.find(item=>item.isDefault === 'Y'); |
|||
if (find && find.status === 'Y'){ |
|||
this.$emit("change",find.dictValue); |
|||
} |
|||
} |
|||
}, |
|||
//初始化options |
|||
async initOption () { |
|||
// 组合查询条件 |
|||
let params = { |
|||
site:this.useSite?this.$store.state.user.site:"*", |
|||
dictType:this.dictType, |
|||
dictTypeList: this.dictTypeList |
|||
} |
|||
if (this.site){ |
|||
params.site = this.site |
|||
} |
|||
|
|||
try { |
|||
// 等待返回值 |
|||
let {data} = await selectDictDataList(params); |
|||
// 参数赋值 |
|||
if (data && data.code === 0){ |
|||
this.options = data.rows; |
|||
if (this.options.length === 0){ |
|||
this.$emit("change",'') |
|||
} |
|||
} |
|||
if (this.useDefaultValue){ |
|||
this.dictDefaultValue(); |
|||
} |
|||
}catch (e) { |
|||
return Promise.reject(e) |
|||
} |
|||
}, |
|||
// el-select @change事件,修改父组件值 |
|||
changeDictData(val){ |
|||
this.$emit('change',val) |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue