From f29900986f01cf5d39b5755cec674825cef27961 Mon Sep 17 00:00:00 2001
From: gaoshp <291585735@qq.com>
Date: 星期二, 19 十一月 2024 19:25:41 +0800
Subject: [PATCH] update

---
 src/views/console/system/user.vue |  226 +++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 167 insertions(+), 59 deletions(-)

diff --git a/src/views/console/system/user.vue b/src/views/console/system/user.vue
index fa33479..82171a3 100644
--- a/src/views/console/system/user.vue
+++ b/src/views/console/system/user.vue
@@ -2,7 +2,7 @@
  * @Author: lzhe lzhe@example.com
  * @Date: 2024-03-26 10:28:33
  * @LastEditors: lzhe lzhe@example.com
- * @LastEditTime: 2024-03-29 16:20:06
+ * @LastEditTime: 2024-04-03 18:22:26
  * @FilePath: /smart-web/src/views/master/person/main/index.vue
  * @Description: 杩欐槸榛樿璁剧疆,璇疯缃甡customMade`, 鎵撳紑koroFileHeader鏌ョ湅閰嶇疆 杩涜璁剧疆: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 -->
@@ -11,22 +11,27 @@
 		<div class="user-top">
 			<div class="right-bottom"> 
 				<el-button type="primary" @click="addPerson">鏂板缓</el-button>
-				<el-button type="danger" plain @click="delPerson">鍒犻櫎</el-button>
+				<el-button type="primary" @click="resetPerson">瀵嗙爜閲嶇疆</el-button>
+				<el-button type="danger" plain @click="delData">鍒犻櫎</el-button>
 			</div>
 			<div>
-				<el-input v-model="input" placeholder="璇疯緭鍏ュ唴瀹�" style="width: 180px;margin-right: 8px;"></el-input>
-				<el-input v-model="input" placeholder="璇疯緭鍏ュ唴瀹�" style="width: 180px;margin-right: 8px;"></el-input>
-				<el-button type="primary" @click="searchUser">鎼滅储</el-button>
+				<el-input v-model="searchData.account" placeholder="璐﹀彿" style="width: 180px;margin-right: 8px;" clearable></el-input>
+				<el-input v-model="searchData.realName" placeholder="璐﹀彿鏄电О" style="width: 180px;margin-right: 8px;" clearable></el-input>
+				<el-button type="primary" @click="searchclick">鎼滅储</el-button>
 			</div>
 		</div>
 		<div class="user-table">
 			<el-table ref="multipleTableRef" :data="tableData" border style="width: 100%" class="multipleTableRef" @selection-change="handleSelectionChange">
 				<el-table-column type="selection" width="55" />
-				<el-table-column prop="date" label="璐﹀彿"></el-table-column>
-				<el-table-column prop="name" label="璐﹀彿鏄电О"></el-table-column>
-				<el-table-column prop="name" label="鎵�灞炶鑹�"></el-table-column>
-				<el-table-column prop="name" label="鏁版嵁鏉冮檺"></el-table-column>
-				<el-table-column prop="name" label="璐﹀彿鐘舵��"></el-table-column>
+				<el-table-column prop="account" label="璐﹀彿"></el-table-column>
+				<el-table-column prop="realName" label="璐﹀彿鏄电О"></el-table-column>
+				<el-table-column prop="roleName" label="鎵�灞炶鑹�"></el-table-column>
+				<el-table-column prop="deptName" label="鏁版嵁鏉冮檺"></el-table-column>
+				<el-table-column prop="name" label="璐﹀彿鐘舵��">
+					<template #default="scope">
+						<el-switch v-model="scope.row.status" @click="changeStatus(scope.row)" />
+					</template>
+				</el-table-column>
 				<el-table-column fixed="right" label="鎿嶄綔">
 					<template #default="scope">
 						<el-button type="text" size="small" @click="table_edit(scope.row, scope.$index)">缂栬緫</el-button>
@@ -35,13 +40,14 @@
 				</el-table-column>
 			</el-table>
 			<el-pagination
+				style="margin-top: 12px;"
 				@size-change="handleSizeChange"
 				@current-change="handleCurrentChange"
 				:current-page="currentPage4"
-				:page-sizes="[100, 200, 300, 400]"
-				:page-size="100"
+				:page-sizes="[15, 50, 100]"
+				:page-size="15"
 				layout="total, sizes, prev, pager, next, jumper"
-				:total="400">
+				:total="total">
 			</el-pagination>
 		</div>
 	</div>
@@ -64,16 +70,7 @@
 		</template>
 	</el-dialog>
 
-	<el-dialog v-model="dialogVisible" width="500" :before-close="handleClose">
-		<span>纭畾灏嗛�夋嫨璐﹀彿瑙i攣?</span>
-		<template #footer>
-		<div class="dialog-footer">
-			<el-button @click="dialogVisible = false">鍙栨秷</el-button>
-			<el-button type="primary" @click="dialogVisible = false">纭畾</el-button>
-		</div>
-		</template>
-	</el-dialog>
-	<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save=false"></save-dialog>
+	<save-dialog v-if="dialog.save" ref="saveDialog" @success="addUserSuccess" @closed="dialog.save=false"></save-dialog>
 </template>
 <script>
 	import saveDialog from './addUser'
@@ -81,7 +78,14 @@
 		name: "bakalaka",
 		data(){
 			return {
-				dialogVisible: false,
+				selection: [],
+				searchData: {
+					account: "",
+					realName: "",
+					current: "1",
+					size: "15"
+				},
+				total: 0,
 				isSaveing: false,
 				groups: [],
 				departmentFrom: {
@@ -103,51 +107,91 @@
 					label: '榛勯噾绯�'
 				}],
 				input3: '',
-				tableData: [{
-					date: '2016-05-02',
-					name: '鐜嬪皬铏�',
-					province: '涓婃捣',
-					city: '鏅檧鍖�',
-					address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1518 寮�',
-					zip: 200333
-					}, {
-					date: '2016-05-04',
-					name: '鐜嬪皬铏�',
-					province: '涓婃捣',
-					city: '鏅檧鍖�',
-					address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1517 寮�',
-					zip: 200333
-					}, {
-					date: '2016-05-01',
-					name: '鐜嬪皬铏�',
-					province: '涓婃捣',
-					city: '鏅檧鍖�',
-					address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1519 寮�',
-					zip: 200333
-					}, {
-					date: '2016-05-03',
-					name: '鐜嬪皬铏�',
-					province: '涓婃捣',
-					city: '鏅檧鍖�',
-					address: '涓婃捣甯傛櫘闄�鍖洪噾娌欐睙璺� 1516 寮�',
-					zip: 200333
-				}]
+				tableData: []
 			}
 		},
 		created(){
 			
 		},
 		mounted(){
-			
+			this.searchUser();
 		},
 		components: {
 			saveDialog
 		},
 		methods: {
-			table_unlock() {
-				this.dialogVisible = true;
+			addUserSuccess() {
+				this.searchclick();
 			},
-			searchUser() {},
+			changeStatus(row) {
+				row.status = !row.status;
+				var obj = {
+					enable: true,
+					id: row.id
+				}
+				var str = "";
+				if(row.status) {
+					obj.enable = false;
+					str = "鍋滅敤";
+				}else {
+					obj.status = true;
+					str = "鍚敤";
+				}
+				this.$confirm('纭畾瑕�'+str+row.account+'锛�','鎻愮ず', {
+					type: 'warning',
+				}).then(() => {
+					//const loading = this.$loading()
+					//loading.close()
+					this.$HTTP.post("/api/blade-user/changeStatus?"+this.$TOOL.qsStringify(obj)).then(res=> {
+						this.isSaveing = false;
+						if(res.code == 200) {
+							this.searchclick();
+							this.$message.success("鎿嶄綔鎴愬姛");
+						}else {
+							this.$alert(res.message, "鎻愮ず", {type: 'error'});
+						}
+					})
+				}).catch(() => {
+					//鍙栨秷
+				})
+			},
+			table_unlock(row) {
+				this.$confirm('纭畾灏嗛�夋嫨璐﹀彿瑙i攣?锛�','鎻愮ず', {
+					type: 'warning',
+				}).then(() => {
+					this.$HTTP.post("/api/blade-user/unlock?userId="+row.id).then(res=> {
+						if(res.code == 200) {
+							this.searchclick();
+							this.$message.success("鎿嶄綔鎴愬姛");
+						}else {
+							this.$alert(res.message, "鎻愮ず", {type: 'error'});
+						}
+					})
+				}).catch(() => {
+					//鍙栨秷
+				})
+			},
+			searchclick() {
+				this.searchData.current = "1";
+				this.searchData.size = "15";
+				this.searchUser();
+			},
+			searchUser() {
+				this.$HTTP.get("/api/blade-user/page",this.searchData).then(res=> {
+					if(res.code == 200) {
+						res.data.records.forEach(item=> {
+							if(item.status == "1") {
+								item.status = true;
+							}else {
+								item.status = false;
+							}
+						})
+						this.tableData = res.data.records;
+						this.total = res.data.total;
+						console.log(this.tableData)
+					}
+				})
+			},
 			departmentSubmit() {
 				this.departmentVisible=false;  //閮ㄩ棬璋冩暣
 			},
@@ -171,8 +215,67 @@
 					this.$refs.saveDialog.open('show').setData(row)
 				})
 			},
-			handleSelectionChange() {},
-			delPerson() {},
+			handleSelectionChange(selection) {
+				this.selection = selection;
+			},
+			resetPerson() {
+				if(this.selection.length == 0) {
+					this.$message({
+			          message: '璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�',
+			          type: 'warning'
+			        });
+			        return;
+				}
+				var selStr = "";
+				this.selection.map(item=> {
+					selStr += item.id + ","
+				})
+				selStr = selStr.replace(/,$/, '');
+				var that = this;
+				this.$confirm('鏄惁纭鍒犻櫎閫変腑璐﹀彿锛�','鎻愮ず', {
+					type: 'warning',
+				}).then(() => {
+					that.$HTTP.post("/api/blade-user/reset-password?userIds="+selStr).then(res=> {
+						if(res.code == 200) {
+							that.$message.success("鎿嶄綔鎴愬姛");
+							that.searchUser();
+						}
+					})
+				}).catch(() => {
+					//鍙栨秷
+				})
+			},
+			delData() {
+				if(this.selection.length == 0) {
+					this.$message({
+			          message: '璇烽�夋嫨鑷冲皯涓�鏉℃暟鎹�',
+			          type: 'warning'
+			        });
+			        return;
+				}
+				var selStr = "";
+				this.selection.map(item=> {
+					selStr += item.id + ","
+				})
+				selStr = selStr.replace(/,$/, '');
+				var that = this;
+				this.$HTTP.get("/api/blade-user/check-user-is-bind-employee?userIds="+selStr).then(res=> {
+					if(res.code == 200) {
+						this.$confirm('鏄惁纭鍒犻櫎閫変腑璐﹀彿锛�','鎻愮ず', {
+							type: 'warning',
+						}).then(() => {
+							that.$HTTP.post("/api/blade-user/remove?ids="+selStr).then(res=> {
+								if(res.code == 200) {
+									that.$message.success("鎿嶄綔鎴愬姛");
+									that.searchUser();
+								}
+							})
+						}).catch(() => {
+							//鍙栨秷
+						})
+					}
+				})
+			},
 			changeDepartment() {
 				this.departmentVisible = true;
 			},
@@ -185,9 +288,14 @@
 			},
 			handleSizeChange(val) {
 				console.log(`姣忛〉 ${val} 鏉);
+				this.searchData.current = "1";
+				this.searchData.size = val;
+				this.searchUser();
 			},
 			handleCurrentChange(val) {
 				console.log(`褰撳墠椤�: ${val}`);
+				this.searchData.current = val;
+				this.searchUser();
 			}
 		}
 	}

--
Gitblit v1.9.3