From 97ae9c64cc0e45903844ea63e3f13dc98da61496 Mon Sep 17 00:00:00 2001 From: 13404089107 <puwei@sinata.cn> Date: 星期四, 20 三月 2025 17:03:51 +0800 Subject: [PATCH] 调试导入 --- src/views/placement-batch/components/exportMoneyApplay.vue | 147 +++++++++++++++++------------------------------- 1 files changed, 52 insertions(+), 95 deletions(-) diff --git a/src/views/placement-batch/components/exportMoneyApplay.vue b/src/views/placement-batch/components/exportMoneyApplay.vue index 0b28fee..1b7f66b 100644 --- a/src/views/placement-batch/components/exportMoneyApplay.vue +++ b/src/views/placement-batch/components/exportMoneyApplay.vue @@ -1,51 +1,37 @@ <template> <el-dialog title="导入人员购房资金申请" :visible.sync="visible" width="600px" :close-on-click-modal="false" append-to-body> <el-form ref="form" :model="form" :rules="rules" label-width="120px"> - <el-form-item label="批次号" prop="batchNo"> - <el-input v-model="form.batchNo" placeholder="请输入" clearable></el-input> + <el-form-item label="批次号" prop="batchNumber"> + <el-input v-model="form.batchNumber" placeholder="请输入" clearable></el-input> </el-form-item> <div> - <el-form-item label="导入资金表" prop="moneyFile"> - <el-upload class="upload-container" :action="uploadUrl" :before-upload="beforeUpload" - :on-success="handleMoneyFileSuccess" :on-error="handleUploadError" :file-list="moneyFileList" :limit="1"> - <div class="upload-area" @click="handleClickUpload"> - <i class="el-icon-folder"></i> - <div class="upload-text">点击或将文件文件拖拽到这里上传</div> - <div class="upload-tip">支持格式:.xlsx、.xls...</div> - </div> - <div slot="tip" class="el-upload__tip"> - 已上传: - <template v-if="moneyFileList.length"> - <div v-for="(file, index) in moneyFileList" :key="index" class="file-item"> - <i class="el-icon-document"></i> - <span class="file-name">{{ file.name }}</span> - <i class="el-icon-close" @click.stop="handleRemoveFile(file, 'money')"></i> - </div> - </template> - </div> - </el-upload> - </el-form-item> + <el-form-item label="导入资金表" prop="assetFile"> + <el-upload class="upload-container" action="#" drag :auto-upload="false" accept=".xlsx,.xls" + :on-change="handlehouseholdFileChangePrice" :limit="1"> + <div class="upload-area"> + <i class="el-icon-folder"></i> + <div class="upload-text">点击或将文件文件拖拽到这里上传</div> + <div class="upload-tip">支持格式:.xlsx、.xls...</div> + </div> + <div slot="tip" class="el-upload__tip"> + 已上传: + </div> + </el-upload> + </el-form-item> - <el-form-item label="导入购房表" prop="houseFile"> - <el-upload class="upload-container" :action="uploadUrl" :before-upload="beforeUpload" - :on-success="handleHouseFileSuccess" :on-error="handleUploadError" :file-list="houseFileList" :limit="1"> - <div class="upload-area" @click="handleClickUpload"> - <i class="el-icon-folder"></i> - <div class="upload-text">点击或将文件文件拖拽到这里上传</div> - <div class="upload-tip">支持格式:.xlsx、.xls...</div> - </div> - <div slot="tip" class="el-upload__tip"> - 已上传: - <template v-if="houseFileList.length"> - <div v-for="(file, index) in houseFileList" :key="index" class="file-item"> - <i class="el-icon-document"></i> - <span class="file-name">{{ file.name }}</span> - <i class="el-icon-close" @click.stop="handleRemoveFile(file, 'house')"></i> - </div> - </template> - </div> - </el-upload> - </el-form-item> + <el-form-item label="导入购房表" prop="householdFile"> + <el-upload class="upload-container" action="#" drag :auto-upload="false" accept=".xlsx,.xls" + :on-change="handlehouseholdFileChange" :limit="1"> + <div class="upload-area"> + <i class="el-icon-folder"></i> + <div class="upload-text">点击或将文件文件拖拽到这里上传</div> + <div class="upload-tip">支持格式:.xlsx、.xls...</div> + </div> + <div slot="tip" class="el-upload__tip"> + 已上传: + </div> + </el-upload> + </el-form-item> </div> </el-form> <div slot="footer" class="dialog-footer"> @@ -69,71 +55,42 @@ loading: false, uploadUrl: '/api/upload', // 上传地址 form: { - batchNo: '', - moneyFile: '', - houseFile: '' + batchNumber: '', + assetFile: '', + householdFile: '' }, rules: { - batchNo: [ + batchNumber: [ { required: true, message: '请输入批次号', trigger: 'blur' } ], - moneyFile: [ + assetFile: [ { required: true, message: '请上传资金表', trigger: 'change' } ], - houseFile: [ + householdFile: [ { required: true, message: '请上传购房表', trigger: 'change' } ] }, - moneyFileList: [], - houseFileList: [] } }, methods: { - // 上传前校验 - beforeUpload(file) { - const isExcel = file.type === 'application/vnd.ms-excel' || - file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' - const isLt10M = file.size / 1024 / 1024 < 10 + handlehouseholdFileChange(file, fileList) { + this.form.householdFile = file.raw + this.$refs.form.validateField('householdFile') - if (!isExcel) { - this.$message.error('上传文件只能是 Excel 格式!') - return false - } - if (!isLt10M) { - this.$message.error('上传文件大小不能超过 10MB!') - return false - } - return true }, - // 资金表上传成功 - handleMoneyFileSuccess(response, file, fileList) { - this.moneyFileList = fileList - this.form.moneyFile = response.data - this.$message.success('上传成功') - }, - // 购房表上传成功 - handleHouseFileSuccess(response, file, fileList) { - this.houseFileList = fileList - this.form.houseFile = response.data - this.$message.success('上传成功') - }, - // 上传失败 - handleUploadError() { - this.$message.error('上传失败') + handlehouseholdFileChangePrice(file, fileList) { + this.form.assetFile = file.raw + this.$refs.form.validateField('assetFile') }, // 移除文件 handleRemoveFile(file, type) { if (type === 'money') { - this.moneyFileList = [] - this.form.moneyFile = '' + this.form.assetFile = '' + this.$refs.form.validateField('assetFile') } else { - this.houseFileList = [] - this.form.houseFile = '' + this.form.householdFile = '' + this.$refs.form.validateField('householdFile') } - }, - // 点击上传区域 - handleClickUpload() { - // 触发上传 }, // 取消 handleCancel() { @@ -145,11 +102,9 @@ this.$refs.form.validate(valid => { if (valid) { this.loading = true - // TODO: 调用接口提交数据 + this.$emit('importPrice', this.form) setTimeout(() => { this.loading = false - this.$message.success('提交成功') - this.$emit('update:visible', false) this.resetForm() }, 1000) } @@ -158,12 +113,10 @@ // 重置表单 resetForm() { this.form = { - batchNo: '', - moneyFile: '', - houseFile: '' + batchNumber: '', + assetFile: '', + householdFile: '' } - this.moneyFileList = [] - this.houseFileList = [] this.$refs.form && this.$refs.form.resetFields() } } @@ -171,6 +124,10 @@ </script> <style lang="scss" scoped> +::v-deep .el-upload-dragger { + width: 100%; + height: unset !important; +} .upload-container { .upload-area { width: 100%; -- Gitblit v1.7.1