平板端快衣店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

145 lines
4.7 KiB

<template>
<view>
<view class="popup-height">
<uni-forms :modelValue="addForm" ref="addForm" validateTrigger="bind" :rules="rules" label-width="160rpx" label-align="right">
<uni-forms-item label="登录账号" required name="username">
<uni-easyinput type="text" v-model="addForm.username" placeholder="请输入登录账号" />
</uni-forms-item>
<uni-forms-item label="密码" required name="password">
<uni-easyinput type="password" v-model="addForm.password" placeholder="请输入登录密码" />
</uni-forms-item>
<uni-forms-item label="用户名" required name="nickname">
<uni-easyinput type="text" v-model="addForm.nickname" placeholder="请输入员工姓名" />
</uni-forms-item>
<uni-forms-item label="手机号" required name="mobile">
<uni-easyinput type="text" v-model="addForm.mobile" placeholder="请输入员工手机号" />
</uni-forms-item>
<uni-forms-item label="邮箱" name="email">
<uni-easyinput type="text" v-model="addForm.email" placeholder="请输入员工邮箱" />
</uni-forms-item>
<uni-forms-item label="所属门店" required name="shopId">
<uni-data-select
style="width: 100%"
v-model="addForm.shopId"
:localdata="shopList"
></uni-data-select>
</uni-forms-item>
<uni-forms-item label="权限" required name="type">
<uni-data-select
style="width: 100%"
v-model="addForm.type"
:localdata="typeList"
></uni-data-select>
</uni-forms-item>
<uni-forms-item label="性别">
<uni-data-select
style="width: 100%"
v-model="addForm.sex"
:localdata="sexList"
></uni-data-select>
</uni-forms-item>
<uni-forms-item label="头像" >
<uni-file-picker fileMediatype="image" v-model="addForm.avatar"></uni-file-picker>
</uni-forms-item>
</uni-forms>
<u-button type="primary" @click="onFormSubmit">保存</u-button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
addForm: {
username: '',
password: '',
nickname:'',
mobile:'',
type:'',
sex:'',
avatar:[],
shopId:'',
email:''
},
typeList:[
{ value: 0, text: "普通用户" },
{ value: 1, text: "管理员" },
],
sexList:[
{ value: "男", text: "男" },
{ value: "女", text: "女" },
],
shopList:[],
rules:{
username:{
rules:[{required:true,errorMessage:'不能为空'}]
},
password:{
rules:[{required:true,errorMessage:'不能为空'}]
},
nickname:{
rules:[{required:true,errorMessage:'不能为空'}]
},
mobile:{
rules:[{required:true,errorMessage:'不能为空'}]
},
shopId:{
rules:[{required:true,errorMessage:'不能为空'}]
},
type:{
rules:[{required:true,errorMessage:'不能为空'}]
},
}
}
},
onLoad(options) {
const {type} = options
if (type === 'edit') {
const editStaffInfo = this.$store.getters.editStaffInfo
console.log('editStaffInfo',editStaffInfo)
Object.assign(this.addForm,editStaffInfo)
}
uni.setNavigationBarTitle({
title: type=== 'add'? '新增员工' : '编辑信息'
});
this.getShopList()
},
methods:{
getShopList() {
this.tui.request('/app/common/shops','get',{}, false,true,false).then(res => {
if (res.code !== 200) {
return uni.showToast({
title:res.message,
icon:'none'
})}
this.shopList = res.result.map((v) => {
return {
text:v.shopName,
value:v.id
}
})
})
},
onFormSubmit() {
console.log('submit')
this.$refs.addForm.validate().then(async () => {
const res = await this.tui.request('/app/common/user/add','post',this.addForm,false,true,false)
if (res.code !== 200) return
uni.navigateBack()
console.log(res)
},(reason) => {
console.log(reason)
})
}
}
}
</script>
<style lang="scss" scoped>
.popup-height {
padding: 0 25upx;
background-color: #fff;
}
</style>