|
|
@@ -1,10 +1,14 @@
|
|
|
<template>
|
|
|
<div class="app-content">
|
|
|
- <div v-show="showStaffArea">
|
|
|
- <!-- 员工信息 -->
|
|
|
+ <div>
|
|
|
<form @submit="formSubmit" @reset="formReset">
|
|
|
<div class="module-com input-line-wrap">
|
|
|
-
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <div class="tui-title required">昵称</div>
|
|
|
+ <input v-model="form.name" type="text" placeholder-class="phcolor" placeholder-style="color:#CCCCCC" class="tui-input" name="name" placeholder="员工昵称" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
<tui-list-cell class="line-cell" :arrow="true">
|
|
|
<div class="tui-title required">角色</div>
|
|
|
<picker mode="selector" :value="form.roleId" :range="roleList" range-key="roleName" @change="changeRoleFn" class="tui-input" >
|
|
|
@@ -14,7 +18,7 @@
|
|
|
</picker>
|
|
|
</tui-list-cell>
|
|
|
|
|
|
- <tui-list-cell class="line-cell" padding="14upx 30upx" :hover="false">
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
<div class="tui-title">动态通知</div>
|
|
|
<view><switch style="transform:scale(0.7,0.7)" :checked="form.remind == 0 ? false : true" @change="remindChangeFn" /></view>
|
|
|
</tui-list-cell>
|
|
|
@@ -34,38 +38,27 @@
|
|
|
<tui-list-cell class="line-cell remark-wrap" :hover="false">
|
|
|
<div class="tui-title">备注信息</div>
|
|
|
<div class="tui-input">
|
|
|
- <textarea v-model="form.remark" class="tui-textarea remark" placeholder-class="phcolor" style="height:80upx;" placeholder="请输入内容" />
|
|
|
+ <textarea v-model="form.remark" class="tui-textarea remark" placeholder-class="phcolor" style="height:80upx;" placeholder="选填" />
|
|
|
</div>
|
|
|
</tui-list-cell>
|
|
|
+
|
|
|
</div>
|
|
|
|
|
|
<div class="confirm-btn">
|
|
|
<button class="admin-button-com big blue" formType="submit">确认</button>
|
|
|
</div>
|
|
|
+
|
|
|
</form>
|
|
|
</div>
|
|
|
- <div v-show="showMiniCodeArea">
|
|
|
- <view style="text-align:center;">
|
|
|
- <image style="width:200upx;height:200upx;margin:0 auto;" :src="miniCodeSrc"></image>
|
|
|
- <view style="text-align:center;margin-top:20upx;margin-bottom:20upx;">请让员工扫描上方太阳码完成绑定</view>
|
|
|
- <button class="admin-button-com big blue" @click="complete" style="padding-left:23upx;padding-right:23upx;">完成</button>
|
|
|
- </view>
|
|
|
- </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
-
|
|
|
<script>
|
|
|
import TuiListCell from "@/components/plugin/list-cell";
|
|
|
import AppAvatarModule from "@/components/module/app-avatar";
|
|
|
const form = require("@/utils/formValidation.js");
|
|
|
-// api
|
|
|
-import {
|
|
|
- getRoleList,
|
|
|
- getStaffDet as getDet,
|
|
|
- updateStaff as update
|
|
|
-} from "@/api/staff";
|
|
|
+import { getRoleList, getStaffDet as getDet, updateStaff as update } from "@/api/staff";
|
|
|
import { getDet as getMemberDet } from "@/api/member";
|
|
|
-import { prepareBind } from "@/api/shop-admin";
|
|
|
+import { getStaffAuthCode,createStaff } from "@/api/staff";
|
|
|
export default {
|
|
|
name: "staff-add",
|
|
|
components: {
|
|
|
@@ -88,22 +81,39 @@ export default {
|
|
|
showStaffArea: true,
|
|
|
showMiniCodeArea: false,
|
|
|
miniCodeSrc:'',
|
|
|
- memberData: {}
|
|
|
+ memberData: {},
|
|
|
+ hasGet:false,
|
|
|
+ INT:null,
|
|
|
+ count:0
|
|
|
};
|
|
|
},
|
|
|
onLoad() {},
|
|
|
onShow() {
|
|
|
- if (this.option.id) {
|
|
|
- uni.setNavigationBarTitle({
|
|
|
- title: `修改员工`
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.setNavigationBarTitle({
|
|
|
- title: `添加员工`
|
|
|
- });
|
|
|
- }
|
|
|
},
|
|
|
methods: {
|
|
|
+ requestAuthCode(){
|
|
|
+ let that = this
|
|
|
+ let mobile = this.form.mobile
|
|
|
+ if(this.$util.checkMobile(mobile) == false){
|
|
|
+ this.$msg('请输入正确手机号')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ getStaffAuthCode({mobile}).then(res=>{
|
|
|
+ if(res.code == 1){
|
|
|
+ that.hasGet = true
|
|
|
+ that.count = 120
|
|
|
+ that.INT = setInterval(function(){
|
|
|
+ if(that.count <= 0){
|
|
|
+ clearInterval(that.INT)
|
|
|
+ that.hasGet = false
|
|
|
+ that.count = 120
|
|
|
+ return
|
|
|
+ }
|
|
|
+ that.count--
|
|
|
+ },1000)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
init() {
|
|
|
let data = uni.getStorageSync("addStaffData");
|
|
|
if (data) {
|
|
|
@@ -127,7 +137,6 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
- // api
|
|
|
async _getRoleList() {
|
|
|
await getRoleList().then(res => {
|
|
|
if (this.$util.isEmpty(res.data)) return false;
|
|
|
@@ -183,47 +192,27 @@ export default {
|
|
|
this.form.status = e.detail.value ? 1 : 0;
|
|
|
},
|
|
|
confirmFn() {
|
|
|
- let hostFn = this.option.id ? update : prepareBind;
|
|
|
- if (this.option.id) {
|
|
|
- this.form.id = this.option.id;
|
|
|
- }
|
|
|
- hostFn(this.form).then(res => {
|
|
|
- console.log('23rh23r23')
|
|
|
- console.log(res)
|
|
|
- console.log(this.option.id)
|
|
|
- if(typeof(this.option.id) == 'undefined'){
|
|
|
- this.showMiniCodeArea = true;
|
|
|
- this.miniCodeSrc = res.data.miniCode;
|
|
|
- this.showStaffArea = false;
|
|
|
- console.log(this.miniCodeSrc)
|
|
|
- console.log('--oo0oooo---')
|
|
|
- }else{
|
|
|
- let promptText = this.option.id ? "修改成功!" : "添加成功!";
|
|
|
- this.$msg(promptText);
|
|
|
- setTimeout(() => {
|
|
|
- this.$util.pageTo(1);
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
-
|
|
|
+ uni.showLoading({mask:true})
|
|
|
+ let that = this
|
|
|
+ createStaff(this.form).then(res => {
|
|
|
+ uni.hideLoading()
|
|
|
+ if(res.code == 1){
|
|
|
+ that.$msg('添加成功')
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.navigateBack()
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
complete(){
|
|
|
this.$util.pageTo(1)
|
|
|
},
|
|
|
- // 表单验证
|
|
|
formSubmit(e) {
|
|
|
- // 表单规则
|
|
|
let rules = [
|
|
|
- {
|
|
|
- name: "roleId",
|
|
|
- rule: ["required"],
|
|
|
- msg: ["请选择角色"]
|
|
|
- }
|
|
|
+ { name: "roleId", rule: ["required"], msg: ["请选择角色"] }
|
|
|
];
|
|
|
- // 进行表单检查
|
|
|
let formData = e.detail.value;
|
|
|
let checkRes = form.validation(formData, rules);
|
|
|
- // 验证通过!
|
|
|
if (!checkRes) {
|
|
|
this.confirmFn();
|
|
|
} else {
|
|
|
@@ -233,7 +222,6 @@ export default {
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
-
|
|
|
<style lang="scss" scoped>
|
|
|
.app-content {
|
|
|
min-height: calc(100vh - 20upx);
|
|
|
@@ -268,4 +256,4 @@ export default {
|
|
|
width: 100%;
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|