|
@@ -30,7 +30,7 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- selectValue: this.value,
|
|
|
+ selectValue: [],
|
|
|
options: []
|
|
|
}
|
|
|
},
|
|
@@ -39,16 +39,22 @@ export default {
|
|
|
return this.$store.state.monthlyReportEdit.selectEnum
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ value() {
|
|
|
+ this.init()
|
|
|
+ }
|
|
|
+ },
|
|
|
mounted() {
|
|
|
// this.selectValue = this.value
|
|
|
this.init()
|
|
|
},
|
|
|
methods: {
|
|
|
init() {
|
|
|
- if (this.selectValue && this.selectValue.length) {
|
|
|
+ if (this.value && this.value.length) {
|
|
|
this.options = []
|
|
|
- this.selectValue.forEach(elm => {
|
|
|
+ this.selectValue = this.value.map(elm => {
|
|
|
this.find(elm, 'value')
|
|
|
+ return `${elm}`
|
|
|
})
|
|
|
this.$forceUpdate()
|
|
|
}
|
|
@@ -58,10 +64,14 @@ export default {
|
|
|
for (let i = 0; i < arr.length; i++) {
|
|
|
const elm = arr[i]
|
|
|
if (key === 'value' && `${elm[key]}` === `${id}`) {
|
|
|
- this.$set(this.options, this.options.length, elm)
|
|
|
+ if (this.isHave(`${id}`) < 0) {
|
|
|
+ this.$set(this.options, this.options.length, elm)
|
|
|
+ }
|
|
|
}
|
|
|
if (key === 'label' && `${elm[key]}`.indexOf(`${id}`) > -1) {
|
|
|
- this.$set(this.options, this.options.length, elm)
|
|
|
+ if (this.isHave(`${id}`) < 0) {
|
|
|
+ this.$set(this.options, this.options.length, elm)
|
|
|
+ }
|
|
|
}
|
|
|
if (elm.children) {
|
|
|
run(elm.children)
|
|
@@ -70,6 +80,18 @@ export default {
|
|
|
}
|
|
|
run(this.selectEnum)
|
|
|
},
|
|
|
+ isHave(id) {
|
|
|
+ console.log(id)
|
|
|
+ let itemIndex = -1
|
|
|
+ for (let index = 0; index < this.options.length; index++) {
|
|
|
+ const element = this.options[index]
|
|
|
+ console.log(element)
|
|
|
+ if (`${element.value}` === `${id}`) {
|
|
|
+ itemIndex = index
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return itemIndex
|
|
|
+ },
|
|
|
async remoteMethod(query) { // 获取部门option
|
|
|
if (query !== '') {
|
|
|
this.options = []
|