From 585fb0bbd4a7bc7f8f333ecba7c5fecd2ee5cbc2 Mon Sep 17 00:00:00 2001 From: qushaowei <qushaowei@163.com> Date: 星期四, 28 三月 2024 09:46:44 +0800 Subject: [PATCH] Merge branch 'master' of http://117.34.109.166:18448/r/vue_mdc_430 into develop --- src/views/eam/modules/uploadModel/UploadModel.vue | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 299 insertions(+), 0 deletions(-) diff --git a/src/views/eam/modules/uploadModel/UploadModel.vue b/src/views/eam/modules/uploadModel/UploadModel.vue new file mode 100644 index 0000000..d77f6c6 --- /dev/null +++ b/src/views/eam/modules/uploadModel/UploadModel.vue @@ -0,0 +1,299 @@ +<template> + <a-modal + :title="title" + :width="850" + :visible="visible" + :maskClosable="false" + :confirmLoading="confirmLoading" + :okButtonProps="{ props: {disabled: disableSubmit} }" + @ok="handleOk" + @cancel="handleCancel" + cancelText="鍏抽棴" + > + <a-spin :spinning="confirmLoading"> + <a-form :form="form"> + + <!-- <a-row :gutter="24"> + <a-col :lg="12"> + <a-form-item + label="鏂囦欢绫诲瀷" + :labelCol="labelCol" + :wrapperCol="wrapperCol" + > + <j-dict-select-tag + placeholder="璇烽�夋嫨鍗曚綅绫诲瀷" + :triggerChange="true" + dictCode="common_upload_type" + v-decorator="['type', validatorRules.type]" + /> + </a-form-item> + </a-col> + <a-col :span="12"> + + </a-col> + </a-row> --> + + <a-row :gutter="24"> + <a-col :span="24"> + <a-form-item + :labelCol="{span:3}" + :wrapperCol="{span:21}" + label="鏂囦欢绫诲瀷" + > + <a-radio-group + v-for="(item,index) in fileTypes" + :key="index" + button-style="solid" + v-decorator="['type', validatorRules.type ]" + :disabled="disableSubmit" + > + + <a-radio-button :value="item.value"> + {{item.text}} + </a-radio-button> + </a-radio-group> + + </a-form-item> + </a-col> + </a-row> + + <a-row :gutter="24"> + <a-col :lg="24"> + <a-form-item + label="鏂囦欢涓婁紶" + :labelCol="{span:3}" + :wrapperCol="{span:21}" + > + <!-- <a-upload + name="file" + @change="handleChange" + :file-list="fileList" + :remove="handleRemove" + :before-upload="beforeUpload" + :multiple="false" + > + <a-button> + <a-icon type="upload" /> 閫夋嫨鏂囦欢 </a-button> + </a-upload> --> + <a-upload-dragger + name="file" + @change="handleChange" + :file-list="fileList" + :remove="handleRemove" + :before-upload="beforeUpload" + :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-item> + </a-col> + </a-row> + + <a-row :gutter="24"> + <a-col :span="24"> + <a-form-item + :labelCol="{span:3}" + :wrapperCol="{span:21}" + label="鎻忚堪" + > + <a-textarea + placeholder="璇疯緭鍏ユ弿杩�" + allow-clear + v-decorator="['description', validatorRules.description]" + /> + </a-form-item> + </a-col> + </a-row> + </a-form> + </a-spin> + + <template slot="footer"> + <a-button + :style="{marginRight: '8px'}" + @click="handleCancel" + > + 鍏抽棴 + </a-button> + <a-button + :disabled="confirmLoading" + :loading="confirmLoading" + @click="handleOk" + type="primary" + >纭畾</a-button> + <!-- icon="save" --> + </template> + + </a-modal> +</template> + +<script> +import pick from 'lodash.pick' +import { postAction } from '@/api/manage' +import { duplicateCheck } from '@/api/api' +import { ajaxGetDictItems } from '@/api/api' + + +let validatorCodeTimer = null + +export default { + name: 'UploadModel', + data() { + return { + title: '', + visible: false, + model: {}, + labelCol: { + xs: { span: 24 }, + sm: { span: 6 }, + }, + wrapperCol: { + xs: { span: 24 }, + sm: { span: 18 }, + }, + confirmLoading: false, + form: this.$form.createForm(this), + validatorRules: { + + type: { + rules: [{ required: true, message: '璇烽�夋嫨鏂囦欢绫诲瀷' }], + }, + description: { + rules: [ + { min: 0, max: 100, message: '鏈�闀� 100 涓瓧绗�', trigger: 'blur' }, + ] + }, + }, + url: { + + add: '/sys/upload/uploadFile', + // add: '/sys/upload/batchUploadFile', + }, + disableSubmit: false, + fileList: [], + fileTypes: [], + } + }, + + methods: { + handleRemove(file) { + const index = this.fileList.indexOf(file) + const newFileList = this.fileList.slice() + newFileList.splice(index, 1) + this.fileList = newFileList + }, + beforeUpload(file) { + this.fileList = [...this.fileList, file]; + return false; + }, + add() { + this.visible = true; + this.form.resetFields(); + this.model = {}; + this.fileList = []; + }, + 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); + var description = ''; + if (values.description) { + description = values.description; + } + that.handleUpload(values.type, description); + + } + }) + }, + handleUpload(type, description) { + + const { fileList } = this; + const formData = new FormData(); + if (fileList.length == 0) { + this.$message.error('璇蜂笂浼犳枃浠讹紒'); + } else { + fileList.forEach((file) => { + formData.append('files[]', file); + }) + formData.append('type', type); + formData.append('description', description); + postAction(this.url.add, formData) + .then((res) => { + if (res.success) { + this.$message.success(res.message); + this.$emit('ok') + } else { + this.$message.warning(res.message); + } + }) + .finally(() => { + this.confirmLoading = false; + this.close(); + }) + } + + }, + + handleChange(info) { + if (info.file.status !== 'uploading') { + console.log(info.file, info.fileList); + } + if (info.file.status === 'done') { + this.$message.success(`${info.file.name} file uploaded successfully`); + } else if (info.file.status === 'error') { + this.$message.error(`${info.file.name} file upload failed.`); + } + }, + + initFileTypes() { + ajaxGetDictItems("standard_type", null).then((res) => { + if (res.success) { + this.fileTypes = res.result; + } + }) + }, + }, + created() { + this.initFileTypes(); + + }, +} +</script> + +<style scoped> +.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