| | |
| | | <template> |
| | | <j-modal |
| | | :title="title" |
| | | :width="800" |
| | | :width="900" |
| | | :visible="visible" |
| | | :confirmLoading="confirmLoading" |
| | | switchFullscreen |
| | | centered |
| | | :mask-closable="false" |
| | | @ok="handleOk" |
| | | @cancel="handleCancel" |
| | | cancelText="关闭" |
| | | > |
| | | |
| | | <a-spin :spinning="confirmLoading"> |
| | | <a-spin :spinning="spinning"> |
| | | <a-form-model |
| | | ref="form" |
| | | :model="model" |
| | | :rules="validatorRules" |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | > |
| | | <a-form-model-item |
| | | :labelCol="labelCol" |
| | |
| | | v-model="model.remark" |
| | | /> |
| | | </a-form-model-item> |
| | | <a-row :gutter="24"> |
| | | <j-vxe-table |
| | | ref="editableDetailTable" |
| | | :rowNumber="true" |
| | | :rowSelection="true" |
| | | :bordered="true" |
| | | :alwaysEdit="true" |
| | | :toolbar="true" |
| | | keep-source |
| | | :height="300" |
| | | :loading="detail.loading" |
| | | :dataSource="detail.dataSource" |
| | | :columns="detail.columns" |
| | | style="margin-top: 8px;" |
| | | /> |
| | | </a-row> |
| | | </a-form-model> |
| | | </a-spin> |
| | | </j-modal> |
| | | </template> |
| | | |
| | | <script> |
| | | import { httpAction, getAction } from '@api/manage' |
| | | import moment from "moment" |
| | | import { getAction, httpAction } from '@/api/manage' |
| | | import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js' |
| | | import { JVXETypes } from '@/components/jeecg/JVxeTable' |
| | | |
| | | export default { |
| | | name: "EamSparePartRequisitionModal", |
| | | name: 'EamSparePartIntoModal', |
| | | mixins: [JVxeTableModelMixin], |
| | | components: {}, |
| | | data() { |
| | | return { |
| | | title: "操作", |
| | | title: '操作', |
| | | visible: false, |
| | | model: {}, |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 5 }, |
| | | sm: { span: 6 } |
| | | }, |
| | | wrapperCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 16 }, |
| | | sm: { span: 15 } |
| | | }, |
| | | |
| | | confirmLoading: false, |
| | | spinning: false, |
| | | disabled: false, |
| | | validatorRules: {}, |
| | | url: { |
| | | //add: '/eam/eamSparePartInventory/add', |
| | | //edit: '/eam/eamSparePartInventory/edit', |
| | | add: "/eam/eamSparePartRequisition/add", |
| | | edit: "/eam/eamSparePartRequisition/edit", |
| | | getDetails: "/eam/eamSparePartRequisitionDetail/list", |
| | | generateRequisitionCode: "sys/sysBusinessCodeRule/generateBusinessCodeSeq" |
| | | }, |
| | | detail: { |
| | | loading: false, |
| | | dataSource: [], |
| | | columns: [ |
| | | { |
| | | title: '备件', |
| | | key: 'partId', |
| | | type: JVXETypes.select, |
| | | width: '30%', |
| | | align: 'center', |
| | | dictCode: 'eam_spare_parts,part_name,id, del_flag!=\'1\'', |
| | | validateRules: [ |
| | | { required: true, message: '备件不能为空!' } |
| | | ] |
| | | }, |
| | | // { |
| | | // title: '批次号', |
| | | // key: 'batchNum', |
| | | // type: JVXETypes.input, |
| | | // width: '10%', |
| | | // align: 'center', |
| | | // validateRules: [ |
| | | // { required: true, message: '批次号不能为空!' } |
| | | // ] |
| | | // }, |
| | | { |
| | | title: '数量', |
| | | key: 'requisitionNum', |
| | | type: JVXETypes.inputNumber, |
| | | width: '30%', |
| | | align: 'center', |
| | | validateRules: [ |
| | | { required: true, message: '数量不能为空!' } |
| | | ] |
| | | }, |
| | | // { |
| | | // title: '出厂日期(生产日期)', |
| | | // key: 'manufactureDate', |
| | | // type: JVXETypes.datetime, |
| | | // width: '16%', |
| | | // align: 'center', |
| | | // validateRules: [ |
| | | // { required: false, message: '出厂日期(生产日期)不能为空!' } |
| | | // ] |
| | | // }, |
| | | |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | created() { |
| | | }, |
| | | methods: { |
| | | add() { |
| | | |
| | | const that = this |
| | | this.visible = true; |
| | | let params = { |
| | | businessCode: "SpareRequisitionCodeRule" |
| | | } |
| | |
| | | }, |
| | | edit(record) { |
| | | this.model = Object.assign({}, record); |
| | | this.detail.dataSource = record.sparePartRequisitionDetails |
| | | this.visible = true; |
| | | }, |
| | | close() { |
| | | this.$emit('close'); |
| | | this.visible = false; |
| | | this.$refs.form.clearValidate(); |
| | | }, |
| | | handleOk() { |
| | | const that = this; |
| | | |
| | | async handleOk() { |
| | | const that = this |
| | | let errMap = await that.$refs.editableDetailTable.validateTable() |
| | | if (errMap) { |
| | | this.$message.warning('数据校验失败!') |
| | | return |
| | | } |
| | | // 触发表单验证 |
| | | this.$refs.form.validate(valid => { |
| | | if (valid) { |
| | | that.confirmLoading = true; |
| | | let httpurl = ''; |
| | | let method = ''; |
| | | let tableData = that.$refs.editableDetailTable.getTableData() |
| | | let removeData = that.$refs.editableDetailTable.getDeleteData() |
| | | that.model.sparePartRequisitionDetails = [...tableData] |
| | | that.model.removeDetailList = [...removeData] |
| | | |
| | | that.confirmLoading = that.spinning = true |
| | | let httpurl = '' |
| | | let method = '' |
| | | if (!this.model.id) { |
| | | httpurl += this.url.add; |
| | | method = 'post'; |
| | | httpurl += this.url.add |
| | | method = 'post' |
| | | } else { |
| | | httpurl += this.url.edit; |
| | | method = 'put'; |
| | | httpurl += this.url.edit |
| | | method = 'put' |
| | | } |
| | | httpAction(httpurl, this.model, method).then((res) => { |
| | | |
| | | if (res.success) { |
| | | that.$message.success(res.message); |
| | | that.$emit('ok'); |
| | | that.$message.success(res.message) |
| | | that.$emit('ok') |
| | | that.close() |
| | | } else { |
| | | that.$message.warning(res.message); |
| | | that.$message.warning(res.message) |
| | | } |
| | | }).finally(() => { |
| | | that.confirmLoading = false; |
| | | that.close(); |
| | | that.confirmLoading = that.spinning = false |
| | | }) |
| | | } else { |
| | | return false; |
| | | return false |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | |
| | | |
| | | handleCancel() { |
| | | this.close() |
| | | }, |
| | | |
| | | close() { |
| | | this.$emit('close') |
| | | this.visible = false |
| | | this.$refs.form.clearValidate() |
| | | } |
| | | } |
| | | } |
| | | </script> |