// import { getCodeCommon } from "@/common.js"; import { getCodeCommon } from '../views/facilityManage/common' const mixin = { data() { return { showOption: false, /** * 字典表数据 */ list: [], show: false, //lodaing loading: false, feildName: '', feild: '', /** * 年份 */ //年份展示 yearShow: false, //获取年份需要给什么字段添加 yearField: '', /** * vuex方法 */ vuexFunc: '', vuexChangeFun: '', datePicker: false, currentDate: new Date(), maxDate: new Date(), minDate: new Date('1980/1/2'), equipTypeOption: { '01':[ {value: "0101", text: "螺杆式空压机"}, {value: "0102", text: "活塞式空压机"}, {value: "0103", text: "离心式空压机"}, {value: "0104", text: "涡旋式空压机"}, {value: "0105", text: "滑片式空压机"}, {value: "0106", text: "无油空压机"}, ], '02':[ {value: "0201", text: "离心泵"}, {value: "0202", text: "轴流泵"}, {value: "0203", text: "混流泵"}, {value: "0204", text: "往复泵"}, {value: "0205", text: "旋转泵"}, {value: "0206", text: "喷射泵"}, {value: "0207", text: "空气提升泵"}, ], '03':[ {value: "0301", text: "离心式风机"}, {value: "0302", text: "轴流式风机"}, {value: "0303", text: "混流式(斜流式)风机"}, {value: "0304", text: "横流式(贯流式)风机"}, {value: "0305", text: "罗茨风机(容积式)"}, ] }, equipEfficiencyOption: [ { value: '01', text: '一级能效'}, { value: '02', text: '二级能效'}, { value: '03', text: '三级能效'}, { value: '04', text: '四级能效'}, { value: '05', text: '五级能效'}, ], element: '', columnsList: [], } }, methods: { // 企业公用弹窗 handelClickOptionShow(name, key){ this.element = name if(key){ this.columnsList = this[name+'Option'][key] }else{ this.columnsList = this[name+'Option'] } this.showOption = true }, onConfirmOption(data){ if(this.$route.params&&this.$route.params.type=='3'){ this.$set(this.form1, this.element, data.value) this.form1[this.element+'Name'] = data.text }else{ this.form[this.element] = data.value this.form[this.element+'Name'] = data.text } this.showOption = false }, //通用的弹框获取数据 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 }, // 日期选择赋值 onConfirmDate(val) { var date2 = new Date(val); var y = date2.getFullYear(); var m = date2.getMonth() + 1; m = m < 10 ? "0" + m : m; var d = date2.getDate(); d = d < 10 ? "0" + d : d; this.form.produceDate = y + "-" + m + "-" + d; console.log(this.form.produceDate); if(this.$route.query&&this.$route.query.id=='heating'){ this.$store.commit('search/SET_HEAT_YEAR', this.form) } if(this.$route.params&&this.$route.params.type=='3'){ this.form1.produceDate = y + "-" + m + "-" + d; } this.datePicker = false; }, // change(data) { // console.log(data); // } } } export default mixin