// import { getCodeCommon } from "@/common.js"; import { getCodeCommon } from '../views/facilityManage/common' const mixin = { data() { return { /** * 字典表数据 */ list: [], show: false, //lodaing loading: false, feildName: '', feild: '', /** * 年份 */ //年份展示 yearShow: false, //获取年份需要给什么字段添加 yearField: '', /** * vuex方法 */ vuexFunc: '', vuexChangeFun: '' } }, methods: { //通用的弹框获取数据 async handelClickHeatingShow(type, id, feildName, feild, title) { this.show = !this.showForm this.loading = true // this.vuexChangeFun = vuexfun this.feildName = feildName this.feild = feild const data = { id: id, type: type } let str1 = "1,2,3,4" let str2 = "5,6,7" try { const res = await getCodeCommon(data) if(title) { switch (title) { case 'kt': this.list = res.filter((ele)=> str1.indexOf(ele.code) != -1) break; case 'lqt': console.log(res); this.list = res.filter((ele)=> str2.indexOf(ele.code) != -1) break; default: break; } } else { this.list = res } } finally { this.loading = false } }, onConfirm(data) { this.formColumns.refrigeType = data.code this.formColumns.refrigeTypeName = data.text this.formColumns[this.feildName] = data.text this.form[this.feild] = data.value this.show = false if (this.vuexChangeFun) { const name = `search/${this.vuexChangeFun}` const info = { name: this.feild, data } this.$store.commit(name, info) } }, onCancel() { this.show = false }, //点击获取设备是否改造选中的值 onConfirmTrueFalse(obj) { console.log(obj,333); if(obj.info.value != 1) { for (const key in this.notData) { if(obj.field == key) { this.notData[key].formField.forEach((v)=>{ this.form[v] = '' }) this.notData[key].formColumnsField.forEach((v)=>{ this.formColumns[v] = '' }) this.notData[key].isShow.forEach((v)=>{ this[v] = false }) if(this.notData[key].list) { this.notData[key].list.forEach((v)=> { v.checked = false this.spliceList.push(v) }) this.resultList = [] } if(this.notData[key].setStore) { const list = this.notData[key].formField.filter((ele)=> ele != 'modifyMode') const yearData = { } list.forEach((v)=> { yearData[v] = '' }) this.$store.commit(`search/${this.notData[key].setStore}`,yearData) } if(this.notData.charging && this.notData.charging.disList) { this.notData.charging.disList.forEach((v)=> { v.checked = false this.resultSpliceDevice.push(v) }) this.resultCheckboxDevice = [] } } } this.required = false } if(obj.special == '1' && obj.info.value == '1') { this.required = true } else { this.required = false } const fieldName = obj.field + 'Name' this.formColumns[fieldName] = obj.info.text this.form[obj.field] = obj.info.value console.log(this.form) }, //点击年份展示弹框 handelClickYear(name, func) { this.yearShow = !this.showForm this.yearField = name console.log(name); this.vuexFunc = func }, //控制年份确认 onConfirmYear(obj) { this.form[this.yearField] = obj.value console.log(this.yearField,this.form[this.yearField]); this.yearShow = false if (!this.vuexFunc) { return } const name = `search/${this.vuexFunc}` this.$store.commit(name, this.form) }, //控制年份取消 onCancelYear() { this.yearShow = false } // change(data) { // console.log(data); // } } } export default mixin