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