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/registrant-count.vue |   19 +++
 src/components/tool/value-table.vue      |   82 ++++++++++++++--
 src/components/view/product-count.vue    |   19 +++
 src/main.js                              |    7 +
 src/components/view/data-reporting.vue   |  147 +++++++++++++++++++++++++----
 src/assets/api/controller.js             |    7 +
 6 files changed, 243 insertions(+), 38 deletions(-)

diff --git a/src/assets/api/controller.js b/src/assets/api/controller.js
index b371575..8471639 100644
--- a/src/assets/api/controller.js
+++ b/src/assets/api/controller.js
@@ -30,6 +30,11 @@
 	upDataReporting: "/dataReporting/upDataReporting", //淇敼鏁版嵁涓婃姤
 	selectProductCountDtoPageList: "/dataReporting/selectProductCountDtoPageList", //鑾峰彇椤圭洰姹囨�诲垪琛�
 	selectRegistrantCountDtoPageList: "/dataReporting/selectRegistrantCountDtoPageList", //鑾峰彇鐧昏浜烘眹鎬诲垪琛�
+	addDataReporting: "/dataReporting/addDataReporting", //娣诲姞鏁版嵁涓婃姤
+	delDataReporting: "/dataReporting/delDataReporting", //鍒犻櫎鏁版嵁涓婃姤
+	downDataReportingFile: "/dataReporting/downDataReportingFile", //瀵煎嚭鏁版嵁涓婃姤
+	downProductCountFile: "/dataReporting/downProductCountFile", //瀵煎嚭椤圭洰鏁版嵁缁熻
+	downRegistrantCountFile: "/dataReporting/downRegistrantCountFile", //瀵煎嚭鍛樺伐鏁版嵁缁熻
 	
 	selectFansSubmitList: "/dataReporting/selectFansSubmitList", //鑾峰彇杩涚矇涓婃姤鍒楄〃
 	delFansSubmit: "/dataReporting/delFansSubmit", //鍒犻櫎杩涚矇涓婃姤淇℃伅
@@ -42,6 +47,8 @@
 	addFinanceSubmit: "/dataReporting/addFinanceSubmit", //娣诲姞璐㈠姟涓婃姤淇℃伅
 	
 	getDataList: "/dataReporting/getDataList", //鑾峰彇棣栭〉鏁版嵁
+	
+	inputCsv: "/dataReporting/inputCsv", //瀵煎叆
 }
 
 const enums = {
diff --git a/src/components/tool/value-table.vue b/src/components/tool/value-table.vue
index d32ed04..e787e0b 100644
--- a/src/components/tool/value-table.vue
+++ b/src/components/tool/value-table.vue
@@ -16,6 +16,20 @@
 		text-align: right;
 		margin-top: 10px;
 	}
+
+	.down-left {
+		width: 50%;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+	}
+
+	.down-right {
+		width: 50%;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+	}
 </style>
 
 <template>
@@ -74,10 +88,10 @@
 			</span>
 		</el-dialog>
 		<el-dialog title="鏂板" :visible.sync="addDia" width="500px">
-			<div class="body" v-if="addDia">
+			<div class="body" v-if="addDia" style="max-height: 600px;overflow-y: auto;">
 				<el-row v-for="(a, ai) in upHead" :key="ai" style="line-height: 50px;">
-					<el-col :span="5" style="text-align: right;">{{a.value}}锛�</el-col>
-					<el-col :span="17" :offset="1">
+					<el-col :span="6" style="text-align: right;">{{a.value}}锛�</el-col>
+					<el-col :span="16" :offset="1">
 						<el-input v-model="upData[a.label]" size="small" clearable :placeholder="`璇疯緭鍏�${a.value}`"
 							v-if="showType(a.label, data.selectField) == null"></el-input>
 						<el-select v-model="upData[a.label]" size="small" v-if="showType(a.label, data.selectField) != null"
@@ -95,12 +109,13 @@
 		</el-dialog>
 		<el-dialog title="瀵煎嚭" :visible.sync="downDia" width="400px">
 			<div style="display: flex;width: 100%;height: 100px;">
-				<div class="down-left"></div>
-				<div class="down-right"></div>
+				<div class="down-left" @click="downFile(true)">
+					<el-button>鏈〉瀵煎嚭</el-button>
+				</div>
+				<div class="down-right" @click="downFile(false)">
+					<el-button>鍏ㄩ儴瀵煎嚭</el-button>
+				</div>
 			</div>
-			<span slot="footer" class="dialog-footer">
-				<el-button @click="downDia = false">鍙� 娑�</el-button>
-			</span>
 		</el-dialog>
 	</div>
 </template>
@@ -120,6 +135,10 @@
 				default: () => null
 			},
 			delUrl: {
+				type: String,
+				default: () => null
+			},
+			downUrl: {
 				type: String,
 				default: () => null
 			},
@@ -385,8 +404,10 @@
 				this.upHead = this.HaveJson(this.tableHead)
 				this.upHead = this.upHead.filter(a => a.label != 'createTime' && a.label != 'updateTime')
 				var val = this.data.do.filter(a => a.id == 'update')[0]
-				if(val == undefined) {
-					val = {field: []}
+				if (val == undefined) {
+					val = {
+						field: []
+					}
 				}
 				val.field.forEach(a => {
 					if (JSON.stringify(this.upData[a]) == undefined) {
@@ -430,8 +451,47 @@
 					this.addLoad = false
 				})
 			},
-			openDownDia(){
+			openDownDia() {
 				this.downDia = true
+			},
+			downFile(type) {
+				if (this.downUrl == null) {
+					this.$message.error('璇风粰瀵煎嚭璇锋眰鍦板潃')
+					return
+				}
+				var page = this.HaveJson(this.page)
+				if (!type) {
+					page.current = 0
+					page.size = this.total
+				}
+				this.loading = true
+				this.$axios.post(this.downUrl, {
+					page: page,
+					entity: this.data.entity
+				}, {
+					headers: {
+						'Content-Type': 'application/json'
+					}
+				}).then(res => {
+					if (res.code === 201) {
+						this.loading = false
+						return
+					}
+					this.downDia = false
+					this.loading = false
+					this.$message.success('瀵煎嚭鎴愬姛')
+					let eleLink = document.createElement('a')
+					eleLink.style.display = 'none'
+					eleLink.download = res.data
+					eleLink.href = this.javaApi + '/outPath/' + res.data
+					document.body.appendChild(eleLink)
+					eleLink.click()
+					document.body.removeChild(eleLink)
+				}).catch(e => {
+					console.log(e);
+					this.loading = false
+					this.$message.error('璇峰埛鏂伴〉闈㈠啀灏濊瘯')
+				})
 			}
 		}
 	}
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);
 			}
 		}
 	}
diff --git a/src/components/view/product-count.vue b/src/components/view/product-count.vue
index 6c57801..c5538d2 100644
--- a/src/components/view/product-count.vue
+++ b/src/components/view/product-count.vue
@@ -42,7 +42,7 @@
 			<el-row class="title">
 				<el-col :span="12" style="padding-left: 20px;">椤圭洰鏁版嵁缁熻</el-col>
 				<el-col :span="12" style="text-align: right;">
-					<el-button size="small" @click="">
+					<el-button size="small" @click="$refs.ValueTable.openDownDia()" v-if="outPower">
 						<i class="el-icon-download" style="color: #3A7BFA;"></i>
 						<span style="color: #3A7BFA;">瀵煎嚭</span>
 					</el-button>
@@ -77,7 +77,7 @@
 			</div>
 		</div>
 		<div class="table">
-			<ValueTable ref="ValueTable" :url="$api.dataReporting.selectProductCountDtoPageList" :componentData="componentData" :key="upIndex"/>
+			<ValueTable ref="ValueTable" :url="$api.dataReporting.selectProductCountDtoPageList" :componentData="componentData" :key="upIndex" :downUrl="$api.dataReporting.downProductCountFile"/>
 		</div>
 	</div>
 </template>
@@ -109,12 +109,14 @@
 				entityCopy: {},
 				upIndex: 0,
 				addDia: false,
-				product: []
+				product: [],
+				outPower: true
 			}
 		},
 		mounted() {
 			this.entityCopy = this.HaveJson(this.componentData.entity)
 			this.selectProductEnumList()
+			this.getPower()
 		},
 		methods: {
 			refreshTable() {
@@ -128,6 +130,17 @@
 				this.$axios.get(this.$api.enums.selectProductEnumList).then(res=>{
 					this.product = res.data
 				})
+			},
+			// 鏉冮檺鍒嗛厤
+			getPower() {
+				let power = JSON.parse(sessionStorage.getItem('power'))
+				let outPower = false
+				for (var i = 0; i < power.length; i++) {
+					if (power[i].menuMethod == 'downProductCountFile') {
+						outPower = true
+					}
+				}
+				this.outPower = outPower
 			}
 		}
 	}
diff --git a/src/components/view/registrant-count.vue b/src/components/view/registrant-count.vue
index 882b39a..8a7fcc6 100644
--- a/src/components/view/registrant-count.vue
+++ b/src/components/view/registrant-count.vue
@@ -47,7 +47,7 @@
 			<el-row class="title">
 				<el-col :span="12" style="padding-left: 20px;">鍛樺伐鏁版嵁缁熻</el-col>
 				<el-col :span="12" style="text-align: right;">
-					<el-button size="small" @click="">
+					<el-button size="small" @click="$refs.ValueTable.openDownDia()" v-if="outPower">
 						<i class="el-icon-download" style="color: #3A7BFA;"></i>
 						<span style="color: #3A7BFA;">瀵煎嚭</span>
 					</el-button>
@@ -79,7 +79,7 @@
 			</div>
 		</div>
 		<div class="table">
-			<ValueTable ref="ValueTable" :url="$api.dataReporting.selectRegistrantCountDtoPageList" :componentData="componentData" :key="upIndex"/>
+			<ValueTable ref="ValueTable" :url="$api.dataReporting.selectRegistrantCountDtoPageList" :componentData="componentData" :key="upIndex" :downUrl="$api.dataReporting.downRegistrantCountFile"/>
 		</div>
 	</div>
 </template>
@@ -111,13 +111,15 @@
 				upIndex: 0,
 				addDia: false,
 				product: [],
-				custom:[]
+				custom:[],
+				outPower: true
 			}
 		},
 		mounted() {
 			this.entityCopy = this.HaveJson(this.componentData.entity)
 			this.selectProductEnumList()
 			this.selectCustomEnumList()
+			this.getPower()
 		},
 		methods: {
 			refreshTable() {
@@ -136,6 +138,17 @@
 				this.$axios.get(this.$api.enums.selectCustomEnumList).then(res=>{
 					this.custom = res.data
 				})
+			},
+			// 鏉冮檺鍒嗛厤
+			getPower() {
+				let power = JSON.parse(sessionStorage.getItem('power'))
+				let outPower = false
+				for (var i = 0; i < power.length; i++) {
+					if (power[i].menuMethod == 'downRegistrantCountFile') {
+						outPower = true
+					}
+				}
+				this.outPower = outPower
 			}
 		}
 	}
diff --git a/src/main.js b/src/main.js
index e495279..c3c10c4 100644
--- a/src/main.js
+++ b/src/main.js
@@ -11,11 +11,16 @@
 import api from './assets/api/controller.js'
 import swal from 'sweetalert'
 
-Vue.prototype.LOCATIONVUE = "http://127.0.0.1:80"; //鍓嶇鏈湴绔彛
+//鏈湴
+Vue.prototype.LOCATIONVUE = "http://127.0.0.1:80"; 
 const javaApi = 'http://localhost:8001';
+//鑳滀簯鏈嶅姟鍣�
+// Vue.prototype.LOCATIONVUE = "http://syxt.shxiao2.cn";
+// const javaApi = 'http://122.114.52.69:8001';
 Vue.prototype.HaveJson = (val) => {
 	return JSON.parse(JSON.stringify(val))
 }
+Vue.prototype.javaApi = javaApi
 
 Vue.use(VueAxios, axios)
 Vue.config.productionTip = false

--
Gitblit v1.9.3