Browse Source

提交会员管理代码

pangqijun 1 year ago
parent
commit
74c6056ecc
3 changed files with 216 additions and 212 deletions
  1. 16 0
      src/api/platform/userapp.js
  2. 42 0
      src/option/platform/userapp.js
  3. 158 212
      src/views/platform/userapp.vue

+ 16 - 0
src/api/platform/userapp.js

@@ -97,3 +97,19 @@ export const expExcelConsign = (param) => {
     responseType: 'blob'
   })
 }
+
+export const removeCommander = (row) => {
+  return request({
+    url: '/api/platform/userApp/remove-commander',
+    method: 'post',
+    data: row
+  })
+}
+
+export const setUpCommander = (row) => {
+  return request({
+    url: '/api/platform/userApp/set-up-commander',
+    method: 'post',
+    data: row
+  })
+}

+ 42 - 0
src/option/platform/userapp.js

@@ -0,0 +1,42 @@
+export const selfTakeOption = {
+    height:'auto',
+        calcHeight: 30,
+        tip: false,
+        searchShow: true,
+        searchMenuSpan: 6,
+        border: true,
+        index: false,
+        viewBtn: false,
+        delBtn: false,
+        addBtn: false,
+        menu: false,
+        selection: true,
+        dialogClickModal: false,
+        column: [
+        {
+            label: "名称",
+            prop: "name",
+            search: true,
+            labelWidth: 120,
+        },
+        {
+            label: "地址",
+            prop: "address",
+            addDisplay: false,
+            editDisplay: false,
+            labelWidth: 120,
+        },
+        {
+            label: "营业开始时间",
+            prop: "busStartTime",
+            valueFormat: 'HH:mm:ss',
+            labelWidth: 120,
+        },
+        {
+            label: "营业结束时间",
+            prop: "busEndTime",
+            valueFormat: 'HH:mm:ss',
+            labelWidth: 120,
+        },
+    ]
+}

+ 158 - 212
src/views/platform/userapp.vue

@@ -26,120 +26,51 @@
                    v-if="permission.userapp_delete"
                    @click="handleDelete">删 除
         </el-button>
-        <el-button type="primary"
-                   size="small"
-                   icon="el-icon-add"
-                   v-if="permission.add_user_ticket"
-                   @click="handleAddTicket">成为供应商
-        </el-button>
-<!--        <el-button type="primary"-->
-<!--                   size="small"-->
-<!--                   icon="el-icon-download"-->
-<!--                   @click="userExportShow = true">导出-->
-<!--        </el-button>-->
+      </template>
+
+      <template slot="isStore" slot-scope="scope">
+        <el-tag v-if="scope.row.isStore === 1" type="success">{{ scope.row.$isStore }}</el-tag>
+        <el-tag v-if="scope.row.isStore === 0" type="primary">{{ scope.row.$isStore }}</el-tag>
+      </template>
 
+      <template slot="livingHall" slot-scope="scope">
+        <el-tag v-if="scope.row.livingHall === 0" type="warning">{{ scope.row.$livingHall }}</el-tag>
+        <el-tag v-else-if="scope.row.livingHall === 1" type="success">{{ scope.row.$livingHall }}</el-tag>
       </template>
+
       <template slot-scope="{type,size,row}" slot="menu">
-         <el-button v-if="row.state !== 2"  icon="el-icon-connection" :size="size" :type="type" @click="forbidden(row)">禁用</el-button>
-         <el-button v-if="row.livingHall === 0" icon="el-icon-connection" :size="size" :type="type" @click="regimental(row)">设为团长</el-button>
-         <el-button v-if="row.livingHall === 1" icon="el-icon-connection" :size="size" :type="type" @click="addSelftake(row)">添加自提点</el-button>
+         <el-button v-if="row.state !== 2" :size="size" :type="type" @click="forbidden(row)">禁用</el-button>
+         <el-button v-if="row.livingHall === 0" :size="size" :type="type" @click="setLeader(row)">设为团长</el-button>
+         <el-button v-if="row.livingHall === 1" :size="size" :type="type" @click="removeLeader(row)">移除团长</el-button>
+         <el-button v-if="row.isStore === 0" :size="size" :type="type" @click="handleAddTicket(row)">设为供应商</el-button>
+         <el-button v-if="row.isStore === 1" :size="size" :type="type" @click="removeStore(row)">移除供应商</el-button>
       </template>
     </avue-crud>
 
-    <el-dialog title="添加自提点" :visible.sync="dialogVisible" width="80%" :append-to-body="true" :before-close="handleClose" >
-
-      <el-row :gutter="20">
-        <el-col span="12" >
-          <el-row>自提点列表</el-row>
-          <el-table
-                  ref="singleTable"
-                  :data="selfTakeList"
-                  highlight-current-row
-                  @current-change="handleCurrentChange"
-                  style="width: 100%">
-            <el-table-column
-                    type="index"
-                    width="50">
-            </el-table-column>
-
-            <el-table-column
-                    property="name"
-                    label="名称"
-                    width="200">
-            </el-table-column>
-            <el-table-column
-                    property="address"
-                    label="地址">
-            </el-table-column>
-          </el-table>
-
-
-          <el-row>
-
-            <el-col span="6" >
-
-            </el-col>
-
-            <el-col span="18">
-              <el-pagination
-                      background
-                      @current-change="getCurrentChange"
-                      layout="prev, pager, next"
-                      :total="selfTakeListTotal">
-              </el-pagination>
-            </el-col>
-
-          </el-row>
-
-
-        </el-col>
-        <el-col span="12" class="">
-          <el-row>已添加自提点列表</el-row>
-          <el-table
-                  :data="mySelfTakeList"
-                  style="width: 100%"
-                  max-height="250">
-
-            <el-table-column
-                    prop="name"
-                    label="名称"
-                    width="200">
-            </el-table-column>
-
-            <el-table-column
-                    prop="address"
-                    label="地址"
-                    >
-            </el-table-column>
-
-            <el-table-column
-                    fixed="right"
-                    label="操作"
-                    width="50">
-              <template slot-scope="scope">
-                <el-button
-                        @click.native.prevent="deleteRow(scope.$index, mySelfTakeList)"
-                        type="text"
-                        size="small">
-                  移除
-                </el-button>
-              </template>
-            </el-table-column>
-          </el-table>
-          </el-col>
-
-      </el-row>
-
-
+    <el-dialog title="选择自提点" :visible.sync="dialogVisible" width="80%" :append-to-body="true" :before-close="handleClose" >
+      <avue-crud :option="selfTakeOption"
+                 :table-loading="selfTakeLoading"
+                 :data="selfTakeData"
+                 :page.sync="selfTakePage"
+                 v-model="selfTakeForm"
+                 ref="selfTakeCrud"
+                 @search-change="selfTakeSearchChange"
+                 @search-reset="selfTakeSearchReset"
+                 @selection-change="selfTakeSelectionChange"
+                 @current-change="selfTakeCurrentChange"
+                 @size-change="selfTakeSizeChange"
+                 @refresh-change="selfTakeRefreshChange"
+                 @on-load="selfTakeOnLoad">
+      </avue-crud>
 
       <span slot="footer" class="dialog-footer">
-        <el-button @click="dialogVisible = false">取 消</el-button>
+        <el-button @click="handleClose">取 消</el-button>
         <el-button type="primary" @click="addUserSelfTake">确 定</el-button>
       </span>
     </el-dialog>
 
 
-    <el-dialog title="新增供应商" append-to-body :visible.sync="addUserTicketBox" width="450px">
+    <el-dialog title="新增供应商" append-to-body :visible.sync="addUserTicketBox" width="450px" :before-close="handleClose">
       <el-form :model="store" ref="store" label-width="80px">
         <el-form-item label="会员名称" labelWidth="130" prop="userName">
           <el-input v-model="store.userName" disabled="false" />
@@ -168,14 +99,16 @@
 </style>
 
 <script>
-  import {getList, getDetail, add, update, remove, addStore} from "../../api/platform/userapp";
+  import {getList, getDetail, add, update, remove, addStore, removeCommander, setUpCommander} from "../../api/platform/userapp";
   import {listByUserId,getList as getSelfTakeList,addUserSelfTake } from "../../api/groupon/selftake";
   import {mapGetters} from "vuex";
-  import {addRedIntegral} from "../../api/platform/userapp";
+  import {selfTakeOption} from "../../option/platform/userapp"
 
   export default {
     data() {
       return {
+        leaderUserId: 0,
+        selfTakeOption: selfTakeOption,
         addTicketButLoading: false,
         dialogVisible: false,
         getCodeButName: '获取验证码',
@@ -212,8 +145,15 @@
           border: true,
           // index: true,
           viewBtn: true,
+          viewBtnIcon: ' ',
+          editBtnIcon: ' ',
           selection: true,
           dialogClickModal: false,
+          menuAlign: 'left',
+          searchLabelWidth:100,
+          menuWidth: 265,
+          searchIcon: true,
+          searchIndex: 3,
           column: [
             {
               label: "主键ID",
@@ -228,46 +168,31 @@
               display: false,
             },
             {
-              label: "头像",
-              prop: "avatar",
-              type: 'upload',
-              rules: [{
-                required: false,
-                message: "请上传头像",
-                trigger: "blur"
-              }],
-              addDisplay: false,
-              editDisplay: false,
-              listType: 'picture-img',
-              span: 24,
-              drag: true,
-            },
-            {
-              label: "账号",
-              prop: "username",
-              addDisplay: false,
-              editDisplay: false,
-              search: true,
-            },
-            {
-              label: "昵称",
+              label: "会员昵称",
               prop: "name",
               addDisplay: true,
               editDisplay: true,
               search: true,
             },
             {
-              label: "姓名",
+              label: "会员姓名",
               prop: "realName",
               addDisplay: true,
               editDisplay: true,
               search: true,
             },
             {
-              label: "性别",
-              prop: "sex",
+              label: "手机号",
+              prop: "phone",
+              addDisplay: false,
+              editDisplay: false,
+              search: true,
+            },
+            {
+              label: "供应商身份",
+              prop: "isStore",
               type: "select",
-              dicUrl: "/api/blade-system/dict/dictionary?code=sex",
+              dicUrl: "/api/blade-system/dict-biz/dictionary?code=is_store",
               props: {
                 label: "dictValue",
                 value: "dictKey"
@@ -275,7 +200,8 @@
               dataType: "number",
               hide: false,
               search: true,
-              addDisplay: true,
+              addDisplay: false,
+              editDisplay: false,
               rules: [{
                 required: true,
                 message: "请选择状态",
@@ -283,7 +209,7 @@
               }]
             },
             {
-              label: "身份",
+              label: "团长身份",
               prop: "livingHall",
               type: "select",
               dicUrl: "/api/blade-system/dict-biz/dictionary?code=is_captain",
@@ -294,7 +220,8 @@
               dataType: "number",
               hide: false,
               search: true,
-              addDisplay: true,
+              addDisplay: false,
+              editDisplay: false,
               rules: [{
                 required: true,
                 message: "请选择状态",
@@ -325,6 +252,7 @@
               prop: "createTime",
               addDisplay: false,
               editDisplay: false,
+              width: 150
             },
           ]
         },
@@ -336,7 +264,18 @@
         selfTakeListTotal:0,
         mySelfTakeList:[],
         mySelfTakeListTotal:0,
-        row:{}
+        row:{},
+
+        selfTakePage: {
+          pageSize: 10,
+          currentPage: 1,
+          total: 0
+        },
+        selfTakeData: [],
+        selfTakeLoading: false,
+        selfTakeForm: {},
+        selfTakeQuery: {},
+        selfTakeSelectionList: []
       };
     },
     computed: {
@@ -366,16 +305,24 @@
       },
 
       addUserSelfTake(){
-        addUserSelfTake({
-          userId:this.row.userId,
-          selfTakeList:Array.from(this.mySelfTakeList,({ id }) => id)
+        if (this.selfTakeSelectionList.length === 0) {
+          this.$message.warning("请选择一条数据");
+          return;
+        }
+        if (this.selfTakeSelectionList.length > 1) {
+          this.$message.warning("只能选择一条数据");
+          return;
+        }
+        setUpCommander({
+          userId: this.leaderUserId,
+          selfTakeId: this.selfTakeSelectionList[0].id
         }).then(res =>{
           this.$message({
             type: "success",
             message: "操作成功!"
           });
-          this.dialogVisible = false;
-          console.log(res)
+          this.onLoad(this.page, this.query)
+          this.handleClose();
         })
       },
 
@@ -409,17 +356,24 @@
       },
 
       /**
-       * 设为团长
+       * 移除团长
        * @param row
        */
-      regimental(row) {
-          this.loading = true;
-          row.livingHall = 1;
-        update(row).then(res => {
-            if(res.data.code !== 200) this.$message.error(res.data.msg);
-            else this.$message.success(res.data.msg);
-            this.loading = false;
-          })
+      removeLeader(row) {
+        removeCommander({
+          userId: row.userId
+        }).then(res =>{
+          this.onLoad(this.page, this.query);
+          this.$message({
+            type: "success",
+            message: "移除成功"
+          });
+        })
+      },
+
+      setLeader(row) {
+        this.leaderUserId = row.userId;
+        this.dialogVisible = true;
       },
 
       /**
@@ -489,33 +443,12 @@
             });
           });
       },
-      handleAddTicket() {
-        if (this.selectionList.length === 0) {
-          this.$message.warning("请选择一条数据");
-          return;
-        }
-        if (this.selectionList.length > 1) {
-          this.$message.warning("只能选择一条数据");
-          return;
-        }
-        this.store.userName = this.selectionList[0].realName
-        this.store.userId = this.selectionList[0].userId
-        this.store.tel = this.selectionList[0].phone
-        console.log(this.store, '-------111111111--------');
-        console.log(this.selectionList, '-------2222222--------');
+      handleAddTicket(row) {
+        this.store.userName = row.realName
+        this.store.userId = row.userId
+        this.store.tel = row.phone
         this.addUserTicketBox = true;
       },
-      handleAddRedIntegral() {
-        if (this.selectionList.length === 0) {
-          this.$message.warning("请选择一条数据");
-          return;
-        }
-        if (this.selectionList.length > 1) {
-          this.$message.warning("只能选择一条数据");
-          return;
-        }
-        this.addRedIntegralBox = true;
-      },
       handleDelete() {
         if (this.selectionList.length === 0) {
           this.$message.warning("请选择至少一条数据");
@@ -594,58 +527,71 @@
             });
             this.addTicketButLoading = true;
             addStore(this.store).then(res => {
-              this.addTicketButLoading = false;
               loading.close();
-              const data = res.data;
-              if (data.code !== 200) {
-                this.$message.warning(data.msg);
-                return;
-              }
               this.$message.success("增加成功");
-              this.addUserTicketBox = false
-              this.store = {};
               this.onLoad(this.page, this.query);
             }).catch(e => {
+              this.addTicketButLoading = false;
               loading.close();
-              this.addUserTicketBox = false
-              this.store = {};
-              this.onLoad(this.page, this.query);
             })
           } else {
             return false;
           }
         });
       },
-      submitTicketRed() {
-        this.$refs["addUserTicketForm"].validate((valid) => {
-          if (valid) {
-            const loading = this.$loading({
-              lock: true,
-              text: '处理中,请稍等...',
-              spinner: 'el-icon-loading',
-              background: 'rgba(0, 0, 0, 0.7)'
-            });
-            this.addTicketButLoading = true;
-            this.addUserTicketForm.userId = this.selectionList[0].userId;
-            addRedIntegral(this.addUserTicketForm).then(res => {
-              this.addTicketButLoading = false;
-              loading.close();
-              const data = res.data;
-              if (data.code !== 200) {
-                this.$message.warning(data.msg);
-                return;
-              }
-              this.$message.success("增加成功");
-              this.addRedIntegralBox = false
-              this.addUserTicketForm = {};
-              this.onLoad(this.page, this.query);
-            })
-          } else {
-            return false;
-          }
+
+      selfTakeSearchReset() {
+        this.selfTakeQuery = {};
+        this.selfTakeOnLoad(this.selfTakePage);
+      },
+      selfTakeSearchChange(params, done) {
+        this.selfTakeQuery = params;
+        this.selfTakePage.currentPage = 1;
+        this.selfTakeOnLoad(this.selfTakePage, params);
+        done();
+      },
+      selfTakeSelectionChange(list) {
+        this.selfTakeSelectionList = list;
+      },
+      selfTakeSelectionClear() {
+        this.selfTakeSelectionList = [];
+        this.$refs.selfTakeCrud.toggleSelection();
+      },
+      selfTakeCurrentChange(currentPage){
+        this.selfTakePage.currentPage = currentPage;
+      },
+      selfTakeSizeChange(pageSize){
+        this.selfTakePage.pageSize = pageSize;
+      },
+      selfTakeRefreshChange() {
+        this.selfTakeOnLoad(this.selfTakePage, this.selfTakeQuery);
+      },
+      selfTakeOnLoad(page, params = {}) {
+        this.selfTakeLoading = true;
+        this.selfTakeQuery.status = 1;
+        getSelfTakeList(page.currentPage, page.pageSize, Object.assign(params, this.selfTakeQuery)).then(res => {
+          const data = res.data.data;
+          this.selfTakePage.total = data.total;
+          this.selfTakeData = data.records;
+          this.selfTakeLoading = false;
+          this.selfTakeSelectionClear();
         });
-      }
+      },
+
+      handleClose() {
+        this.leaderUserId = 0;
+        this.dialogVisible = false;
+        this.addUserTicketBox = false
+        this.store = {};
+        this.addTicketButLoading = false;
+      },
 
+      /**
+       * 移除供应商
+       */
+      removeStore(row) {
+
+      }
     }
   };
 </script>