/* * @Author: zwq * @Date: 2022-08-24 11:19:43 * @LastEditors: zwq * @LastEditTime: 2023-10-08 10:44:25 * @Description: */ export default { data() { /* eslint-disable */ return { urlOptions: { createURL: '', updateURL: '', infoURL: '', codeURL: '', getOption: false, isGetCode: false, optionArrUrl: [], optionArr: {} }, aId: '1696803324030865409', bId: '1698950657556340737', visible: false, setData: false } }, created() { }, activated() { }, methods: { init(id,bPage) { this.dataForm.id = id || ""; this.visible = true; if (this.urlOptions.getOption) { this.getArr() } if(bPage){ this.dataForm.warehouseId = this.bId; }else{ this.dataForm.warehouseId = this.aId; } this.$nextTick(() => { this.$refs["dataForm"].resetFields(); if (this.dataForm.id) { this.urlOptions.infoURL(id).then(response => { this.dataForm = response.data; if (this.setData) { this.setDataForm() } }); } else { if (this.urlOptions.isGetCode) { this.getCode() } } }); }, getCode() { this.urlOptions.codeURL() .then(({ data: res }) => { if (this.urlOptions.codeName) { this.dataForm[this.urlOptions.codeName] = res; } else { this.dataForm.code = res; } }) .catch(() => { }); }, getArr() { const params = { pageSize: 100, pageNo: 1, } this.urlOptions.optionArrUrl.forEach((item, index) => { item(params).then(({ data: res }) => { this.$set(this.urlOptions.optionArr, `arr${index}`, res.list) }) .catch(() => { }); }); }, // 表单提交 dataFormSubmit() { this.$refs["dataForm"].validate((valid) => { if (!valid) { return false; } // 修改的提交 if (this.dataForm.id) { this.urlOptions.updateURL(this.dataForm).then(response => { if(response.data){ this.$modal.msgSuccess("修改成功"); this.visible = false; this.$emit("refreshDataList"); }else{ this.$modal.msgWarning('名称或编码不能重复');; } }); return; } // 添加的提交 this.urlOptions.createURL(this.dataForm).then(response => { if(response.data){ this.$modal.msgSuccess("新增成功"); this.visible = false; this.$emit("refreshDataList"); }else{ this.$modal.msgWarning('名称或编码不能重复');; } }); }); }, formClear() { this.$refs.dataForm.resetFields() } } }