diff --git a/components/qianziyu-select/qianziyu-select.vue b/components/qianziyu-select/qianziyu-select.vue new file mode 100644 index 0000000..2c2b31f --- /dev/null +++ b/components/qianziyu-select/qianziyu-select.vue @@ -0,0 +1,181 @@ + + + + + diff --git a/pages/index/Staffmanagement.vue b/pages/index/Staffmanagement.vue index 4813b0f..83f6854 100644 --- a/pages/index/Staffmanagement.vue +++ b/pages/index/Staffmanagement.vue @@ -96,7 +96,7 @@ 身份证号: - + 入职时间: @@ -113,6 +113,13 @@ + + 驾照类型: + + + + 附件: @@ -160,7 +167,7 @@ + + @@ -218,7 +237,6 @@ export default { show: false, realName: "", phoneNum: "", - idCard: "", workName: "", workids: [], postid: '', @@ -228,20 +246,25 @@ export default { addRoleId: undefined, education: null, educationText: null, - idNumber: null, - joinedDate: null, - formalDate: null, - safeDate: null, + idCard: null, + joinDate: null, + probationPeriod: null, + socialSecurityBuyDate: null, educations: [], showEducation: false, showJoinedDate: false, showFormalDate: false, showSafeDate: false, - files: [] + files: [], + showDriveType: false, + driverLicenseType: [], + driverLicenseTypeArr: [], + driverLicenseTypeArrStr: null } }, onLoad() { - + this.getDriveType() + this.gettab() }, onPullDownRefresh() { uni.showLoading() @@ -262,23 +285,22 @@ export default { } }, onShow() { - this.gettab() // this.baseUrl = this.$baseUrl this.partnerId = uni.getStorageSync('partnerId') // this.getindex() }, computed: { formattedJoinedDate() { - if (!this.joinedDate) return ''; - return formatDate(this.joinedDate); // 确保formatDate返回'yyyy-MM-dd'格式 + if (!this.joinDate) return ''; + return formatDate(this.joinDate); // 确保formatDate返回'yyyy-MM-dd'格式 }, formattedFormalDate() { - if (!this.formalDate) return ''; - return formatDate(this.formalDate); // 确保formatDate返回'yyyy-MM-dd'格式 + if (!this.probationPeriod) return ''; + return formatDate(this.probationPeriod); // 确保formatDate返回'yyyy-MM-dd'格式 }, formattedSafeDate() { - if (!this.safeDate) return ''; - return formatDate(this.safeDate); // 确保formatDate返回'yyyy-MM-dd'格式 + if (!this.socialSecurityBuyDate) return ''; + return formatDate(this.socialSecurityBuyDate); // 确保formatDate返回'yyyy-MM-dd'格式 }, }, methods: { @@ -291,6 +313,15 @@ export default { this.files[index].fileUrl = config.baseImageUrl + "/" + res.data.url }) }, + getDriveType() { + return request({ + url: '/common/down/getDriverLicenseType', + method: 'get' + }).then(res => { + //提取出数组中的id属性 + this.driverLicenseType = res.data + }) + }, deletedUrl(index) { this.files.splice(index, 1) }, @@ -303,15 +334,15 @@ export default { } }, chooseJoinDate(e) { - this.joinedDate = formatDate(e.value) + this.joinDate = formatDate(e.value) this.showJoinedDate = false }, chooseFormalDate(e) { - this.formalDate = formatDate(e.value) + this.probationPeriod = formatDate(e.value) this.showFormalDate = false }, chooseSafeDate(e) { - this.safeDate = formatDate(e.value) + this.socialSecurityBuyDate = formatDate(e.value) this.showSafeDate = false }, chooseEducation(e) { @@ -334,6 +365,13 @@ export default { this.gwindex = index this.gwid = id }, + onsubmit(selectedData) { + console.log('提交的数据:', selectedData); + selectedData.map(item => item.id); + this.driverLicenseTypeArr = selectedData; + this.driverLicenseTypeArrStr = selectedData.map(item => item.id).join(','); + this.showDriveType = false; // 提交后关闭弹窗 + }, async gettab() { let res = await request({ url: '/system/role/pageByQuery', @@ -461,6 +499,8 @@ export default { title: "操作成功", }) + this.pageNum = 1 + this.goodsList = [] this.getindex() } }, @@ -483,10 +523,17 @@ export default { status: 0, userType: '01', roleId: this.gwid, + name: this.realName, + joinDate: this.joinDate, + idCard: this.idCard, + educational: this.educationText, + probationPeriod: this.probationPeriod, + socialSecurityBuyDate: this.socialSecurityBuyDate, + driverLicenseTypeArr: this.driverLicenseTypeArr.map(item => item.id), password: '123456' } let res = await request({ - url: '/system/user/create', + url: '/inspectionStaff/save', method: 'post', data: data }) @@ -502,26 +549,6 @@ export default { roleIds: roleIds } }) - - const staffData = { - userId: res.data, - name: this.realName, - tel: this.phoneNum, - joinedDate: this.joinedDate, - idNumber: this.idNumber, - education: this.education, - formalDate: this.formalDate, - safeDate: this.safeDate, - fileNames: this.files.length > 0 ? this.files.map(item => item.name).join(",") : "", - fileUrls: this.files.length > 0 ? this.files.map(item => { - return item.fileUrl.replace(config.baseImageUrl + "/", "") - }).join(",") : "" - } - const staffRes = await request({ - url: '/company/staff/updateByExistUser', - method: 'post', - data: staffData - }) uni.showToast({ title: "添加成功" }) diff --git a/pages/manage/deviceManage.vue b/pages/manage/deviceManage.vue index 96474e3..8efb9b9 100644 --- a/pages/manage/deviceManage.vue +++ b/pages/manage/deviceManage.vue @@ -168,7 +168,7 @@ }, viewFile(filePath){ uni.downloadFile({ - url: this.$baseImageUrl+filePath, + url: this.$baseImageUrl+'/'+filePath, success: function (res) { var filePath = res.tempFilePath; uni.openDocument({ diff --git a/pages/staff/StaffInfo.vue b/pages/staff/StaffInfo.vue index 4a457de..51cce49 100644 --- a/pages/staff/StaffInfo.vue +++ b/pages/staff/StaffInfo.vue @@ -10,20 +10,20 @@ 姓名: - + 电话: - + 学历: + placeholder="请选择学历" v-model="staff.educational"> 身份证号: - + 入职时间: @@ -40,17 +40,25 @@ + + 驾照类型: + + + + + 附件: 添加附件 - + 名称: - + - - + x @@ -78,7 +86,7 @@ + + @@ -111,8 +131,8 @@ import upload from '@/utils/upload.js' export default { name: "StaffInfo", - data(){ - return{ + data() { + return { userId: null, staff: {}, user: {}, @@ -122,58 +142,71 @@ export default { showJoinedDate: false, showFormalDate: false, showSafeDate: false, - topName: null + showDriveType: false, + topName: null, + driverLicenseTypeArr: [], + driverLicenseType: [], + driverLicenseTypeArrStr: null, + baseImageUrl: config.baseImageUrl, + fileKey: 0, // 初始化 key 值 } }, - onLoad(data){ - if (data.id){ + onLoad(data) { + if (data.id) { this.userId = data.id this.getInfoByUserId() + this.getDriveType() } }, - computed:{ - getEducation(){ - if (!this.educations || this.educations.length === 0){ + computed: { + getEducation() { + if (!this.educations || this.educations.length === 0) { this.getEducations() } const index = this.educations.findIndex(item => item.value === this.staff.education) - if (index !== -1){ + if (index !== -1) { return this.educations[index].label } return '' }, formattedJoinedDate() { - if (!this.staff.joinedDate) return ''; - return formatDate(this.staff.joinedDate); // 确保formatDate返回'yyyy-MM-dd'格式 + if (!this.staff.joinDate) return ''; + return formatDate(this.staff.joinDate); // 确保formatDate返回'yyyy-MM-dd'格式 }, formattedFormalDate() { - if (!this.staff.formalDate) return ''; - return formatDate(this.staff.formalDate); // 确保formatDate返回'yyyy-MM-dd'格式 + if (!this.staff.probationPeriod) return ''; + return formatDate(this.staff.probationPeriod); // 确保formatDate返回'yyyy-MM-dd'格式 }, formattedSafeDate() { - if (!this.staff.safeDate) return ''; - return formatDate(this.staff.safeDate); // 确保formatDate返回'yyyy-MM-dd'格式 + if (!this.staff.socialSecurityBuyDate) return ''; + return formatDate(this.staff.socialSecurityBuyDate); // 确保formatDate返回'yyyy-MM-dd'格式 }, }, - methods:{ - getyadd(){ - if (!this.staff.name || !this.staff.tel) { + methods: { + getyadd() { + if (!this.staff.nickname || !this.staff.mobile) { uni.showToast({ title: '姓名和电话不能有空', icon: 'none' }) return } + // 手动格式化日期字段,确保是格式化后的字符串 + if (this.staff.probationPeriod) { + this.staff.probationPeriod = formatDate(this.staff.probationPeriod); + } + + this.staff.userId = this.userId + console.log(this.staff) const data = { ...this.staff, - fileNames: this.files.length > 0 ? this.files.map(item => item.fileName).join(",") : null, - fileUrls: this.files.length > 0 ? this.files.map(item => { - return item.fileUrl.replace(config.baseImageUrl + "/", "") - }).join(",") : null + fileList: this.files, + driverLicenseType: this.driverLicenseTypeArrStr, + driverLicenseTypeArr: this.driverLicenseTypeArr.map(item => item.id) } request({ - url: '/company/staff/updateByExistUser', - method: 'post', + url: '/inspectionStaff/update', + method: 'put', data: data }).then(res => { uni.showToast({ @@ -182,6 +215,9 @@ export default { this.getInfoByUserId() }) }, + forceRefreshFiles() { + this.fileKey += 1; // 改变 key 值以强制刷新组件 + }, addFile() { if (this.files.length === 0 || this.files[0].fileUrl !== null) { this.files.unshift({ @@ -196,8 +232,10 @@ export default { filePath: event.file[0].url, }).then((res) => { this.files[index].name = event.file[0].name - this.files[index].fileUrl = config.baseImageUrl + "/" + res.data.url + this.files[index].url = res.data.url + this.forceRefreshFiles(); // 强制刷新文件列表 }) + console.log(this.files) }, deletedUrl(index) { this.files.splice(index, 1) @@ -207,49 +245,76 @@ export default { this.showJoinedDate = false }, chooseFormalDate(e) { - this.staff.formalDate = formatDate(e.value) - this.showFormalDate = false + const formattedDate = formatDate(e.value); + console.log('Formatted probationPeriod:', formattedDate); // 确认输出是字符串 + + this.staff.probationPeriod = formattedDate; + console.log(this.staff.probationPeriod); // 确认保存的值是格式化后的字符串 + this.showFormalDate = false; }, + chooseSafeDate(e) { - this.staff.safeDate = formatDate(e.value) + this.staff.socialSecurityBuyDate = formatDate(e.value) this.showSafeDate = false }, chooseEducation(e) { - this.$set(this.staff, 'education', e.value[0].value) + this.$set(this.staff, 'education', e.value[0].label) // this.staff['education'] = e.value[0].value + // console.log('education', this.staff.education) + this.staff.educational = e.value[0].label this.showEducation = false }, - async getEducations(){ + async getEducations() { this.educations = await getDictDataByType("company_staff_edu") }, - async getInfoByUserId(){ + async getInfoByUserId() { const res = await request({ - url: '/company/staff/getByUserId?id=' + this.userId, + url: '/inspectionStaff/get', + params: { + id: this.userId + }, method: 'get' }) - const data = res.data - this.staff = data?.staff || this.staff - this.user = data?.user - this.topName = this.user?.nickname || this.staff?.name || this.user?.username - this.staff.name = this.user?.nickname || this.user?.username - if (!data?.staff){ - this.staff.tel = this.user?.username || this.user?.mobile - this.staff.userId = this.user.id + this.staff = res.data + this.topName = this.staff?.nickname + if (res.data.driverLicenseType) { + this.driverLicenseTypeArrStr = res.data.driverLicenseType + res.data.driverLicenseTypeArr.forEach(item => { + let temp = { + id: item, + name: item + } + this.driverLicenseTypeArr.push(temp) + }) } - if (this?.staff?.fileNames){ + if (this?.staff?.fileList) { this.files = [] - const names = this.staff.fileNames.split(",") - const urls = this.staff.fileUrls.split(",") - names.forEach((item, index) => { + this.staff.fileList.forEach((item) => { const temp = { - fileName: item, - fileUrl: config.baseImageUrl + (urls[index][0] === "/" ? urls[index] : "/" + urls[index]) + name: item.name, + url: item.url } this.files.push(temp) }) } }, - getback(){ + getDriveType() { + return request({ + url: '/common/down/getDriverLicenseType', + method: 'get' + }).then(res => { + //提取出数组中的id属性 + this.driverLicenseType = res.data + }) + }, + onsubmit(selectedData) { + console.log('提交的数据:', selectedData); + selectedData.map(item => item.id); + this.driverLicenseTypeArr = selectedData; + this.driverLicenseTypeArrStr = selectedData.map(item => item.id).join(','); + this.showDriveType = false; // 提交后关闭弹窗 + }, + getback() { uni.navigateBack() }, } @@ -263,7 +328,8 @@ export default { height: calc(100vh); background: white; } -.c-top{ + +.c-top { width: 100%; box-sizing: border-box; padding: 15px; @@ -273,15 +339,18 @@ export default { align-items: center; background-color: white; } -.c-title{ + +.c-title { font-size: 18px; font-weight: bold } -.ail{ + +.ail { width: 100%; box-sizing: border-box; padding: 15px; } + .on-input { width: 100%; display: flex; @@ -292,14 +361,17 @@ export default { margin: 10px; justify-content: space-between; } + .on-input input { text-align: right; padding-right: 1rem } + .s-huix { width: 30%; text-align: right; } + .image-container { position: relative; /* 使子元素可以相对于此容器进行绝对定位 */ width: 100%; diff --git a/utils/utils.js b/utils/utils.js index a8935db..73968ef 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -11,7 +11,7 @@ export async function getDictDataByType(type) { const response = await request({ url: '/system/dict-data/type', method: 'get', - params: { type } + params: {type} }); data = response.data; setStorageWithExpiry(type, data, 3600); // 存储数据并设置过期时间