| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { getAction, postAction, requestPut } from '@/api/manage' |
| | | |
| | | import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js' |
| | | import ToolsModal from '@views/tms/requirement/modules/ToolsModal.vue' |
| | | import pick from 'lodash.pick' |
| | | import DeviceListModel from '@views/mdc/base/modules/EquipmentList/DeviceListModal.vue' |
| | | |
| | | import { requestPut, postAction, httpAction } from '@/api/manage' |
| | | export default { |
| | | name: 'ToolsSharpeningModal', |
| | | mixins: [JVxeTableModelMixin], |
| | |
| | | lastSelectionData: null, |
| | | url: { |
| | | add: '/tms/toolSharpening/add', |
| | | edit: '/tms/toolSharpening/edit', |
| | | // queryDetailList: '/tms/toolSharpening/listToolSharpening' |
| | | edit: '/tms/toolSharpening/edit' |
| | | } |
| | | } |
| | | }, |
| | |
| | | let that = this |
| | | that.visible = true |
| | | that.model = Object.assign({}, record) |
| | | // this.$nextTick(() => { |
| | | // this.form.setFieldsValue(pick(that.model, 'selectedDeparts', 'selectedProduction', 'equipmentId', 'equipmentName', 'equipmentModel', 'equipmentType', 'equipmentIp', 'dataPort', |
| | | // 'driveType', 'sortNo', 'remark', 'systemVersion', 'devicePower', 'controlSystem', 'saveTableName', 'systemValue')) |
| | | // }) |
| | | }, |
| | | // edit(record) { |
| | | // let that = this |
| | | // that.visible = true |
| | | // that.model = Object.assign({}, record) |
| | | // |
| | | // // 如果有 selectionRows 数据,则重新赋值 |
| | | // if (this.lastSelectionData && this.lastSelectionData.length > 0) { |
| | | // this.assignModelFromSelection(this.lastSelectionData[0]) |
| | | // console.log('this.model',this.assignModelFromSelection(this.lastSelectionData[0])) |
| | | // } |
| | | // }, |
| | | |
| | | close() { |
| | | this.$emit('close') |
| | | this.visible = false |
| | | |
| | | }, |
| | | handleOk() { |
| | | const that = this |
| | | that.confirmLoading = true |
| | | |
| | | // ✅ 触发表单验证 |
| | | // 触发表单验证 |
| | | this.$refs.form.validate(valid => { |
| | | if (valid) { |
| | | let formData = Object.assign(this.model) |
| | | |
| | | let obj |
| | | that.confirmLoading = true |
| | | let httpurl = '' |
| | | let method = '' |
| | | if (!this.model.id) { |
| | | obj = postAction(this.url.add, formData) |
| | | httpurl += this.url.add |
| | | method = 'post' |
| | | } else { |
| | | obj = requestPut(this.url.edit, formData, { id: this.model.id }) |
| | | httpurl += this.url.edit |
| | | method = 'put' |
| | | } |
| | | |
| | | obj.then((res) => { |
| | | httpAction(httpurl, this.model, method,formData).then((res) => { |
| | | if (res.success) { |
| | | that.$message.success(res.message) |
| | | that.$emit('ok') |
| | | that.close() |
| | | } else { |
| | | that.$message.warning(res.message) |
| | | } |
| | | }).finally(() => { |
| | | that.confirmLoading = false |
| | | that.close() |
| | | }) |
| | | } else { |
| | | that.$message.warning('请填写必填字段') |
| | | that.confirmLoading = false |
| | | return false |
| | | } |
| | | }) |
| | | }, |
| | | // handleOk() { |
| | | // const that = this |
| | | // that.confirmLoading = true |
| | | // |
| | | // // ✅ 触发表单验证 |
| | | // this.$refs.form.validate(valid => { |
| | | // if (valid) { |
| | | // let formData = Object.assign(this.model) |
| | | // |
| | | // let obj |
| | | // if (!this.model.id) { |
| | | // obj = postAction(this.url.add, formData) |
| | | // } else { |
| | | // obj = requestPut(this.url.edit, formData, { id: this.model.id }) |
| | | // } |
| | | // |
| | | // obj.then((res) => { |
| | | // if (res.success) { |
| | | // that.$message.success(res.message) |
| | | // that.$emit('ok') |
| | | // that.close() |
| | | // } else { |
| | | // that.$message.warning(res.message) |
| | | // } |
| | | // }).finally(() => { |
| | | // that.confirmLoading = false |
| | | // }) |
| | | // } else { |
| | | // that.$message.warning('请填写必填字段') |
| | | // that.confirmLoading = false |
| | | // return false |
| | | // } |
| | | // }) |
| | | // }, |
| | | |
| | | handleCancel() { |
| | | this.close() |