1
0
dukai 3 жил өмнө
parent
commit
6539cb369e

+ 628 - 620
src/views/system/employeenInfo/index.vue

@@ -20,7 +20,7 @@
 		</div>
 		<div class="content-container">
 			<!-- 公司部门 -->
-			<TreeChoice :dataList="deptOptions" nodeKey="id" nodeVal="label" v-model="queryParams.deptIds" />
+			<TreeChoice :dataList="deptOptions" nodeKey="id" nodeVal="label" v-model="queryParams.deptIds" @click="deptClick" />
 			<div class="main">
 				<div class="table-nav">
 					<div class="tags">
@@ -537,647 +537,655 @@
 </template>
 
 <script>
-	import {
-		delUser,
-		addUser,
-		updateUser,
-		getStaffList,
-		getLevelTreeSelect,
-		getNatureTreeSelect,
-		getAuthRole,
-		updateAuthRole,
-		getDataRole,
-		updateDataRole,
-		getAccountInfo,
-		getPersonnel
-	} from '@/api/system/employeenInfo'
-	import { getToken } from '@/utils/auth'
-	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'
-	import '@riophae/vue-treeselect/dist/vue-treeselect.css'
-	import { deepClone } from '@/utils/index.js'
+import {
+	delUser,
+	addUser,
+	updateUser,
+	getStaffList,
+	getLevelTreeSelect,
+	getNatureTreeSelect,
+	getAuthRole,
+	updateAuthRole,
+	getDataRole,
+	updateDataRole,
+	getAccountInfo,
+	getPersonnel
+} from '@/api/system/employeenInfo'
+import { getToken } from '@/utils/auth'
+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'
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
+import { deepClone } from '@/utils/index.js'
 
-	export default {
-		name: 'employeenInfo',
-		dicts: [
-			'sys_normal_disable',
-			'sys_user_sex',
-			'sys_account_status',
-			'sys_employee_education',
-			'sys_marital_status',
-			'sys_employee_personality',
-			'sys_staff_adept',
-			'sys_income_life',
-			'sys_staff_hobby',
-			'sys_staff_height',
-			'sys_staff_appearance',
-			'sys_staff_constitution',
-			'sys_staff_medicalHistory',
-			'sys_staff_criminalLaw',
-			'sys_spare_relationship'
-		],
-		components: { Treeselect, TreeChoice, userAvatar },
-		data() {
-			return {
-				// 遮罩层
-				loading: true,
-				// 显示搜索条件
-				showSearch: true,
-				// 总条数
-				total: 0,
-				// 用户表格数据
-				userList: null,
-				// 弹出层标题
-				title: '',
-				// 部门树选项
-				deptOptions: undefined,
-				// 是否显示弹出层
-				open: false,
-				// 岗位选项
-				postOptions: [],
-				// 角色选项
-				roleOptions: [],
-				// 账号表单参数
-				accountForm: {
-					serialNumber: 0,
-					userNumber: '',
-					realName: '',
-					phoneNumber: '',
-					status: '',
-					sex: '',
-					idNumber: '',
-					deptIds: [],
-					levelJobIds: [],
-					naturePostIds: []
-				},
-				// 基础表单参数
-				basicsForm: {},
-				defaultProps: {
-					children: 'children',
-					label: 'label'
-				},
-				// 用户导入参数
-				upload: {
-					// 是否显示弹出层(用户导入)
-					open: false,
-					// 弹出层标题(用户导入)
-					title: '',
-					// 是否禁用上传
-					isUploading: false,
-					// 是否更新已经存在的用户数据
-					updateSupport: 0,
-					// 设置上传的请求头部
-					headers: { Authorization: 'Bearer ' + getToken() },
-					// 上传的地址
-					url: process.env.VUE_APP_BASE_API + '/system/user/importData'
-				},
-				// 查询参数
-				queryParams: {
-					pageNum: 1,
-					pageSize: 10,
-					realName: undefined,
-					phonenumber: undefined,
-					deptIds: [],
-				},
-				// 列信息
-				columns: [
-					{ key: 0, label: `序号`, visible: true },
-					{ key: 1, label: `头像`, visible: true },
-					{ key: 2, label: `姓名`, visible: true },
-					{ key: 3, label: `公司部门`, visible: true },
-					{ key: 4, label: `级别职务`, visible: true },
-					{ key: 5, label: `性质岗位`, visible: true },
-					{ key: 6, label: `角色权限`, visible: true },
-					{ key: 7, label: `手机号码`, visible: true }
-				],
-				// 表单校验
-				accountFormRules: {
-					realName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
-					phoneNumber: [
-						{ required: true, message: '手机号不能为空', trigger: 'blur' },
-						{
-							pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
-							message: '请输入正确的手机号码',
-							trigger: 'blur'
-						}
-					],
-					idNumber: [
-						{ required: true, message: '身份证号不能为空', trigger: 'blur' },
-						{
-							pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
-							message: '请输入正确的身份证号码',
-							trigger: 'blur'
-						}
-					],
-					deptIds: [{ required: true, message: '请选择公司部门', trigger: 'submit' }],
-					levelJobIds: [{ required: true, message: '请选择职称级别', trigger: 'submit' }],
-					naturePostIds: [{ required: true, message: '请选择性质岗位', trigger: 'submit' }]
-				},
-				basicsRules: {
-					education: [{ required: true, message: '请选择学历', trigger: 'submit' }],
-					origin: [{ required: true, message: '请输入原籍', trigger: 'submit' }],
-					currentAddress: [{ required: true, message: '请输入现住址', trigger: 'submit' }],
-					maritalStatus: [{ required: true, message: '请选择婚姻状况', trigger: 'submit' }],
-					workExpertise: [{ required: true, message: '请输入工作特长', trigger: 'submit' }],
-					workDesire: [{ required: true, message: '请输入期望职位', trigger: 'submit' }],
-					incomeDesire: [{ required: true, message: '请输入收入愿望', trigger: 'submit' }]
-				},
-				dialogTableRolePermissions: false, // 角色权限弹出层
-				dialogPower: false, // 责权信息弹出层
-				accountShow: true, // 账号信息
-				basicsShow: false, // 基础信息
-				dialogTableDataRole: false, // 数据权限
-				props: { multiple: true }, // 联级多选
-				levelList: [], // 级别列表
-				natureList: [], // 性质岗位列表
-				levelJobs: [], // 责权信息列表
-				jodId: '', // 职位id
-				responsibility: '', // 职责
-				right: '', // 权力
-				roleList: [], // 员工角色列表
-				dateRange: [], // 日期范围
-				basicsForm: {
-					age: '', //年龄
-					appearance: '', //颜值
-					character: '', //性格
-					constitution: '', //体质
-					contactEmployer: '', //工作单位
-					contactName: '', //备用联系人姓名
-					contactPhoneNumber: '', //备用联系人电话
-					contactRelation: '', //与之关系
-					contactSex: '', //备用联系人性别
-					criminalLaw: '', //刑法
-					currentAddress: '', //现住址
-					dateOfBirth: '', //出生日期
-					// descriptionJson: '',
-					descriptionJson: [{ name: '', startDate: '', endDate: '', duty: '', inCome: '', id: 1 }], //原工作单位json串
-					dream: '', //梦想
-					education: '', //学历
-					favorite: [], //喜爱
-					height: '', //身高
-					householdIncome: '', //家庭收入
-					incomeDesire: '', //收入愿望
-					life: '', //生活
-					maritalStatus: '', //婚姻状况
-					medicalHistory: '', //病史
-					memberOfFamily: '', //家庭成员
-					origin: '', //原籍
-					personnelType: 0, //人员类型
-					qqNumber: '', //qq号
-					specialty: [], //擅长
-					workDesire: '', //期望职位
-					workExpertise: '', //工作特长
-					wxUserId: '' //企业微信号
-				},
-				rolesParams: {
-					roleName: undefined,
-					roleKey: undefined,
-					roleSort: undefined
-				},
-				DataRoleParams: {
-					pageNum: 1,
-					pageSize: 10
-				},
-				dataRoleListAll: [], // 所有数据权限列表
-				dataRoleList: [] // 员工数据权限
-			}
-		},
-		created() {
-			this.getList()
-			this.getTreeselect()
-		},
-		methods: {
-			/** 查询用户列表 */
-			getList() {
-				this.loading = true
-				getStaffList(this.queryParams).then((response) => {
-					this.userList = response.rows
-					this.total = response.total
-					this.loading = false
-				})
+export default {
+	name: 'employeenInfo',
+	dicts: [
+		'sys_normal_disable',
+		'sys_user_sex',
+		'sys_account_status',
+		'sys_employee_education',
+		'sys_marital_status',
+		'sys_employee_personality',
+		'sys_staff_adept',
+		'sys_income_life',
+		'sys_staff_hobby',
+		'sys_staff_height',
+		'sys_staff_appearance',
+		'sys_staff_constitution',
+		'sys_staff_medicalHistory',
+		'sys_staff_criminalLaw',
+		'sys_spare_relationship'
+	],
+	components: { Treeselect, TreeChoice, userAvatar },
+	data() {
+		return {
+			// 遮罩层
+			loading: true,
+			// 显示搜索条件
+			showSearch: true,
+			// 总条数
+			total: 0,
+			// 用户表格数据
+			userList: null,
+			// 弹出层标题
+			title: '',
+			// 部门树选项
+			deptOptions: undefined,
+			// 是否显示弹出层
+			open: false,
+			// 岗位选项
+			postOptions: [],
+			// 角色选项
+			roleOptions: [],
+			// 账号表单参数
+			accountForm: {
+				serialNumber: 0,
+				userNumber: '',
+				realName: '',
+				phoneNumber: '',
+				status: '',
+				sex: '',
+				idNumber: '',
+				deptIds: [],
+				levelJobIds: [],
+				naturePostIds: []
 			},
-			/** 查询部门下拉树结构 */
-			getTreeselect() {
-				treeselect().then((response) => {
-					this.deptOptions = response.data
-					// this.deptOptions.map((item) => item.id.toString())
-				})
-			},
-			// 节点单击事件
-			handleNodeClick(data) {
-				this.queryParams.deptId = data.id
-				this.getList()
-			},
-			// 取消按钮
-			cancel() {
-				this.open = false
-				this.reset()
-			},
-			// 表单重置
-			reset() {
-				this.form = {
-					userId: undefined,
-					deptId: undefined,
-					// userName: undefined,
-					nickName: undefined,
-					password: undefined,
-					phonenumber: undefined,
-					email: undefined,
-					sex: undefined,
-					status: '0',
-					remark: undefined,
-					postIds: [],
-					roleIds: []
-				}
-				this.resetForm('form')
-			},
-			/** 搜索按钮操作 */
-			handleQuery() {
-				this.queryParams.pageNum = 1
-				this.getList()
+			// 基础表单参数
+			basicsForm: {},
+			defaultProps: {
+				children: 'children',
+				label: 'label'
 			},
-			/** 重置按钮操作 */
-			resetQuery() {
-				this.resetForm('queryForm')
-				this.handleQuery()
-			},
-			/** 新增按钮操作 */
-			handleAdd() {
-				this.reset()
-				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) {
-				this.userId = row.userId
-				getAuthRole(row.userId).then((res) => {
-					if (res.code === 200) {
-						this.roleList = res.roles
-						console.log(this.roleList)
-						this.dialogTableRolePermissions = true
-					}
-				})
-			},
-			// 修改数据权限
-			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
-					}
-				})
-			},
-			// 保存数据权限修改
-			saveDataRole() {
-				let newArr = this.dataRoleList.filter((item, index, c) => item.flag == true)
-				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: '修改成功' })
-						this.getList()
-					}
-				})
-			},
-			// 取消数据权限修改
-			cancalDataRole() {
-				this.dialogTableDataRole = false
-			},
-			// 切换角色选中状态
-			roleChange(row, index) {
-				row.flag = !row.flag
-			},
-			// 切换数据角色选中状态
-			dataRoleChange(row, index) {
-				row.flag = !row.flag
-			},
-			// 保存角色权限修改
-			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(',')
-				updateAuthRole({ userId: this.userId, roleIds: roleIds }).then((res) => {
-					if (res.code === 200) {
-						this.dialogTableRolePermissions = false
-						this.$msg({ message: '修改成功' })
-						this.getList()
-					}
-				})
-			},
-			// 取消角色权限修改
-			cancalRolePermissions() {
-				this.dialogTableRolePermissions = false
-			},
-			// 职责权限
-			getDutiesPowers(row) {
-				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
-			},
-			// 账号信息
-			getAccountInfo() {
-				this.accountShow = true
-				this.basicsShow = false
-			},
-			// 基础信息
-			getBasicsInfo() {
-				this.accountShow = false
-				this.basicsShow = true
-			},
-			// 修改头像
-			modifyAvatar(row) {
-				this.$refs.userAvatar.editCropper()
+			// 用户导入参数
+			upload: {
+				// 是否显示弹出层(用户导入)
+				open: false,
+				// 弹出层标题(用户导入)
+				title: '',
+				// 是否禁用上传
+				isUploading: false,
+				// 是否更新已经存在的用户数据
+				updateSupport: 0,
+				// 设置上传的请求头部
+				headers: { Authorization: 'Bearer ' + getToken() },
+				// 上传的地址
+				url: process.env.VUE_APP_BASE_API + '/system/user/importData'
 			},
-			// 关闭责权信息
-			handleClose() {
-				this.dialogPower = false
+			// 查询参数
+			queryParams: {
+				pageNum: 1,
+				pageSize: 10,
+				realName: undefined,
+				phonenumber: undefined,
+				deptIds: []
 			},
-			//获取级别数据
-			getLevelList() {
-				getLevelTreeSelect().then((res) => {
-					if (res.code == 200) {
-						this.levelList = res.data
-						// this.levelList.map((item) => item.id.toString())
-					} else {
-						this.$msg({ type: 'error', message: res.msg })
-					}
-				})
-			},
-			// 获取性质岗位数据
-			getNatureList() {
-				getNatureTreeSelect().then((res) => {
-					if (res.code == 200) {
-						this.natureList = res.data
-						// this.natureList.map((item) => item.id.toString())
-					} else {
-						this.$msg({ type: 'error', message: res.msg })
+			// 列信息
+			columns: [
+				{ key: 0, label: `序号`, visible: true },
+				{ key: 1, label: `头像`, visible: true },
+				{ key: 2, label: `姓名`, visible: true },
+				{ key: 3, label: `公司部门`, visible: true },
+				{ key: 4, label: `级别职务`, visible: true },
+				{ key: 5, label: `性质岗位`, visible: true },
+				{ key: 6, label: `角色权限`, visible: true },
+				{ key: 7, label: `手机号码`, visible: true }
+			],
+			// 表单校验
+			accountFormRules: {
+				realName: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
+				phoneNumber: [
+					{ required: true, message: '手机号不能为空', trigger: 'blur' },
+					{
+						pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
+						message: '请输入正确的手机号码',
+						trigger: 'blur'
 					}
-				})
-			},
-			/** 修改按钮操作 */
-			handleUpdate(row) {
-				// debugger
-				this.userId = row.userId
-				this.getTreeselect()
-				this.getLevelList()
-				this.getNatureList()
-				// 查询账号信息
-				getAccountInfo(row.userId).then((response) => {
-					console.log(response)
-					this.open = true
-					this.title = '修改用户'
-					this.accountForm = response.data
-					this.accountForm.deptIds = response.data.deptIds.split(',')
-					this.accountForm.levelJobIds = response.data.levelJobIds.split(',')
-					this.accountForm.naturePostIds = response.data.naturePostIds.split(',')
-				})
-				// 查询基础信息
-				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(',')
-					this.basicsForm.specialty = res.data.specialty.split(',')
-				})
-			},
-			/** 提交按钮 */
-			submitForm: function () {
-				let accountStr = deepClone(this.accountForm)
-				accountStr.deptIds = accountStr.deptIds.join(',')
-				accountStr.levelJobIds = accountStr.levelJobIds.join(',')
-				accountStr.naturePostIds = accountStr.naturePostIds.join(',')
-				let str = deepClone(this.basicsForm)
-				str.dateOfBirth = this.ageInfo.birthday
-				str.age = this.ageInfo.age
-				str.favorite = str.favorite.join(',')
-				str.specialty = str.specialty.join(',')
-				str.descriptionJson = JSON.stringify(str.descriptionJson)
-				let params = { ...accountStr, ...str }
-				params.userId = this.userId
-				console.log(params)
-				this.$refs['accountForm'].validate((valid) => {
-					if (valid) {
-						if (params.userId != null) {
-							console.log(1231231312)
-							updateUser(params).then((response) => {
-								this.$modal.msgSuccess('修改成功')
-								this.open = false
-								this.getList()
-							})
-						} else {
-							addUser(params).then((response) => {
-								this.$modal.msgSuccess('新增成功')
-								this.open = false
-								this.getList()
-							})
-						}
+				],
+				idNumber: [
+					{ required: true, message: '身份证号不能为空', trigger: 'blur' },
+					{
+						pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
+						message: '请输入正确的身份证号码',
+						trigger: 'blur'
 					}
-				})
-			},
-			/** 删除按钮操作 */
-			handleDelete(row) {
-				// const userIds = row.userId
-				this.$modal
-					.confirm('是否确认删除用户编号为"' + row.userId + '"的数据项?')
-					.then(function () {
-						return delUser(row.userId)
-					})
-					.then(() => {
-						this.getList()
-						this.$modal.msgSuccess('删除成功')
-					})
-					.catch(() => {})
+				],
+				deptIds: [{ required: true, message: '请选择公司部门', trigger: 'submit' }],
+				levelJobIds: [{ required: true, message: '请选择职称级别', trigger: 'submit' }],
+				naturePostIds: [{ required: true, message: '请选择性质岗位', trigger: 'submit' }]
 			},
-			/** 导出按钮操作 */
-			handleExport() {
-				this.download(
-					'system/user/export',
-					{
-						...this.queryParams
-					},
-					`user_${new Date().getTime()}.xlsx`
-				)
+			basicsRules: {
+				education: [{ required: true, message: '请选择学历', trigger: 'submit' }],
+				origin: [{ required: true, message: '请输入原籍', trigger: 'submit' }],
+				currentAddress: [{ required: true, message: '请输入现住址', trigger: 'submit' }],
+				maritalStatus: [{ required: true, message: '请选择婚姻状况', trigger: 'submit' }],
+				workExpertise: [{ required: true, message: '请输入工作特长', trigger: 'submit' }],
+				workDesire: [{ required: true, message: '请输入期望职位', trigger: 'submit' }],
+				incomeDesire: [{ required: true, message: '请输入收入愿望', trigger: 'submit' }]
 			},
-			/** 导入按钮操作 */
-			handleImport() {
-				this.upload.title = '用户导入'
-				this.upload.open = true
+			dialogTableRolePermissions: false, // 角色权限弹出层
+			dialogPower: false, // 责权信息弹出层
+			accountShow: true, // 账号信息
+			basicsShow: false, // 基础信息
+			dialogTableDataRole: false, // 数据权限
+			props: { multiple: true }, // 联级多选
+			levelList: [], // 级别列表
+			natureList: [], // 性质岗位列表
+			levelJobs: [], // 责权信息列表
+			jodId: '', // 职位id
+			responsibility: '', // 职责
+			right: '', // 权力
+			roleList: [], // 员工角色列表
+			dateRange: [], // 日期范围
+			basicsForm: {
+				age: '', //年龄
+				appearance: '', //颜值
+				character: '', //性格
+				constitution: '', //体质
+				contactEmployer: '', //工作单位
+				contactName: '', //备用联系人姓名
+				contactPhoneNumber: '', //备用联系人电话
+				contactRelation: '', //与之关系
+				contactSex: '', //备用联系人性别
+				criminalLaw: '', //刑法
+				currentAddress: '', //现住址
+				dateOfBirth: '', //出生日期
+				// descriptionJson: '',
+				descriptionJson: [{ name: '', startDate: '', endDate: '', duty: '', inCome: '', id: 1 }], //原工作单位json串
+				dream: '', //梦想
+				education: '', //学历
+				favorite: [], //喜爱
+				height: '', //身高
+				householdIncome: '', //家庭收入
+				incomeDesire: '', //收入愿望
+				life: '', //生活
+				maritalStatus: '', //婚姻状况
+				medicalHistory: '', //病史
+				memberOfFamily: '', //家庭成员
+				origin: '', //原籍
+				personnelType: 0, //人员类型
+				qqNumber: '', //qq号
+				specialty: [], //擅长
+				workDesire: '', //期望职位
+				workExpertise: '', //工作特长
+				wxUserId: '' //企业微信号
 			},
-			/** 下载模板操作 */
-			importTemplate() {
-				this.download('system/user/importTemplate', {}, `user_template_${new Date().getTime()}.xlsx`)
+			rolesParams: {
+				roleName: undefined,
+				roleKey: undefined,
+				roleSort: undefined
 			},
-			// 文件上传中处理
-			handleFileUploadProgress(event, file, fileList) {
-				this.upload.isUploading = true
+			DataRoleParams: {
+				pageNum: 1,
+				pageSize: 10
 			},
-			// 文件上传成功处理
-			handleFileSuccess(response, file, fileList) {
-				this.upload.open = false
-				this.upload.isUploading = false
-				this.$refs.upload.clearFiles()
-				this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
+			dataRoleListAll: [], // 所有数据权限列表
+			dataRoleList: [] // 员工数据权限
+		}
+	},
+	created() {
+		this.getList()
+		this.getTreeselect()
+	},
+	methods: {
+		/** 查询用户列表 */
+		getList() {
+			this.loading = true
+			getStaffList(this.queryParams).then((response) => {
+				this.userList = response.rows
+				this.total = response.total
+				this.loading = false
+			})
+		},
+		/** 查询部门下拉树结构 */
+		getTreeselect() {
+			treeselect().then((response) => {
+				this.deptOptions = response.data
+				// this.deptOptions.map((item) => item.id.toString())
+			})
+		},
+		// 节点单击事件
+		handleNodeClick(data) {
+			this.queryParams.deptId = data.id
+			this.getList()
+		},
+		// 取消按钮
+		cancel() {
+			this.open = false
+			this.reset()
+		},
+		// 表单重置
+		reset() {
+			this.form = {
+				userId: undefined,
+				deptId: undefined,
+				// userName: undefined,
+				nickName: undefined,
+				password: undefined,
+				phonenumber: undefined,
+				email: undefined,
+				sex: undefined,
+				status: '0',
+				remark: undefined,
+				postIds: [],
+				roleIds: []
+			}
+			this.resetForm('form')
+		},
+		/** 搜索按钮操作 */
+		handleQuery() {
+			this.queryParams.pageNum = 1
+			this.getList()
+		},
+		deptClick() {
+			// this.queryParams.pageNum = 1
+			if (this.queryParams.deptIds == []) {
+				return
+			} else {
 				this.getList()
-			},
-			// 提交上传文件
-			submitFileForm() {
-				this.$refs.upload.submit()
-			},
-			addDescription(id) {
-				this.basicsForm.descriptionJson.push({ name: '', startDate: '', endDate: '', duty: '', inCome: '', id: id + 1 })
-			},
-			//删除原单位
-			delDescription(id) {
-				this.basicsForm.descriptionJson = this.basicsForm.descriptionJson.filter((item) => item.id != id)
 			}
 		},
-		computed: {
-			//获取主题颜色
-			theme() {
-				return this.$store.state.settings.theme
-			},
-			//根据身份证号获取年龄和生日
-			ageInfo() {
-				let num = this.accountForm.idNumber
-				if (/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(num)) {
-					let birthday = num.substring(6, 10) + '-' + num.substring(10, 12) + '-' + num.substring(12, 14)
-					var birthdays = new Date(birthday.replace(/-/g, '/'))
-					let d = new Date()
-					let age = d.getFullYear() - birthdays.getFullYear() - (d.getMonth() < birthdays.getMonth() || (d.getMonth() == birthdays.getMonth() && d.getDate() < birthdays.getDate()) ? 1 : 0)
-					return {
-						age,
-						birthday
-					}
+		/** 重置按钮操作 */
+		resetQuery() {
+			this.resetForm('queryForm')
+			this.handleQuery()
+		},
+		/** 新增按钮操作 */
+		handleAdd() {
+			this.reset()
+			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) {
+			this.userId = row.userId
+			getAuthRole(row.userId).then((res) => {
+				if (res.code === 200) {
+					this.roleList = res.roles
+					console.log(this.roleList)
+					this.dialogTableRolePermissions = true
 				}
-				return {
-					age: '',
-					birthday: ''
+			})
+		},
+		// 修改数据权限
+		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
 				}
-			},
-			isClick() {
-				return function (id) {
-					let obj = this.basicsForm.descriptionJson.find((item) => item.id == id)
-					let values = Object.values(obj).filter((item) => typeof item == 'string')
-					return values.every((item) => item != '')
+			})
+		},
+		// 保存数据权限修改
+		saveDataRole() {
+			let newArr = this.dataRoleList.filter((item, index, c) => item.flag == true)
+			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: '修改成功' })
+					this.getList()
 				}
-			},
-			//判断是不是最后一条
-			isLast() {
-				return function (id) {
-					let obj = this.basicsForm.descriptionJson.some((item) => item.id > id)
-					return !obj
+			})
+		},
+		// 取消数据权限修改
+		cancalDataRole() {
+			this.dialogTableDataRole = false
+		},
+		// 切换角色选中状态
+		roleChange(row, index) {
+			row.flag = !row.flag
+		},
+		// 切换数据角色选中状态
+		dataRoleChange(row, index) {
+			row.flag = !row.flag
+		},
+		// 保存角色权限修改
+		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(',')
+			updateAuthRole({ userId: this.userId, roleIds: roleIds }).then((res) => {
+				if (res.code === 200) {
+					this.dialogTableRolePermissions = false
+					this.$msg({ message: '修改成功' })
+					this.getList()
+				}
+			})
+		},
+		// 取消角色权限修改
+		cancalRolePermissions() {
+			this.dialogTableRolePermissions = false
+		},
+		// 职责权限
+		getDutiesPowers(row) {
+			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
+		},
+		// 账号信息
+		getAccountInfo() {
+			this.accountShow = true
+			this.basicsShow = false
+		},
+		// 基础信息
+		getBasicsInfo() {
+			this.accountShow = false
+			this.basicsShow = true
+		},
+		// 修改头像
+		modifyAvatar(row) {
+			this.$refs.userAvatar.editCropper()
+		},
+		// 关闭责权信息
+		handleClose() {
+			this.dialogPower = false
+		},
+		//获取级别数据
+		getLevelList() {
+			getLevelTreeSelect().then((res) => {
+				if (res.code == 200) {
+					this.levelList = res.data
+					// this.levelList.map((item) => item.id.toString())
+				} else {
+					this.$msg({ type: 'error', message: res.msg })
+				}
+			})
+		},
+		// 获取性质岗位数据
+		getNatureList() {
+			getNatureTreeSelect().then((res) => {
+				if (res.code == 200) {
+					this.natureList = res.data
+					// this.natureList.map((item) => item.id.toString())
+				} else {
+					this.$msg({ type: 'error', message: res.msg })
+				}
+			})
+		},
+		/** 修改按钮操作 */
+		handleUpdate(row) {
+			// debugger
+			this.userId = row.userId
+			this.getTreeselect()
+			this.getLevelList()
+			this.getNatureList()
+			// 查询账号信息
+			getAccountInfo(row.userId).then((response) => {
+				console.log(response)
+				this.open = true
+				this.title = '修改用户'
+				this.accountForm = response.data
+				this.accountForm.deptIds = response.data.deptIds.split(',')
+				this.accountForm.levelJobIds = response.data.levelJobIds.split(',')
+				this.accountForm.naturePostIds = response.data.naturePostIds.split(',')
+			})
+			// 查询基础信息
+			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(',')
+				this.basicsForm.specialty = res.data.specialty.split(',')
+			})
+		},
+		/** 提交按钮 */
+		submitForm: function () {
+			let accountStr = deepClone(this.accountForm)
+			accountStr.deptIds = accountStr.deptIds.join(',')
+			accountStr.levelJobIds = accountStr.levelJobIds.join(',')
+			accountStr.naturePostIds = accountStr.naturePostIds.join(',')
+			let str = deepClone(this.basicsForm)
+			str.dateOfBirth = this.ageInfo.birthday
+			str.age = this.ageInfo.age
+			str.favorite = str.favorite.join(',')
+			str.specialty = str.specialty.join(',')
+			str.descriptionJson = JSON.stringify(str.descriptionJson)
+			let params = { ...accountStr, ...str }
+			params.userId = this.userId
+			console.log(params)
+			this.$refs['accountForm'].validate((valid) => {
+				if (valid) {
+					if (params.userId != null) {
+						console.log(1231231312)
+						updateUser(params).then((response) => {
+							this.$modal.msgSuccess('修改成功')
+							this.open = false
+							this.getList()
+						})
+					} else {
+						addUser(params).then((response) => {
+							this.$modal.msgSuccess('新增成功')
+							this.open = false
+							this.getList()
+						})
+					}
+				}
+			})
+		},
+		/** 删除按钮操作 */
+		handleDelete(row) {
+			// const userIds = row.userId
+			this.$modal
+				.confirm('是否确认删除用户编号为"' + row.userId + '"的数据项?')
+				.then(function () {
+					return delUser(row.userId)
+				})
+				.then(() => {
+					this.getList()
+					this.$modal.msgSuccess('删除成功')
+				})
+				.catch(() => {})
+		},
+		/** 导出按钮操作 */
+		handleExport() {
+			this.download(
+				'system/user/export',
+				{
+					...this.queryParams
+				},
+				`user_${new Date().getTime()}.xlsx`
+			)
+		},
+		/** 导入按钮操作 */
+		handleImport() {
+			this.upload.title = '用户导入'
+			this.upload.open = true
+		},
+		/** 下载模板操作 */
+		importTemplate() {
+			this.download('system/user/importTemplate', {}, `user_template_${new Date().getTime()}.xlsx`)
+		},
+		// 文件上传中处理
+		handleFileUploadProgress(event, file, fileList) {
+			this.upload.isUploading = true
+		},
+		// 文件上传成功处理
+		handleFileSuccess(response, file, fileList) {
+			this.upload.open = false
+			this.upload.isUploading = false
+			this.$refs.upload.clearFiles()
+			this.$alert(response.msg, '导入结果', { dangerouslyUseHTMLString: true })
+			this.getList()
+		},
+		// 提交上传文件
+		submitFileForm() {
+			this.$refs.upload.submit()
+		},
+		addDescription(id) {
+			this.basicsForm.descriptionJson.push({ name: '', startDate: '', endDate: '', duty: '', inCome: '', id: id + 1 })
+		},
+		//删除原单位
+		delDescription(id) {
+			this.basicsForm.descriptionJson = this.basicsForm.descriptionJson.filter((item) => item.id != id)
+		}
+	},
+	computed: {
+		//获取主题颜色
+		theme() {
+			return this.$store.state.settings.theme
+		},
+		//根据身份证号获取年龄和生日
+		ageInfo() {
+			let num = this.accountForm.idNumber
+			if (/^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/.test(num)) {
+				let birthday = num.substring(6, 10) + '-' + num.substring(10, 12) + '-' + num.substring(12, 14)
+				var birthdays = new Date(birthday.replace(/-/g, '/'))
+				let d = new Date()
+				let age = d.getFullYear() - birthdays.getFullYear() - (d.getMonth() < birthdays.getMonth() || (d.getMonth() == birthdays.getMonth() && d.getDate() < birthdays.getDate()) ? 1 : 0)
+				return {
+					age,
+					birthday
 				}
 			}
+			return {
+				age: '',
+				birthday: ''
+			}
+		},
+		isClick() {
+			return function (id) {
+				let obj = this.basicsForm.descriptionJson.find((item) => item.id == id)
+				let values = Object.values(obj).filter((item) => typeof item == 'string')
+				return values.every((item) => item != '')
+			}
+		},
+		//判断是不是最后一条
+		isLast() {
+			return function (id) {
+				let obj = this.basicsForm.descriptionJson.some((item) => item.id > id)
+				return !obj
+			}
 		}
 	}
+}
 </script>
 <style scoped>
-	.responsibility {
-		width: 108px;
-		height: 32px;
-		margin-top: 20px;
-		font-weight: bold;
-	}
-	.option {
-		display: flex;
-		margin-bottom: 10px;
-		border-bottom: 1px solid #dfe6ec;
-	}
-	.account {
-		width: 90px;
-		height: 40px;
-		text-align: center;
-		line-height: 40px;
-		font-size: 14px;
-		border: 1px solid #dfe6ec;
-		border-top-left-radius: 5px;
-		border-right: none;
-		border-bottom: none;
-	}
-	.basics {
-		width: 90px;
-		height: 40px;
-		text-align: center;
-		line-height: 40px;
-		font-size: 14px;
-		border: 1px solid #dfe6ec;
-		border-bottom: none;
-	}
-	.basics_form {
-		overflow: auto;
-		height: 600px;
-	}
-	.img_height {
-		height: 32px;
-		width: 32px;
-		vertical-align: middle;
-		cursor: pointer;
-	}
-	.el-col-lg-4-8 {
-		width: 20%;
-	}
-	.search_form {
-		display: flex;
-		justify-content: space-between;
-	}
-	.search_form .el-form-item {
-		margin-bottom: 0;
-	}
-	.role_ {
-		margin-left: 5px;
-	}
-	::v-deep .el-radio__inner {
-		border-radius: 0;
-		position: relative;
-	}
-	::v-deep .el-radio__input.is-checked .el-radio__inner::after {
-		background: none;
-		border-radius: 0;
-		-webkit-box-sizing: content-box;
-		box-sizing: content-box;
-		content: '';
-		border: 1px solid #ffffff;
-		border-left: 0;
-		border-top: 0;
-		height: 7px;
-		left: 4px;
-		position: absolute;
-		top: 1px;
-		-webkit-transform: rotate(45deg);
-		transform: rotate(45deg);
-		width: 3px;
-		-webkit-transition: -webkit-transform 0.15s ease-in 0.05s;
-		transition: -webkit-transform 0.15s ease-in 0.05s;
-		transition: transform 0.15s ease-in 0.05s;
-		transition: transform 0.15s ease-in 0.05s, -webkit-transform 0.15s ease-in 0.05s;
-		-webkit-transform-origin: center;
-		transform-origin: center;
-	}
-	.description {
-		border-top: 1px solid #dedede;
-		padding-top: 10px;
-		margin-top: 10px;
-	}
+.responsibility {
+	width: 108px;
+	height: 32px;
+	margin-top: 20px;
+	font-weight: bold;
+}
+.option {
+	display: flex;
+	margin-bottom: 10px;
+	border-bottom: 1px solid #dfe6ec;
+}
+.account {
+	width: 90px;
+	height: 40px;
+	text-align: center;
+	line-height: 40px;
+	font-size: 14px;
+	border: 1px solid #dfe6ec;
+	border-top-left-radius: 5px;
+	border-right: none;
+	border-bottom: none;
+}
+.basics {
+	width: 90px;
+	height: 40px;
+	text-align: center;
+	line-height: 40px;
+	font-size: 14px;
+	border: 1px solid #dfe6ec;
+	border-bottom: none;
+}
+.basics_form {
+	overflow: auto;
+	height: 600px;
+}
+.img_height {
+	height: 32px;
+	width: 32px;
+	vertical-align: middle;
+	cursor: pointer;
+}
+.el-col-lg-4-8 {
+	width: 20%;
+}
+.search_form {
+	display: flex;
+	justify-content: space-between;
+}
+.search_form .el-form-item {
+	margin-bottom: 0;
+}
+.role_ {
+	margin-left: 5px;
+}
+::v-deep .el-radio__inner {
+	border-radius: 0;
+	position: relative;
+}
+::v-deep .el-radio__input.is-checked .el-radio__inner::after {
+	background: none;
+	border-radius: 0;
+	-webkit-box-sizing: content-box;
+	box-sizing: content-box;
+	content: '';
+	border: 1px solid #ffffff;
+	border-left: 0;
+	border-top: 0;
+	height: 7px;
+	left: 4px;
+	position: absolute;
+	top: 1px;
+	-webkit-transform: rotate(45deg);
+	transform: rotate(45deg);
+	width: 3px;
+	-webkit-transition: -webkit-transform 0.15s ease-in 0.05s;
+	transition: -webkit-transform 0.15s ease-in 0.05s;
+	transition: transform 0.15s ease-in 0.05s;
+	transition: transform 0.15s ease-in 0.05s, -webkit-transform 0.15s ease-in 0.05s;
+	-webkit-transform-origin: center;
+	transform-origin: center;
+}
+.description {
+	border-top: 1px solid #dedede;
+	padding-top: 10px;
+	margin-top: 10px;
+}
 </style>