/* * @Author: zhp * @Date: 2024-02-28 09:51:25 * @LastEditTime: 2024-03-15 14:34:29 * @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() { this.dataForm.logTime = this.format(new Date().getTime()) console.log(this.dataForm.logTime); }, mounted () { }, // activated() { // }, methods: { format(dataString) { //dataString是整数,否则要parseInt转换 var time = new Date(dataString); var year = time.getFullYear(); var month = time.getMonth() + 1; var day = time.getDate(); var hour = time.getHours(); var minute = time.getMinutes(); var second = time.getSeconds(); return year + '-' + (month < 10 ? '0' + month : month) + '-' + (day < 10 ? '0' + day : day) + ' ' + (hour < 10 ? '0' + hour : hour) + ':' + (minute < 10 ? '0' + minute : minute) + ':' + (second < 10 ? '0' + second : second) }, 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.getWorksectionById(this.dataForm.lineId) 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() } } }