员工添加编辑员工列表

This commit is contained in:
唐明明
2021-09-15 14:17:19 +08:00
parent 291ce57704
commit 1d81f03eea
19 changed files with 5073 additions and 788 deletions

View File

@@ -24,7 +24,7 @@
<input type="text" v-model="job" placeholder="职业"/>
</view>
<view class="info-inputs">
<picker :range="section" range-key="name" @change="pickerChange">
<picker :range="section" range-key="name" :value="sectionIndex" @change="pickerChange">
<view class="picker-text">
{{section[sectionIndex].name}}
<uni-icons class="icon" type="arrowdown" color="#555"></uni-icons>
@@ -33,6 +33,15 @@
</view>
</view>
</view>
<view class="jurisdiction switch">
<view class="item">
<label>
<view class="item-title">设为推荐</view>
<view class="item-info">设为推荐员工将在企业自媒体中优先展示</view>
<switch class="item-switch" :checked="isPosition" color="#e93340" @change="switchChange" />
</label>
</view>
</view>
<!-- 权限设置 -->
<view class="title">权限设置</view>
<view class="jurisdiction">
@@ -41,24 +50,25 @@
<label>
<view class="item-title">{{item.title}}</view>
<view class="item-info">{{item.description}}</view>
<checkbox class="item-checkbox" color="#c82626" :value="item.permission_id" />
<checkbox class="item-checkbox" :checked="item.check" color="#e93340" :value="item.permission_id" />
</label>
</view>
</checkbox-group>
</view>
<!-- 按钮 -->
<view class="add-btns">
<button size="default" @click="onAddEmployees">确认添加</button>
<button size="default" @click="onAddEmployees">{{type === 'PUT' ? '修改': '添加'}}</button>
</view>
</view>
</template>
<script>
import { employeesConfig, addEmployees } from '@/apis/interfaces/employees'
import { employeesConfig, addEmployees, employeesInfo, employeesPut } from '@/apis/interfaces/employees'
import { uploads } from '@/apis/interfaces/uploading'
export default {
data() {
return {
type : '',
loging : true,
section : [],
permissions : [],
@@ -70,17 +80,53 @@
},
name : '',
phone : '',
job : ''
job : '',
isPosition : false
};
},
created() {
if(this.$Route.query.type === 'PUT'){
this.type = 'PUT'
uni.setNavigationBarTitle({
title: '编辑员工'
})
}
employeesConfig().then(res => {
this.section = res.store
this.permissions = res.permissions
this.loging = false
if(this.$Route.query.type === 'PUT'){
employeesInfo(this.$Route.query.id || 4).then(res => {
let permissionIds = []
for(let val of res.permission){
if(val.check){
permissionIds.push(val.permission_id)
}
}
this.permissions = res.permission
this.sectionIndex = this.section.findIndex(val => val.store_id == res.store.store_id)
this.permissionIds= permissionIds
this.name = res.name
this.phone = res.mobile
this.job = res.job
this.cover = res.cover
this.isPosition = res.is_position
this.loging = false
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
}else{
this.permissions = res.permissions
this.loging = false
}
})
},
methods:{
// 设为推荐
switchChange(e){
this.isPosition = e.detail.value
},
// 选择部门
pickerChange(e){
this.sectionIndex = e.detail.value
@@ -112,16 +158,19 @@
},
// 添加员工
onAddEmployees(){
addEmployees({
let data = {
name : this.name,
mobileNo : this.phone,
job : this.job,
cover : this.cover.path,
position : 1,
position : this.isPosition ? 1: 0,
order : 0,
store_id : this.section[this.sectionIndex].store_id,
permission : this.permissionIds
}).then(res => {
}
let submitAdd = this.type == 'PUT' ? employeesPut(this.$Route.query.id, data) : addEmployees(data)
submitAdd.then(res => {
uni.showModal({
title : '提示',
content : res,
@@ -151,6 +200,9 @@
}
.jurisdiction{
background: white;
&.switch{
margin-top: $margin;
}
.item{
position: relative;
padding: $padding 150rpx $padding $padding;
@@ -171,7 +223,13 @@
right: $padding;
top: 50%;
height: 40rpx;
width: 40rpx;
margin-top: -27rpx;
}
.item-switch{
position: absolute;
right: $padding;
top: 50%;
height: 40rpx;
margin-top: -27rpx;
}
.item-title{