From 222147e808eec8780fb32a0fc5f23d3ae974ec3f Mon Sep 17 00:00:00 2001
From: zhuo <2089219845@qq.com>
Date: 星期三, 28 二月 2024 08:49:04 +0800
Subject: [PATCH] 系统日志

---
 src/components/view/data-reporting.vue |  286 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 259 insertions(+), 27 deletions(-)

diff --git a/src/components/view/data-reporting.vue b/src/components/view/data-reporting.vue
index e300894..effeab1 100644
--- a/src/components/view/data-reporting.vue
+++ b/src/components/view/data-reporting.vue
@@ -34,23 +34,40 @@
 		height: calc(100% - 60px - 80px - 10px - 40px);
 		padding: 20px;
 	}
+	.el-radio-group{
+		width: 100%;
+	}
 </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="chooseDia = true" 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-button size="medium" type="danger" @click="delNowAll" v-if="delAllPower">涓�閿垹闄�</el-button>
 				</el-col>
 			</el-row>
 		</div>
@@ -58,13 +75,17 @@
 			<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.createTime" type="date" placeholder="閫夋嫨鏃ユ湡"
+						value-format="yyyy-MM-dd HH:mm:ss" :clearable="false" :editable="false" @change="refreshTable"></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-select size="small" style="width: 100%;" placeholder="鐧昏浜�" v-model="componentData.entity.registrant">
+						<el-option :value="null" label="鍏ㄩ儴"></el-option>
+						<el-option v-for="(a, ai) in userNames" :key="ai" :label="a" :value="a"></el-option>
+					</el-select>
 				</div>
 			</div>
 			<div class="search_thing">
@@ -82,11 +103,11 @@
 			</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">
+			<div class="body" v-if="upDia" style="max-height: 550px;overflow-y: auto;">
 				<el-row style="line-height: 50px;">
 					<el-col :span="4" style="text-align: right;padding-right: 8px;">绯荤粺鏃ユ湡</el-col>
 					<el-col :span="7">
@@ -118,9 +139,19 @@
 					</el-col>
 				</el-row>
 				<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.name2" size="small" disabled></el-input>
+					</el-col>
+					<el-col :span="4" style="text-align: right;padding-right: 8px;">浠g悊</el-col>
+					<el-col :span="7">
+						<el-input v-model="upData.agent" size="small" disabled></el-input>
+					</el-col>
+				</el-row>
+				<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">
@@ -162,7 +193,7 @@
 					<el-col :span="7">
 						<el-input v-model="upData.profit" size="small" disabled></el-input>
 					</el-col>
-					<el-col :span="4" style="text-align: right;padding-right: 8px;">浠g悊杩旂偣</el-col>
+					<el-col :span="4" style="text-align: right;padding-right: 8px;">鍛樺伐浠g悊杩旂偣</el-col>
 					<el-col :span="7">
 						<el-input v-model="upData.agentRebate" size="small" disabled></el-input>
 					</el-col>
@@ -182,15 +213,48 @@
 					<el-col :span="7">
 						<el-input v-model="upData.customerRebate" size="small"></el-input>
 					</el-col>
-					<el-col :span="4" style="text-align: right;padding-right: 8px;">澶囩敤瀛楁</el-col>
+					<el-col :span="4" style="text-align: right;padding-right: 8px;">鍋氳繘鏉�</el-col>
 					<el-col :span="7">
 						<el-input v-model="upData.remark" size="small"></el-input>
+					</el-col>
+				</el-row>
+				<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.vxCard" size="small"></el-input>
 					</el-col>
 				</el-row>
 			</div>
 			<span slot="footer" class="dialog-footer" style="margin-right: 18px;">
 				<el-button type="primary" @click="saveUpData" :loading="upLoad">纭� 瀹�</el-button>
 				<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" :data="{param: componentData.uploadStr}">
+					<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>
+		<el-dialog title="璇烽�夋嫨鏁版嵁涓婃姤鐨勫井淇″彿" :visible.sync="chooseDia" width="500px">
+			<div class="body" v-if="chooseDia" style="max-height: 550px;overflow-y: auto;padding: 5px 0;">
+				<el-radio-group v-model="vx">
+					<el-col :span="8" v-for="(a, ai) in vxs" :key="ai" style="margin-bottom: 5px;">
+						<el-radio border size="small" :label="a.vx">{{a.vx}}</el-radio>
+					</el-col>
+				</el-radio-group>
+			</div>
+			<span slot="footer" class="dialog-footer">
+				<el-button @click="chooseDia = false">鍙栨秷</el-button>
+				<el-button type="primary" @click="openUpload()">涓嬩竴姝�</el-button>
 			</span>
 		</el-dialog>
 	</div>
@@ -206,23 +270,40 @@
 			return {
 				componentData: {
 					entity: {
-						updateTime: null,
+						createTime: null,
 						registrant: null,
 						product: null,
 						orderBy: {
 							field: 'id',
-							order: 'desc'
+							order: 'asc'
 						}
 					},
 					isIndex: true,
-					showSelect: true,
+					showSelect: false,
 					select: true,
 					do: [{
+						id: 'update',
 						font: '缂栬緫',
 						type: 'text',
-						method: 'upRole'
+						method: 'upRole',
+						field: ['createUserName', 'updateUserName', 'registrant', 'department', 'consumption',
+							'rebateConsumption', 'discountedConsumption', 'profit', 'remark', 'actualCost', 'fansAdd', 'agentRebate'
+						]
+					}, {
+						id: 'delete',
+						font: '鍒犻櫎',
+						type: 'text',
+						method: 'doDiy'
 					}],
-					tagField: {}
+					tagField: {},
+					selectField: {
+						vxCard: {
+							select: []
+						}
+					},
+					requiredAdd:['name2','agent','channel','product','showNum','click','accountConsumption','vxCard'],
+					countFleid: ['fansAdd'],
+					uploadStr: ""
 				},
 				entityCopy: {},
 				upIndex: 0,
@@ -231,26 +312,61 @@
 				upLoad: false,
 				upData: {},
 				product: [],
+				uploadDia: false,
+				fileList: [],
+				uploading: false,
+				addPower: true,
+				token: null,
+				inPower: true,
+				outPower: true,
+				delAllPower: true,
+				userNames: [],
+				vxs: [],
+				chooseDia: false,
+				vx: null
 			}
+		},
+		created() {
+			var today = new Date();
+			var yesterday = new Date(today);
+			yesterday.setDate(today.getDate() - 1);
+			var yyyy = yesterday.getFullYear();
+			var mm = yesterday.getMonth() + 1;
+			var dd = yesterday.getDate()
+			if (dd < 10) {
+				dd = "0" + dd;
+			}
+			if (mm < 10) {
+				mm = "0" + mm;
+			}
+			this.componentData.entity.createTime = this.HaveJson(`${yyyy}-${mm}-${dd} 00:00:00`)
 		},
 		mounted() {
 			this.entityCopy = this.HaveJson(this.componentData.entity)
 			this.selectProductEnumList()
 			this.getPower()
+			this.token = {
+				'token': sessionStorage.getItem('token')
+			}
+			this.selectDataReportingForCreateUserNames()
+			this.selectVxs()
 		},
 		methods: {
 			refreshTable() {
 				this.$refs['ValueTable'].selectList()
+				this.selectDataReportingForCreateUserNames()
+				this.selectVxs()
 			},
 			refresh() {
 				this.componentData.entity = this.HaveJson(this.entityCopy)
 				this.upIndex++
+				this.selectDataReportingForCreateUserNames()
 			},
 			upRole(row) {
 				this.upData = this.HaveJson(row)
 				this.upDia = true
 			},
-			saveUpData(){
+			saveUpData() {
 				this.upLoad = true
 				delete this.upData.createTime
 				delete this.upData.updateTime
@@ -260,9 +376,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,25 +386,141 @@
 					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
+				let delAllPower = 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 (power[i].menuMethod == 'deleteAllData') {
+						delAllPower = 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
+				this.delAllPower = delAllPower
+			},
+			openUpload() {
+				if(this.vx == null || this.vx == undefined) {
+					this.$message.error('璇烽�夋嫨鏁版嵁涓婃姤鐨勫井淇″彿')
+					return
+				}
+				this.componentData.uploadStr = this.vx
+				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();
+				this.uploadDia = false
+			},
+			onSuccess(response, file, fileList) {
+				this.$refs.upload.clearFiles()
+				this.uploadDia = false
+				this.uploading = false
+				this.chooseDia = false
+				if(response.code==201){
+					this.$message.error(response.message)
+					return
+				}
+				this.$message.success('涓婁紶鎴愬姛')
+				this.refreshTable()
+			},
+			onError(err, file, fileList) {
+				this.$message.error('涓婁紶澶辫触')
+				this.$refs.upload.clearFiles()
+				this.uploading = false
+			},
+			opeaAdd() {
+				this.$refs.ValueTable.openAddDia(this.$api.dataReporting.addDataReporting);
+			},
+			delNowAll(){
+				this.$confirm('鏄惁鍒犻櫎 '+this.componentData.entity.createTime.split(' ')[0]+' 鏁版嵁鏃堕棿鐨勫叏閮ㄦ暟鎹�?', "璀﹀憡", {
+					confirmButtonText: "纭畾",
+					cancelButtonText: "鍙栨秷",
+					type: "error"
+				}).then(() => {
+					this.uploading = true
+					this.$axios.post(this.$api.dataReporting.deleteAllData, {
+						date: this.componentData.entity.createTime.split(' ')[0]
+					}).then(res => {
+						this.uploading = false
+						if (res.code === 201) {
+							return
+						}
+						this.$message.success('鍒犻櫎鎴愬姛')
+						this.refreshTable()
+					})
+				}).catch(() => {})
+			},
+			selectDataReportingForCreateUserNames(){
+				this.$axios.post(this.$api.dataReporting.selectDataReportingForCreateUserNames,{
+					time: this.componentData.entity.createTime
+				}).then(res => {
+					this.userNames = res.data
+				})
+			},
+			selectVxs(){
+				this.$axios.get(this.$api.dataReporting.selectVxs,{
+					params:{
+						time: this.componentData.entity.createTime
+					}
+				}).then(res => {
+					if (res.code === 201) {
+						return
+					}
+					this.vxs = res.data
+					var str = []
+					res.data.forEach(a => {
+						str.push({
+							label: a.vx,
+							value: a.vx
+						})
+					})
+					this.componentData.selectField.vxCard.select = str
+				})
 			}
 		}
 	}
-</script>
\ No newline at end of file
+</script>

--
Gitblit v1.9.3