dukai 3 éve
szülő
commit
34e0013f34

+ 15 - 0
src/api/system/stockLocation.js

@@ -30,3 +30,18 @@ export function stockList(params) {
 		params
 	})
 }
+// 根据部门职务员工列表查询
+export function selectListByDeptId(deptId, levelJobId) {
+	return request({
+		url: '/system/user/selectListByDeptId?deptId=' + deptId + '&levelJobId=' + levelJobId,
+		method: 'get',
+	})
+}
+// 更新库位保管员
+export function updateKeeper(data) {
+	return request({
+		url: '/system/location/updateKeeper',
+		method: 'put',
+		data
+	})
+}

+ 118 - 69
src/components/userChoice/index.vue

@@ -1,84 +1,133 @@
 <template>
-  <div class="main">
-    <el-card class="box-card" v-show="list.length">
-      <div slot="header" class="header">
-        <span class="title">{{ title }}</span>
-      </div>
-      <div class="list_item">
-        <div v-for="(item, index) in list" :key="index" class="text item">
-          <el-button size="small" class="btn">{{ item }}</el-button>
-        </div>
-      </div>
-      <div class="footer">
-        <span slot="footer" class="btn_foot">
-          <el-button size="small">取 消</el-button>
-          <el-button type="primary" size="small">确 定</el-button>
-        </span>
-      </div>
-    </el-card>
-  </div>
+	<el-dialog title="人员选择" :visible.sync="open" width="42%">
+		<div class="select">
+			<div class="item">
+				<Treeselect v-model="deptId" noChildrenText="无数据" :disable-branch-nodes="true" search-nested :options="depList" placeholder="公司部门" @select="selectDept" />
+			</div>
+			<div class="item">
+				<Treeselect v-model="postId" noChildrenText="无数据" :disable-branch-nodes="true" search-nested :options="postList" placeholder="级别职称" @select="selectPost" />
+			</div>
+			<div class="item">
+				<el-select v-model="userId" placeholder="全部人员" clearable @change="selectedPerson">
+					<el-option v-for="item in personList" :key="item.userId" :label="item.realName" :value="item.userId"></el-option>
+				</el-select>
+			</div>
+		</div>
+		<div class="list_item">
+			<!-- <div v-for="(item, index) in list" :key="index" class="text item">
+				<el-button size="small" class="btn">{{ item }}</el-button>
+			</div> -->
+		</div>
+		<span slot="footer" class="dialog-footer">
+			<el-button type="primary" size="small" @click="submit">确 定</el-button>
+		</span>
+	</el-dialog>
 </template>
 <script>
+import { getLevelTreeSelect } from '@/api/system/employeenInfo'
+import { selectListByDeptId } from '@/api/system/stockLocation'
+import Treeselect from '@riophae/vue-treeselect'
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
 export default {
-  data() {
-    return {
-      list: [],
-      title: "",
-    };
-  },
-  created() {
-    this.inin();
-  },
-  methods: {
-    inin(val, title) {
-      if (val) {
-        this.list = val;
-        this.title = title;
-      }
-    },
-  },
-};
+	data() {
+		return {
+			open: false,
+			deptId: 0, // 公司部门id
+			postId: 0, // 级别职称id
+			userId: null, // 人员id
+			depList: [], // 公司部门树
+			postList: [], // 级别职称树
+			personList: [] // 人员列表
+		}
+	},
+	components: { Treeselect },
+	created() {
+		this.init()
+		this.getLevelList()
+		this.selectPerson()
+	},
+	methods: {
+		init(val, list) {
+			if (val) {
+				this.open = val
+				this.depList = list
+			}
+		},
+		// 选择部门
+		selectDept(node, instanceId) {
+			console.log(node)
+			this.personList = []
+			this.deptId = node.id
+			this.selectPerson()
+		},
+		//获取级别数据
+		getLevelList() {
+			getLevelTreeSelect().then((res) => {
+				if (res.code == 200) {
+					this.postList = res.data
+					this.postList.unshift({ id: '0', label: '全部级别' })
+				} else {
+					this.$msg({ type: 'error', message: res.msg })
+				}
+			})
+		},
+		// 选择级别
+		selectPost(node, instanceId) {
+			console.log(node)
+			this.personList = []
+			this.postId = node.id
+			this.selectPerson()
+		},
+		// 人员查询
+		selectPerson() {
+			this.personList = []
+			selectListByDeptId(this.deptId, this.postId).then((res) => {
+				console.log(res)
+				this.personList = res.data
+			})
+		},
+		// 选定人员
+		selectedPerson() {},
+		// 确认提交
+		submit() {
+			if (this.userId) {
+				this.$emit('selectedPerson', this.userId)
+				this.open = false
+			} else {
+				this.$notify({title: '警告', message: '请选择人员', type: 'warning'})
+			}
+		}
+	}
+}
 </script>
 <style scoped>
-.main{
-  margin-left: 100px;
-}
-.box-card {
-  width: 510px;
-}
 .list_item {
-  height: 200px;
-  overflow-y: scroll;
-  display: flex;
-  flex-wrap: wrap;
-  padding: 0 10px;
-}
-.text{
-  margin-top: 8px;
+	height: 200px;
+	overflow-y: scroll;
+	display: flex;
+	flex-wrap: wrap;
+	padding: 0px 10px;
+	margin-top: 20px;
 }
-.el-button{
-  font-size: 14px;
+.select {
+	display: flex;
+	justify-content: space-between;
 }
-.btn {
-  width: 85px;
-  margin-left: 9px;
+.item {
+	width: 250px;
 }
-.btn_foot{
-  padding-right: 50px;
-  display: flex;
-  justify-content: flex-end;
+.text {
+	margin-top: 8px;
 }
-.title{
-  font-size: 18px;
-  font-weight: bold;
+.btn {
+	width: 85px;
+	margin-left: 9px;
 }
-.footer{
-  border-top: #EBEEF5 solid 1px;
-  padding: 8px 0;
+.title {
+	font-size: 18px;
+	font-weight: bold;
 }
-</style>
-<style scoped>
-.el-card >>> .el-card__body{
-  padding: 0;
+.footer {
+	padding: 8px 0;
 }
 </style>

+ 8 - 21
src/views/system/employeenInfo/index.vue

@@ -552,7 +552,7 @@ import {
 	getPersonnel
 } from '@/api/system/employeenInfo'
 import { getToken } from '@/utils/auth'
-// import { treeselect } from '@/api/system/dept'
+import { treeselect } from '@/api/system/dept'
 import userAvatar from './profile/userAvatar.vue'
 import Treeselect from '@riophae/vue-treeselect'
 import TreeChoice from '@/components/deptTreeChoice/index.vue'
@@ -746,7 +746,6 @@ export default {
 	},
 	created() {
 		this.getList()
-		// this.getTreeselect()
 	},
 	methods: {
 		/** 查询用户列表 */
@@ -759,12 +758,11 @@ export default {
 			})
 		},
 		/** 查询部门下拉树结构 */
-		// getTreeselect() {
-		// 	treeselect().then((response) => {
-		// 		this.deptOptions = response.data
-		// 		// this.deptOptions.map((item) => item.id.toString())
-		// 	})
-		// },
+		getTreeselect() {
+			treeselect().then((response) => {
+				this.deptOptions = response.data
+			})
+		},
 		// 节点单击事件
 		handleNodeClick(data) {
 			this.queryParams.deptId = data.id
@@ -814,14 +812,13 @@ export default {
 		/** 新增按钮操作 */
 		handleAdd() {
 			this.reset()
-			// this.getTreeselect()
+			this.getTreeselect()
 			this.open = true
 			this.title = '添加用户'
 			this.getLevelList()
 			this.getNatureList()
 			// this.userList.map((item, index, c) => item.serialNumber)
 			this.accountForm.serialNumber = this.total + 1
-			console.log(this.accountForm.serialNumber)
 		},
 		// 修改角色权限
 		getRolePermissions(row) {
@@ -829,7 +826,6 @@ export default {
 			getAuthRole(row.userId).then((res) => {
 				if (res.code === 200) {
 					this.roleList = res.roles
-					console.log(this.roleList)
 					this.dialogTableRolePermissions = true
 				}
 			})
@@ -838,10 +834,8 @@ export default {
 		getDataRole(row) {
 			this.userId = row.userId
 			getDataRole(row.userId).then((res) => {
-				console.log(res)
 				if (res.code === 200) {
 					this.dataRoleList = res.dataRoles
-					console.log(this.dataRoleList)
 					this.dialogTableDataRole = true
 				}
 			})
@@ -852,7 +846,6 @@ export default {
 			let dataRoleIds = newArr.map((item, index, c) => item.dataRoleId)
 			// let dataRoleIdsStr = dataRoleIds.join(',')
 			updateDataRole({ userId: this.userId, roleIds: dataRoleIds }).then((res) => {
-				console.log(res)
 				if (res.code === 200) {
 					this.dialogTableDataRole = false
 					this.$msg({ message: '修改成功' })
@@ -874,7 +867,6 @@ export default {
 		},
 		// 保存角色权限修改
 		saveRolePermissions() {
-			console.log(this.roleList)
 			let newArr = this.roleList.filter((item, index, c) => item.flag == true)
 			let roleIds = newArr.map((item, index, c) => item.roleId)
 			// let roleIdsStr = roleIds.join(',')
@@ -895,12 +887,10 @@ export default {
 			let staff = this.userList.find((item, index, c) => item.userId === row.userId)
 			this.levelJobs = staff.levelJobs
 			// this.jodId = this.levelJobs[0].jobId
-			console.log(this.levelJobs)
 			this.dialogPower = true
 		},
 		// 选择职责权限
 		changeJob(val) {
-			console.log(val)
 			this.responsibility = val.responsibility
 			this.right = val.right
 		},
@@ -953,7 +943,6 @@ export default {
 			this.getNatureList()
 			// 查询账号信息
 			getAccountInfo(row.userId).then((response) => {
-				console.log(response)
 				this.open = true
 				this.title = '修改用户'
 				this.accountForm = response.data
@@ -963,7 +952,6 @@ export default {
 			})
 			// 查询基础信息
 			getPersonnel(row.userId).then((res) => {
-				console.log(res)
 				this.basicsForm = res.data
 				this.basicsForm.descriptionJson = JSON.parse(res.data.descriptionJson)
 				this.basicsForm.favorite = res.data.favorite.split(',')
@@ -974,8 +962,8 @@ export default {
 		submitForm: function () {
 			let accountStr = deepClone(this.accountForm)
 			accountStr.deptIds = accountStr.deptIds.join(',')
-			accountStr.levelJobIds = accountStr.levelJobIds.join(',')
 			accountStr.naturePostIds = accountStr.naturePostIds.join(',')
+			accountStr.levelJobIds = accountStr.levelJobIds.join(',')
 			let str = deepClone(this.basicsForm)
 			str.dateOfBirth = this.ageInfo.birthday
 			str.age = this.ageInfo.age
@@ -988,7 +976,6 @@ export default {
 			this.$refs['accountForm'].validate((valid) => {
 				if (valid) {
 					if (params.userId != null) {
-						console.log(1231231312)
 						updateUser(params).then((response) => {
 							this.$modal.msgSuccess('修改成功')
 							this.open = false

+ 147 - 130
src/views/system/stockLocation/index.vue

@@ -25,7 +25,7 @@
 				<el-table v-loading="loading" :data="dataList" border highlight-current-row>
 					<el-table-column label="库位" prop="locationName" width="200"></el-table-column>
 					<el-table-column label="公司部门" prop="deptName" width="300"></el-table-column>
-					<el-table-column label="保管员" prop="deptNames" width="200"></el-table-column>
+					<el-table-column label="保管员" prop="keeperName" width="200"></el-table-column>
 					<el-table-column label="描述" prop="remark" />
 					<el-table-column label="操作" class-name="small-padding fixed-width" width="300" align="center">
 						<template slot-scope="scope">
@@ -53,152 +53,169 @@
 						<el-button type="primary" size="small" @click="stockSub">保 存</el-button>
 					</div>
 				</el-dialog>
-				<UserChoice />
+				<UserChoice ref="userChoice" @selectedPerson="selectedPerson"/>
 			</div>
 		</div>
 	</div>
 </template>
 
 <script>
-	import { stockList, stockAdd, stockUpd, stockDel } from '@/api/system/stockLocation.js'
-	import TreeChoice from '@/components/deptTreeChoice/index.vue'
-	import UserChoice from '@/components/userChoice/index.vue'
-	export default {
-		name: 'stockLocation',
-		components: {
-			TreeChoice,
-			UserChoice
+import { stockList, stockAdd, stockUpd, stockDel, updateKeeper } from '@/api/system/stockLocation.js'
+import { treeselect } from '@/api/system/dept'
+import TreeChoice from '@/components/deptTreeChoice/index.vue'
+import UserChoice from '@/components/userChoice/index.vue'
+export default {
+	name: 'stockLocation',
+	components: {
+		TreeChoice,
+		UserChoice
+	},
+	data() {
+		return {
+			loading: false,
+			//拥有权限的部门id数组
+			hasDeptIds: [],
+			//数据
+			dataList: [],
+			//库位编辑弹窗显示
+			stockShow: false,
+			//库位编辑弹窗标题
+			title: '',
+			// 部门信息
+			deptOptions: [],
+			//库位表单
+			stockForm: { deptId: '', locationName: '', remark: '', deptName: '' },
+			//库位表单验证
+			stockRules: { locationName: [{ required: true, message: '名称不能为空', trigger: 'blur' }] },
+			locationId: '', // 库位id
+		}
+	},
+	methods: {
+		//获取数据
+		getList() {
+			if (!this.hasDeptIds.length) {
+				this.dataList = []
+				return
+			}
+			this.loading = true
+			stockList({ deptIds: this.hasDeptIds }).then((res) => {
+				if (res.code === 200) {
+					this.dataList = res.data
+					this.loading = false
+				}
+			})
+		},
+		//获取部门信息
+		getDeptInfo(d) {
+			this.stockForm.deptId = d.deptId
+			this.stockForm.deptName = d.deptName
 		},
-		data() {
-			return {
-				loading: false,
-				//拥有权限的部门id数组
-				hasDeptIds: [],
-				//数据
-				dataList: [],
-				//库位编辑弹窗显示
-				stockShow: false,
-				//库位编辑弹窗标题
-				title: '',
-				//库位表单
-				stockForm: { deptId: '', locationName: '', remark: '', deptName: '' },
-				//库位表单验证
-				stockRules: { locationName: [{ required: true, message: '名称不能为空', trigger: 'blur' }] }
+		//显示库位弹窗
+		addStockShow() {
+			this.title = '库位添加'
+			this.stockShow = true
+		},
+		//表单重置
+		resetForm() {
+			this.stockForm = { deptId: '', locationName: '', remark: '', deptName: '' }
+		},
+		//检测重名
+		checkName(data) {
+			let o = this.dataList.find((item) => item.locationName == data.locationName && item.locationId != data.locationId)
+			if (o) {
+				return '库位名称重复'
 			}
+			return false
 		},
-		methods: {
-			//获取数据
-			getList() {
-				if (!this.hasDeptIds.length) {
-					this.dataList = []
-					return
-				}
-				this.loading = true
-				stockList({ deptIds: this.hasDeptIds }).then((res) => {
-					if (res.code === 200) {
-						this.dataList = res.data
-						this.loading = false
+		//库位弹窗取消
+		stockCancel() {
+			this.resetForm()
+			this.stockShow = false
+		},
+		//库位弹窗提交
+		stockSub() {
+			this.$refs.stockForm.validate((valid) => {
+				if (valid) {
+					let checkFiled = this.checkName(this.stockForm)
+					if (checkFiled) {
+						this.$msg({ type: 'error', message: checkFiled })
+						return
 					}
-				})
-			},
-			//获取部门信息
-			getDeptInfo(d) {
-				this.stockForm.deptId = d.deptId
-				this.stockForm.deptName = d.deptName
-			},
-			//显示库位弹窗
-			addStockShow() {
-				this.title = '库位添加'
-				this.stockShow = true
-			},
-			//表单重置
-			resetForm() {
-				this.stockForm = { deptId: '', locationName: '', remark: '', deptName: '' }
-			},
-			//检测重名
-			checkName(data) {
-				let o = this.dataList.find((item) => item.locationName == data.locationName && item.locationId != data.locationId)
-				if (o) {
-					return '库位名称重复'
-				}
-				return false
-			},
-			//库位弹窗取消
-			stockCancel() {
-				this.resetForm()
-				this.stockShow = false
-			},
-			//库位弹窗提交
-			stockSub() {
-				this.$refs.stockForm.validate((valid) => {
-					if (valid) {
-						let checkFiled = this.checkName(this.stockForm)
-						if (checkFiled) {
-							this.$msg({ type: 'error', message: checkFiled })
-							return
-						}
-						if (this.stockForm.locationId) {
-							stockUpd(this.stockForm).then((res) => {
-								if (res.code === 200) {
-									this.$msg({ message: '修改成功' })
-									this.dataList = this.dataList.map((item) => {
-										if (item.locationId == this.stockForm.locationId) {
-											return {
-												...item,
-												...this.stockForm
-											}
-										}
+					if (this.stockForm.locationId) {
+						stockUpd(this.stockForm).then((res) => {
+							if (res.code === 200) {
+								this.$msg({ message: '修改成功' })
+								this.dataList = this.dataList.map((item) => {
+									if (item.locationId == this.stockForm.locationId) {
 										return {
-											...item
+											...item,
+											...this.stockForm
 										}
-									})
-									this.stockCancel()
-								}
-							})
-						} else {
-							stockAdd(this.stockForm).then((res) => {
-								if (res.code === 200) {
-									this.$msg({ message: '添加成功' })
-									this.getList()
-									this.stockCancel()
-								}
-							})
-						}
-					}
-				})
-			},
-			//选择人员
-			choiceUser() {},
-			//修改
-			updStock(row) {
-				this.stockForm = {
-					deptId: row.deptId,
-					locationName: row.locationName,
-					remark: row.remark,
-					deptName: row.deptName,
-					locationId: row.locationId
-				}
-				this.title = '库位修改'
-				this.stockShow = true
-			},
-			//删除
-			delStock(row) {
-				this.$modal
-					.confirm('确定要删除吗')
-					.then(() => {
-						stockDel(row.locationId).then((res) => {
-							if (res.code == 200) {
-								this.$msg({ message: '删除成功' })
-								this.dataList = this.dataList.filter((item) => item.locationId != row.locationId)
-							} else {
-								this.$msg({ type: 'error', message: res.msg })
+									}
+									return {
+										...item
+									}
+								})
+								this.stockCancel()
 							}
 						})
-					})
-					.catch(() => {})
+					} else {
+						stockAdd(this.stockForm).then((res) => {
+							if (res.code === 200) {
+								this.$msg({ message: '添加成功' })
+								this.getList()
+								this.stockCancel()
+							}
+						})
+					}
+				}
+			})
+		},
+		//选择人员
+		choiceUser(row) {
+			this.locationId = row.locationId
+			treeselect().then((response) => {
+				this.deptOptions = response.data
+				this.deptOptions.unshift({id: '0', label: '全部部门'})
+				this.$refs.userChoice.init(true, this.deptOptions)
+			})
+		},
+		//人员回调
+		selectedPerson(data) {
+			updateKeeper({keeper: data, locationId: this.locationId}).then(res => {
+				this.getList()
+			})
+		},
+		//修改
+		updStock(row) {
+			this.stockForm = {
+				deptId: row.deptId,
+				locationName: row.locationName,
+				remark: row.remark,
+				deptName: row.deptName,
+				locationId: row.locationId
 			}
+			this.title = '库位修改'
+			this.stockShow = true
+		},
+		//删除
+		delStock(row) {
+			this.$modal
+				.confirm('确定要删除吗')
+				.then(() => {
+					stockDel(row.locationId).then((res) => {
+						if (res.code == 200) {
+							this.$msg({ message: '删除成功' })
+							this.dataList = this.dataList.filter((item) => item.locationId != row.locationId)
+						} else {
+							this.$msg({ type: 'error', message: res.msg })
+						}
+					})
+				})
+				.catch(() => {})
 		}
 	}
+}
 </script>
 
 <style></style>