平板端快衣店
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.
 
 
 
 
 

107 lines
2.5 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="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="权限" required name="type">
<uni-data-select style="width: 100%" v-model="addForm.type" :localdata="typeList"></uni-data-select>
</uni-forms-item>
</uni-forms>
<u-button type="primary" @click="onFormSubmit">保存</u-button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
addForm: {
nickname: '',
mobile: '',
type: '',
password:'123456'
},
id: '',
typeList: [{
value: 0,
text: "管理员"
},
{
value: 1,
text: "员工"
},
],
rules: {
nickname: {
rules: [{
required: true,
errorMessage: '不能为空'
}]
},
mobile: {
rules: [{
required: true,
errorMessage: '不能为空'
}]
},
type: {
rules: [{
required: true,
errorMessage: '不能为空'
}]
},
}
}
},
onLoad(options) {
const type = options.type
const item = JSON.parse(options.item)
this.type = options.type
if (type === 'edit') {
this.addForm.nickname = item.nickname
this.addForm.mobile = item.mobile
this.addForm.type = Number(item.type)
this.id = item.id
}
uni.setNavigationBarTitle({
title: type === 'add' ? '新增员工' : '编辑信息'
});
},
methods: {
onFormSubmit() {
this.$refs.addForm.validate().then(async () => {
let url;
if(this.type=='edit'){
url = '/app/common/user/edit'
this.addForm.id = this.id
}else{
url = '/app/common/user/add'
}
const res = await this.tui.request(url, 'post', this.addForm, false,
true, false)
if (res.code == 200) {
uni.navigateBack()
} else {
this.tui.toast(res.message)
}
}, (reason) => {
})
}
}
}
</script>
<style lang="scss" scoped>
.popup-height {
padding: 0 25upx;
background-color: #fff;
}
</style>