¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <j-modal |
| | | :title="title" |
| | | :width="width" |
| | | :visible="visible" |
| | | :confirmLoading="confirmLoading" |
| | | switchFullscreen |
| | | @ok="handleOk" |
| | | @cancel="handleCancel" |
| | | cancelText="å
³é" |
| | | > |
| | | <a-spin :spinning="confirmLoading"> |
| | | <a-form-model |
| | | ref="form" |
| | | :model="model" |
| | | :rules="validatorRules" |
| | | > |
| | | <a-row> |
| | | <a-col :span="24"> |
| | | <a-form-model-item |
| | | label="ææ¡£ç¼å·" |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | prop="num" |
| | | > |
| | | <a-input |
| | | placeholder="请è¾å
¥ææ¡£ç¼å·" |
| | | v-model="model.num" |
| | | /> |
| | | </a-form-model-item> |
| | | </a-col> |
| | | <a-col :span="24"> |
| | | <a-form-model-item |
| | | label="ææ¡£ç±»å" |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | prop="fileType" |
| | | > |
| | | <j-dict-select-tag |
| | | allow-clear |
| | | placeholder="è¯·éæ©ææ¡£ç±»å" |
| | | :triggerChange="true" |
| | | dictCode="mom_eam_document_type,name,id, del_flag!='1'" |
| | | v-model="model.fileType" |
| | | /> |
| | | </a-form-model-item> |
| | | </a-col> |
| | | <a-col :span="24"> |
| | | <a-form-model-item |
| | | label="ææ¡£ä¸ä¼ " |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | > |
| | | <!-- prop="fileType" --> |
| | | <a-upload-dragger |
| | | name="file" |
| | | :customRequest="customRequest" |
| | | @change="handleChange" |
| | | :file-list="fileList" |
| | | :multiple="false" |
| | | > |
| | | <p class="ant-upload-drag-icon"> |
| | | <a-icon type="inbox" /> |
| | | </p> |
| | | <p class="ant-upload-text"> |
| | | ç¹å»ä¸ä¼ æææ½æä»¶è³è¯¥åºåè¿è¡ä¸ä¼ |
| | | </p> |
| | | <p class="ant-upload-hint"> |
| | | ä»
æ¯æåæä»¶ä¸ä¼ |
| | | </p> |
| | | </a-upload-dragger> |
| | | </a-form-model-item> |
| | | </a-col> |
| | | <a-col :span="24"> |
| | | <a-form-model-item |
| | | label="æä»¶åç§°" |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | prop="name" |
| | | > |
| | | <a-input |
| | | placeholder="请è¾å
¥æä»¶åç§°" |
| | | v-model="model.name" |
| | | /> |
| | | </a-form-model-item> |
| | | </a-col> |
| | | <a-col :span="24"> |
| | | <a-form-model-item |
| | | label="夿³¨" |
| | | :labelCol="labelCol" |
| | | :wrapperCol="wrapperCol" |
| | | prop="remark" |
| | | > |
| | | <a-textarea |
| | | placeholder="请è¾å
¥å¤æ³¨" |
| | | allow-clear |
| | | v-model="model.remark" |
| | | /> |
| | | </a-form-model-item> |
| | | </a-col> |
| | | </a-row> |
| | | </a-form-model> |
| | | </a-spin> |
| | | </j-modal> |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | import { httpAction } from '@/api/manage' |
| | | import { validateDuplicateValue } from '@/utils/util' |
| | | import { getAction, postFileAction } from '../../../../api/manage' |
| | | import { ACCESS_TOKEN, TENANT_ID } from "@/store/mutation-types" |
| | | import Vue from 'vue' |
| | | |
| | | export default { |
| | | name: "EquipmentDocumentModal", |
| | | components: { |
| | | }, |
| | | props: { |
| | | mainId: { |
| | | type: String, |
| | | required: false, |
| | | default: '' |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | title: "æä½", |
| | | width: 800, |
| | | visible: false, |
| | | model: { |
| | | }, |
| | | labelCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 5 }, |
| | | }, |
| | | wrapperCol: { |
| | | xs: { span: 24 }, |
| | | sm: { span: 16 }, |
| | | }, |
| | | headers: {}, |
| | | |
| | | confirmLoading: false, |
| | | validatorRules: { |
| | | num: [ |
| | | { required: true, message: '请è¾å
¥ææ¡£ç¼å·ï¼' }, |
| | | ], |
| | | fileType: [ |
| | | { required: true, message: '请è¾å
¥éæ©ç±»åï¼' }, |
| | | ] |
| | | }, |
| | | url: { |
| | | add: "/eam/equipmentDocument/add", |
| | | edit: "/eam/equipmentDocument/edit", |
| | | listByBusIdAndBusType: "/system/sysUploadRela/listByBusIdAndBusType", |
| | | }, |
| | | fileList: [], |
| | | fileObject: {}, |
| | | isFileChange: false, |
| | | uploadId: '', |
| | | } |
| | | }, |
| | | created() { |
| | | //å¤ä»½modelåå§å¼ |
| | | this.modelDefault = JSON.parse(JSON.stringify(this.model)); |
| | | // this.initFileTypes(); |
| | | const token = Vue.ls.get(ACCESS_TOKEN); |
| | | const tenantid = Vue.ls.get(TENANT_ID) |
| | | this.headers = { |
| | | 'Content-Type': 'multipart/form-data', |
| | | "X-Access-Token": token, |
| | | 'X-Access-Tenant': tenantid |
| | | }; |
| | | }, |
| | | methods: { |
| | | add() { |
| | | this.edit(this.modelDefault); |
| | | }, |
| | | customRequest(val) { |
| | | if (this.fileList.length == 0) { |
| | | this.fileObject = val; |
| | | } |
| | | }, |
| | | handleChange(info) { |
| | | //é»è®¤ç»éä»¶ç¶æï¼ä»
æ§å¶æ ·å¼ |
| | | let file = info.file; |
| | | //æä»¶æ´æ¹ï¼æ è®°æ´æ° |
| | | if (this.model.id) { |
| | | this.isFileChange = true; |
| | | } |
| | | //å é¤ |
| | | if (file.status == "removed") { |
| | | this.fileList = []; |
| | | this.fileObject.file = {}; |
| | | this.model.name = '' |
| | | return false; |
| | | } |
| | | //åæä»¶æ§å¶ |
| | | if (this.fileList.length > 0) { |
| | | this.$message.warning("å½åä»
å
许ä¸ä¼ ä¸ä¸ªæä»¶ï¼"); |
| | | return false; |
| | | } |
| | | file.status = 'done'; |
| | | //页é¢å±ç¤ºä¸ä¼ æä»¶ |
| | | this.fileList.push(file); |
| | | this.model.name = file.name; |
| | | this.model = Object.assign({}, this.model); |
| | | |
| | | }, |
| | | edit(record) { |
| | | this.fileList = []; |
| | | this.uploadId = '' |
| | | this.model = Object.assign({}, record); |
| | | var that = this; |
| | | getAction(that.url.listByBusIdAndBusType, { busId: record.id, busType: 'equipment_file' }).then((res) => { |
| | | if (res.success) { |
| | | for (let i = 0; i < res.result.length; i++) { |
| | | that.fileList.push({ |
| | | uid: res.result[i].upload.id, |
| | | name: res.result[i].upload.name, |
| | | status: "done", |
| | | }) |
| | | that.$nextTick(() => { |
| | | that.model.name = res.result[i].upload.name |
| | | }); |
| | | } |
| | | } |
| | | }) |
| | | this.visible = true; |
| | | }, |
| | | close() { |
| | | this.$emit('close'); |
| | | this.visible = false; |
| | | this.$refs.form.clearValidate(); |
| | | }, |
| | | handleOk() { |
| | | const that = this; |
| | | // 触å表åéªè¯ |
| | | this.$refs.form.validate(valid => { |
| | | if (JSON.stringify(that.fileObject.file) == '{}' && that.uploadId == '' && that.fileList.length == 0) { |
| | | that.$message.warning("请ä¸ä¼ æä»¶"); |
| | | return false |
| | | } |
| | | if (valid) { |
| | | that.confirmLoading = true; |
| | | let formData = Object.assign({}, that.model); |
| | | let httpurl = '' |
| | | let method = '' |
| | | if (!that.model.id) { |
| | | httpurl += that.url.add; |
| | | method = 'post'; |
| | | formData.equipmentId = that.mainId; |
| | | } else { |
| | | httpurl += that.url.edit; |
| | | method = 'put'; |
| | | } |
| | | |
| | | formData.type = "equipment_file"; |
| | | formData.uploadId = that.uploadId; |
| | | // formData.fileType = "7";//æä»¶ç±»å 7ï¼å¾ç |
| | | var saveDate = new FormData(); |
| | | |
| | | formData.isFileChange = that.isFileChange; |
| | | |
| | | saveDate.append("file", that.fileObject.file); |
| | | saveDate.append('data', JSON.stringify(formData)); |
| | | |
| | | postFileAction(httpurl, saveDate, this.headers).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(); |
| | | }) |
| | | |
| | | |
| | | } else { |
| | | return false |
| | | } |
| | | }) |
| | | }, |
| | | handleCancel() { |
| | | this.close() |
| | | }, |
| | | |
| | | |
| | | }, |
| | | |
| | | } |
| | | </script> |