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/dailyInspectionStandard/DailylnspectionStandardModal.vue | 649 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 649 insertions(+), 0 deletions(-) diff --git a/src/views/eam/modules/dailyInspectionStandard/DailylnspectionStandardModal.vue b/src/views/eam/modules/dailyInspectionStandard/DailylnspectionStandardModal.vue new file mode 100644 index 0000000..4c933fc --- /dev/null +++ b/src/views/eam/modules/dailyInspectionStandard/DailylnspectionStandardModal.vue @@ -0,0 +1,649 @@ +<template> + <a-modal + :title="title" + :width="1250" + :visible="visible" + :maskClosable="false" + @ok="handleOk" + cancelText="鍏抽棴" + @cancel="handleCancel" + :confirmLoading="confirmLoading" + > + + <a-spin :spinning="confirmLoading"> + <a-form :form="form"> + + <!-- title="宸ヨ壓璺緞鍩烘湰淇℃伅" --> + <a-row :gutter="24"> + <a-col :span="12"> + <a-form-item + label="鐐规鏍囧噯缂栫爜" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="codeDisable" + :placeholder="disableSubmit?'':'璇疯緭鍏ョ偣妫�鏍囧噯缂栫爜'" + v-decorator="['num', validatorRules.num ]" + /> + </a-form-item> + </a-col> + <a-col :span="12"> + <a-form-item + label="瀵硅薄閮ㄩ棬" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <!-- <a-input-search + :disabled="disableSubmit" + placeholder="璇烽�夋嫨瀵硅薄閮ㄩ棬" + enter-button + @search="onDepartList()" + :read-only="true" + v-decorator="['useDepartName', validatorRules.useDepartName]" + /> --> + <a-tree-select + style="width: 100%" + :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" + :tree-data="treeData" + placeholder="璇烽�夋嫨瀵硅薄閮ㄩ棬" + tree-default-expand-all + v-decorator="['useId', validatorRules.useId ]" + /> + </a-form-item> + </a-col> + </a-row> + <a-row :gutter="24"> + <a-col :span="12"> + <a-form-item + label="璁惧鍚嶇О" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input-search + :disabled="disableSubmit" + placeholder="璇烽�夋嫨璁惧" + enter-button + @search="onEquipmentList()" + :read-only="true" + v-decorator="['equipmentName', validatorRules.equipmentName]" + /> + </a-form-item> + </a-col> + <a-col :span="12"> + <a-form-item + label="璐d换鐝粍" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="true" + :placeholder="disableSubmit?'':'璇疯緭鍏ヨ矗浠荤彮缁�'" + v-decorator="['teamName', validatorRules.teamName ]" + /> + </a-form-item> + </a-col> + </a-row> + <a-row + hidden + :gutter="24" + > + <a-col :span="12"> + <a-form-item + label="璁惧Id" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="true" + :placeholder="disableSubmit?'':'璇疯緭鍏ヨ澶囩紪鐮�/鍚嶇О/鍨嬪彿'" + v-decorator="['equipmentId', validatorRules.equipmentId ]" + /> + </a-form-item> + </a-col> + <!-- <a-col :span="12"> + <a-form-item + label="瀵硅薄閮ㄩ棬Id" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allow-clear + :disabled="true" + :placeholder="disableSubmit?'':'璇疯緭鍏ュ璞¢儴闂╥d'" + v-decorator="['useId', validatorRules.useId ]" + /> + </a-form-item> + </a-col> --> + </a-row> + <a-row :gutter="24"> + <a-col :span="12"> + <a-form-item + label="娲惧伐鏂瑰紡" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <j-dict-select-tag + allow-clear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇烽�夋嫨娲惧伐鏂瑰紡'" + :triggerChange="true" + dictCode="assign_mode" + v-decorator="['assignMode', validatorRules.assignMode]" + /> + </a-form-item> + </a-col> + <a-col :span="12"> + <a-form-item + label="鐗堟湰" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allowClear + :disabled="true" + :placeholder="disableSubmit?'':'璇疯緭鍏ョ増鏈彿'" + v-decorator="[ 'version', validatorRules.version]" + /> + </a-form-item> + </a-col> + </a-row> + <a-row :gutter="24"> + <a-col + v-if="this.isRevise == true" + :span="12" + > + <a-form-item + label="鍘嗗彶鐗堟湰" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <a-input + allowClear + :disabled="true" + :placeholder="disableSubmit?'':'璇疯緭鍏ュ巻鍙茬増鏈彿'" + v-decorator="[ 'historyVersion', validatorRules.historyVersion]" + /> + </a-form-item> + </a-col> + </a-row> + <a-row :gutter="24"> + <a-col :span="24"> + <a-form-item + label="澶囨敞" + :labelCol="{span:3}" + :wrapperCol="{span:21}" + > + <a-textarea + allowClear + :disabled="disableSubmit" + :placeholder="disableSubmit?'':'璇疯緭鍏ュ娉�'" + v-decorator="[ 'remark', validatorRules.remark]" + /> + </a-form-item> + </a-col> + </a-row> + </a-form> + </a-spin> + <a-button + type="primary" + :style="{ marginRight: '8px',marginBottom:'8px' }" + :loading="confirmLoading" + @click="selectInspectionProjects()" + >鐐规椤圭洰</a-button> + <a-table + ref="table" + bordered + size="middle" + rowKey='id' + :columns="columns" + :dataSource="dataSource" + > + <template + v-for="col in columns" + :slot="col.dataIndex" + slot-scope='text, record, index' + > + <div :key="col.dataIndex"> + <a-select + v-if="col.dataIndex == 'inspectionCycleId'" + :value="text" + :options="record.inspectionCycles" + @change="(e) => handleChange(e, record.key, col, index)" + style="width: 100%" + :disabled="false" + /> + <j-image-upload + :value="text" + v-if="col.dataIndex == 'photo'" + :isMultiple="false" + auto-size + placeholder="璇蜂笂浼犲浘鐗�" + @change="(e)=>handleChange(e, record.key, col, index)" + > + </j-image-upload> + <a-input + :value="text" + v-if="col.dataIndex == 'location'" + :maxLength="32" + auto-size + placeholder="璇疯緭鍏ラ儴浣�" + @change="(e)=>handleChange(e, record.key, col, index)" + /> + </div> + </template> + + <span + slot="action" + slot-scope="text, record, index" + > + <a-popconfirm + title="纭畾鍒犻櫎鍚�?" + @confirm="() => handleDelete(text,record, index)" + > + <a>鍒犻櫎</a> + </a-popconfirm> + </span> + </a-table> + <template slot="footer"> + <a-button + :style="{marginRight: '8px'}" + @click="handleCancel()" + > + 鍏抽棴 + </a-button> + + <a-button + @click="handleOk()" + type="primary" + :loading="confirmLoading" + >纭畾</a-button> + </template> + + <equipment-list + ref="EquipmentList" + @sendEquipmentRecord='sendEquipmentRecord' + ></equipment-list> + + <depart-list + ref="DepartList" + @sendDepartRecord='sendDepartRecord' + ></depart-list> + + <j-select-dailylnspection-standard-modal ref="inspectionStandardModalForm"></j-select-dailylnspection-standard-modal> + </a-modal> + +</template> + +<script> +import { getAction, postAction, requestPut } from '@/api/manage' +import pick from 'lodash.pick' +import JMultiSelectTag from '@/components/dict/JMultiSelectTag' +import { duplicateCheck } from '@/api/api' +import Tooltip from 'ant-design-vue/es/tooltip' +import JSelectDailylnspectionStandardModal from './JSelectDailylnspectionStandardModal' +import EquipmentList from './EquipmentList' +import DepartList from './DepartList' + +export default { + name: "DailylnspectionStandardModal", + components: { + JMultiSelectTag, + Tooltip, + JSelectDailylnspectionStandardModal, + EquipmentList, + DepartList + }, + data() { + return { + columns: [ + { + title: '#', + dataIndex: '', + key: 'rowIndex', + align: 'center', + customRender: function (t, r, index) { + return parseInt(index) + 1 + }, + width: 50, + }, + { + title: '鐐规椤圭洰', + align: 'center', + dataIndex: 'name' + }, + { + title: '妫�娴嬫爣鍑�', + align: 'center', + dataIndex: 'detectionStandard' + }, + { + title: '鍚堟牸鑼冨洿', + align: 'center', + dataIndex: 'acceptabilityLimit' + }, + { + title: '鏂规硶', + align: 'center', + dataIndex: 'inspectionMethodName' + }, + { + title: '宸ュ叿', + align: 'center', + dataIndex: 'inspectionTool' + }, + { + title: '鍛ㄦ湡', + align: 'center', + dataIndex: 'inspectionCycleId', + scopedSlots: { customRender: 'inspectionCycleId' }, + width: 170, + }, + { + title: '绀烘剰鍥�', + align: 'center', + dataIndex: 'photo', + scopedSlots: { customRender: 'photo' }, + width: 170, + }, + { + title: '閮ㄤ綅', + align: 'center', + dataIndex: 'location', + scopedSlots: { customRender: 'location' }, + width: 170, + }, + { + title: '鎿嶄綔', + align: 'center', + dataIndex: 'action', + scopedSlots: { + customRender: 'action' + }, + } + ], + title: "鎿嶄綔", + visible: false, + disableSubmit: false, + codeDisable: true, + isRevise: false, + model: {}, + inspectionCycles: {}, + treeData: [], + labelCol: { + xs: { span: 24 }, + sm: { span: 6 }, + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 18 }, + }, + confirmLoading: false, + form: this.$form.createForm(this), + validatorRules: { + num: { + rules: [ + { required: true, message: '璇疯緭鍏ョ偣妫�鏍囧噯缂栫爜!' }, + ] + }, + equipmentName: { + rules: [ + { required: true, message: '璇烽�夋嫨璁惧!' }, + // { validator: this.validateEquipmentId }, + ] + }, + assignMode: { + rules: [ + { required: true, message: '璇烽�夋嫨娲惧伐鏂瑰紡!' }, + ] + }, + version: { + rules: [ + { required: true, message: '璇疯緭鍏ョ増鏈�!' }, + ] + }, + historyVersion: { + rules: [ + { required: true, message: '璇疯緭鍏ュ巻鍙茬増鏈�!' }, + ] + }, + }, + url: { + add: "/eam/inspectionStandard/add", + edit: "/eam/inspectionStandard/edit", + getInspectionCycle: "/eam/inspectionStandardDetail/getInspectionCycle", + revise: '/eam/inspectionStandard/revise', + getReviseVersion: "/eam/inspectionStandard/getReviseVersion", + loadOptions: '/sys/sysDepart/loadDepartTreeOptions', + }, + + dataSource: [], + } + }, + + + mounted() { + this.$bus.$on('selectionRows', (data) => { + for (let i = 0; i < data.length; i++) { + this.dataSource.push({ + id: data[i].id, + inspectionProjectId: data[i].id, + name: data[i].name, + detectionStandard: data[i].detectionStandard, + acceptabilityLimit: data[i].acceptabilityLimit, + inspectionMethodName: data[i].inspectionMethod_dictText, + inspectionTool: data[i].inspectionTool, + inspectionCycles: this.inspectionCycles, + }) + } + }) + }, + + + methods: { + + //閫夋嫨鐐规椤圭洰 + selectInspectionProjects: function () { + let ids = []; + for (let i = 0; i < this.dataSource.length; i++) { + ids.push(this.dataSource[i].inspectionProjectId); + } + this.$refs.inspectionStandardModalForm.showModals(ids); + this.$refs.inspectionStandardModalForm.title = '閫夋嫨鐐规椤圭洰'; + this.$refs.inspectionStandardModalForm.disableSubmit = false; + }, + + add() { + this.edit({ dailyInspectionStandardDetaillist: [] }) + }, + + edit(record) { + let that = this; + that.getInspectionCycle() + that.initOptions(); + that.dataSource = []; + that.form.resetFields(); + that.model = Object.assign({}, record); + that.visible = true; + if (record.dailyInspectionStandardDetaillist != undefined) { + const temp = [...record.dailyInspectionStandardDetaillist]; + that.dataSource = temp; + } + that.$nextTick(() => { + that.form.setFieldsValue(pick(that.model, 'num', 'equipmentId', 'equipmentName', 'useDepartName', 'useId', 'teamName', 'assignMode', 'version', 'remark')); + }); + if (record.id) { + that.codeDisable = true; + that.$nextTick(() => { + if (that.isRevise) { + requestPut(that.url.getReviseVersion, record).then((res) => { + if (res.success) { + that.form.setFieldsValue({ version: res.result, historyVersion: record.version }) + } + }) + } + }, 200); + } else { + that.codeDisable = false; + that.$nextTick(() => { + that.form.setFieldsValue({ "version": "1.0", }) + }); + } + }, + + initOptions() { + getAction(this.url.loadOptions).then(res => { + if (res.success) { + this.treeData = res.result + } else { + this.$message.warning(res.message) + } + }) + }, + onEquipmentList() { + let data = this.form.getFieldsValue(['useId']); + this.$refs.EquipmentList.list(data.useId); + this.$refs.EquipmentList.title = "閫夋嫨璁惧淇℃伅"; + }, + sendEquipmentRecord(data) { + this.dataSource = []; + let record = data.record; + this.form.setFieldsValue({ equipmentId: record.id, equipmentName: record.num + "/" + record.name + "/" + record.model, teamName: record.teamId_dictText }); + }, + + onDepartList() { + this.$refs.DepartList.list(); + this.$refs.DepartList.title = "閫夋嫨瀵硅薄閮ㄩ棬"; + }, + sendDepartRecord(data) { + this.dataSource = []; + let record = data.record; + this.form.setFieldsValue({ useId: record.id, useDepartName: record.departName }); + }, + + close() { + this.$emit('close'); + this.visible = false; + }, + + handleCancel() { + this.close(); + }, + + handleOk() { + const that = this; + this.form.validateFields((err, values) => { + if (!err) { + that.confirmLoading = true; + let formData = Object.assign(this.model, values); + formData.dailyInspectionStandardDetaillist = that.dataSource; + let obj; + if (!this.model.id) { + formData.versionStatus = '1' + obj = postAction(this.url.add, formData); + } else { + if (this.isRevise) { + formData.versionStatus = '1' + obj = postAction(this.url.revise, 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'); + } else { + that.$message.warning(res.message); + } + }).finally(() => { + that.confirmLoading = false; + that.close(); + }) + } + }) + }, + + handleDelete(text, record, index) { + this.dataSource.splice(index, 1); + }, + + getInspectionCycle() { + getAction(this.url.getInspectionCycle).then((res) => { + if (res.success) { + this.inspectionCycles = res.result + } + }) + }, + + handleChange(value, key, column, index) { + let that = this; + const temp = [...that.dataSource]; + const target = temp.filter(item => key === item.key)[index]; + if (target) { + if (column.dataIndex == 'inspectionCycleId') { + target[column.dataIndex] = value; + } + if ('photo' == column.dataIndex) { + target['photo'] = value; + } + if ('location' == column.dataIndex) { + target['location'] = value.target.value; + } + //鏄剧ず甯﹁繃鏉ョ殑鏁版嵁 + that.dataSource = temp; + } + }, + //楠岃瘉 缂栧彿 + validateEquipmentId(rule, value, callback) { + var params = { + tableName: 'mom_eam_daily_inspection_standard', + fieldName: 'equipment_id', + fieldVal: value, + dataId: this.model.id, + //鏁版嵁搴撲腑瀛樺湪瀛楁del_flag骞朵娇鐢ㄨ瀛楁浣滀负鏈垹闄ょ瓥鐣ワ紝鐪熷垹闄わ細false 鍋囧垹闄わ細true + delFlag: 'true', + }; + duplicateCheck(params).then((res) => { + if (res.success) { + callback(); + } else { + callback("璇ヨ澶囧凡缁存姢鐐规鏍囧噯!"); + } + }) + }, + + }, +} +</script> + +<style lang="less" scoped> +/deep/ .frozenRowClass { + color: #c9c9c9; +} +.fontweight { + font-weight: bold; +} +.ant-btn { + padding: 0 10px; + margin-left: 3px; +} + +.ant-form-item-control { + line-height: 0px; +} + +/** 涓昏〃鍗曡闂磋窛 */ +.ant-form .ant-form-item { + margin-bottom: 10px; +} + +/** Tab椤甸潰琛岄棿璺� */ +.ant-tabs-content .ant-form-item { + margin-bottom: 0px; +} +</style> \ No newline at end of file -- Gitblit v1.9.3