更新检测员工相关
This commit is contained in:
parent
e738661bdc
commit
23ce4633a9
181
components/qianziyu-select/qianziyu-select.vue
Normal file
181
components/qianziyu-select/qianziyu-select.vue
Normal file
@ -0,0 +1,181 @@
|
||||
<template>
|
||||
<view>
|
||||
<u-popup :show="show" @close="cancel">
|
||||
<view class="title">{{ popupTitle }}</view>
|
||||
<view style="padding: 20rpx;">
|
||||
<u-search v-if="showSearch" @custom="search" @search="search" :placeholder="placeholder"
|
||||
v-model="keyword"></u-search>
|
||||
<u-gap v-if="showSearch" height="15"></u-gap>
|
||||
<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" @scrolltolower="$emit('lower')">
|
||||
|
||||
<!--单选-->
|
||||
<u-radio-group v-if="type == 'radio'" :borderBottom="true" iconPlacement="right" placement="column"
|
||||
@change="groupChange" v-model="radioValue">
|
||||
<u-radio :customStyle="{marginBottom: '12px'}" v-for="(item, index) in dataLists" :key="index"
|
||||
:label="item[name]" :name="index">
|
||||
</u-radio>
|
||||
</u-radio-group>
|
||||
|
||||
<!--多选-->
|
||||
<u-checkbox-group v-if="type == 'checkbox'" :borderBottom="true" placement="column"
|
||||
iconPlacement="right" @change="checkboxChange" v-model="checkboxValue">
|
||||
<u-checkbox :customStyle="{marginBottom: '12px',paddingBottom:'12px'}"
|
||||
v-for="(item, index) in dataLists" :key="index" :label="item[name]" :name="index">
|
||||
</u-checkbox>
|
||||
</u-checkbox-group>
|
||||
|
||||
</scroll-view>
|
||||
<u-gap height="45"></u-gap>
|
||||
<view class="bottons">
|
||||
<u-row>
|
||||
<u-col customStyle="padding:0 10rpx 20rpx 20rpx" span="6">
|
||||
<u-button @click="cancel">取消</u-button>
|
||||
</u-col>
|
||||
<u-col customStyle="padding:0 20rpx 20rpx 10rpx" span="6">
|
||||
<u-button @click="submit" type="primary" throttleTime="1000"
|
||||
:disabled="(JSON.stringify(radioData) === '{}') && (checkboxData.length === 0)">确认
|
||||
</u-button>
|
||||
</u-col>
|
||||
</u-row>
|
||||
</view>
|
||||
</view>
|
||||
</u-popup>
|
||||
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 公共选择下拉框,基于uview。支持下拉加载、列表搜索、单选|多选
|
||||
* @author qianziyu
|
||||
* @description 弹出层选择器,基于uview中u-popup实现
|
||||
* @property {Array} dataLists 数据列表
|
||||
* @property {String} name 列表显示的字段名
|
||||
* @property {Boolean} show 是否展示弹窗 (默认 false )
|
||||
* @property {String} type 选择类型 单选|多选 (默认 单选 )
|
||||
* @property {Boolean} showSearch 是否显示搜索框 (默认 true )
|
||||
* @property {String} popupTitle 列表标题
|
||||
* @property {String} placeholder 搜索框placeholder
|
||||
* @event {Function} search 搜索事件,返回keyword
|
||||
* @event {Function} lower 滑动到底部触发,用于下拉加载新数据
|
||||
* @event {Function} cancel 组件关闭事件
|
||||
* @event {Function} submit 提交按钮,返回选中的列表数据
|
||||
* @example <common-select :show="show" :popupTitle="popupTitle" @cancel="show=false" @search="selectSearch" name="cworkStationName" @submit="onsubmit"
|
||||
:dataLists="dataLists" placeholder="输入工站名称搜索"></common-select>
|
||||
*/
|
||||
export default {
|
||||
name: "qianziyu-select",
|
||||
props: {
|
||||
dataLists: {
|
||||
default: {},
|
||||
type: Array
|
||||
},
|
||||
name: {
|
||||
default: 'name',
|
||||
},
|
||||
show: {
|
||||
default: false,
|
||||
type: Boolean
|
||||
},
|
||||
type: {
|
||||
default: 'radio',
|
||||
type: String
|
||||
},
|
||||
showSearch: {
|
||||
default: true,
|
||||
type: Boolean
|
||||
},
|
||||
popupTitle: {
|
||||
default: '列表选择',
|
||||
type: String
|
||||
},
|
||||
placeholder: {
|
||||
default: '请输入搜索内容'
|
||||
},
|
||||
checkboxData: { // 新增的prop
|
||||
default: () => [], // 默认选中的项
|
||||
type: Array
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
keyword: '',
|
||||
scrollTop: 0,
|
||||
checkboxValue: [],
|
||||
radioData: {},
|
||||
radioValue: '',
|
||||
// checkboxData: this.checkboxData, // 将父组件传递的checkboxData设置为默认值
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
checkboxData(newVal) {
|
||||
// 如果 checkboxData 改变,更新 checkboxValue(使其回显默认值)
|
||||
this.checkboxValue = newVal.map(item => {
|
||||
return this.dataLists.findIndex(listItem => listItem[this.name] === item[this.name]);
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
checkboxChange(n) {
|
||||
const newCheckboxData = [];
|
||||
n.forEach(key => {
|
||||
newCheckboxData.push(this.dataLists[key]);
|
||||
});
|
||||
this.$emit('update:checkboxData', newCheckboxData); // 更新父组件中的 checkboxData
|
||||
},
|
||||
//选择列表项触发
|
||||
groupChange(n) {
|
||||
this.radioData = this.dataLists[n]
|
||||
},
|
||||
//点击搜索触发
|
||||
search() {
|
||||
this.$emit('search', this.keyword)
|
||||
},
|
||||
//点击取消按钮触发
|
||||
cancel() {
|
||||
this.$emit('cancel')
|
||||
},
|
||||
//提交触发
|
||||
submit() {
|
||||
if (this.type == 'radio') {
|
||||
if (JSON.stringify(this.radioData) == '{}') {
|
||||
uni.$u.toast('请选择数据')
|
||||
return;
|
||||
}
|
||||
this.$emit('submit', this.radioData)
|
||||
} else if (this.type == 'checkbox') {
|
||||
if (this.checkboxData.length == 0) {
|
||||
uni.$u.toast('请选择数据')
|
||||
return;
|
||||
}
|
||||
this.$emit('submit', this.checkboxData)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.u-popup {
|
||||
.title {
|
||||
border-bottom: 1px solid #f7f7f7;
|
||||
padding: 20rpx;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
|
||||
.scroll-Y {
|
||||
height: 650rpx;
|
||||
}
|
||||
|
||||
.bottons {
|
||||
background-color: white;
|
||||
position: fixed;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
bottom: constant(safe-area-inset-bottom);
|
||||
bottom: env(safe-area-inset-bottom);
|
||||
}
|
||||
</style>
|
@ -96,7 +96,7 @@
|
||||
</view>
|
||||
<view class="on-input">
|
||||
<view class="s-huix">身份证号:</view>
|
||||
<view class=""><input v-model="idNumber" type="text" placeholder="请输入身份证号"></view>
|
||||
<view class=""><input v-model="idCard" type="text" placeholder="请输入身份证号"></view>
|
||||
</view>
|
||||
<view class="on-input">
|
||||
<view class="s-huix">入职时间:</view>
|
||||
@ -113,6 +113,13 @@
|
||||
<view class="" @click="showSafeDate = true"><input disabled :value="formattedSafeDate" type="text"
|
||||
placeholder="请选择购买保险时间"></view>
|
||||
</view>
|
||||
<view class="on-input">
|
||||
<view class="s-huix">驾照类型:</view>
|
||||
<view class="" @click="showDriveType = true">
|
||||
<input disabled :value="driverLicenseTypeArrStr" type="text"
|
||||
placeholder="请选择驾照类型">
|
||||
</view>
|
||||
</view>
|
||||
<view class="on-input">
|
||||
<view class="s-huix">附件:</view>
|
||||
<view class="" @click="addFile"><input disabled type="text" placeholder="添加附件"></view>
|
||||
@ -160,7 +167,7 @@
|
||||
|
||||
<u-datetime-picker
|
||||
:show="showJoinedDate"
|
||||
v-model="joinedDate"
|
||||
v-model="joinDate"
|
||||
@cancel="showJoinedDate = false"
|
||||
@confirm="chooseJoinDate"
|
||||
mode="date"
|
||||
@ -168,7 +175,7 @@
|
||||
></u-datetime-picker>
|
||||
<u-datetime-picker
|
||||
:show="showFormalDate"
|
||||
v-model="formalDate"
|
||||
v-model="probationPeriod"
|
||||
@cancel="showFormalDate = false"
|
||||
@confirm="chooseFormalDate"
|
||||
mode="date"
|
||||
@ -176,12 +183,24 @@
|
||||
></u-datetime-picker>
|
||||
<u-datetime-picker
|
||||
:show="showSafeDate"
|
||||
v-model="safeDate"
|
||||
v-model="socialSecurityBuyDate"
|
||||
@cancel="showSafeDate = false"
|
||||
@confirm="chooseSafeDate"
|
||||
mode="date"
|
||||
return-type='string'
|
||||
></u-datetime-picker>
|
||||
<qianziyu-select
|
||||
:show="showDriveType"
|
||||
type="checkbox"
|
||||
name="id"
|
||||
:dataLists="driverLicenseType"
|
||||
:showSearch=false
|
||||
@cancel="showDriveType = false"
|
||||
:checkboxData="driverLicenseTypeArr"
|
||||
@submit="onsubmit"
|
||||
@update:checkboxData="driverLicenseTypeArr = $event"
|
||||
>
|
||||
</qianziyu-select>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -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: "添加成功"
|
||||
})
|
||||
|
@ -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({
|
||||
|
@ -10,20 +10,20 @@
|
||||
<view class="ail">
|
||||
<view class="on-input">
|
||||
<view class="s-huix">姓名:</view>
|
||||
<view class=""><input v-model="staff.name" type="text" placeholder="请输入姓名"></view>
|
||||
<view class=""><input v-model="staff.nickname" type="text" placeholder="请输入姓名"></view>
|
||||
</view>
|
||||
<view class="on-input">
|
||||
<view class="s-huix">电话:</view>
|
||||
<view class=""><input v-model="staff.tel" type="text" placeholder="请输入手机号"></view>
|
||||
<view class=""><input v-model="staff.mobile" type="text" placeholder="请输入手机号"></view>
|
||||
</view>
|
||||
<view class="on-input">
|
||||
<view class="s-huix">学历:</view>
|
||||
<view class="" @click="showEducation = true"><input disabled :value="getEducation" type="text"
|
||||
placeholder="请选择学历"></view>
|
||||
placeholder="请选择学历" v-model="staff.educational"></view>
|
||||
</view>
|
||||
<view class="on-input">
|
||||
<view class="s-huix">身份证号:</view>
|
||||
<view class=""><input v-model="staff.idNumber" type="text" placeholder="请输入身份证号"></view>
|
||||
<view class=""><input v-model="staff.idCard" type="text" placeholder="请输入身份证号"></view>
|
||||
</view>
|
||||
<view class="on-input">
|
||||
<view class="s-huix">入职时间:</view>
|
||||
@ -40,17 +40,25 @@
|
||||
<view class="" @click="showSafeDate = true"><input disabled :value="formattedSafeDate" type="text"
|
||||
placeholder="请选择购买保险时间"></view>
|
||||
</view>
|
||||
<view class="on-input">
|
||||
<view class="s-huix">驾照类型:</view>
|
||||
<view class="" @click="showDriveType = true">
|
||||
<input disabled :value="driverLicenseTypeArrStr" type="text"
|
||||
placeholder="请选择驾照类型">
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="">
|
||||
<view style="display: flex;justify-content: space-between;margin: 1rem auto">
|
||||
<view class="s-huix" style="text-align: left">附件:</view>
|
||||
<view class="" style="color: #3391ff" @click="addFile">添加附件</view>
|
||||
</view>
|
||||
<view v-for="(item, index) in files" style="margin-bottom: 1rem;border-bottom: 1px solid #DAE1F8;">
|
||||
<view v-for="(item, index) in files" :key="fileKey + index" style="margin-bottom: 1rem;border-bottom: 1px solid #DAE1F8;">
|
||||
<view class="on-input">
|
||||
<view class="s-huix">名称:</view>
|
||||
<view class=""><input v-model="item.fileName" type="text" placeholder="请输入附件名称"></view>
|
||||
<view class=""><input v-model="item.name" type="text" placeholder="请输入附件名称"></view>
|
||||
</view>
|
||||
<u-upload v-if="!item.fileUrl"
|
||||
<u-upload v-if="!item.url"
|
||||
@afterRead="uploadFilePromise($event, index)"
|
||||
name="6"
|
||||
multiple
|
||||
@ -60,7 +68,7 @@
|
||||
>
|
||||
</u-upload>
|
||||
<view v-else class="image-container">
|
||||
<image :src="item.fileUrl" style="width: 100%;height: 140px;"></image>
|
||||
<image :src="baseImageUrl + '/' + item.url" style="width: 100%;height: 140px;"></image>
|
||||
<view @click="deletedUrl(index)" class="close-button">
|
||||
<text>x</text>
|
||||
</view>
|
||||
@ -78,7 +86,7 @@
|
||||
|
||||
<u-datetime-picker
|
||||
:show="showJoinedDate"
|
||||
v-model="staff.joinedDate"
|
||||
v-model="staff.joinDate"
|
||||
@cancel="showJoinedDate = false"
|
||||
@confirm="chooseJoinDate"
|
||||
mode="date"
|
||||
@ -86,7 +94,7 @@
|
||||
></u-datetime-picker>
|
||||
<u-datetime-picker
|
||||
:show="showFormalDate"
|
||||
v-model="staff.formalDate"
|
||||
v-model="staff.probationPeriod"
|
||||
@cancel="showFormalDate = false"
|
||||
@confirm="chooseFormalDate"
|
||||
mode="date"
|
||||
@ -94,12 +102,24 @@
|
||||
></u-datetime-picker>
|
||||
<u-datetime-picker
|
||||
:show="showSafeDate"
|
||||
v-model="staff.safeDate"
|
||||
v-model="staff.socialSecurityBuyDate"
|
||||
@cancel="showSafeDate = false"
|
||||
@confirm="chooseSafeDate"
|
||||
mode="date"
|
||||
return-type='string'
|
||||
></u-datetime-picker>
|
||||
<qianziyu-select
|
||||
:show="showDriveType"
|
||||
type="checkbox"
|
||||
name="id"
|
||||
:dataLists="driverLicenseType"
|
||||
:showSearch=false
|
||||
@cancel="showDriveType = false"
|
||||
:checkboxData="driverLicenseTypeArr"
|
||||
@submit="onsubmit"
|
||||
@update:checkboxData="driverLicenseTypeArr = $event"
|
||||
>
|
||||
</qianziyu-select>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@ -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%;
|
||||
|
@ -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); // 存储数据并设置过期时间
|
||||
|
Loading…
Reference in New Issue
Block a user