snow 2 năm trước cách đây
mục cha
commit
0bdff94999

+ 1 - 1
src/apis/user/index.js

@@ -62,7 +62,7 @@ export function requsetCompanyList(data){
 }
 
 //超管用户获取所有企业列表
-export function requsetCompanyAll(data){
+export function requsetSupertubeCompany(data){
   return http({
     url: `${urlConfig.baseURL}admin/comprehensiveList`,
     method: "post",

+ 16 - 15
src/layout/components/company-select/index.vue

@@ -30,7 +30,8 @@
 
 <script>
 import { mapState } from "vuex";
-import { requsetCompanyAll, requsetBindCompany } from "@/apis/user";
+
+import { requsetSupertubeCompany, requsetBindCompany } from "@/apis/user";
 
 export default {
   props: {
@@ -82,7 +83,7 @@ export default {
   data() {
     return {
       companylist: [],
-      scrollWrapper: null,
+      ScrollWrapper: null,
       state: {
         loading: false,
         noMore: false
@@ -96,17 +97,17 @@ export default {
   },
   async mounted() {
     this.initalData();
-    this.scrollWrapper = await this.getScrollWrapper();
-    this.scrollWrapper && this.bindEvent(this.scrollWrapper);
+    this.ScrollWrapper = await this.getScrollWrapper();
+    this.ScrollWrapper && this.bindEvent(this.ScrollWrapper);
   },
   beforeDetoryed() {
-    this.scrollWrapper && this.removeEvent(this.scrollWrapper);
+    this.ScrollWrapper && this.removeEvent(this.ScrollWrapper);
   },
   methods: {
     async initalData() {
       //todo:区分是否超管用户请求不同接口
       this.state.loading = true;
-      const { code, data } = await requsetCompanyAll(this.params);
+      const { code, data } = await requsetSupertubeCompany(this.params);
       if (data.list.length < 10) this.state.noMore = true;
       this.state.loading = false;
       this.params.page++;
@@ -137,10 +138,10 @@ export default {
     },
 
     async handleScroll() {
-      const scrollWrapper = this.scrollWrapper;
-      const height = scrollWrapper.clientHeight;
-      const scrollTop = scrollWrapper.scrollTop;
-      const scrollHeight = scrollWrapper.scrollHeight;
+      const ScrollWrapper = this.ScrollWrapper;
+      const height = ScrollWrapper.clientHeight;
+      const scrollTop = ScrollWrapper.scrollTop;
+      const scrollHeight = ScrollWrapper.scrollHeight;
 
       const { loading, noMore } = this.state;
       const isLoad = !loading && !noMore;
@@ -154,7 +155,7 @@ export default {
     async loadMore() {
       this.state.loading = true;
       //todo:区分是否超管用户请求不同接口
-      const { data } = await requsetCompanyAll(this.params);
+      const { data } = await requsetSupertubeCompany(this.params);
       this.state.loading = false;
       const isOverflow = this.companylist.length >= Number(data.count);
       if (isOverflow || data.list.length < 10) {
@@ -175,12 +176,12 @@ export default {
       this.initalData();
     },
 
-    bindEvent(scrollWrapper) {
-      scrollWrapper.addEventListener("scroll", this.handleScroll);
+    bindEvent(ScrollWrapper) {
+      ScrollWrapper.addEventListener("scroll", this.handleScroll);
     },
 
-    removeEvent(scrollWrapper) {
-      scrollWrapper.removeEventListener("scroll", this.handleScroll);
+    removeEvent(ScrollWrapper) {
+      ScrollWrapper.removeEventListener("scroll", this.handleScroll);
     }
   }
 };

+ 10 - 6
src/mixins/reloadData.js

@@ -10,19 +10,23 @@ const reloadData = {
     })
   },
   methods:{
-    onCompanyChangeInnner(){
-      this.pageInfo.curr = 1;
-      this.parmValue.page = 1;
+    onCompanyChangeInner(){
+      if(this.pageInfo) this.pageInfo.curr = 1;
+      if(this.parmValue) this.parmValue.page = 1;
       this.searchList && this.searchList();
     }
   },
   watch: {
     currentCompany: {
       handler() {
-        const ctx = this;
-        //超管角色刷新列表
-        ctx.onCompanyChange ? ctx.onCompanyChange() : ctx.onCompanyChangeInnner();
+        const context = this;
+        const { onCompanyChange,onCompanyChangeInner } = context;
+        //超管角色刷新列表 todo:区分是否超管 非超管不执行
+        const isSupertube = true;
+        if(!isSupertube) return null;
+        onCompanyChange ? onCompanyChange() : onCompanyChangeInner();
       },
+      //
       deep: true
     }
   }

+ 52 - 71
src/views/interest/role/index.vue

@@ -85,32 +85,17 @@
                   @click="searchList"
                 />
               </el-col>
-              <el-col
-                :span="3"
-                style="width: 66px"
-              >
-                <el-button
-                  type="warning"
-                  class="fr"
-                  :size="searchSize"
-                  @click="restSearch"
-                >
-                  重置
-                </el-button>
+              <el-col :span="3" style="width: 66px">
+                <el-button type="warning" class="fr" :size="searchSize" @click="restSearch">重置</el-button>
               </el-col>
-              <el-col
-                :span="3"
-                style="width: 66px; float: right"
-              >
+              <el-col :span="3" style="width: 66px; float: right">
                 <el-button
                   type="primary"
                   :size="searchSize"
                   style="float: right"
                   @click="searchList"
-                >
-                  刷新
-                </el-button></el-col
-              >
+                >刷新</el-button>
+              </el-col>
               <el-col
                 :span="3"
                 style="width: 66px; float: right"
@@ -121,9 +106,7 @@
                   type="success"
                   style="float: right"
                   @click="openModal('add', false)"
-                >
-                  添加
-                </el-button>
+                >添加</el-button>
               </el-col>
             </el-col>
           </el-row>
@@ -147,10 +130,7 @@
           content="详情"
           placement="top"
         >
-          <i
-            class="el-icon-view tb-icon"
-            @click="openModal(scope.row.id, true)"
-          ></i>
+          <i class="el-icon-view tb-icon" @click="openModal(scope.row.id, true)"></i>
         </el-tooltip>
         <el-tooltip
           v-if="powers.some((i) => i == '005')"
@@ -158,10 +138,7 @@
           content="修改"
           placement="top"
         >
-          <i
-            class="el-icon-edit tb-icon"
-            @click="openModal(scope.row.id, false)"
-          ></i>
+          <i class="el-icon-edit tb-icon" @click="openModal(scope.row.id, false)"></i>
         </el-tooltip>
         <el-tooltip
           v-if="
@@ -205,27 +182,28 @@
 <script>
 import addEdit from "./addEdit";
 import asyncRequest from "@/apis/service/interest/role";
-import {statusList} from "@/assets/js/statusList";
+import { statusList } from "@/assets/js/statusList";
 import roleLevel from "@/assets/js/roleLevel";
-import mixinPage from "@/mixins/elPaginationHandle";``
+import mixinPage from "@/mixins/elPaginationHandle";
+``;
 import resToken from "@/mixins/resToken";
 import reloadData from "@/mixins/reloadData";
 import { mapGetters } from "vuex";
 export default {
   name: "role",
-  mixins: [mixinPage, resToken,reloadData],
+  mixins: [mixinPage, resToken, reloadData],
   components: {
-    addEdit,
+    addEdit
   },
   computed: {
     //组件SIZE设置
     ...mapGetters(["tablebtnSize", "searchSize", "size"]),
     powers() {
       const { btnList } = this.$store.getters;
-      const tran = btnList.find((i) => i.menu_route == "role") || {};
+      const tran = btnList.find(i => i.menu_route == "role") || {};
       const { action } = tran ?? {};
       return action ?? [];
-    },
+    }
   },
   data() {
     return {
@@ -240,17 +218,17 @@ export default {
         fullName: "", // 姓名
         type: 2, // 用户类型(1运营人员 2物业人员)
         page: 1, // 页码
-        size: 15, // 每页显示条数
+        size: 15 // 每页显示条数
       },
       // 状态
       statusOptions: [
         { id: 0, label: "禁用" },
-        { id: 1, label: "启用" },
+        { id: 1, label: "启用" }
       ],
       // 角色等级
       authOptions: [
         { id: "1", label: "管理员" },
-        { id: "2", label: "非管理员" },
+        { id: "2", label: "非管理员" }
       ],
       // 表格 - 数据
       tableData: [],
@@ -258,59 +236,59 @@ export default {
       table: {
         stripe: true,
         border: true,
-        _defaultHeader_: ["setcol"],
+        _defaultHeader_: ["setcol"]
       },
       // 表格 - 分页
       pageInfo: {
         size: 15,
         curr: 1,
-        total: 0,
+        total: 0
       },
       // 表格 - 列参数
       columns: [
         {
           prop: "role_name",
-          label: "角色名称",
+          label: "角色名称"
         },
         {
           prop: "level",
           label: "角色等级",
-          _format_: (d) => {
+          _format_: d => {
             return (
-              this.authOptions.find((item) => {
+              this.authOptions.find(item => {
                 return item.id == d.level;
               }) || {}
             ).label;
-          },
+          }
         },
         {
-          prop:'companyNo',
-          label:'公司编号'
+          prop: "companyNo",
+          label: "公司编号"
         },
         {
-          prop:'companyName',
-          label:'公司名称'
+          prop: "companyName",
+          label: "公司名称"
         },
         {
           prop: "addtime",
           label: "创建时间",
-          sortable: true,
+          sortable: true
         },
         {
           prop: "status",
           label: "状态",
           sortable: true,
-          _slot_: "status",
+          _slot_: "status"
         },
         {
           prop: "",
           label: "操作",
           fixed: "right",
-          width:'125px',
+          width: "125px",
           _noset_: true,
-          _slot_: "operation",
-        },
-      ],
+          _slot_: "operation"
+        }
+      ]
     };
   },
   mounted() {
@@ -322,22 +300,22 @@ export default {
       this.pageInfo = {
         size: 15,
         curr: 1,
-        total: 0,
+        total: 0
       };
       this.parmValue = {
         status: "", // 账户
         level: "", // 姓名
         role_name: "",
         page: 1, // 页码
-        size: 15, // 每页显示条数
+        size: 15 // 每页显示条数
       };
       this.searchList();
     },
     // 新建/编辑/详情
     openModal(id, isDetail) {
-      if(!this.currentCompany){
-        this.$message.warning('请在右上角选择一家公司');
-        return
+      if (!this.currentCompany) {
+        this.$message.warning("请在右上角选择一家公司");
+        return;
       }
 
       this.showModel = true;
@@ -350,21 +328,24 @@ export default {
      * @param {String} status 0-禁用 1-启用
      */
     async changeStatus(id, status) {
-      await this.$confirm(`确定要改为${status + '' === "1" ? "禁用" : "启用"}?`, {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning",
-      })
+      await this.$confirm(
+        `确定要改为${status + "" === "1" ? "禁用" : "启用"}?`,
+        {
+          confirmButtonText: "确定",
+          cancelButtonText: "取消",
+          type: "warning"
+        }
+      )
         .then(async () => {
           const model = {
             roleid: id,
-            status: status + '' === "1" ? "0" : "1",
+            status: status + "" === "1" ? "0" : "1"
           };
           const res = await asyncRequest.status(model);
           if (res && res.code === 0) {
             this.$notify.success({
               title: "状态修改成功",
-              message: "",
+              message: ""
             });
             this.searchList();
           } else if (res && res.code >= 100 && res.code <= 104) {
@@ -378,7 +359,7 @@ export default {
         });
     },
 
-    *getFullData(){
+    *getFullData() {
       console.log(11);
     },
 
@@ -403,8 +384,8 @@ export default {
         this.pageInfo.total = 0;
       }
       this.loading = false;
-    },
-  },
+    }
+  }
 };
 </script>