dukai 3 éve
szülő
commit
6a22ae9a98

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

@@ -52,3 +52,11 @@ export function getCommonPerson(belongUserId) {
 		method: 'get',
 	})
 }
+// 更新业务常用人信息
+export function updateCommonPerson(data) {
+	return request({
+		url: '/system/commonPerson',
+		method: 'put',
+		data
+	})
+}

+ 27 - 6
src/components/userChoice/index.vue

@@ -14,9 +14,9 @@
 			</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 v-for="(item, index) in commonPersonList" :key="index" class="text">
+				<el-button size="small" class="btn" @click="selectedCommonPerson(item.userId)">{{ item.commonPersonName }}</el-button>
+			</div>
 		</div>
 		<span slot="footer" class="dialog-footer">
 			<el-input v-model="userName" disabled size="small" style="width: 100px; margin-right: 10px" />
@@ -26,7 +26,7 @@
 </template>
 <script>
 import { getLevelTreeSelect } from '@/api/system/employeenInfo'
-import { selectListByDeptId } from '@/api/system/stockLocation'
+import { selectListByDeptId, updateCommonPerson, getCommonPerson } from '@/api/system/stockLocation'
 import Treeselect from '@riophae/vue-treeselect'
 import '@riophae/vue-treeselect/dist/vue-treeselect.css'
 export default {
@@ -39,7 +39,8 @@ export default {
 			depList: [], // 公司部门树
 			postList: [], // 级别职称树
 			personList: [], // 人员列表
-			userName: '' //展示人名
+			userName: '', //展示人名
+			commonPersonList: [] // 常用人列表
 		}
 	},
 	components: { Treeselect },
@@ -47,6 +48,7 @@ export default {
 		this.init()
 		this.getLevelList()
 		this.selectPerson()
+		this.getCommonPerson()
 	},
 	methods: {
 		init(val, list) {
@@ -55,6 +57,14 @@ export default {
 				this.depList = list
 			}
 		},
+		// 查询常用人
+		getCommonPerson() {
+			getCommonPerson(this.$store.state.user.userId).then(res => {
+				if (res.code === 200) {
+					this.commonPersonList = res.data
+				}
+			})
+		},
 		// 选择部门
 		selectDept(node, instanceId) {
 			console.log(node)
@@ -91,9 +101,20 @@ export default {
 		selectedPerson(e) {
 			this.userName = this.personList.find(item => item.userId === e).realName
 		},
+		// 选定常用人
+		selectedCommonPerson(userId) {
+			this.userName = this.personList.find(item => item.userId === userId).realName
+			this.userId = userId
+		},
 		// 确认提交
 		submit() {
-			if (this.userId) {
+			const exist = this.commonPersonList.some((item, index, c) => item.userId === this.userId)
+			if (this.userId && !exist) {
+				updateCommonPerson({ belongUserId: this.$store.state.user.userId, commonPersonName: this.userName, userId: this.userId }).then(res => {
+					this.$emit('selectedPerson', this.userId)
+					this.open = false
+				})
+			} else if (this.userId && exist) {
 				this.$emit('selectedPerson', this.userId)
 				this.open = false
 			} else {

+ 1 - 0
src/views/system/stockLocation/index.vue

@@ -170,6 +170,7 @@ export default {
 				this.deptOptions.unshift({ id: '0', label: '全部部门' })
 				this.$refs.userChoice.init(true, this.deptOptions)
 			})
+			this.$refs.userChoice.selectPerson()
 		},
 		//人员回调
 		selectedPerson(data) {