From 92ff846fb659c62037a32b1d8c15eae9df9d9b54 Mon Sep 17 00:00:00 2001 From: zenglf <18502938215@163.com> Date: 星期一, 18 九月 2023 13:24:30 +0800 Subject: [PATCH] Merge branch 'develop' of http://117.34.109.166:18448/r/vue_mdc_430 --- src/views/eam/modules/projectMaintenanceOrder/ProjectMaintenanceOrderForm.vue | 742 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 742 insertions(+), 0 deletions(-) diff --git a/src/views/eam/modules/projectMaintenanceOrder/ProjectMaintenanceOrderForm.vue b/src/views/eam/modules/projectMaintenanceOrder/ProjectMaintenanceOrderForm.vue new file mode 100644 index 0000000..73205d1 --- /dev/null +++ b/src/views/eam/modules/projectMaintenanceOrder/ProjectMaintenanceOrderForm.vue @@ -0,0 +1,742 @@ +<template> + <a-spin :spinning='confirmLoading'> + <j-form-container :disabled='formDisabled'> + <!-- 涓昏〃鍗曞尯鍩� --> + <a-form-model + ref='form' + :model='model' + :rules='validatorRules' + slot='detail' + > + <a-row> + <a-col :span='12'> + <a-form-model-item + label='璁″垝鍗曠紪鍙�' + :labelCol='labelCol' + :wrapperCol='wrapperCol' + prop='num' + > + <a-input + v-model='model.num' + placeholder='璇疯緭鍏ヨ鍒掑崟缂栧彿' + ></a-input> + </a-form-model-item> + </a-col> + <a-col :span='12'> + <a-form-model-item + label='璁″垝鍚嶇О' + :labelCol='labelCol' + :wrapperCol='wrapperCol' + prop='璁″垝鍚嶇О' + > + <a-input + v-model='model.name' + rows='4' + placeholder='璇疯緭鍏ヨ鍒掑悕绉�' + /> + </a-form-model-item> + </a-col> + <a-col :span='12'> + <a-form-model-item + label='璁″垝寮�濮嬫棩鏈�' + :labelCol='labelCol' + :wrapperCol='wrapperCol' + prop='planStartTime' + > + <j-date + placeholder='璇烽�夋嫨璁″垝寮�濮嬫棩鏈�' + v-model='model.planStartTime' + style='width: 100%' + :showTime='true' + dateFormat='YYYY-MM-DD HH:mm:ss' + /> + </a-form-model-item> + </a-col> + <a-col :span='12'> + <a-form-model-item + label='璁″垝缁撴潫鏃ユ湡' + :labelCol='labelCol' + :wrapperCol='wrapperCol' + prop='planEndTime' + > + <j-date + placeholder='璇烽�夋嫨璁″垝缁撴潫鏃ユ湡' + v-model='model.planEndTime' + style='width: 100%' + :showTime='true' + dateFormat='YYYY-MM-DD HH:mm:ss' + /> + </a-form-model-item> + </a-col> + <!-- <a-col :span='12'> + <a-form-model-item label='瀹為檯寮�濮嬫棩鏈�' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='actualStartTime'> + <j-date + placeholder='璇烽�夋嫨瀹為檯寮�濮嬫棩鏈�' + v-model='model.actualStartTime' + style='width: 100%' + :showTime='true' + dateFormat='YYYY-MM-DD HH:mm:ss' + /> + </a-form-model-item> + </a-col> + <a-col :span='12'> + <a-form-model-item label='瀹為檯缁撴潫鏃ユ湡' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='actualEndTime'> + <j-date + placeholder='璇烽�夋嫨瀹為檯寮�濮嬫棩鏈�' + v-model='model.actualEndTime' + style='width: 100%' + :showTime='true' + dateFormat='YYYY-MM-DD HH:mm:ss' + /> + </a-form-model-item> + </a-col> --> + <a-col :span='12'> + <a-form-model-item + label='闄勪欢' + :labelCol='labelCol' + :wrapperCol='wrapperCol' + prop='annex' + > + <j-upload :returnUrl= "false" :isMultiple="false" v-model="model.file" ></j-upload> + </a-form-model-item> + </a-col> + <a-col :span='12'> + <a-form-model-item + label='澶囨敞' + :labelCol='labelCol' + :wrapperCol='wrapperCol' + prop='remark' + > + <a-textarea + v-model='model.remark' + rows='4' + placeholder='璇疯緭鍏ュ娉�' + /> + </a-form-model-item> + </a-col> + + </a-row> + </a-form-model> + </j-form-container> + <!-- 瀛愯〃鍗曞尯鍩� --> + <a-tabs + v-model='activeKey' + @change='handleChangeTabs' + > + <a-tab-pane + tab='椤圭洰鎬х淮淇槑缁�' + :key='refKeys[0]' + :forceRender='true' + > + <j-vxe-table + keep-source + :ref='refKeys[0]' + :loading='projectMaintenanceOrderDetailTable.loading' + :columns='projectMaintenanceOrderDetailTable.columns' + :dataSource='projectMaintenanceOrderDetailTable.dataSource' + :maxHeight='400' + :disabled='formDisabled' + :rowNumber='true' + :rowSelection='true' + :alwaysEdit='true' + :toolbar='true' + :bordered='true' + :toolbarConfig='toolbarConfig' + :linkage-config='linkageConfig' + > + <template slot='toolbarPrefix'> + <a-button + type='primary' + @click='selectEquipmentList' + :disabled='formDisabled' + >閫夋嫨璁惧 + </a-button> + </template> + + <template v-slot:supplierId='props'> + <a-select + v-model='props.row.supplierId' + :options='supplierVoList' + style='width: 100%' + placeholder='璇烽�夋嫨' + @change='(e) => handleChange(e, props.row)' + /> + + </template> + <template v-slot:teamId='props'> + <a-select + v-model='props.row.teamId' + :options='teamVoList' + style='width: 100%' + placeholder='璇烽�夋嫨' + @change='(e) => handleChange(e, props.row)' + /> + + </template> + <template v-slot:userId='props'> + <a-select + v-model='props.row.userId' + :options='userVoList' + style='width: 100%' + placeholder='璇烽�夋嫨' + @change='(e) => handleChange(e, props.row)' + /> + <!-- <a-select + placeholder="璇烽�夋嫨璐d换浜�" + allowClear + showSearch + style='width: 100%' + v-model="props.row.userId" + > + <a-select-option v-for="item of userVoList" :value="item.id" :key="item.id" > + {{item.realname}} + </a-select-option> + </a-select> --> + </template> + </j-vxe-table> + </a-tab-pane> + </a-tabs> + <equipment-select-modal + @selectionRows='selectionRows' + :equipmentStatus="['2', '3']" + ref='EquipmentSelectModal' + ></equipment-select-modal> + </a-spin> +</template> + +<script> + + +import { validateDuplicateValue } from '@/utils/util' +import EquipmentSelectModal from '@/components/tools/EquipmentSelection.vue' + +import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js' +import { JVXETypes } from '@comp/jeecg/JVxeTable' + +import JFormContainer from '@/components/jeecg/JFormContainer' +import { getAction } from '@api/manage' +import { VALIDATE_FAILED, getRefPromise, validateFormAndTables,validateFormModelAndTables} from '@/components/jeecg/JVxeTable/utils/vxeUtils.js' + +export default { + name: 'ProjectMaintenanceOrderForm', + mixins: [JVxeTableModelMixin], + components: { + EquipmentSelectModal, + JFormContainer + }, + data() { + return { + supplierVoList: {}, + userVoList: {}, + teamVoList: {}, + toolbarConfig: { + // prefix 鍓嶇紑锛泂uffix 鍚庣紑 + slot: ['prefix', 'suffix'], + // add 鏂板鎸夐挳锛況emove 鍒犻櫎鎸夐挳锛沜learSelection 娓呯┖閫夋嫨鎸夐挳 + btn: ['remove', 'clearSelection'] + }, + labelCol: { + xs: { span: 24 }, + sm: { span: 6 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 18 } + }, + // 鏂板鏃跺瓙琛ㄩ粯璁ゆ坊鍔犲嚑琛岀┖鏁版嵁 + addDefaultRowNum: 0, + model: {}, + validatorRules: { + num: [ + { required: true, message: '璇疯緭鍏ヨ鍒掔紪鍙�!' }, + { validator: (rule, value, callback) => validateDuplicateValue('mom_eam_project_maintenance_order', 'num', value, this.model.id, callback) } + ], + remark: [ + { required: false, message: '璇疯緭鍏ュ娉�!' } + ] + }, + linkageConfig: [ + { handleVerify: this.handleVerify, key: 'maintenanceAfterUnseal' } + ], + refKeys: ['projectMaintenanceOrderDetail'], + tableKeys: ['projectMaintenanceOrderDetail'], + activeKey: 'projectMaintenanceOrderDetail', + projectMaintenanceOrderDetailTable: { + loading: false, + dataSource: [], + columns: [ + // { + // title: '鎿嶄綔', + // key: 'action', + // width: '60px', + // type: FormTypes.slot, // 瀹氫箟璇ュ垪涓� 鑷畾涔夋彃鍊煎垪 + // slotName: 'action' // slot 鐨勫悕绉帮紝瀵瑰簲 v-slot 鍐掑彿鍚庨潰鍜岀瓑鍙峰墠闈㈢殑鍐呭 + // }, + { + title: '璁惧灏佸瓨鏄庣粏id', + key: 'id', + type: JVXETypes.hidden, + width: '100px', + fixed: 'left' + }, + { + title: '椤圭洰鎬х淮淇崟id', + key: 'projectMaintenanceOrderId', + type: JVXETypes.hidden, + + placeholder: '璇疯緭鍏�${title}', + defaultValue: '' + }, + { + title: '璁惧ID', + key: 'equipmentId', + type: JVXETypes.hidden, + defaultValue: '' + }, + { + title: '浠诲姟缂栫爜', + key: 'taskNum', + type: JVXETypes.input, + width: '180px', + align: "center", + fixed: 'left', + validateRules: [ + { + required: true, // 蹇呭~ + message: '璇疯緭鍏�${title}' // 鏄剧ず鐨勬枃鏈� + }] + }, + { + title: '璁惧缂栫爜', + key: 'equipmentNum', + type: JVXETypes.normal, + width: '140px', + align: "center", + fixed: 'left' + }, + { + title: '璧勪骇缂栫爜', + key: 'assetNumber', + type: JVXETypes.normal, + width: '140px', + align: "center", + fixed: 'left', + defaultValue: '' + }, + { + title: '濮斿鍗曚綅', + key: 'supplierId', + type: JVXETypes.slot, + disabled: true, + width: '140px', + align: "center", + slotName: 'supplierId', + defaultValue: '' + }, + { + title: '濮斿鍗曚綅', + key: 'supplierId', + type: JVXETypes.hidden + }, + { + title: '缁翠繚鏂瑰紡', + key: 'maintenanceMode', + type: JVXETypes.select, + dictCode: 'maintenance_method', + validateRules: [ + { + required: true, // 蹇呭~ + message: '璇疯緭鍏�${title}' // 鏄剧ず鐨勬枃鏈� + }], + width: '140px', + align: "center", + defaultValue: '' + }, + // { + // title: '鐗圭璁惧', + // key: 'specificEquipment', + // type: JVXETypes.hidden, + // disabled: true, + // placeholder: '璇疯緭鍏�${title}', + // defaultValue: '' + // }, + // { + // title: '鐗圭璁惧', + // key: 'specificEquipment_dictText', + // type: JVXETypes.slot, + // disabled: true, + // width: '100px', + // defaultValue: '' + // }, + { + title: '璁惧鍚嶇О', + key: 'equipmentName', + type: JVXETypes.normal, + disabled: true, + width: '140px', + align: "center", + defaultValue: '' + }, + { + title: '璁惧鍨嬪彿', + key: 'model', + type: JVXETypes.normal, + disabled: true, + width: '140px', + align: "center", + defaultValue: '' + }, + { + title: '璁惧瑙勬牸', + key: 'specification', + type: JVXETypes.normal, + disabled: true, + width: '140px', + align: "center", + placeholder: '璇疯緭鍏�${title}', + defaultValue: '' + }, + { + title: '璁惧鐘舵��', + key: 'equipmentStatus_dictText', + type: JVXETypes.normal, + disabled: true, + width: '140px', + align: "center", + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '' + }, + + { + title: '鎶�鏈姸鎬�', + key: 'technologyStatus_dictText', + type: JVXETypes.normal, + disabled: true, + width: '140px', + align: "center", + defaultValue: '' + }, + { + title: '椤圭洰鍐呭', + key: 'itemName', + type: JVXETypes.input, + placeholder: '璇疯緭鍏�${title}', + width: '240px', + validateRules: [{ + required: true, // 蹇呭~ + message: '璇疯緭鍏�${title}' // 鏄剧ず鐨勬枃鏈� + }], + align: "center", + defaultValue: '' + }, + { + title: '绱ф�ョ▼搴�', + key: 'urgency', + type: JVXETypes.select, + dictCode: 'urgency', + placeholder: '璇疯緭鍏�${title}', + width: '140px', + align: "center", + defaultValue: '' + }, + { + title: '璐d换鐝粍', + key: 'teamId', + type: JVXETypes.slot, + disabled: true, + width: '150px', + placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align: "center", + slotName: 'teamId' + }, + { + title: '璐d换鐝粍', + key: 'teamId', + type: JVXETypes.hidden + }, + { + title: '璐d换浜�', + key: 'userId', + type: JVXETypes.slot, + disabled: true, + width: '160px', + placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align: "center", + slotName: 'userId' + }, + { + title: '璐d换浜�', + key: 'userId', + type: JVXETypes.hidden + }, + { + title: '璁″垝寮�濮嬫椂闂�', + key: 'planStartTime', + type: JVXETypes.datetime, + width: '140px', + align: "center", + placeholder: '璇疯緭鍏�${title}', + defaultValue: '' + }, { + title: '璁″垝瀹屾垚鏃堕棿', + key: 'planEndTime', + type: JVXETypes.datetime, + width: '140px', + align: "center", + placeholder: '璇疯緭鍏�${title}', + defaultValue: '' + }, + // { + // title: '瀹為檯寮�濮嬫椂闂�', + // key: 'actualStartTime', + // type: JVXETypes.datetime, + // width: '120px', + // placeholder: '璇疯緭鍏�${title}', + // defaultValue: '' + // }, { + // title: '瀹為檯瀹屾垚鏃堕棿', + // key: 'actualEndTime', + // type: JVXETypes.datetime, + // width: '120px', + // placeholder: '璇疯緭鍏�${title}', + // defaultValue: '' + // } + ] + }, + url: { + add: '/eam/projectMaintenanceOrder/add', + edit: '/eam/projectMaintenanceOrder/edit', + supplierVoList: 'eam/projectMaintenanceOrder/getSupplier', + userVoList: 'eam/projectMaintenanceOrder/getUser', + teamVoList: 'eam/projectMaintenanceOrder/getTeam', + getSupplier: '/eam/projectMaintenanceOrder/getSupplier', + queryById: '/eam/projectMaintenanceOrder/queryById', + projectMaintenanceOrderDetail: { + list: '/eam/projectMaintenanceOrder/queryProjectMaintenanceOrderDetailByMainId' + }, + queryUserByTeamId: '/base/team/queryUserByTeamId' + } + } + }, + props: { + //琛ㄥ崟绂佺敤 + disabled: { + type: Boolean, + default: false, + required: false + } + }, + computed: { + formDisabled() { + return this.disabled + } + }, + created() { + this.getSuppler(); + this.getTeam(); + this.getUser(); + }, + methods: { + + handleOk() { + this.model['annex'] = this.model.file[0].filePath; + /** 瑙﹀彂琛ㄥ崟楠岃瘉 */ + this.getAllTable().then(tables => { + /** 涓�娆℃�ч獙璇佷富琛ㄥ拰鎵�鏈夌殑娆¤〃 */ + return validateFormModelAndTables(this.$refs.form,this.model, tables) + }).then(allValues => { + /** 涓�娆℃�ч獙璇佷竴瀵逛竴鐨勬墍鏈夊瓙琛� */ + return this.validateSubForm(allValues) + }).then(allValues => { + if (typeof this.classifyIntoFormData !== 'function') { + throw this.throwNotFunction('classifyIntoFormData') + } + let formData = this.classifyIntoFormData(allValues) + // 鍙戣捣璇锋眰 + return this.request(formData) + }).catch(e => { + if (e.error === VALIDATE_FAILED) { + // 濡傛灉鏈夋湭閫氳繃琛ㄥ崟楠岃瘉鐨勫瓙琛紝灏辫嚜鍔ㄨ烦杞埌瀹冩墍鍦ㄧ殑tab + this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index] + } else { + console.error(e) + } + }) + }, + + getSuppler() { + getAction(this.url.supplierVoList).then((res) => { + if (res.success) { + this.supplierVoList = res.result + } else { + this.$message.warn(res.message) + } + }) + }, + + getUser() { + getAction(this.url.userVoList).then((res) => { + if (res.success) { + this.userVoList = res.result + } else { + this.$message.warn(res.message) + } + }) + }, + getTeam() { + getAction(this.url.teamVoList).then((res) => { + if (res.success) { + this.teamVoList = res.result + } else { + this.$message.warn(res.message) + } + }) + }, + // handleChangeTeam(value, data) { + // console.log(value) + // this.getUserVoList(value) + // console.log(data) + // this.$nextTick(() => { + // this.$set(data, 'teamId', data.teamId) + // }) + // }, + handleChange(value, data) { + console.log(value) + console.log(data) + this.$nextTick(() => { + this.$set(data, 'supplierId', data.supplierId) + this.$set(data, 'teamId', data.teamId) + this.$set(data, 'userId', data.userId) + }) + }, + getUserVoList(val) { + getAction(this.url.queryUserByTeamId, { teamId: val }).then(res => { + if (res.success) { + this.userVoList = res.result + } + else { + this.$message.error(res.message); + } + }) + }, + handleVerify(parent) { + if (parent == 'Y') { + // 蹇呭~銆� + } + }, + selectionRows(data) { + // 澧炲姞閫変腑鐨勮澶囧埌鍒楄〃涓� + this.addSelectedEquipments(data) + }, + //閫夋嫨璁惧 + selectEquipmentList() { + let ids = [] + let tableData = this.$refs.projectMaintenanceOrderDetail.getTableData() + let deleteData = this.$refs.projectMaintenanceOrderDetail.getDeleteData() + for (let i = 0; i < tableData.length; i++) { + ids.push(tableData[i].equipmentId) + } + this.$refs.EquipmentSelectModal.showModals(ids, tableData) + this.$refs.EquipmentSelectModal.title = '閫夋嫨璁惧' + this.$refs.EquipmentSelectModal.disableSubmit = false + }, + addSelectedEquipments(data) { + let tableData = this.$refs.projectMaintenanceOrderDetail.getTableData() + let tableStr = tableData.toString() + let addRows = [] + for (let i = 0; i < data.length; i++) { + var sealDetail = {} + if (tableStr.indexOf(data[i].id) == -1) { + sealDetail = { + equipmentId: data[i].id, + equipmentNum: data[i].num, + equipmentName: data[i].name, + assetNumber: data[i].assetNumber, + specificEquipment_dictText: data[i].specificEquipment_dictText, + specificEquipment: data[i].specificEquipment, + model: data[i].model, + specification: data[i].specification, + equipmentStatus_dictText: data[i].equipmentStatus_dictText, + equipmentStatus: data[i].equipmentStatus, + technologyStatus_dictText: data[i].technologyStatus_dictText, + technologyStatus: data[i].technologyStatus, + supplierVoList: this.supplierVoList, + userVoList: this.userVoList, + teamVoList: this.teamVoList, + userId: data[i].userId + + } + } + addRows.push(sealDetail) + } + this.$refs.projectMaintenanceOrderDetail.clearAllData() + this.$refs.projectMaintenanceOrderDetail.pushRows(addRows) + }, + addBefore() { + this.projectMaintenanceOrderDetailTable.dataSource = [] + }, + getAllTable() { + let values = this.tableKeys.map(key => getRefPromise(this, key)) + return Promise.all(values) + }, + /** 璋冪敤瀹宔dit()鏂规硶涔嬪悗浼氳嚜鍔ㄨ皟鐢ㄦ鏂规硶 */ + editAfter() { + this.$nextTick(() => { + }) + // 鍔犺浇瀛愯〃鏁版嵁 + if (this.model.id) { + let params = { id: this.model.id } + this.requestSubTableData(this.url.projectMaintenanceOrderDetail.list, params, this.projectMaintenanceOrderDetailTable) + } + }, + //鏍¢獙鎵�鏈変竴瀵逛竴瀛愯〃琛ㄥ崟 + validateSubForm(allValues) { + if (this.$refs.projectMaintenanceOrderDetail.getTableData().length == 0) { + this.$message.warning("璇锋坊鍔犵淮淇槑缁嗭紒") + return + } + return new Promise((resolve, reject) => { + Promise.all([]).then(() => { + resolve(allValues) + }).catch(e => { + if (e.error === VALIDATE_FAILED) { + // 濡傛灉鏈夋湭閫氳繃琛ㄥ崟楠岃瘉鐨勫瓙琛紝灏辫嚜鍔ㄨ烦杞埌瀹冩墍鍦ㄧ殑tab + this.activeKey = e.index == null ? this.activeKey : this.refKeys[e.index] + } else { + console.error(e) + } + }) + }) + }, + /** 鏁寸悊鎴恌ormData */ + classifyIntoFormData(allValues) { + let main = Object.assign(this.model, allValues.formValue) + return { + ...main, // 灞曞紑 + projectMaintenanceOrderDetailList: allValues.tablesValue[0].tableData + } + }, + validateError(msg) { + this.$message.error(msg) + } + + } + +} +</script> + +<style scoped> +/** tab panel 涓湁涓嬫媺妗�/鏃ユ湡 杩欑被甯︿笅鎷夋晥鏋滅殑锛岄渶瑕佸姞姝ゆ牱寮� */ + +::v-deep .jeecg-tabs-top { + overflow: visible; +} + +::v-deep .ant-form-explain { + position: absolute; + right: -50px; + top: 12px; +} +</style> \ No newline at end of file -- Gitblit v1.9.3