Commit ba51dd98 by yangxiaolei

inputCurrency 增加依赖收集功能

parent 169002c7
<template>
<el-input :class="{'redClass':red && isDisable}" v-storeModify :id="id" ref="form-item" v-model="model" v-bind="attrs" v-on="$listeners" v-bind:disabled="isDisable">
<el-input :class="{'redClass':red && isDisplay}" v-storeModify :id="id" ref="form-item" v-model="model" v-bind="attrs" v-on="$listeners" v-bind:disabled="isDisable">
<template v-slot:suffix>
<slot name="suffix"></slot>
</template>
......@@ -76,6 +76,11 @@ export default {
return this.mode === 'display' || this.disabled
}
},
isDisplay: {
get () {
return this.mode === 'display'
}
},
highlight () {
return this.$store.state.Status.highlights.indexOf(this.id) !== -1
},
......
<template>
<el-input
:id="id"
v-storeModify
:class="{'redClass':isDisplay && isDisable}"
ref="form-item"
class="m-input-currency"
v-model="model"
......@@ -15,6 +17,44 @@
<script>
import BigNumber from "bignumber.js";
export default {
inject: ["root"],
directives:{
storeModify:{
update(el,bind,vnode){
let _this = vnode.context
let key = vnode.parent.data.model.expression
let keyArray = key.split('.')
let curKey = keyArray.pop()
let resultKey = keyArray.join(".")
let deepData = _this.getProperty(resultKey,_this.root)
if(deepData && Array.isArray(deepData.modifySet)){
if(deepData.modifySet.includes(curKey)){
_this.red = true
}
}
el.onchange = (...args)=>{
console.log("12")
if(deepData.modifySet){
if(Array.isArray(deepData.modifySet)){
if(deepData.modifySet.includes(curKey)){
return
}
deepData.modifySet.push(curKey)
}
} else {
deepData.modifySet = [curKey]
}
}
}
}
},
data(){
return {
red:false
}
},
props: {
value: {
type: [String, Number],
......@@ -69,6 +109,11 @@ export default {
get() {
return this.mode === "display" || this.disabled;
}
},
isDisplay: {
get () {
return this.mode === 'display'
}
}
},
methods: {
......@@ -153,6 +198,15 @@ export default {
}
return this.value;
},
getProperty(str, value) {
let keys = str?.split('.')
for (let key of keys) {
if (value) {
value = value[key]
}
}
return value
},
formatValue(value) {
if (value !== null && value !== undefined && value.toString) {
var temp = value
......@@ -211,7 +265,11 @@ export default {
};
</script>
<style>
<style lang="less" scoped>
.redClass /deep/ .el-input__inner{
border-color: red;
}
/* .el-input.highlight .el-input__inner{
border-color: red;
} */
......
<template>
<el-input-number :id="id" :class="{'highlight': highlight}" ref="form-item" v-model="model" :controls="false" v-bind="$attrs" v-on="$listeners" v-bind:disabled="isDisable"/>
<el-input-number :id="id" v-storeModify :class="{'highlight': highlight,'redClass':red && isDisable}" ref="form-item" v-model="model" :controls="false" v-bind="$attrs" v-on="$listeners" v-bind:disabled="isDisable"/>
</template>
<script>
export default {
inject: ["root"],
directives:{
storeModify:{
update(el,bind,vnode){
let _this = vnode.context
let key = vnode.parent.data.model.expression
let keyArray = key.split('.')
let curKey = keyArray.pop()
let resultKey = keyArray.join(".")
let deepData = _this.getProperty(resultKey,_this.root)
if(deepData && Array.isArray(deepData.modifySet)){
if(deepData.modifySet.includes(curKey)){
_this.red = true
}
}
el.onchange = (...args)=>{
if(deepData.modifySet){
if(Array.isArray(deepData.modifySet)){
if(deepData.modifySet.includes(curKey)){
return
}
deepData.modifySet.push(curKey)
}
} else {
deepData.modifySet = [curKey]
}
}
}
}
},
data(){
return {
red:false
}
},
props: {
value: {
type: Number,
......@@ -38,14 +75,28 @@ export default {
highlight () {
return this.$store.state.Status.highlights.indexOf(this.id) !== -1
}
},
methods:{
getProperty(str, value) {
let keys = str?.split('.')
for (let key of keys) {
if (value) {
value = value[key]
}
}
return value
}
}
}
</script>
<style scope>
<style lang="less" scoped>
.el-input-number .el-input__inner {
text-align: left;
}
.el-input.highlight .el-input__inner{
border-color: red;
}
.redClass /deep/ .el-input__inner{
border-color: red;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment