|
|
@@ -30,7 +30,7 @@
|
|
|
|
|
|
<tui-list-cell class="line-cell" :hover="false">
|
|
|
<div class="tui-title required">验证码</div>
|
|
|
- <input v-model="form.authCode" type="number" style="width:330upx;" placeholder-class="phcolor" placeholder-style="color:#CCCCCC" class="tui-input" name="authCode" placeholder="请填写" />
|
|
|
+ <input v-model="form.authCode" type="number" style="width:330upx;" placeholder-class="phcolor" placeholder-style="color:#CCCCCC" class="tui-input" name="authCode" placeholder="员工收到的验证码" />
|
|
|
<button v-if="hasGet == false" class="admin-button-com blue middle" @click="requestAuthCode()">获取</button>
|
|
|
<button v-else class="admin-button-com default middle" >{{count}}</button>
|
|
|
</tui-list-cell>
|
|
|
@@ -61,9 +61,9 @@
|
|
|
import TuiListCell from "@/components/plugin/list-cell";
|
|
|
import AppAvatarModule from "@/components/module/app-avatar";
|
|
|
const form = require("@/utils/formValidation.js");
|
|
|
-import { getRoleList, getStaffDet as getDet, updateStaff as update } from "@/api/staff";
|
|
|
+import { getRoleList, getStaffDet as getDet } 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: {
|
|
|
@@ -78,7 +78,8 @@ export default {
|
|
|
password: "",
|
|
|
status: 1,
|
|
|
remark: "",
|
|
|
- name:''
|
|
|
+ name:'',
|
|
|
+ mobile:''
|
|
|
},
|
|
|
roleList: [],
|
|
|
roleSelData: {},
|
|
|
@@ -86,18 +87,38 @@ export default {
|
|
|
showMiniCodeArea: false,
|
|
|
miniCodeSrc:'',
|
|
|
memberData: {},
|
|
|
- hasGet:false
|
|
|
+ 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) {
|
|
|
@@ -167,41 +188,25 @@ export default {
|
|
|
statusChangeFn(e) {
|
|
|
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 => {
|
|
|
- if(typeof(this.option.id) == 'undefined'){
|
|
|
- this.showMiniCodeArea = true;
|
|
|
- this.miniCodeSrc = res.data.miniCode;
|
|
|
- this.showStaffArea = false;
|
|
|
- }else{
|
|
|
- let promptText = this.option.id ? "修改成功!" : "添加成功!";
|
|
|
- this.$msg(promptText);
|
|
|
- setTimeout(() => {
|
|
|
- this.$util.pageTo(1);
|
|
|
- }, 1000);
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- },
|
|
|
complete(){
|
|
|
this.$util.pageTo(1)
|
|
|
},
|
|
|
formSubmit(e) {
|
|
|
- let rules = [
|
|
|
- {
|
|
|
- name: "roleId",
|
|
|
- rule: ["required"],
|
|
|
- msg: ["请选择角色"]
|
|
|
- }
|
|
|
- ];
|
|
|
+ let that = this
|
|
|
+ let rules = [{ name: "roleId", rule: ["required"], msg: ["请选择角色"] }]
|
|
|
let formData = e.detail.value;
|
|
|
let checkRes = form.validation(formData, rules);
|
|
|
if (!checkRes) {
|
|
|
- this.confirmFn();
|
|
|
+ uni.showLoading({mask:true});
|
|
|
+ createStaff(that.form).then(res => {
|
|
|
+ uni.hideLoading()
|
|
|
+ if(res.code == 1){
|
|
|
+ that.$msg('添加成功')
|
|
|
+ setTimeout(() => {
|
|
|
+ uni.navigateBack()
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
+ })
|
|
|
} else {
|
|
|
this.$msg(checkRes);
|
|
|
}
|