shish hace 4 años
padre
commit
c8d6971c1e

+ 4 - 2
ghsApp/src/admin/home/login.vue

@@ -75,13 +75,15 @@ export default {
 								}
 							})
 						},
-						fail(res){  
+						fail(res){
+							console.log(res)  
 							// 登录失败
 							//关闭一键登录弹出窗口
 							uni.closeAuthView()
 							uni.hideLoading()
 						},
-						complete: () => {
+						complete: (res) => {
+							console.log(res)
 							uni.closeAuthView()
 							uni.hideLoading()
 						}

+ 15 - 71
ghsApp/src/admin/staff/add.vue

@@ -1,85 +1,46 @@
 <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" :arrow="true">
             <div class="tui-title required">角色</div>
-            <picker
-              mode="selector"
-              :value="form.roleId"
-              :range="roleList"
-              range-key="roleName"
-              @change="changeRoleFn"
-              class="tui-input"
-            >
+            <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>
-        </div>
-        <!-- 动态通知 -->
-        <div class="module-com input-line-wrap">
-          <tui-list-cell class="line-cell between" padding="14upx 30upx" :hover="false">
-            <div class="tui-title">动态通知</div>
-            <div>
-              <switch :checked="form.remind == 0 ? false : true" @change="remindChangeFn" />
-            </div>
-          </tui-list-cell>
-        </div>
-        <div class="module-com input-line-wrap">
           <tui-list-cell class="line-cell" :hover="false">
-            <div class="tui-title">登录密码</div>
-            <input
-              v-model="form.password"
-              placeholder-class="phcolor"
-              class="tui-input"
-              name="password"
-              placeholder="请输入"
-              maxlength="50"
-              type="password"
-            />
+            <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 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"
-                placeholder="选填"
-              />
+              <textarea v-model="form.remark" 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>
+          <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>
+          <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");
-// 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";
 export default {
@@ -108,13 +69,9 @@ export default {
   onLoad() {},
   onShow() {
     if (this.option.id) {
-      uni.setNavigationBarTitle({
-        title: `修改员工`
-      });
+      uni.setNavigationBarTitle({ title: `修改员工` })
     } else {
-      uni.setNavigationBarTitle({
-        title: `添加员工`
-      });
+      uni.setNavigationBarTitle({ title: `添加员工` })
     }
   },
   methods: {
@@ -132,16 +89,15 @@ export default {
         this.memberData = memberData;
         this.form.userId = memberData.id;
       }
-
-      if (data) return false;
-
+      if (data){
+        return false;
+      } 
       this._getRoleList().then(res => {
         if (this.option.id) {
           this._getDet();
         }
       });
     },
-    // api
     async _getRoleList() {
       await getRoleList().then(res => {
         if (this.$util.isEmpty(res.data)) return false;
@@ -163,15 +119,12 @@ export default {
         }
       });
     },
-    // 获取客户详情
     _getMemberDet() {
       getMemberDet({ userId: this.form.userId }).then(res => {
         if (this.$util.isEmpty(res.data)) return;
         this.memberData = res.data;
       });
     },
-    // option
-    // 关联微信
     selMemberFn() {
       let data = {
         form: this.form,
@@ -197,15 +150,10 @@ export default {
         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);
@@ -219,7 +167,6 @@ export default {
     complete(){
       this.$util.pageTo(1)
     },
-    // 表单验证
     formSubmit(e) {
       let rules = [
         {
@@ -239,7 +186,6 @@ export default {
   }
 };
 </script>
-
 <style lang="scss" scoped>
 .app-content {
   min-height: calc(100vh - 20upx);
@@ -250,7 +196,6 @@ export default {
   padding-left: 30upx;
   margin-bottom: 30upx;
 }
-// ---
 .module-com {
   margin-bottom: 20upx;
   .member-wrap {
@@ -266,7 +211,6 @@ export default {
     }
   }
 }
-// 按钮
 .confirm-btn {
   width: calc(100% - 60upx);
   margin: 60upx 30upx 20upx;
@@ -274,4 +218,4 @@ export default {
     width: 100%;
   }
 }
-</style>
+</style>

+ 221 - 0
ghsApp/src/admin/staff/detail.vue

@@ -0,0 +1,221 @@
+<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" :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.remind == 0 ? false : true" @change="remindChangeFn" /></view>
+          </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" 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, updateStaff as update } from "@/api/staff";
+import { getDet as getMemberDet } from "@/api/member";
+import { prepareBind } from "@/api/shop-admin";
+export default {
+  name: "staff-add",
+  components: {
+    TuiListCell,
+    AppAvatarModule
+  },
+  data() {
+    return {
+      form: {
+        roleId: "",
+        remind: 1,
+        password: "",
+        status: 1,
+        remark: "",
+      },
+      roleList: [],
+      roleSelData: {},
+      showStaffArea: true,
+      showMiniCodeArea: false,
+      miniCodeSrc:'',
+      memberData: {}
+    };
+  },
+  onLoad() {},
+  onShow() {
+    if (this.option.id) {
+      uni.setNavigationBarTitle({ title: `修改员工` })
+    } else {
+      uni.setNavigationBarTitle({ title: `添加员工` })
+    }
+  },
+  methods: {
+    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;
+    },
+    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 formData = e.detail.value;
+      let checkRes = form.validation(formData, rules);
+      if (!checkRes) {
+        this.confirmFn();
+      } 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>

+ 2 - 8
ghsApp/src/admin/staff/list.vue

@@ -39,14 +39,8 @@
 								</div>
 							</div>
 							<div class="list-det-right">
-								<!-- 删除 -->
-								<div v-if="item.super == 0 && item.id != loginInfo.shopAdminId" @click="delModalFn(item)">
-									<i class="iconfont iconshanchu1"></i>
-								</div>
-								<!-- 修改 -->
-								<div @click="pageTo({url: '/admin/staff/add',query: {id: item.id}})">
-								<i class="iconfont iconbianji"></i>
-								</div>
+								<div v-if="item.super == 0 && item.id != loginInfo.shopAdminId" @click="delModalFn(item)"> <i class="iconfont iconshanchu1"></i> </div>
+								<div @click="pageTo({url: '/admin/staff/detail',query: {id: item.id}})"> <i class="iconfont iconbianji"></i> </div>
 							</div>
 						</div>
 					</div>

+ 1 - 2
ghsApp/src/components/module/shopSelect.vue

@@ -91,7 +91,6 @@ export default {
     }
 }
 </script>
-
 <style lang="scss" scoped>
 .select-bg_bx {
     .select-title {
@@ -124,7 +123,7 @@ export default {
         left: 0upx;
         top:0upx;
         z-index: 29;
-        padding:50upx 30upx 40upx;
+        padding:110upx 30upx 40upx;
         border-radius: 0upx 0upx 20upx 20upx;
         transition: all 0.5s ease-in-out;
         & .select-item-box {

+ 3 - 2
ghsApp/src/pages.json

@@ -130,7 +130,8 @@
 			"root": "admin/staff",
 			"pages": [
 				{"path": "list","style": {"navigationBarTitleText": "员工管理"}},
-				{"path": "add","style": {"navigationBarTitleText": ""}},
+				{"path": "add","style": {"navigationBarTitleText": "添加员工"}},
+				{"path": "detail","style": {"navigationBarTitleText": "详情"}},
 				{"path": "sel-member","style": {"navigationBarTitleText": "客户列表"}},
 				{"path": "achieve","style": {"navigationBarTitleText": "员工业绩"}}
 			]
@@ -179,7 +180,7 @@
 		{
 			"root": "admin/shopAdmin",
 			"pages": [
-				{"path": "bind","style": {"navigationBarTitleText": "管理员绑定"}}
+				{"path": "bind","style": {"navigationBarTitleText": "新员工加入"}}
 			]
 		},
 		{