Szx 2 years ago
parent
commit
7709e60f24
1 changed files with 69 additions and 104 deletions
  1. 69 104
      src/views/put/put-ad-plan.vue

+ 69 - 104
src/views/put/put-ad-plan.vue

@@ -37,31 +37,22 @@
       <template v-if="!!showDropDownBox">
         <div class="tool-bar-item">
           <p class="label">推广员</p>
-          <a-select
-            v-model:value="groupuids"
-            placeholder="请选择组"
+          <!-- <a-select
+            mode="multiple"
+            v-model:value="uids"
+            placeholder="请选择推广员"
             style="width: 300px"
-            @change="groupChange"
           >
             <a-select-option
-              v-for="(user, index) in filter_users"
-              :key="user.group_name"
-              :value="user.group_id"
+              v-for="user in available_uids"
+              :key="user.id"
+              :value="user.id"
             >
-              {{ user.group_name }}
-
-              <div style="display:inline-block;float:right">
-                是否全选
-                <a-checkbox
-                  v-model:checked="isCheckoutAll[index]"
-                  @change.native="getCheckoutChange(index, isCheckoutAll)"
-                ></a-checkbox>
-              </div>
+              {{ user.nickname }}
             </a-select-option>
-          </a-select>
-
+          </a-select> -->
           <!-- {{ filter_users }} -->
-          <!-- <a-cascader
+          <a-cascader
             v-model:value="getuids"
             style="width: 100%"
             mode="multiple"
@@ -70,24 +61,9 @@
             placeholder="请选择推广员"
             @change="getPromoteUser"
             :allowClear="false"
-          ></a-cascader> -->
+          ></a-cascader>
         </div>
-        <a-select
-          mode="multiple"
-          v-model:value="uids"
-          placeholder="请选择推广员"
-          style="width: 300px"
-          allowClear
-        >
-          <a-select-option
-            v-for="user in filter_user_item"
-            :key="user.uid"
-            :value="user.uid"
-          >
-            {{ user.nickname }}
-          </a-select-option>
-        </a-select>
-        <!-- <div class="tool-bar-item">
+        <div class="tool-bar-item">
           <a-select
             v-model:value="uidslabel"
             mode="tags"
@@ -97,7 +73,7 @@
             @change="delItems"
           >
           </a-select>
-        </div> -->
+        </div>
       </template>
     </tool-bar>
 
@@ -425,7 +401,7 @@ import {
 import { ADPlanItem, PageOptions, PlanBack } from "#/api";
 import useAuthUser from "@/hooks/composable/useAuthUser";
 import ARow from "ant-design-vue/lib/grid/Row";
-import { any, arrayOf } from "vue-types";
+import { any } from "vue-types";
 const PutAdPlan = defineComponent({
   components: {
     ToolBar,
@@ -512,46 +488,35 @@ const PutAdPlan = defineComponent({
       uids: ref<number[]>([]),
       options: ref<any>([]),
       filter_users: ref<any>([]),
-      groupuids: ref<number>(),
-      // getuids: ref<number[]>([]),
-      // uidslabel: ref<string[]>([]),
-      // uidslabelCurrent: ref<any>([]),
-      filter_user_item: ref<any>([]),
-      checkAllFlag: [],
-      isCheckoutAll: [],
+      getuids: ref<number[]>([]),
+      uidslabel: ref<string[]>([]),
+      uidslabelCurrent: ref<any>([]),
     });
-    const groupChange = (val: any) => {
-      state.isCheckoutAll = [];
-      state.groupuids = val;
-      state.filter_users.map((item: any) => {
-        if (item.group_id == val) {
-          state.filter_user_item = item.users;
-        }
-      });
-    };
-    const getCheckoutChange = (index: any, ischeckList: any) => {
-      state.checkAllFlag = ischeckList;
-      console.log(state.checkAllFlag[index]);
-      let arr = [] as any;
-      if (state.checkAllFlag[index]) {
-        console.log(state.filter_user_item);
-        state.checkAllFlag.map((item: any) => {
-          if (item) {
-            state.filter_user_item.map((item: any) => {
-              arr.push(item.uid);
-            });
-          }
-        });
-
-        state.uids = arr;
-      }
-      state.checkAllFlag = [];
-    };
     const groupHandle = () => {
       getAuthorUser().then((res) => {
         state.filter_users = res.data.filter_users;
+        let arr = [] as any;
+        state.filter_users.map((item: any, useIndex: any) => {
+          arr.push({
+            value: item.group_id,
+            label: item.group_name,
+            children: [],
+          });
+          arr.map((a: any, index: any) => {
+            item.users.forEach((i: any, indexi: any) => {
+              if (index == useIndex) {
+                a.children.push({
+                  value: i.uid,
+                  label: i.nickname,
+                });
+              }
+            });
+          });
+        });
+        state.options = arr;
       });
     };
+
     groupHandle();
     if (
       route.query &&
@@ -778,38 +743,38 @@ const PutAdPlan = defineComponent({
         width: 230,
       });
     });
-    // const getPromoteUser = (val: any, selectedOptions: any) => {
-    //   if (val) {
-    //     state.uids.push(val.slice(-1));
-    //     state.uidslabelCurrent.push(selectedOptions[1]);
-    //     state.uidslabel.push(selectedOptions[1].label);
-    //   }
-    //   console.log(state.uids, "state.uids");
-    // };
+    const getPromoteUser = (val: any, selectedOptions: any) => {
+      if (val) {
+        state.uids.push(val.slice(-1));
+        state.uidslabelCurrent.push(selectedOptions[1]);
+        state.uidslabel.push(selectedOptions[1].label);
+      }
+      console.log(state.uids, "state.uids");
+    };
     //删除监听
-    // const delItems = (value: any) => {
-    //   if (!value[0]) {
-    //     state.uids = [];
-    //   }
-    //   let arr = [] as any;
-    //   state.uidslabelCurrent.map((item: any) =>
-    //     value.map((i: any) => {
-    //       if (i == item.label) {
-    //         console.log(item.value);
-    //         arr.push(item.value);
-    //       }
-    //     })
-    //   );
-    //   state.uids = unique(arr) as any;
-    // };
+    const delItems = (value: any) => {
+      if (!value[0]) {
+        state.uids = [];
+      }
+      let arr = [] as any;
+      state.uidslabelCurrent.map((item: any) =>
+        value.map((i: any) => {
+          if (i == item.label) {
+            console.log(item.value);
+            arr.push(item.value);
+          }
+        })
+      );
+      state.uids = unique(arr) as any;
+    };
     //去重
-    // const unique = (arr: any) => {
-    //   if (!Array.isArray(arr)) {
-    //     console.log("type error!");
-    //     return;
-    //   }
-    //   return Array.from(new Set(arr));
-    // };
+    const unique = (arr: any) => {
+      if (!Array.isArray(arr)) {
+        console.log("type error!");
+        return;
+      }
+      return Array.from(new Set(arr));
+    };
 
     const setSateSwitch = (val: string, name: string) => {
       state.cost_order = 0;
@@ -869,8 +834,8 @@ const PutAdPlan = defineComponent({
       handleTableChange,
       onSearch,
       switchDate,
-      getCheckoutChange,
-      groupChange,
+      getPromoteUser,
+      delItems,
     };
   },
   mounted() {