|
|
@@ -0,0 +1,258 @@
|
|
|
+<template>
|
|
|
+ <div class="app-content">
|
|
|
+ <div v-show="showStaffArea">
|
|
|
+ <form @submit="formSubmit">
|
|
|
+ <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" >
|
|
|
+ <input v-model="form.roleId" name="roleId" type="text" hidden />
|
|
|
+ <div v-if="form.roleId">{{ roleSelData.roleName }}</div>
|
|
|
+ <div class="tui-placeholder" v-else>请选择</div>
|
|
|
+ </picker>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <div class="tui-title">超管权限</div>
|
|
|
+ <view><switch style="transform:scale(0.7,0.7)" :checked="form.super == 0 ? false : true" @change="superChangeFn" /></view>
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <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>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell" :hover="false">
|
|
|
+ <div class="tui-title required">手机号</div>
|
|
|
+ <input v-model="form.mobile" type="number" placeholder-class="phcolor" placeholder-style="color:#CCCCCC" class="tui-input" name="mobile" placeholder="员工手机号" />
|
|
|
+ </tui-list-cell>
|
|
|
+
|
|
|
+ <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="员工收到的验证码" />
|
|
|
+ <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>
|
|
|
+
|
|
|
+ <tui-list-cell class="line-cell remark-wrap" :hover="false">
|
|
|
+ <div class="tui-title">备注信息</div>
|
|
|
+ <div class="tui-input">
|
|
|
+ <textarea v-model="form.remark" style="height:80upx;" class="tui-textarea remark" placeholder-class="phcolor" 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:400upx;height:400upx;margin:0 auto;" :src="miniCodeSrc"></image>
|
|
|
+ <view style="text-align:center;margin-top:20upx;margin-bottom:20upx;font-size:30upx;">请让员工扫描上方太阳码完成添加</view>
|
|
|
+ <button class="admin-button-com big blue" @click="complete" style="padding-left:40upx;padding-right:40upx;">完成</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");
|
|
|
+import { getRoleList, getStaffDet as getDet } from "@/api/staff";
|
|
|
+import { getDet as getMemberDet } from "@/api/member";
|
|
|
+import { getStaffAuthCode,createStaff } from "@/api/staff";
|
|
|
+export default {
|
|
|
+ name: "staff-add",
|
|
|
+ components: {
|
|
|
+ TuiListCell,
|
|
|
+ AppAvatarModule
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {
|
|
|
+ roleId: "",
|
|
|
+ remind: 1,
|
|
|
+ password: "",
|
|
|
+ status: 1,
|
|
|
+ remark: "",
|
|
|
+ name:'',
|
|
|
+ mobile:'',
|
|
|
+ super:0
|
|
|
+ },
|
|
|
+ roleList: [],
|
|
|
+ roleSelData: {},
|
|
|
+ showStaffArea: true,
|
|
|
+ showMiniCodeArea: false,
|
|
|
+ miniCodeSrc:'',
|
|
|
+ memberData: {},
|
|
|
+ hasGet:false,
|
|
|
+ INT:null,
|
|
|
+ count:0
|
|
|
+ };
|
|
|
+ },
|
|
|
+ onLoad() {},
|
|
|
+ onShow() {
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ superChangeFn(e){
|
|
|
+ this.form.super = e.detail.value ? 1 : 0;
|
|
|
+ },
|
|
|
+ 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) {
|
|
|
+ uni.removeStorageSync("addStaffData");
|
|
|
+ this.form = data.form;
|
|
|
+ this.roleList = data.roleList;
|
|
|
+ this.roleSelData = data.roleSelData;
|
|
|
+ }
|
|
|
+ let memberData = uni.getStorageSync("addSelMember");
|
|
|
+ if (memberData) {
|
|
|
+ uni.removeStorageSync("addSelMember");
|
|
|
+ this.memberData = memberData;
|
|
|
+ this.form.userId = memberData.id;
|
|
|
+ }
|
|
|
+ if (data){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ this._getRoleList().then(res => {
|
|
|
+ if (this.option.id) {
|
|
|
+ this._getDet();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async _getRoleList() {
|
|
|
+ await getRoleList().then(res => {
|
|
|
+ if (this.$util.isEmpty(res.data)) return false;
|
|
|
+ this.roleList = res.data.list;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ _getDet() {
|
|
|
+ getDet({ id: this.option.id }).then(res => {
|
|
|
+ if (this.$util.isEmpty(res.data)) return;
|
|
|
+ Object.keys(this.form).forEach((i, index) => {
|
|
|
+ this.form[i] = res.data[i];
|
|
|
+ });
|
|
|
+ this.roleSelData = this.roleList.filter(
|
|
|
+ e => this.form.roleId == e.id
|
|
|
+ )[0];
|
|
|
+
|
|
|
+ if (this.form.userId && this.form.userId != "0") {
|
|
|
+ this._getMemberDet();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ _getMemberDet() {
|
|
|
+ getMemberDet({ userId: this.form.userId }).then(res => {
|
|
|
+ if (this.$util.isEmpty(res.data)) return;
|
|
|
+ this.memberData = res.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ selMemberFn() {
|
|
|
+ let data = {
|
|
|
+ form: this.form,
|
|
|
+ roleList: this.roleList,
|
|
|
+ roleSelData: this.roleSelData
|
|
|
+ };
|
|
|
+ uni.setStorageSync("addStaffData", data);
|
|
|
+ this.$util.pageTo(1);
|
|
|
+ },
|
|
|
+ changeRoleFn(e) {
|
|
|
+ this.roleSelData = this.roleList[e.detail.value];
|
|
|
+ this.form.roleId = this.roleSelData.id;
|
|
|
+ },
|
|
|
+ remindChangeFn(e) {
|
|
|
+ this.form.remind = e.detail.value ? 1 : 0;
|
|
|
+ },
|
|
|
+ statusChangeFn(e) {
|
|
|
+ this.form.status = e.detail.value ? 1 : 0;
|
|
|
+ },
|
|
|
+ complete(){
|
|
|
+ this.$util.pageTo(1)
|
|
|
+ },
|
|
|
+ formSubmit(e) {
|
|
|
+ let that = this
|
|
|
+ let rules = [{ name: "roleId", rule: ["required"], msg: ["请选择角色"] }]
|
|
|
+ let formData = e.detail.value;
|
|
|
+ let checkRes = form.validation(formData, rules);
|
|
|
+ if (!checkRes) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.app-content {
|
|
|
+ min-height: calc(100vh - 20upx);
|
|
|
+ padding-top: 20upx;
|
|
|
+}
|
|
|
+.prompt-text {
|
|
|
+ color: $fontColor3;
|
|
|
+ padding-left: 30upx;
|
|
|
+ margin-bottom: 30upx;
|
|
|
+}
|
|
|
+.module-com {
|
|
|
+ margin-bottom: 20upx;
|
|
|
+ .member-wrap {
|
|
|
+ .member-det {
|
|
|
+ font-size: 24upx;
|
|
|
+ margin-left: 20upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .remark-wrap {
|
|
|
+ align-items: flex-start;
|
|
|
+ .remark {
|
|
|
+ height: 240upx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.confirm-btn {
|
|
|
+ width: calc(100% - 60upx);
|
|
|
+ margin: 60upx 30upx 20upx;
|
|
|
+ .admin-button-com {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|