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/equipmentScrap/EquipmentScrapForm.vue | 644 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 644 insertions(+), 0 deletions(-) diff --git a/src/views/eam/modules/equipmentScrap/EquipmentScrapForm.vue b/src/views/eam/modules/equipmentScrap/EquipmentScrapForm.vue new file mode 100644 index 0000000..330cf05 --- /dev/null +++ b/src/views/eam/modules/equipmentScrap/EquipmentScrapForm.vue @@ -0,0 +1,644 @@ +<template> + <a-spin :spinning="confirmLoading"> + + <!-- <a-tabs v-model="activeKey" @change="handleChangeTabs">--> + <!--涓昏〃鍖哄煙 --> + <!-- <a-tab-pane tab="璁惧鍙樺姩" :key="refKeys[0]" :forceRender="true" :class="'jeecg-tabs-top'" :animated="false">--> + <j-form-container :disabled="formDisabled"> + <!-- 涓昏〃鍗曞尯鍩� --> + <a-form-model + ref="form" + :model="model" + :rules="validatorRules" + slot="detail" + > + <a-row> + <a-col :span="24"> + <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" + :hidden=true + > + <a-form-model-item + label="鍙樺姩鏂瑰紡" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + prop="changeMethod" + > + <a-input + v-model="model.changeMethod" + placeholder="璇疯緭鍏ュ彉鍔ㄦ柟寮�" + defaultValue="seal" + ></a-input> + </a-form-model-item> + </a-col> + <a-col :span="24"> + <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-tab-pane>--> + +<!-- <a-button--> +<!-- type="primary"--> +<!-- :style="{ marginRight: '8px',marginBottom:'8px' }"--> +<!-- :loading="confirmLoading"--> +<!-- @click="selectEquipmentList()"--> +<!-- >閫夋嫨璁惧--> +<!-- </a-button>--> + + <!--瀛愯〃鍗曞尯鍩� --> +<!-- <a-tab-pane tab="璁惧鎶ュ簾鏄庣粏" :key="refKeys[1]" :forceRender="true">--> +<!-- <j-editable-table--> +<!-- :ref="refKeys[1]"--> +<!-- :loading="equipmentScrapDetailTable.loading"--> +<!-- :columns="equipmentScrapDetailTable.columns"--> +<!-- :dataSource="equipmentScrapDetailTable.dataSource"--> +<!-- :maxHeight="800"--> +<!-- :rowNumber="true"--> +<!-- :rowSelection="true"--> +<!-- :actionButton="false">--> + + +<!-- <template v-slot:action="props">--> +<!-- <a @click="handleDelete(props)">鍒犻櫎</a>--> +<!-- </template>--> +<!-- </j-editable-table>--> +<!-- </a-tab-pane>--> + + <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="equipmentScrapDetailTable.loading" + :columns="equipmentScrapDetailTable.columns" + :dataSource="equipmentScrapDetailTable.dataSource" + :maxHeight="900" + :disabled="formDisabled" + :rowNumber="true" + :rowSelection="true" + :alwaysEdit="true" + :bordered="true" + :toolbar="true" + :toolbarConfig="toolbarConfig" + > + <!-- 璁惧鍥剧墖鎻掓Ы --> + <template v-slot:equipmentPhoto='props'> + <Tooltip + placement="top" + title="棰勮鍥剧墖" + > + <span v-if="!text" style="font-size: 12px;font-style: italic;">鏃犲浘鐗�</span> + <img v-else :src="getImgView(text)" :preview="props.rowId" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/> + </Tooltip> + </template> + <template v-slot:action="props"> + <a-popconfirm title="纭畾鍒犻櫎鍚楋紵" @confirm="handleDL(props)"> + <a>鍒犻櫎</a> + </a-popconfirm> + </template> + + <template slot="toolbarPrefix"> + <a-button type="primary" @click="selectEquipmentList" :disabled="formDisabled">閫夋嫨璁惧 + </a-button> + </template> + </j-vxe-table> + </a-tab-pane> + </a-tabs> + <equipment-select-modal ref="EquipmentSelectModal"></equipment-select-modal> + </a-spin> +</template> + +<script> + +// import { FormTypes, getRefPromise } from '@/utils/JEditableTableUtil' +import { JEditableTableModelMixin } from '@/mixins/JEditableTableModelMixin' +import { randomUUID, randomNumber } from '@/utils/util' +// import JEditableTable from '@/components/jeecg/JEditableTable' +import { validateDuplicateValue } from '@/utils/util' +// import { VALIDATE_NO_PASSED, validateFormModelAndTables } from '@/utils/JEditableTableUtil' +import pick from 'lodash.pick' +import { getAction, postAction, requestPut } from '@api/manage' +import EquipmentSelectModal from './EquipmentSelectModal.vue' +import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js' +import { JVXETypes } from '@/components/jeecg/JVxeTable' +import { getRefPromise, VALIDATE_FAILED } from '@/components/jeecg/JVxeTable/utils/vxeUtils.js' + +import JFormContainer from '@/components/jeecg/JFormContainer' +export default { + name: 'EquipmentScrapForm', + mixins: [JVxeTableModelMixin], + components: { + EquipmentSelectModal, + JFormContainer + }, + data() { + return { + changeMethod: 'scrap', + toolbarConfig: { + // prefix 鍓嶇紑锛泂uffix 鍚庣紑 + slot: ['prefix', 'suffix'], + // add 鏂板鎸夐挳锛況emove 鍒犻櫎鎸夐挳锛沜learSelection 娓呯┖閫夋嫨鎸夐挳 + btn: ['remove', 'clearSelection'] + }, + labelCol: { + xs: { span: 24 }, + sm: { span: 3 } + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 16 } + }, + // 鏂板鏃跺瓙琛ㄩ粯璁ゆ坊鍔犲嚑琛岀┖鏁版嵁 + addDefaultRowNum: 0, + model: {}, + validatorRules: { + num: [ + { required: true, message: '璇疯緭鍏ュ崟鎹彿!' }, + { validator: (rule, value, callback) => validateDuplicateValue('mom_eam_equipment_change', 'num', value, this.model.id, callback) } + ], + remark: [ + { required: false, message: '璇疯緭鍏ュ娉�!' } + ] + }, + refKeys: ['equipmentScrapDetail'], + tableKeys: ['equipmentScrapDetail'], + activeKey: 'equipmentScrapDetail', + // 璁惧鎶ュ簾鏄庣粏 + equipmentScrapDetailTable: { + loading: false, + dataSource: [], + columns: [ + + // { + // title: '鎿嶄綔', + // key: 'action', + // width: '60px', + // type: FormTypes.slot, // 瀹氫箟璇ュ垪涓� 鑷畾涔夋彃鍊煎垪 + // slotName: 'action' // slot 鐨勫悕绉帮紝瀵瑰簲 v-slot 鍐掑彿鍚庨潰鍜岀瓑鍙峰墠闈㈢殑鍐呭 + // }, + { + title: '璁惧鎶ュ簾鍗曟槑缁唅d', + key: 'id', + type: JVXETypes.hidden, + width: '100px', + align:'center', + }, + { + title: '璁惧鍙樺姩鍗昳d', + key: 'equipmentChangeId', + type: JVXETypes.hidden, + width: '200px', + placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + { + title: '璁惧ID', + key: 'equipmentId', + type: JVXETypes.hidden, + disabled: true, + width: '60px', + placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + { + title: '璁惧缂栫爜', + key: 'equipmentNum', + type: JVXETypes.normal, + disabled: true, + width: '200px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + { + title: '璁惧鍚嶇О', + key: 'equipmentName', + type: JVXETypes.normal, + disabled: true, + width: '200px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + + { + title: '璁惧鍨嬪彿', + key: 'model', + type: JVXETypes.normal, + disabled: true, + width: '200px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + { + title: '璁惧瑙勬牸', + key: 'specification', + type: JVXETypes.normal, + disabled: true, + width: '200px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + { + title: '璁惧鐘舵��', + key: 'equipmentStatus_dictText', + type: JVXETypes.normal, + disabled: true, + width: '195px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + { + title: '璧勪骇缂栫爜', + key: 'assetNumber', + type: JVXETypes.normal, + disabled: true, + width: '195px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + { + title: '鎶ュ簾鏃ユ湡', + key: 'scrapDate', + type: JVXETypes.datetime, + width: '200px', + placeholder: '璇烽�夋嫨${title}', + defaultValue: '', + align:'center', + // fixed: 'left', + // 琛ㄥ崟楠岃瘉瑙勫垯 + validateRules: [ + { + required: true, // 蹇呭~ + message: '${title}涓嶈兘涓虹┖' // 鎻愮ず鐨勬枃鏈� + }] + }, + { + title: '鎶ュ簾鍘熷洜', + key: 'scrapReason', + type: JVXETypes.input, + width: '195px', + placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + // fixed: 'left', + // 琛ㄥ崟楠岃瘉瑙勫垯 + validateRules: [ + { + required: true, // 蹇呭~ + message: '${title}涓嶈兘涓虹┖' // 鎻愮ず鐨勬枃鏈� + }] + }, + { + title: '鐗圭璁惧', + key: 'specificEquipment', + type: JVXETypes.hidden, + align:'center', + disabled: true, + width: '200px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '' + }, + { + title: '鐗圭璁惧', + key: 'specificEquipment_dictText', + type: JVXETypes.normal, + disabled: true, + width: '200px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + // { + // title: '璁惧鐘舵��', + // key: 'equipmentStatus', + // type: JVXETypes.select, + // options: [], + // dictCode: 'equipment_status', + // disabled: true, + // width: '200px', + // // placeholder: '璇疯緭鍏�${title}', + // defaultValue: '' + // }, + { + title: '鎶�鏈姸鎬�', + key: 'technologyStatus_dictText', + type: JVXETypes.normal, + disabled: true, + width: '200px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + + { + title: '璁惧浣嶇疆', + key: 'location', + type: JVXETypes.normal, + disabled: true, + width: '200px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + { + title: '閲嶈搴�', + key: 'equipmentImportanceId_dictText', + type: JVXETypes.normal, + disabled: true, + width: '200px', + // placeholder: '璇疯緭鍏�${title}', + defaultValue: '', + align:'center', + }, + // { + // title: '閲嶈搴�', + // key: 'equipmentImportanceId', + // type: JVXETypes.hidden, + // disabled: true, + // width: '200px', + // // placeholder: '璇疯緭鍏�${title}', + // defaultValue: '' + // }, + // { + // title: '璁惧鍥剧墖', + // key: 'equipmentPhoto', + // type: JVXETypes.normal, + // width: '200px', + // // placeholder: '璇疯緭鍏�${title}', + // defaultValue: '' + // } + // { + // title: '璁惧鍥剧墖', + // key: 'equipmentPhoto', + // type: JVXETypes.slot, + // disabled: true, + // width: '200px', + // slotName:'equipmentPhoto', + // align:'center', + + // }, + // { + // title: '鎿嶄綔', + // key: 'action', + // type: JVXETypes.slot, + // disabled: true, + // width: '100px', + // slotName: 'action', + // }, + + ] + }, + + url: { + add: '/eam/equipmentScrap/add', + edit: '/eam/equipmentScrap/edit', + equipmentChange: { + list: '/eam/equipmentScrap/queryById' + }, + equipmentScrapDetail: { + list: '/eam/equipmentScrap/listEquipmentScrapDetailByMainId' + } + } + } + }, + props: { + //琛ㄥ崟绂佺敤 + disabled: { + type: Boolean, + default: false, + required: false + } + }, + computed: { + formDisabled() { + return this.disabled + } + }, + mounted() { + this.$bus.$on('selectionRows', (data) => { + // 澧炲姞閫変腑鐨勮澶囧埌鍒楄〃涓� + this.addSelectedEquipments(data) + + }) + }, + created() { + }, + methods: { + + //閫夋嫨璁惧 + selectEquipmentList() { + let ids = [] + let tableData = this.$refs.equipmentScrapDetail.getTableData() + let deleteData = this.$refs.equipmentScrapDetail.getDeleteData() + for (let i = 0; i < tableData.length; i++) { + ids.push(tableData[i].equipmentId) + } + this.$refs.EquipmentSelectModal.showModals(ids) + this.$refs.EquipmentSelectModal.title = '閫夋嫨璁惧' + this.$refs.EquipmentSelectModal.disableSubmit = false + }, + addSelectedEquipments(data) { + let tableData = this.$refs.equipmentScrapDetail.getTableData() + // const seletedEquipmentIds = tableData. + var tableStr = JSON.stringify(tableData) + const addRows = [] + for (let i = 0; i < data.length; i++) { + var scrapDetail = {} + if (tableStr.indexOf(data[i].id)==-1) { + scrapDetail = { + 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, + equipmentPhoto: data[i].equipmentPhoto, + location: data[i].location, + equipmentImportanceId_dictText: data[i].equipmentImportanceId_dictText, + equipmentImportanceId: data[i].equipmentImportanceId + } + } + addRows.push(scrapDetail) + } + + this.$refs.equipmentScrapDetail.pushRows(addRows) + }, + handleDL(props) { + // 璋冪敤鍒犻櫎鏂规硶 + props.target.removeRows(props.row) + }, + addBefore() { + this.equipmentScrapDetailTable.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 = { equipmentChangeId: this.model.id } + this.requestSubTableData(this.url.equipmentScrapDetail.list, params, this.equipmentScrapDetailTable) + } + }, + //鏍¢獙鎵�鏈変竴瀵逛竴瀛愯〃琛ㄥ崟 + validateSubForm(allValues) { + 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, // 灞曞紑 + equipmentScrapDetailList: allValues.tablesValue[0].tableData + } + }, + /** 纭畾鎸夐挳鐐瑰嚮浜嬩欢 */ + // handleOk() { + // /** 瑙﹀彂琛ㄥ崟楠岃瘉 */ + // 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') + // } + // console.log('this.classifyIntoFormData', typeof this.classifyIntoFormData) + // let formData = this.classifyIntoFormData(allValues) + // + // // 鍙戣捣璇锋眰 + // return this.request(formData) + // }).catch(e => { + // if (e.error === VALIDATE_NO_PASSED) { + // // 濡傛灉鏈夋湭閫氳繃琛ㄥ崟楠岃瘉鐨勫瓙琛紝灏辫嚜鍔ㄨ烦杞埌瀹冩墍鍦ㄧ殑tab + // this.activeKey = e.index == null ? this.refKeys[0] : this.refKeys[e.index + 1] + // } else { + // console.error(e) + // } + // }) + // }, + validateError(msg) { + this.$message.error(msg) + }, + close() { + this.visible = false + this.$emit('close') + this.$refs.form.clearValidate() + }, + // ******************************************** + + /* a 鏍囩鐨勭偣鍑讳簨浠讹紝鍒犻櫎褰撳墠閫変腑鐨勮 */ + handleDelete(props) { + // 鍙傛暟瑙i噴 + // props.index 锛氬綋鍓嶈鐨勪笅鏍� + // props.text 锛氬綋鍓嶅�硷紝鍙兘鏄痙efaultValue瀹氫箟鐨勫�硷紝涔熷彲鑳芥槸浠巇ataSource涓彇鍑虹殑鍊� + // props.rowId 锛氬綋鍓嶉�変腑琛岀殑id锛屽鏋滄槸鏂板琛屽垯鏄复鏃秈d + // props.column 锛氬綋鍓嶆搷浣滅殑鍒� + // props.getValue 锛氳繖鏄竴涓猣unction锛屾墽琛屽悗鍙互鑾峰彇褰撳墠琛岀殑鎵�鏈夊�硷紙绂佹鍦╰emplate涓娇鐢級 + // 渚嬶細const value = props.getValue() + // props.target 锛氳Е鍙戝綋鍓嶄簨浠剁殑瀹炰緥锛屽彲鐩存帴璋冪敤璇ュ疄渚嬪唴鐨勬柟娉曪紙绂佹鍦╰emplate涓娇鐢級 + // 渚嬶細target.add() + + // 浣跨敤瀹炰緥锛氬垹闄ゅ綋鍓嶆搷浣滅殑琛� + let { rowId, target } = props + target.removeRows(rowId) + }, + // 閲嶅啓add 鏂规硶 榛樿涓嶅鍔犱竴琛� + add(num = 0, forceScrollToBottom = false) { + if (num < 1) return + // let timestamp = new Date().getTime() + let rows = this.rows + let row + for (let i = 0; i < num; i++) { + rows = this.push({}, false, rows) + row = rows[rows.length - 1] + } + this.rows = rows + + this.$nextTick(() => { + this.updateFormValues() + }) + // 瑙﹀彂add浜嬩欢 + this.$emit('added', { + row: (() => { + let r = Object.assign({}, row) + r.id = this.getCleanId(r.id) + return r + })(), + target: this + }) + // 璁剧疆婊氬姩鏉′綅缃� + let tbody = this.getElement('tbody') + let offsetHeight = tbody.offsetHeight + let realScrollTop = tbody.scrollTop + offsetHeight + if (forceScrollToBottom) { + this.$nextTick(() => { + this.resetScrollTop(this.$refs.scrollView.scrollHeight) + }) + } + } + + } +} +</script> + +<style scoped> +/** tab panel 涓湁涓嬫媺妗�/鏃ユ湡 杩欑被甯︿笅鎷夋晥鏋滅殑锛岄渶瑕佸姞姝ゆ牱寮� */ +/deep/ .jeecg-tabs-top { + overflow: visible; +} +</style> \ No newline at end of file -- Gitblit v1.9.3