/* * @Author: zhp * @Date: 2024-02-28 09:51:25 * @LastEditTime: 2024-03-08 13:46:46 * @LastEditors: zhp * @Description: */ export default { data() { /* eslint-disable */ return { urlOptions: { createURL: '', updateURL: '', infoURL: '', codeURL: '', getOption: false, isGetCode: false, optionArrUrl: [], optionArr: {} }, visible: false, setData: false } }, created() { }, activated() { }, methods: { init(id) { this.dataForm.id = id || ""; this.visible = true; if (this.urlOptions.getOption) { this.getArr() } this.$nextTick(() => { this.$refs["dataForm"].resetFields(); if (this.dataForm.id) { this.urlOptions.infoURL(id).then(response => { console.log(response) this.dataForm = response.data this.dataForm.detId = response.data.detIdList this.dataForm.logTime = new Date(response.data.logTime) // if (this.setData) { // this.setDataForm() // } }); } else { if (this.urlOptions.isGetCode) { this.getCode() } } }); }, getCode() { this.urlOptions.codeURL() .then(({ data: res }) => { 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; } // 修改的提交 let str = this.dataForm.detId.join(',') this.dataForm.detId = str if (this.dataForm.id) { this.urlOptions.updateURL(this.dataForm).then(response => { this.$modal.msgSuccess("修改成功"); this.visible = false; this.$emit("refreshDataList"); }); return; } // 添加的提交 this.urlOptions.createURL(this.dataForm).then(response => { this.$modal.msgSuccess("新增成功"); this.visible = false; this.$emit("refreshDataList"); }); }); }, formClear() { this.$refs.dataForm.resetFields() } } }