From e3f6244998e835635154bbab8754a1000b8ef815 Mon Sep 17 00:00:00 2001 From: 李林 <z1292839451@163.com> Date: 星期二, 02 一月 2024 03:35:10 +0800 Subject: [PATCH] 修订版本1.0 --- src/components/view/data-reporting.vue | 147 ++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 127 insertions(+), 20 deletions(-) diff --git a/src/components/view/data-reporting.vue b/src/components/view/data-reporting.vue index e300894..ac2dd1b 100644 --- a/src/components/view/data-reporting.vue +++ b/src/components/view/data-reporting.vue @@ -36,21 +36,34 @@ } </style> <style> - .data_reporting .data_reporting_dia .el-dialog__body{ + .data_reporting .data_reporting_dia .el-dialog__body { padding: 15px 0; + } + + .data_reporting .el-upload { + width: 100%; + } + + .data_reporting .el-upload-dragger { + width: 100%; } </style> <template> - <div class="data_reporting"> + <div class="data_reporting" v-loading="uploading"> <div> <el-row class="title"> <el-col :span="12" style="padding-left: 20px;">鏁版嵁涓婃姤</el-col> <el-col :span="12" style="text-align: right;padding-right: 8px;"> - <el-button size="small" @click="$refs.ValueTable.openDownDia()"> + <el-button size="medium" @click="openUpload()" v-if="inPower"> + <i class="el-icon-upload2" style="color: #3A7BFA;"></i> + <span style="color: #3A7BFA;">瀵煎叆</span> + </el-button> + <el-button size="medium" @click="$refs.ValueTable.openDownDia()" v-if="outPower"> <i class="el-icon-download" style="color: #3A7BFA;"></i> <span style="color: #3A7BFA;">瀵煎嚭</span> </el-button> + <el-button size="medium" type="primary" @click="opeaAdd" v-if="addPower">鏂板</el-button> </el-col> </el-row> </div> @@ -58,13 +71,15 @@ <div class="search_thing"> <div class="search_label">绯荤粺鏃ユ湡锛�</div> <div class="search_input"> - <el-date-picker size="small" v-model="componentData.entity.updateTime" type="date" placeholder="閫夋嫨鏃ユ湡" value-format="yyyy-MM-dd HH:mm:ss" clearable></el-date-picker> + <el-date-picker size="small" v-model="componentData.entity.updateTime" type="date" placeholder="閫夋嫨鏃ユ湡" + value-format="yyyy-MM-dd HH:mm:ss" clearable></el-date-picker> </div> </div> <div class="search_thing"> <div class="search_label">鐧昏浜猴細</div> <div class="search_input"> - <el-input size="small" v-model="componentData.entity.registrant" clearable placeholder="鐧昏浜�" @keyup.enter.native="refreshTable()"></el-input> + <el-input size="small" v-model="componentData.entity.registrant" clearable placeholder="鐧昏浜�" + @keyup.enter.native="refreshTable()"></el-input> </div> </div> <div class="search_thing"> @@ -82,8 +97,8 @@ </div> </div> <div class="table"> - <ValueTable ref="ValueTable" :url="$api.dataReporting.selectDataReportingList" :componentData="componentData" - :key="upIndex" @upRole="upRole" /> + <ValueTable ref="ValueTable" :url="$api.dataReporting.selectDataReportingList" + :delUrl="$api.dataReporting.delDataReporting" :componentData="componentData" :key="upIndex" @upRole="upRole" :downUrl="$api.dataReporting.downDataReportingFile"/> </div> <el-dialog title="涓婃姤淇敼" :visible.sync="upDia" width="700px" class="data_reporting_dia"> <div class="body" v-if="upDia"> @@ -120,7 +135,7 @@ <el-row style="line-height: 50px;"> <el-col :span="4" style="text-align: right;padding-right: 8px;">灞曠幇閲�</el-col> <el-col :span="7"> - <el-input v-model="upData.show" size="small" disabled></el-input> + <el-input v-model="upData.showNum" size="small" disabled></el-input> </el-col> <el-col :span="4" style="text-align: right;padding-right: 8px;">鐐瑰嚮閲�</el-col> <el-col :span="7"> @@ -193,6 +208,20 @@ <el-button @click="upDia = false">鍙� 娑�</el-button> </span> </el-dialog> + <el-dialog title="鏁版嵁瀵煎叆" :visible.sync="uploadDia" width="500px"> + <div style="margin: 0 auto;"> + <el-upload ref="upload" drag :action="javaApi + $api.dataReporting.inputCsv" :headers="token" + :file-list="fileList" name="file" :auto-upload="false" accept=".csv" :limit="1" :on-change="beforeUpload" + :on-success="onSuccess" :on-error="onError"> + <i class="el-icon-upload"></i> + <div class="el-upload__text">灏嗘枃浠舵嫋鍒版澶勶紝鎴�<em>鐐瑰嚮涓婁紶</em></div> + </el-upload> + </div> + <span slot="footer" class="dialog-footer"> + <el-button @click="uploadDia = false">鍙� 娑�</el-button> + <el-button type="primary" @click="submitUpload()">涓� 浼�</el-button> + </span> + </el-dialog> </div> </template> @@ -218,11 +247,21 @@ showSelect: true, select: true, do: [{ + id: 'update', font: '缂栬緫', type: 'text', - method: 'upRole' + method: 'upRole', + field: ['createUserName', 'updateUserName', 'registrant', 'department', 'consumption', + 'rebateConsumption', 'discountedConsumption', 'profit', 'remark', 'actualCost' + ] + }, { + id: 'delete', + font: '鍒犻櫎', + type: 'text', + method: 'doDiy' }], - tagField: {} + tagField: {}, + selectField: {} }, entityCopy: {}, upIndex: 0, @@ -231,12 +270,22 @@ upLoad: false, upData: {}, product: [], + uploadDia: false, + fileList: [], + uploading: false, + addPower: true, + token: null, + inPower: true, + outPower: true } }, mounted() { this.entityCopy = this.HaveJson(this.componentData.entity) this.selectProductEnumList() this.getPower() + this.token = { + 'token': sessionStorage.getItem('token') + } }, methods: { refreshTable() { @@ -250,7 +299,7 @@ this.upData = this.HaveJson(row) this.upDia = true }, - saveUpData(){ + saveUpData() { this.upLoad = true delete this.upData.createTime delete this.upData.updateTime @@ -260,9 +309,9 @@ headers: { 'Content-Type': 'application/json' } - }).then(res=>{ + }).then(res => { this.upLoad = false - if(res.code == 201){ + if (res.code == 201) { return } this.$message.success('淇敼鎴愬姛') @@ -270,24 +319,82 @@ this.refreshTable() }) }, - selectProductEnumList(){ - this.$axios.get(this.$api.enums.selectProductEnumList).then(res=>{ + selectProductEnumList() { + this.$axios.get(this.$api.enums.selectProductEnumList).then(res => { this.product = res.data }) }, // 鏉冮檺鍒嗛厤 - getPower(){ + getPower() { let power = JSON.parse(sessionStorage.getItem('power')) let up = false + let del = false + let add = false + let inPower = false + let outPower = false for (var i = 0; i < power.length; i++) { - if(power[i].menuMethod=='upDataReporting'){ + if (power[i].menuMethod == 'upDataReporting') { up = true - break + } + if (power[i].menuMethod == 'delDataReporting') { + del = true + } + if (power[i].menuMethod == 'addDataReporting') { + add = true + } + if (power[i].menuMethod == 'inputCsv') { + inPower = true + } + if (power[i].menuMethod == 'downDataReportingFile') { + outPower = true } } - if(!up){ - this.componentData.do = [] + if (!del) { + this.componentData.do.splice(1, 1) } + if (!up) { + this.componentData.do.splice(0, 1) + } + this.addPower = add + this.inPower = inPower + this.outPower = outPower + }, + openUpload() { + this.uploadDia = true + }, + beforeUpload(file, fileList) { + if (file.raw.type != 'text/csv') { + this.$message.error('涓婁紶鏂囦欢鏍煎紡涓嶆纭�'); + this.$refs.upload.clearFiles() + return false; + } + }, + submitUpload() { + if (this.$refs.upload.uploadFiles.length == 0) { + this.$message.error('鏈�夋嫨鏂囦欢') + return + } + this.uploading = true + this.$refs.upload.submit(); + }, + onSuccess(response, file, fileList) { + this.$refs.upload.clearFiles() + this.uploadDia = false + this.uploading = false + if(response.code==201){ + this.$message.error(response.message) + return + } + this.$message.success('涓婁紶鎴愬姛') + this.refreshTable() + }, + onError(err, file, fileList) { + this.$message.success('涓婁紶澶辫触') + this.$refs.upload.clearFiles() + this.uploading = false + }, + opeaAdd() { + this.$refs.ValueTable.openAddDia(this.$api.dataReporting.addDataReporting); } } } -- Gitblit v1.9.3