ソースを参照

节-业务层次新增最近选择记录

Tang 3 年 前
コミット
cdbb954cd6

+ 74 - 1
src/utils/methodsTool.js

@@ -1,4 +1,5 @@
 import * as baseUrls from "@/utils/request.js";
+import api from '@/api/api'
 import router from '@/router/index'//引入路由对象
 // import { map } from "core-js/core/array";
 export default {
@@ -353,5 +354,77 @@ export default {
 		} else {
 			return []
 		}
-	}
+	},
+	/**
+	 *
+	 * @param {Bool} status true 全部 false 筛选
+	 * @param {Number} id 筛选情况下 教育类型ID
+	 */
+	concatList(status, id) {
+		return new Promise((resolve, reject) => {
+			let options = [
+				{
+					label: "最近选择",
+					options: [],
+				},
+				{
+					label: "业务层级",
+					options: [],
+				},
+			];
+			api.inquirebusinessList({ status: 1 }).then((res) => {
+				let courTypeOptions = res.rows;
+				if (status) {
+					if (this.getBusinessList().length) {
+						let arrlist = this.getBusinessList();
+						courTypeOptions.forEach((item) => {
+							if (arrlist.includes(item.id)) {
+								options[0].options.push(item);
+							} else {
+								options[1].options.push(item);
+							}
+						});
+					} else {
+						options[1].options = courTypeOptions;
+					}
+					// let arrs = options.filter((item) => {
+					//   if (item.options.length) {
+					//     return item;
+					//   }
+					// });
+					resolve({
+						value: res.rows,
+						options: options
+					})
+				} else {
+					let arr = [];
+					if (this.getBusinessList().length) {
+						let arrlist = this.getBusinessList();
+						courTypeOptions.forEach((item) => {
+							if (arrlist.includes(item.id)) {
+								options[0].options.push(item);
+							}
+						});
+						arr = courTypeOptions.filter((item) => {
+							return item.educationId == id && !arrlist.includes(item.id);
+						});
+					} else {
+						arr = courTypeOptions.filter((item) => {
+							return item.educationId == id;
+						});
+					}
+					options[1].options = arr;
+					// let arrs = options.filter((item) => {
+					//   if (item.options.length) {
+					//     return item;
+					//   }
+					// });
+					resolve({
+						value: res.rows,
+						options: options
+					})
+				}
+			});
+		})
+	},
 }

+ 36 - 94
src/views/resource/videoManagement/festival/add/index.vue

@@ -48,7 +48,7 @@
               <el-option
                 v-for="(items, indexs) in item.options"
                 :key="indexs"
-                :label="items.projectName + '-' + items.businessName"
+                :label="items.projectName + ' - ' + items.businessName"
                 :value="items.id"
               >
               </el-option>
@@ -118,6 +118,12 @@
             v-if="newSujectApis.length > 1"
             @click="changeType"
             >{{ changeHeight ? "展开" : "关闭" }}</el-button
+          ><el-button
+            size="mini"
+            type="danger"
+            v-if="newSujectApis.length > 0"
+            @click="sujectApis = []"
+            >清空</el-button
           >
           <!-- <span v-if="newSujectApis.length === 0">未选项目类型</span> -->
         </el-form-item>
@@ -797,75 +803,15 @@ export default {
       this.handleCheckedCitiesChange();
     },
     hideHandle() {},
-    /**
-     *
-     * @param {Bool} status true 全部 false 筛选
-     * @param {Number} id 筛选情况下 教育类型ID
-     */
-    concatList(status, id) {
-      let options = [
-        {
-          label: "最近选择",
-          options: [],
-        },
-        {
-          label: "业务层级",
-          options: [],
-        },
-      ];
-      if (status) {
-        this.$api.inquirebusinessList({ status: 1 }).then((res) => {
-          this.courTypeOptions = res.rows;
-          if (this.$methodsTools.getBusinessList().length) {
-            let arrlist = this.$methodsTools.getBusinessList();
-            res.rows.forEach((item) => {
-              if (arrlist.includes(item.id)) {
-                options[0].options.push(item);
-              } else {
-                options[1].options.push(item);
-              }
-            });
-          } else {
-            options[1].options = res.rows;
-          }
-          // let arrs = options.filter((item) => {
-          //   if (item.options.length) {
-          //     return item;
-          //   }
-          // });
-          this.newCourTypeOptions = options;
-        });
-      } else {
-        let arr = [];
-        if (this.$methodsTools.getBusinessList().length) {
-          let arrlist = this.$methodsTools.getBusinessList();
-          this.courTypeOptions.forEach((item) => {
-            if (arrlist.includes(item.id)) {
-              options[0].options.push(item);
-            }
-          });
-          arr = this.courTypeOptions.filter((item) => {
-            return item.educationId == id && !arrlist.includes(item.id);
-          });
-        } else {
-          arr = this.courTypeOptions.filter((item) => {
-            return item.educationId == id;
-          });
-        }
-        options[1].options = arr;
-        // let arrs = options.filter((item) => {
-        //   if (item.options.length) {
-        //     return item;
-        //   }
-        // });
-        this.newCourTypeOptions = options;
-      }
-    },
     getDict() {
       this.$api.inquireCourseEducationType({ status: 1 }).then((res) => {
         this.eduTypeOptions = res.rows;
       });
-      this.concatList(true);
+      this.$methodsTools.concatList(true).then((res) => {
+        this.courTypeOptions = res.value;
+        this.newCourTypeOptions = res.options;
+      });
+
       this.$api.inquireCourseSubject({ status: 1 }).then((res) => {
         res.rows.map((item, index) => {
           var array = [];
@@ -897,40 +843,36 @@ export default {
       });
     },
     changeEduType(v) {
-      this.concatList(false, v);
-      return;
-      if (!(this.courType === undefined || this.courType === "")) {
-        this.courType = "";
-      }
-      var arrays = [];
-      this.courTypeOptions.map((item) => {
-        if (item.educationId === this.eduType) {
-          arrays.push(item);
-        }
+      this.$methodsTools.concatList(false, v).then((res) => {
+        this.newCourTypeOptions = res.options;
       });
-      this.newCourTypeOptions = arrays;
+      this.courType = "";
     },
     changecourseType(ids) {
+      /**
+       * 进入缓存方法
+       */
       this.$methodsTools.cacheBusinessList(ids);
-      this.newCourTypeOptions.map((item, index) => {
-        if (item.id === this.courType) {
-          this.eduType = item.educationId;
-          var array = [];
-          this.sujectOption.map((items, indexs) => {
-            if (items.courseArrays.indexOf(item.projectId) !== -1) {
-              array.push(items);
-            }
-          });
-          this.newSujectOption = array;
-        }
+      /**
+       * 查找选中的业务层次对应的教育类型ID 并筛选出对应业务层级列表
+       */
+      let idArr = this.courTypeOptions.find((item) => {
+        return item.id == ids;
       });
-      var arrays = [];
-      this.courTypeOptions.map((item) => {
-        if (item.educationId === this.eduType) {
-          arrays.push(item);
-        }
+      this.eduType = idArr.educationId;
+      this.$methodsTools.concatList(false, idArr.educationId).then((res) => {
+        this.newCourTypeOptions = res.options;
       });
-      this.newCourTypeOptions = arrays;
+      /**
+       * 筛选科目
+       */
+      var array = this.sujectOption.filter((items, indexs) => {
+        return items.courseArrays.includes(idArr.projectId);
+      });
+      this.newSujectOption = array;
+      /**
+       * 关闭科目弹窗
+       */
       this.$refs.popovers.doClose();
     },
     submit(formName) {

+ 56 - 32
src/views/resource/videoManagement/festival/edit/index.vue

@@ -22,7 +22,7 @@
             >
             </el-option>
           </el-select>
-          <el-select
+          <!-- <el-select
             v-model="courType"
             placeholder="请选择业务层次"
             @change="changecourseType"
@@ -34,6 +34,25 @@
               :value="item.id"
             >
             </el-option>
+          </el-select> -->
+          <el-select
+            v-model="courType"
+            placeholder="请选择业务层次"
+            @change="changecourseType"
+          >
+            <el-option-group
+              v-for="(item, index) in newCourTypeOptions"
+              :key="index"
+              :label="item.label"
+            >
+              <el-option
+                v-for="(items, indexs) in item.options"
+                :key="indexs"
+                :label="items.projectName + ' - ' + items.businessName"
+                :value="items.id"
+              >
+              </el-option>
+            </el-option-group>
           </el-select>
           <el-popover
             ref="popovers"
@@ -99,6 +118,12 @@
             v-if="newSujectApis.length > 1"
             @click="changeType"
             >{{ changeHeight ? "展开" : "关闭" }}</el-button
+          ><el-button
+            size="mini"
+            type="danger"
+            v-if="newSujectApis.length > 0"
+            @click="sujectApis = []"
+            >清空</el-button
           >
           <!-- <span v-if="newSujectApis.length === 0">未选项目类型</span> -->
         </el-form-item>
@@ -853,9 +878,9 @@ export default {
     },
     businTys() {
       return new Promise((resolve, reject) => {
-        this.$api.inquirebusinessList({ status: 1 }).then((res) => {
-          this.courTypeOptions = res.rows;
-          this.newCourTypeOptions = res.rows;
+        this.$methodsTools.concatList(true).then((res) => {
+          this.courTypeOptions = res.value;
+          this.newCourTypeOptions = res.options;
           resolve();
         });
       });
@@ -899,38 +924,37 @@ export default {
         });
       });
     },
-    changeEduType() {
-      if (!(this.courType === undefined || this.courType === "")) {
-        this.courType = "";
-      }
-      var arrays = [];
-      this.courTypeOptions.map((item) => {
-        if (item.educationId === this.eduType) {
-          arrays.push(item);
-        }
+    changeEduType(v) {
+      this.$methodsTools.concatList(false, v).then((res) => {
+        this.newCourTypeOptions = res.options;
       });
-      this.newCourTypeOptions = arrays;
+      this.courType = "";
     },
-    changecourseType() {
-      this.newCourTypeOptions.map((item, index) => {
-        if (item.id === this.courType) {
-          this.eduType = item.educationId;
-          var array = [];
-          this.sujectOption.map((items, indexs) => {
-            if (items.courseArrays.indexOf(item.projectId) !== -1) {
-              array.push(items);
-            }
-          });
-          this.newSujectOption = array;
-        }
+    changecourseType(ids) {
+      /**
+       * 进入缓存方法
+       */
+      this.$methodsTools.cacheBusinessList(ids);
+      /**
+       * 查找选中的业务层次对应的教育类型ID 并筛选出对应业务层级列表
+       */
+      let idArr = this.courTypeOptions.find((item) => {
+        return item.id == ids;
       });
-      var arrays = [];
-      this.courTypeOptions.map((item) => {
-        if (item.educationId === this.eduType) {
-          arrays.push(item);
-        }
+      this.eduType = idArr.educationId;
+      this.$methodsTools.concatList(false, idArr.educationId).then((res) => {
+        this.newCourTypeOptions = res.options;
       });
-      this.newCourTypeOptions = arrays;
+      /**
+       * 筛选科目
+       */
+      var array = this.sujectOption.filter((items, indexs) => {
+        return items.courseArrays.includes(idArr.projectId);
+      });
+      this.newSujectOption = array;
+      /**
+       * 关闭科目弹窗
+       */
       this.$refs.popovers.doClose();
     },
     submit(formName) {