lex-xin 10 月之前
父节点
当前提交
55afc22313

+ 1 - 1
src/utils/request2.js

@@ -103,7 +103,7 @@ service.interceptors.request.use(
     } else {
       config.data = noCleanDeep ? config.data : cleanDeep(config.data);
     }
-    config.params = noCleanDeep ? config.data : cleanDeep(config.params);
+    config.params = noCleanDeep ? config.params : cleanDeep(config.params);
     return config;
   },
   async error => {

+ 39 - 3
src/views/categroyManager/productSystem/api.js

@@ -13,6 +13,15 @@ export function getAllmemberRank(data) {
   })
 }
 
+// 获取所有会员列表
+export function api_getMemberRankSetting(data) {
+  return request2({
+    url: api + '/memberRankOrganizationFeeMapper/getMemberRankSetting',
+    method: 'post',
+    data
+  })
+}
+
 // 新增会员类型
 export function addMemberRank(data) {
   return request2({
@@ -22,11 +31,12 @@ export function addMemberRank(data) {
   })
 }
 
+
 export function getmemberRankList(data) {
   return request2({
     url: api + '/memberRankSetting/queryPage',
-    method: 'get',
-    params: data
+    method: 'post',
+    data
   })
 }
 
@@ -45,7 +55,6 @@ export function resetMemberRank(data) {
     url: api + '/memberRankSetting/update',
     method: 'post',
     data: data,
-
   })
 }
 
@@ -58,6 +67,15 @@ export function addMemberOrganizationFeeMapper(data) {
   })
 }
 
+// 新增会员收费
+export function addMemberOrganizationFeeMapperV2(data) {
+  return request2({
+    url: api + '/memberRankOrganizationFeeMapper/addV2',
+    method: 'post',
+    data: data
+  })
+}
+
 export function getmemberRankOrganizationFeeMapper(data) {
   return request2({
     url: api + '/memberRankOrganizationFeeMapper/queryPage',
@@ -84,3 +102,21 @@ export function resetMemberOrganizationFeeMapper(data) {
     requestType: 'json'
   })
 }
+
+
+// 分类树状列表
+export function api_memberRankCategoryTree(data) {
+  return request2({
+    url: api + '/memberRankSetting/categoryTree',
+    method: 'get',
+    params: data,
+  })
+}
+
+// 删除
+export function api_memberRankDel(data) {
+  return request2({
+    url: api + '/memberRankSetting/del/' + data.id,
+    method: 'post'
+  })
+}

+ 84 - 51
src/views/categroyManager/productSystem/memberFeeSet.vue

@@ -2,7 +2,7 @@
   <div class="m-container">
     <h2>
       <div class="squrt"></div>
-      云练习收费标准
+      学练宝收费标准
     </h2>
     <div
       class="m-core"
@@ -22,7 +22,7 @@
           <el-input
             v-model.trim="searchForm.search"
             clearable
-            placeholder="云练习名称"
+            placeholder="学练宝名称"
           ></el-input>
         </el-form-item>
         <el-form-item prop="organId">
@@ -66,8 +66,8 @@
         <el-table-column
           align="left"
           prop="rankName"
-          label="云练习名称"
-          width="90px"
+          label="学练宝名称"
+          width="120px"
         ></el-table-column>
         <el-table-column align="left" prop="type" label="月收费">
           <template slot-scope="scope">
@@ -228,8 +228,8 @@
     </div>
     <emptyPage
       @submit="addFee"
-      title="云练习收费标准"
-      btnTitle="新建云练习收费标准"
+      title="学练宝收费标准"
+      btnTitle="新建学练宝收费标准"
       :context="context"
       v-if="!(tableList.length > 0 || rules.page > 1) && contextFlag"
     />
@@ -248,17 +248,20 @@
         <div class="wrap">
           <el-form-item
             label="所属分部"
-            prop="organId"
+            prop="organIds"
             :rules="[{ required: true, message: '请选择分部' }]"
             :label-width="formLabelWidth"
           >
             <el-select
-              :disabled="addDisabled"
+              :disabled="addDisabled || pageType === 'update'"
               class="multiple"
               filterable
-              v-model.trim="form.organId"
+              v-model.trim="form.organIds"
               clearable
+              multiple
+              :collapse-tags="true"
               placeholder="请选择分部"
+              @change="getAllMember"
             >
               <el-option
                 v-for="(item, index) in selects.branchs"
@@ -269,18 +272,28 @@
             </el-select>
           </el-form-item>
           <el-form-item
-            label="云练习名称"
+            label="学练宝版本"
             prop="memberRankSettingId"
-            :rules="[{ required: true, message: '请选择云练习' }]"
+            :rules="[{ required: true, message: '请选择学练宝版本' }]"
             :label-width="formLabelWidth"
           >
-            <el-select
-              disabled
+          <el-cascader
+              filterable
+              v-model.trim="form.memberRankSettingId"
+              clearable
+              placeholder="请选择学练宝版本"
+              :disabled="addDisabled"
+              :options="remberList"
+              :props="{ value: 'id', label: 'name' }"
+              :show-all-levels="false"
+            ></el-cascader>
+            <!-- <el-select
+              :disabled="addDisabled"
               class="multiple"
               filterable
               v-model.trim="form.memberRankSettingId"
               clearable
-              placeholder="请选择云练习"
+              placeholder="请选择学练宝"
             >
               <el-option
                 v-for="(item, index) in remberList"
@@ -288,7 +301,7 @@
                 :label="item.name"
                 :value="item.id"
               ></el-option>
-            </el-select>
+            </el-select> -->
           </el-form-item>
         </div>
 
@@ -691,10 +704,9 @@
   </div>
 </template>
 <script>
-import numeral from "numeral";
 import {
-  getAllmemberRank,
-  addMemberOrganizationFeeMapper,
+  api_getMemberRankSetting,
+  addMemberOrganizationFeeMapperV2,
   getmemberRankOrganizationFeeMapper,
   getmemberOrganizationFeeMapperkDetail,
   resetMemberOrganizationFeeMapper
@@ -738,7 +750,7 @@ export default {
         groupPurchaseMonthFee: "",
         groupPurchaseQuarterlyFee: "",
         groupPurchaseYearFee: "",
-        organId: "",
+        organIds: [],
         memberRankSettingId: "",
         incomeMonthFee: "", // 月经营报表
         incomeQuarterlyFee: "", // 季度经营报表
@@ -758,26 +770,31 @@ export default {
         maxYearFee: null
       },
       context:
-        "云练习收费标准,可根据各分部的实际情况为分部制定不同的售价标准,设置完成后,各分部为学员创建云练习缴费时默认以此处设置的价格向学员收费。",
+        "学练宝收费标准,可根据各分部的实际情况为分部制定不同的售价标准,设置完成后,各分部为学员创建学练宝缴费时默认以此处设置的价格向学员收费。",
       contextFlag: false
     };
   },
   async mounted() {
     await this.$store.dispatch("setBranchs");
-    // 获取所有的会员
-    try {
-      const res = await getAllmemberRank();
-      this.remberList = res.data;
-      // 默认选中第一个
-      if (this.pageType == "create" && this.remberList.length > 0) {
-        this.form.memberRankSettingId = this.remberList[0].id;
-      }
-    } catch {}
-
+    
     this.getList();
     this.getRules();
   },
   methods: {
+    async getAllMember() {
+      // 获取所有的会员
+      try {
+        const res = await api_getMemberRankSetting({
+          organIds: this.form.organIds.join(','),
+          id: this.form.outId
+        });
+        this.remberList = res.data;
+        // 默认选中第一个
+        // if (this.pageType == "create" && this.remberList.length > 0) {
+        //   this.form.memberRankSettingId = this.remberList[0].id;
+        // }
+      } catch {}
+    },
     async getRules() {
       try {
         const res = await sysConfigList({ group: "DEFAULT" });
@@ -790,13 +807,8 @@ export default {
             if (itemValue) {
               this.rulesForm = itemValue;
             }
-            // this.$set(this.form, item.id, item.paranValue);
           }
-          // this.form[item.paramName] = item.paranValue
-          // this.$set(this.form, item.id, item.paranValue);
         });
-        // this.$forceUpdate()
-        // console.log(this.form);
       } catch (e) {
         console.log(e);
       }
@@ -835,7 +847,7 @@ export default {
         incomeQuarterlyFee: "", // 季度经营报表
         incomeHalfYearFee: "", // 半年经营报表
         incomeYearFee: "", // 年经营报表
-        organId: "",
+        organIds: [],
         memberRankSettingId: ""
       }),
         this.$refs[ruleForm].resetFields();
@@ -843,10 +855,11 @@ export default {
     addFee() {
       this.title = "新增收费标准";
       this.addDisabled = false;
+      this.form.outId = null;
       this.pageType = "create";
       this.branchStatus = true;
     },
-    resetFee(row, type) {
+    async resetFee(row, type) {
       if (type == "update") {
         this.title = "修改收费标准";
         this.pageType = "update";
@@ -862,29 +875,49 @@ export default {
           obj[key] = row.memberFeeSetting[key];
         }
       }
-
+      
       this.form = {
         ...obj,
-        organId: row.organId,
-        memberRankSettingId: row.memberRankSettingId,
+        organIds: row.organId ? [row.organId] : [],
         outId: row.id
       };
+      await this.getAllMember()
+      this.form.memberRankSettingId = row.memberRankSettingId ? this.formatParentId(row.memberRankSettingId, this.remberList) : [],
+     
       this.branchStatus = true;
     },
+    formatParentId(id, list, ids = []) {
+      for (const item of list) {
+        if (item.children) {
+          const cIds = this.formatParentId(
+            id,
+            item.children,
+            [...ids, item.id]
+          );
+          if (cIds.includes(id)) {
+            return cIds;
+          }
+        }
+        if (item.id === id) {
+          return [...ids, id];
+        }
+      }
+      return ids;
+    },
     onSubmit() {
-      console.log(this.pageType);
       if (this.pageType == "look") {
         this.branchStatus = false;
         return;
       }
       this.$refs.ruleForm.validate(async flag => {
         if (flag) {
+          const memberRankSettingId = this.form.memberRankSettingId.length > 0 ? this.form.memberRankSettingId[this.form.memberRankSettingId.length -1] : null
           if (this.pageType == "update") {
             try {
-              const res = await resetMemberOrganizationFeeMapper({
+               await resetMemberOrganizationFeeMapper({
                 memberFeeSetting: { ...this.form },
-                organId: this.form.organId,
-                memberRankSettingId: this.form.memberRankSettingId,
+                organId: this.form.organIds.join(','),
+                memberRankSettingId,
                 id: this.form.outId
               });
               this.$message.success("修改成功");
@@ -895,10 +928,10 @@ export default {
             }
           } else if (this.pageType == "create") {
             try {
-              const res = await addMemberOrganizationFeeMapper({
+               await addMemberOrganizationFeeMapperV2({
                 memberFeeSetting: { ...this.form },
-                organId: this.form.organId,
-                memberRankSettingId: this.form.memberRankSettingId
+                organIds: this.form.organIds.join(','),
+                memberRankSettingId
               });
               this.$message.success("新建成功");
               this.branchStatus = false;
@@ -926,7 +959,7 @@ export default {
       if (one >= min && one <= max) {
         return callback();
       }
-      return callback(new Error(`月度云练习定价应在${min}-${max}之间`));
+      return callback(new Error(`月度学练宝定价应在${min}-${max}之间`));
     },
     validateQuarterlyIncome(rule, value, callback) {
       const one = Number(value);
@@ -946,7 +979,7 @@ export default {
       if (one >= min && one <= max) {
         return callback();
       }
-      return callback(new Error(`季度云练习定价应在${min}-${max}之间`));
+      return callback(new Error(`季度学练宝定价应在${min}-${max}之间`));
     },
     validateHalfYearIncome(rule, value, callback) {
       const one = Number(value);
@@ -966,7 +999,7 @@ export default {
       if (one >= min && one <= max) {
         return callback();
       }
-      return callback(new Error(`半年云练习定价应在${min}-${max}之间`));
+      return callback(new Error(`半年学练宝定价应在${min}-${max}之间`));
     },
     validateYearIncome(rule, value, callback) {
       const one = Number(value);
@@ -986,7 +1019,7 @@ export default {
       if (one >= min && one <= max) {
         return callback();
       }
-      return callback(new Error(`年度云练习定价应在${min}-${max}之间`));
+      return callback(new Error(`年度学练宝定价应在${min}-${max}之间`));
     }
   },
   watch: {

+ 336 - 114
src/views/categroyManager/productSystem/memberSet.vue

@@ -16,7 +16,7 @@
         <!-- 状态 指导老师 活动方案-->
         <el-form-item>
           <el-input
-            v-model.trim="searchForm.search"
+            v-model.trim="searchForm.name"
             clearable
             placeholder="学练宝名称"
           ></el-input>
@@ -57,20 +57,16 @@
         row-key="id"
         :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
       >
-        <el-table-column
-          align="center"
-          prop="name"
-          label="学练宝名称"
-        ></el-table-column>
+        <el-table-column prop="name" label="学练宝名称"></el-table-column>
 
+        <el-table-column align="center" prop="intro" label="学练宝介绍">
+          <template slot-scope="scope">
+            <tooltip :content="scope.row.intro" />
+          </template>
+        </el-table-column>
         <el-table-column
           align="center"
-          prop="name"
-          label="学练宝介绍"
-        ></el-table-column>
-        <el-table-column
-          align="center"
-          prop="name"
+          prop="musicCount"
           label="曲目数量"
         ></el-table-column>
         <el-table-column
@@ -87,7 +83,7 @@
           <template slot-scope="scope">
             <div>
               <auth auths="memberRankSetting/get">
-                <el-button type="text" @click="resetMember(scope.row)"
+                <el-button v-if="scope.row.parentId <= 0" type="text" @click="addLeave(scope.row)"
                   >添加了项</el-button
                 >
               </auth>
@@ -105,11 +101,15 @@
                   >修改</el-button
                 >
               </auth>
+
+              <el-button type="text" @click="removeMember(scope.row)"
+                >删除</el-button
+              >
             </div>
           </template>
         </el-table-column>
       </el-table>
-      <pagination
+      <!-- <pagination
         save-key="memberSet"
         :total.sync="rules.total"
         sync
@@ -117,7 +117,7 @@
         :limit.sync="rules.limit"
         :page-sizes="rules.page_size"
         @pagination="getList"
-      />
+      /> -->
     </div>
     <el-dialog
       :title="title"
@@ -138,12 +138,13 @@
         </el-alert>
         <el-form-item
           label="父级"
-          prop="name"
+          prop="parentName"
+          v-if="form.parentId"
           :label-width="formLabelWidth"
         >
           <el-input
             :disabled="true"
-            v-model.trim="form.name"
+            v-model.trim="form.parentName"
             style="width: 620px"
           ></el-input>
         </el-form-item>
@@ -160,6 +161,7 @@
             style="width: 620px"
             maxlength="10"
             show-word-limit
+            placeholder="请输入学练宝名称"
           ></el-input>
         </el-form-item>
         <el-form-item
@@ -177,23 +179,27 @@
             type="textarea"
             :rows="5"
             style="width: 620px"
+            placeholder="请输入学练宝介绍"
           ></el-input>
         </el-form-item>
-      
-        
+
         <el-alert
-          title="会员权益"
+          title="学练宝权益"
           type="info"
           :closable="false"
           style="margin-bottom: 20px"
         >
         </el-alert>
-        <el-form-item :label="searchName" :label-width="formLabelWidth">
+        <el-form-item label="搜索:" :label-width="formLabelWidth">
           <el-input
             style="width: 210px"
-            v-model.trim="seachRoleValue"
+            v-model.trim="searchRoleValue"
+            placeholder="请输入搜索内容"
           ></el-input>
-          <el-button style="margin-left: 10px" type="danger" @click="seachRoles"
+          <el-button
+            style="margin-left: 10px"
+            type="danger"
+            @click="searchRoles"
             >搜索</el-button
           >
           <el-button type="primary" @click="onReSetRole">重置</el-button>
@@ -201,23 +207,23 @@
         <br />
         <el-form-item label="学练宝内容" :label-width="formLabelWidth">
           <el-checkbox
-            :disabled="addDisabled"
-            :indeterminate="isIndeterminate"
-            @change="onCheckAll"
-            v-model.trim="checkAll"
+            :disabled="addDisabled || this.buyFlag && pageType === 'update'"
+            :indeterminate="isMemberIndeterminate"
+            @change="onCheckMemberAll"
+            v-model.trim="memberCheckAll"
             >全选</el-checkbox
           >
           <div>
             <el-tree
               class="tree"
-              :data="treeData"
+              :data="treeMemberData"
               show-checkbox
               node-key="id"
-              @check="onTreeCheck"
+              @check="onTreeMemberCheck"
               :filter-node-method="filterNode"
-              ref="trees"
+              ref="memberTrees"
               highlight-current
-              :default-checked-keys="checkList"
+              :default-checked-keys="memberCheckList"
               :props="defaultProps"
             >
               <div slot-scope="{ node, data }">
@@ -227,10 +233,37 @@
           </div>
         </el-form-item>
 
+        <el-form-item label="学练宝内容2" :label-width="formLabelWidth">
+          <!-- <el-checkbox
+            :disabled="addDisabled"
+            :indeterminate="isMemberIndeterminate"
+            @change="onCheckMemberAll"
+            v-model.trim="memberCheckAll"
+            >全选</el-checkbox
+          > -->
+          <div style="padding-top: 5px;">
+            <el-tree
+              class="tree"
+              :data="treeClassData"
+              show-checkbox
+              node-key="id"
+              @check="onTreeClassCheck"
+              :filter-node-method="filterNode"
+              ref="classTrees"
+              highlight-current
+              :default-checked-keys="classCheckList"
+              :props="defaultProps"
+            >
+              <div slot-scope="{ node, data }">
+                {{ node.label }}
+              </div>
+            </el-tree>
+          </div>
+        </el-form-item>
 
         <el-form-item label="学练宝功能" :label-width="formLabelWidth">
           <el-checkbox
-            :disabled="addDisabled"
+            :disabled="addDisabled || this.buyFlag && pageType === 'update'"
             :indeterminate="isIndeterminate"
             @change="onCheckAll"
             v-model.trim="checkAll"
@@ -242,6 +275,7 @@
               :data="treeData"
               show-checkbox
               node-key="id"
+              ref="trees"
               @check="onTreeCheck"
               :filter-node-method="filterNode"
               highlight-current
@@ -262,76 +296,84 @@
         <el-button @click="onSubmit" type="primary">确 定</el-button>
       </span>
     </el-dialog>
-
   </div>
 </template>
 <script>
 import pagination from "@/components/Pagination/index";
 import Upload from "@/components/Upload/index";
-import ImageCropper from '@/components/ImageCropper'
+import ImageCropper from "@/components/ImageCropper";
+import Tooltip from "@/components/Tooltip/index";
 import {
   addMemberRank,
   getmemberRankList,
   getmemberRankDetail,
   resetMemberRank,
+  api_memberRankCategoryTree,
+  api_memberRankDel
 } from "./api";
-import { getTimes } from "@/utils";
+import { getTimeFormat } from "@/utils";
 import { getMemberPrivilegesItem } from "@/views/dictionaryManager/api";
 export default {
-  components: { pagination, Upload, ImageCropper },
+  components: { pagination, Upload, ImageCropper, Tooltip },
   name: "memberSet",
   data() {
     return {
       formLabelWidth: "120px",
       searchForm: {
-        search: null,
+        name: null,
         updateName: null,
-        createTimer: [],
+        createTimer: []
       },
       rules: {
         // 分页规则
         limit: 10, // 限制显示条数
         page: 1, // 当前页
         total: 0, // 总条数
-        page_size: [10, 20, 40, 50], // 选择限制显示条数
+        page_size: [10, 20, 40, 50] // 选择限制显示条数
       },
       tableList: [],
       title: "新增会员等级",
       branchStatus: false,
       form: {
-        name: "",
-        // icon: "",
-        // into: "",
-        // experienceIcon:'',
+        name: null,
+        intro: null,
+        memberCategoryIdList: [],
+        memberCourseTypeList: [],
+        memberPrivilegesItemIdList: []
       },
+      buyFlag: false, // 是否购买
       addDisabled: false,
       checkAll: false,
       isIndeterminate: false,
+      memberCheckAll: false,
+      isMemberIndeterminate: false,
       treeData: [],
+      treeMemberData: [],
+      treeClassData: [],
       defaultProps: {
         children: "children",
         label: "label",
-        disabled: this.addDisabled,
+        disabled: this.addDisabled
       },
       result: {
         roleName: null,
-        roleDesc: null,
+        roleDesc: null
       },
-      seachRoleValue: "",
+      classList: [],
+      classCount: 0,
+      memberRankList: [],
+      memberRankCount: 0,
+      searchRoleValue: "",
       silderList: [],
       slideCount: 0,
       pageType: "",
       allChildIds: [],
+      allMemberChildIds: [],
+      allClassChildIds: [],
       checkList: [],
-      searchName: "搜索\xa0\xa0\xa0\xa0\xa0\xa0\xa0",
-      cropperOptions: {
-        autoCrop: true, //是否默认生成截图框
-        autoCropWidth: 200, //默认生成截图框宽度
-        autoCropHeight: 200, //默认生成截图框高度
-        fixedBox: true, //是否固定截图框大小 不允许改变
-        previewsCircle: false, //预览图是否是圆形
-        title: '会员标识', //模态框上显示的标题
-      },
+      memberCheckList: [],
+      classCheckList: [],
+      searchName: ""
     };
   },
   async mounted() {
@@ -342,8 +384,8 @@ export default {
       this.form = {
         name: "",
         icon: "",
-        into: "",
-      }
+        into: ""
+      };
       this.$refs.trees.setCheckedNodes([]);
       this.onTreeCheck();
       this.$refs[ruleForm].resetFields();
@@ -354,30 +396,62 @@ export default {
     },
     onReSet() {
       this.searchForm = {
-        search: null,
+        name: null,
         updateName: null,
-        createTimer: [],
-      }
-      this.search()
+        createTimer: []
+      };
+      this.search();
     },
     async getList() {
       try {
+        // this.tableList = []
         let { createTimer, ...reset } = this.searchForm;
         const res = await getmemberRankList({
           ...reset,
-          ...getTimes(createTimer, ["startDate", "endDate"], "YYYY-MM-DD"),
-          rows: this.rules.limit,
-          page: this.rules.page,
+          ...getTimeFormat(
+            createTimer,
+            ["updateStartTime", "updateEndTime"],
+            "YYYY-MM-DD"
+          )
+          // rows: this.rules.limit,
+          // page: this.rules.page,
         });
-        this.tableList = res.data.rows;
-        this.rules.total = res.data.total;
+        this.tableList = res.data;
+        // this.rules.total = res.data.total;
       } catch {}
     },
-    async addLeave() {
+    async addLeave(row) {
       this.checkList = [];
+      this.memberCheckList = [];
+      this.classCheckList = [];
+      this.isIndeterminate = false;
+      this.checkAll = false;
+      this.isMemberIndeterminate = false;
+      this.memberCheckAll = false;
+
       this.title = "新增";
+      // 添加新增
+      if (row) {
+        this.form.parentId = row.id;
+        this.form.parentName = row.name
+      } else {
+        this.form.parentId = 0
+      }
+      
       this.addDisabled = false;
       this.pageType = "create";
+      await this.getMemberRankList();
+      this.memberRankCount = 0;
+      this.treeMemberData = await this.setMemberTableData(
+        this.memberRankList,
+        this.addDisabled
+      );
+      this.classCount = 0;
+      this.treeClassData = await this.setMemberTableData(
+        this.classList,
+        this.addDisabled,
+        "class"
+      );
       await this.getNewTree();
       this.slideCount = 0;
       this.treeData = await this.setTableData(
@@ -387,16 +461,26 @@ export default {
       this.branchStatus = true;
     },
     onSubmit() {
-      this.$refs.ruleForm.validate(async (flag) => {
+      this.$refs.ruleForm.validate(async flag => {
         if (flag) {
-          let tempIds = this.$refs.trees.getCheckedKeys();
-          let halfIds = this.$refs.trees.getHalfCheckedKeys();
-          let allIds = [...tempIds, ...halfIds];
+          const tempIds = this.$refs.trees.getCheckedKeys();
+          const halfIds = this.$refs.trees.getHalfCheckedKeys();
+          const allIds = [...tempIds, ...halfIds];
+
+          const memberTempIds = this.$refs.memberTrees.getCheckedKeys();
+          const memberHalfIds = this.$refs.memberTrees.getHalfCheckedKeys();
+          const memberAllIds = [...memberTempIds, ...memberHalfIds];
+
+          const classTempIds = this.$refs.classTrees.getCheckedKeys();
+          const classHalfIds = this.$refs.classTrees.getHalfCheckedKeys();
+          const classAllIds = [...classTempIds, ...classHalfIds];
           if (this.pageType == "update") {
             try {
-              const res = await resetMemberRank({
+              await resetMemberRank({
                 ...this.form,
                 memberPrivilegesItemIdList: allIds,
+                memberCategoryIdList: memberAllIds,
+                memberCourseTypeList: classAllIds
               });
               this.$message.success("修改成功");
               this.branchStatus = false;
@@ -404,11 +488,13 @@ export default {
             } catch {}
           } else if (this.pageType == "create") {
             try {
-              const res = await addMemberRank({
+              await addMemberRank({
                 ...this.form,
                 memberPrivilegesItemIdList: allIds,
+                memberCategoryIdList: memberAllIds,
+                memberCourseTypeList: classAllIds
               });
-              this.$message.success("新建会员成功");
+              this.$message.success("新建成功");
               this.branchStatus = false;
               this.getList();
             } catch {}
@@ -418,6 +504,15 @@ export default {
         }
       });
     },
+    onCheckMemberAll(val) {
+      if (val) {
+        // 先去掉半选
+        this.isMemberIndeterminate = false;
+        this.$refs.memberTrees.setCheckedNodes(this.treeMemberData);
+      } else {
+        this.$refs.memberTrees.setCheckedNodes([]);
+      }
+    },
     onCheckAll(val) {
       if (val) {
         // 先去掉半选
@@ -427,6 +522,13 @@ export default {
         this.$refs.trees.setCheckedNodes([]);
       }
     },
+    onTreeMemberCheck() {
+      let checkTree = this.$refs.memberTrees.getCheckedKeys();
+      this.memberCheckAll = checkTree.length >= this.memberRankCount;
+      this.isMemberIndeterminate =
+        checkTree.length > 0 && checkTree.length < this.memberRankCount;
+    },
+    onTreeClassCheck() {},
     onTreeCheck() {
       let checkTree = this.$refs.trees.getCheckedKeys();
       this.checkAll = checkTree.length >= this.slideCount;
@@ -437,24 +539,26 @@ export default {
       if (!value) return true;
       return data.label.indexOf(value) !== -1;
     },
-    seachRoles() {
-      this.$refs.trees.filter(this.seachRoleValue);
+    searchRoles() {
+      this.$refs.memberTrees.filter(this.searchRoleValue);
+      this.$refs.classTrees.filter(this.searchRoleValue);
+      this.$refs.trees.filter(this.searchRoleValue);
     },
     onReSetRole() {
-      this.seachRoleValue = "";
-      this.$refs.trees.filter(this.seachRoleValue);
-      // console.log(this.data);
+      this.searchRoleValue = "";
+      this.$refs.memberTrees.filter(this.searchRoleValue);
+      this.$refs.classTrees.filter(this.searchRoleValue);
+      this.$refs.trees.filter(this.searchRoleValue);
     },
     setTableData(result, disabled) {
       let list = [];
-
-      list = result.map((res) => {
+      list = result.map(res => {
         let tempList = {};
         tempList = {
           id: res.id,
           name: res.name,
           label: res.name,
-          disabled: disabled ? disabled : false,
+          disabled: disabled ? disabled : false
         };
         this.slideCount++;
         if (res.memberPrivilegesItems && res.memberPrivilegesItems.length > 0) {
@@ -467,77 +571,184 @@ export default {
       });
       return list;
     },
+    setMemberTableData(result, disabled, type = "music") {
+      let list = [];
+      list = result.map(res => {
+        let tempList = {};
+        tempList = {
+          id: res.id,
+          name: res.name,
+          label: res.name,
+          disabled: disabled ? disabled : false
+        };
+        if (type === "music") {
+          this.memberRankCount++;
+        } else {
+          this.classCount++;
+        }
+        if (
+          res.sysMusicScoreCategoriesList &&
+          res.sysMusicScoreCategoriesList.length > 0
+        ) {
+          tempList.children = this.setMemberTableData(
+            res.sysMusicScoreCategoriesList,
+            disabled
+          );
+        }
+        return tempList;
+      });
+      return list;
+    },
+    removeMember(row) {
+      this.$confirm("是否删除该学练宝设置?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      })
+        .then(async () => {
+          await api_memberRankDel({ id: row.id });
+          this.$message.success("删除成功");
+          this.getList()
+        })
+        .catch(() => {});
+    },
     async resetMember(row, type) {
       this.branchStatus = true;
       await this.resetTree(row);
+      let tempStatus = false
       if (type) {
         this.title = "修改";
         this.pageType = "update";
         this.addDisabled = false;
-        this.slideCount = 0;
-        this.treeData = await this.setTableData(
-          this.silderList,
-          this.addDisabled
-        );
+        tempStatus =  row.buyFlag || false
+        this.buyFlag = row.buyFlag;
       } else {
         this.addDisabled = true;
+        tempStatus = true;
         this.title = "查看";
         this.pageType = "";
-        this.slideCount = 0;
-        this.treeData = await this.setTableData(
-          this.silderList,
-          this.addDisabled
-        );
       }
+      this.slideCount = 0;
+      this.treeData = await this.setTableData(
+        this.silderList,
+        tempStatus
+      );
+
+      this.memberRankCount = 0;
+      this.treeMemberData = await this.setMemberTableData(
+        this.memberRankList,
+        tempStatus
+      );
+
+      this.classCount = 0;
+      this.treeClassData = await this.setMemberTableData(
+        this.classList,
+        tempStatus,
+        "class"
+      );
     },
     //递归获取到所有的为子级的ID
-    getParent(checkIds, data) {
+    getParent(checkIds, data, type = "tree") {
       let removeIds = JSON.parse(JSON.stringify(checkIds));
-      this.getAllChildIds(data);
-      let tempAllChildIds = this.allChildIds;
+      this.getAllChildIds(data, type);
+      let tempAllChildIds = [];
+      if (type === "tree") {
+        tempAllChildIds = this.allChildIds;
+      } else if (type === "member") {
+        tempAllChildIds = this.allMemberChildIds;
+      } else if (type === "class") {
+        tempAllChildIds = this.allClassChildIds;
+      }
+      
       for (let i = checkIds.length; i > 0; i--) {
-        if (!tempAllChildIds.includes(checkIds[i - 1])) {
+        if (!tempAllChildIds.includes(Number(checkIds[i - 1]))) {
           removeIds.splice(i - 1, 1);
         }
       }
       return removeIds;
     },
-    getAllChildIds(data) {
+    getAllChildIds(data, type) {
       // 获取所有最子集编号
-      let child = this.allChildIds;
-      let tempList = [];
-      data.forEach((item, index) => {
+      data.forEach(item => {
         let temp = [];
         if (item.children && item.children.length > 0) {
-          temp = this.getAllChildIds(item.children);
+          temp = this.getAllChildIds(item.children, type);
         } else {
-          child.push(item.id);
+          if (type === "member") {
+            this.allMemberChildIds.push(item.id);
+          } else if (type === "class") {
+            this.allClassChildIds.push(item.id);
+          } else if (type === "tree") {
+            this.allChildIds.push(item.id);
+          }
         }
       });
     },
     async resetTree(row) {
       try {
-        this.treeData = await this.getNewTree();
-        const res = await getmemberRankDetail({ memberRankSettingId: row.id });
-        this.form = { ...res.data };
-
+        await this.getNewTree();
+        await this.getMemberRankList();
+        this.treeMemberData = await this.setMemberTableData(
+          this.memberRankList
+        );
+        this.treeClassData = await this.setMemberTableData(
+          this.classList,
+          false,
+          "class"
+        );
+        this.treeData = await this.setTableData(this.silderList);
+        const { data } = await getmemberRankDetail({
+          memberRankSettingId: row.id
+        });
+        this.form = { ...data };
+        console.log(row.parentId, 'parentId')
+        if(row.parentId) {
+          this.form.parentId = row.parentId;
+          this.form.parentName = row.parentName
+        }
+        
         this.checkAll =
-          res.data.memberPrivilegesItemIdList?.length >= this.slideCount ||
-          false;
+          data.memberPrivilegesItemIdList?.length >= this.slideCount || false;
         // 反写树的值
         this.isIndeterminate =
-          res.data.memberPrivilegesItemIdList?.length > 0 &&
-          res.data.memberPrivilegesItemIdList?.length < this.slideCount;
+          data.memberPrivilegesItemIdList?.length > 0 &&
+          data.memberPrivilegesItemIdList?.length < this.slideCount;
 
-        this.checkList = res.data.memberPrivilegesItemIdList;
+        this.checkList = data.memberPrivilegesItemIdList;
         let tSplice = this.getParent(
-          res.data.memberPrivilegesItemIdList || [],
+          data.memberPrivilegesItemIdList || [],
           this.treeData
         );
         this.checkList = tSplice;
         this.$nextTick(() => {
           this.$refs.trees.setCheckedKeys(this.checkList);
         });
+
+        this.memberCheckAll = data.memberCategoryIdList?.length >= this.memberRankCount || false;
+        this.isMemberIndeterminate = data.memberCategoryIdList?.length > 0 && data.memberCategoryIdList?.length < this.memberRankCount;
+        this.memberCheckList = data.memberCategoryIdList;
+        const mSplice = this.getParent(data.memberCategoryIdList || [], this.treeMemberData, 'member')
+        this.memberCheckList = mSplice;
+        this.$nextTick(() => {
+          this.$refs.memberTrees.setCheckedKeys(this.memberCheckList);
+        });
+
+        // this.classCheckAll =
+        //   data.memberCourseTypeList?.length >= this.memberRankCount || false;
+        // this.isClassIndeterminate =
+        //   data.memberCourseTypeList?.length > 0 &&
+        //   data.memberCourseTypeList?.length < this.memberRankCount;
+
+        this.classCheckList = data.memberCourseTypeList;
+        const cSplice = this.getParent(
+          data.memberCourseTypeList || [],
+          this.treeClassData,
+          "class"
+        );
+        this.classCheckList = cSplice;
+        this.$nextTick(() => {
+          this.$refs.classTrees.setCheckedKeys(this.classCheckList);
+        });
       } catch (e) {
         console.log(e);
       }
@@ -547,10 +758,21 @@ export default {
         const resTree = await getMemberPrivilegesItem();
         this.silderList = resTree.data;
         this.slideCount = 0;
-        return this.setTableData(resTree.data);
       } catch {}
     },
-  },
+    async getMemberRankList(parentId) {
+      try {
+        const { data } = await api_memberRankCategoryTree({ parentId });
+        this.memberRankList = data.musicScoreCategories || [];
+        this.memberRankCount = 0;
+
+        this.classList = data.lessonCategories || [];
+        this.classCount = 0;
+
+        // return this.setMemberTableData(data)
+      } catch {}
+    }
+  }
 };
 </script>
 <style lang="scss" scoped>

+ 198 - 166
src/views/organManager/components/memberSettingMore.vue

@@ -7,154 +7,169 @@
       :closable="false"
       style="margin-bottom: 20px"
     ></el-alert>
-    <el-form
-      ref="form"
-      label-position="right"
-      :model="form"
-      :inline="true"
-    >
-      <row>
-        <col :span="6">
-          <el-form-item label="机构可用版本" prop="teachingMaterialId" label-width="130px">
+    <el-form ref="form" label-position="top" :model="form" :inline="true">
+      <el-row v-for="(item, index) in form.setting" :key="index">
+        <el-col :span="3">
+          <el-form-item
+            label="学练宝版本"
+            :prop="'setting.' + index + '.memberRankSettingId'"
+            :rules="[
+              { required: true, message: '请选择学练宝版本', trigger: 'blur' }
+            ]"
+            label-width="130px"
+          >
             <el-cascader
-              v-model.trim="form.teachingMaterialId"
+              v-model.trim="item.memberRankSettingId"
               :disabled="isDisabled"
-              v-show="!isDisabled"
-              style="width: 300px !important"
               :options="teachList"
-              :props="{ multiple: true }"
+              :props="{ value: 'id', label: 'name',  }"
               :show-all-levels="false"
               collapse-tags
-              ref="cascader"
-              @change="onChange"
               clearable
+              placeholder="请选择学练宝版本"
+              @visible-change="(value) => onVisibleChange(value, item.memberRankSettingId)"
             ></el-cascader>
-
-            <el-tag
-              :key="tag.id"
-              v-show="isDisabled"
-              v-for="tag in dynamicTags"
-              :disable-transitions="false"
-              @close="handleClose(tag)"
-            >
-              {{ tag.name }}
-            </el-tag>
           </el-form-item>
-        </col>
-        <col :span="6">
-          <div>
-            <el-form-item label="激活周期" prop="serveId" label-width="110px"
-            :rules="[{ required: true, message: '请选择激活周期', trigger: 'change' }]">
-            <el-select
-              v-model="form.serveId"
+        </el-col>
+        <el-col :span="4">
+          <el-form-item
+            label="按天会员激活金额"
+            :prop="'setting.' + index + '.dayDivide'"
+            :rules="[
+              { required: true, message: '请输入会员激活金额', trigger: 'blur' }
+            ]"
+          >
+            <el-input
               :disabled="isDisabled"
-              placeholder="请选择激活周期"
+              placeholder="请输入会员激活金额"
+              v-model="item.dayDivide"
+              @keyup.native="keyupEvent($event)"
             >
-              <!-- <el-option v-for="item in productList" :key="item.id"
-                :label="item.serveName" :value="item.id"></el-option> -->
-            </el-select>
+              <div slot="append">元/天/人</div>
+            </el-input>
           </el-form-item>
+        </el-col>
+        <el-col :span="4">
           <el-form-item
-            label="激活金额" label-width="110px"
-            prop="year_divide"
+            label="月度会员激活价"
+            :prop="'setting.' + index + '.monthDivide'"
             :rules="[
-              { required: true, message: '请输入激活金额', trigger: 'blur' }
+              { required: true, message: '请输入会员激活价', trigger: 'blur' }
             ]"
           >
             <el-input
               :disabled="isDisabled"
-              placeholder="请输入激活金额"
+              placeholder="请输入会员激活价"
+              v-model="item.monthDivide"
               @keyup.native="keyupEvent($event)"
-              v-model="form.year_divide"
-              style="width: 238px;"
+              
             >
-              <div slot="append">元</div>
+              <div slot="append">元/月/人</div>
             </el-input>
           </el-form-item>
-
-          <el-button icon="el-icon-plus" circle></el-button>
-          <el-button icon="el-icon-delete" circle></el-button>
-          </div>
-          <div>
-            <el-form-item label="激活周期" prop="serveId" label-width="110px"
-            :rules="[{ required: true, message: '请选择激活周期', trigger: 'change' }]">
-            <el-select
-              v-model="form.serveId"
+        </el-col>
+        <el-col :span="4">
+          <el-form-item
+            label="季度会员激活价"
+            prop="quarterDivide"
+            :prop="'setting.' + index + '.quarterDivide'"
+            :rules="[
+              { required: true, message: '请输入会员激活价', trigger: 'blur' }
+            ]"
+          >
+            <el-input
               :disabled="isDisabled"
-              placeholder="请选择激活周期"
+              placeholder="请输入会员激活价"
+              v-model="item.quarterDivide"
+              @keyup.native="keyupEvent($event)"
+              
             >
-              <!-- <el-option v-for="item in productList" :key="item.id"
-                :label="item.serveName" :value="item.id"></el-option> -->
-            </el-select>
+              <div slot="append">元/季/人</div>
+            </el-input>
           </el-form-item>
+        </el-col>
+        <el-col :span="4"
+          ><el-form-item
+            label="半年会员激活价"
+            prop="halfYearDivide"
+            :prop="'setting.' + index + '.halfYearDivide'"
+            :rules="[
+              { required: true, message: '请输入会员激活价', trigger: 'blur' }
+            ]"
+          >
+            <el-input
+              :disabled="isDisabled"
+              placeholder="请输入会员激活价"
+              @keyup.native="keyupEvent($event)"
+              v-model="item.halfYearDivide"
+              
+            >
+              <div slot="append">元/半年/人</div>
+            </el-input>
+          </el-form-item></el-col
+        >
+        <el-col :span="4">
           <el-form-item
-            label="激活金额" label-width="110px"
-            prop="year_divide"
+            label="年度会员激活价"
+            prop="yearDivide"
+            :prop="'setting.' + index + '.yearDivide'"
             :rules="[
-              { required: true, message: '请输入激活金额', trigger: 'blur' }
+              { required: true, message: '请输入会员激活价', trigger: 'blur' }
             ]"
           >
             <el-input
               :disabled="isDisabled"
-              placeholder="请输入激活金额"
+              placeholder="请输入会员激活价"
               @keyup.native="keyupEvent($event)"
-              v-model="form.year_divide"
-              style="width: 238px;"
+              v-model="item.yearDivide"
+              
             >
-              <div slot="append">元</div>
+              <div slot="append">元/年/人</div>
             </el-input>
           </el-form-item>
-
-          <el-button icon="el-icon-plus" circle></el-button>
-          <el-button icon="el-icon-delete" circle></el-button>
+          
+        </el-col>
+        <el-col :span="1">
+          <div style="height: 104px;display: flex;align-items: center;">
+            <el-button :disabled="isDisabled || form.setting.length <= 1" icon="el-icon-delete" circle @click="onDelete(form.setting, index)"></el-button>
           </div>
-        </col>
-      </row>
-      <!--       
-      <el-form-item label="可用教材" prop="teachingMaterialId">
-        <el-cascader
-          v-model.trim="form.teachingMaterialId"
-          :disabled="isDisabled"
-          v-show="!isDisabled"
-          style="width: 300px !important"
-          :options="teachList"
-          :props="{ multiple: true }"
-          :show-all-levels="false"
-          collapse-tags
-          ref="cascader"
-          @change="onChange"
-          clearable
-        ></el-cascader>
-
-        <el-tag
-          :key="tag.id"
-          v-show="isDisabled"
-          v-for="tag in dynamicTags"
-          :disable-transitions="false"
-          @close="handleClose(tag)"
-        >
-          {{ tag.name }}
-        </el-tag>
-      </el-form-item> -->
+        </el-col>
+      </el-row>
+      <el-row style="margin-bottom: 16px;">
+        <el-col :span="24">
+          <el-button
+            style="width: 100%"
+            type="default"
+            icon="el-icon-plus"
+            :disabled="isDisabled"
+            @click="addMemberItem"
+            >添加学练宝版本</el-button
+          >
+        </el-col>
+       
+      </el-row>
     </el-form>
   </div>
 </template>
 
 <script>
-import { queryTree } from "../../accompaniment/api";
+import { getmemberRankList } from "../../categroyManager/productSystem/api"
 import _ from "lodash";
 export default {
   props: ["type", "data"],
   data() {
     return {
       form: {
-        day_divide: null,
-        month_divide: null,
-        quarter_divide: null,
-        half_year_divide: null,
-        year_divide: null,
-        teachingMaterialId: [] // 可用教材
+        setting: [{
+          memberRankSettingId: null,
+          dayDivide: null,
+          monthDivide: null,
+          quarterDivide: null,
+          halfYearDivide: null,
+          yearDivide: null,
+        }],
       },
+      memberRankSettingId: [], // 可用教材
       teachList: [], // 教材列表
       dynamicTags: []
     };
@@ -162,22 +177,16 @@ export default {
   async mounted() {
     await this.__init();
     if (this.data) {
-      const { config, teachingMaterialId } = this.data;
-      const tmpConfig = config ? JSON.parse(config) : {};
-      let tempIdArr = [];
-      if (teachingMaterialId) {
-        const tempIds = teachingMaterialId.split(",").map(i => Number(i));
-        tempIds.forEach(id => {
-          tempIdArr.push(this.formatParentId(id, this.teachList));
-        });
-      }
-      this.form = {
-        ...tmpConfig.member_config,
-        teachingMaterialId: tempIdArr
-      };
-      this.$nextTick(() => {
-        this.onChange();
-      });
+      const memberInfos = this.data;
+      const tempSetting = []
+      memberInfos.forEach(item => {
+        const { memberRankSettingId, memberConfig } = item 
+        tempSetting.push({
+          memberRankSettingId: this.formatParentId(memberRankSettingId, this.teachList),
+          ...memberConfig
+        })
+      })
+      this.form.setting = tempSetting
     }
   },
   computed: {
@@ -186,50 +195,12 @@ export default {
     }
   },
   methods: {
-    async __init() {
-      try {
-        // 不管是添加、查看、修改都传-1
-        const tenantId = -1;
-        const res = await queryTree({ enable: 1, tenantId, queryType: 'ALL' });
-        const rows = res.data || [];
-        rows.forEach(item => {
-          let children = [];
-          item.label = item.name;
-          item.value = item.id;
-          let childList = item.sysMusicScoreCategoriesList
-            ? item.sysMusicScoreCategoriesList
-            : [];
-          if (childList.length > 0) {
-            childList.forEach(child => {
-              child.label = child.name;
-              child.value = child.id;
-              child.sysMusicScoreCategoriesList = [];
-              children.push(child);
-            });
-          }
-          item.children = children.length > 0 ? children : null;
-          this.teachList.push(item);
-        });
-      } catch (e) {
-        console.log(e);
-      }
-    },
-    onChange() {
-      let childNodes = this.$refs.cascader.getCheckedNodes(true);
-      this.dynamicTags = [];
-      childNodes.forEach(node => {
-        this.dynamicTags.push({
-          name: node.label,
-          id: node.value
-        });
-      });
-    },
     formatParentId(id, list, ids = []) {
       for (const item of list) {
-        if (item.sysMusicScoreCategoriesList) {
+        if (item.children) {
           const cIds = this.formatParentId(
             id,
-            item.sysMusicScoreCategoriesList,
+            item.children,
             [...ids, item.id]
           );
           if (cIds.includes(id)) {
@@ -242,7 +213,30 @@ export default {
       }
       return ids;
     },
-    handleClose(tag) {},
+    async __init() {
+      try {
+        const {data} = await getmemberRankList({
+          hasChildren: true
+        });
+        this.teachList = data || []
+      } catch (e) {
+        console.log(e);
+      }
+    },
+    // 删除选项
+    onDelete(arr, index) {
+      arr.splice(index, 1);
+    },
+    addMemberItem() {
+      this.form.setting.push({
+        memberRankSettingId: null,
+        dayDivide: null,
+        monthDivide: null,
+        quarterDivide: null,
+        halfYearDivide: null,
+        yearDivide: null,
+      })
+    },
     onSubmit() {
       let status = false;
       this.$refs.form.validate(_ => {
@@ -250,15 +244,52 @@ export default {
       });
       return status;
     },
+    onVisibleChange(value, id) {
+      if(!value) return
+      const tempId = id ? id[id.length - 1] : null
+      const ids = []
+      this.form.setting.forEach(item => {
+        const itemId = item.memberRankSettingId ? item.memberRankSettingId[item.memberRankSettingId.length - 1] : null
+        if(itemId !== tempId) {
+          ids.push(itemId)
+        }
+      })
+      console.log(ids, 'ids')
+      console.log(value, id, 'teachList', this.teachList)
+      this.teachList.forEach((item) => {
+        if(ids.includes(item.id)) {
+          item.disabled = true;
+        } else {
+          item.disabled = false;
+        }
+
+        if(item.children && item.children.length > 0) {
+          item.children.forEach(child => {
+            if(ids.includes(child.id)) {
+              child.disabled = true;
+            } else {
+              child.disabled = false;
+            }
+          })
+        }
+      })
+      this.$forceUpdate();
+    },
     getValues() {
-      const { teachingMaterialId, ...res } = this.form;
-      let tempArr = [];
-      teachingMaterialId.forEach(ids => {
-        tempArr.push(_.last(ids));
-      });
+      const setting = this.form.setting
+      const tempConfig = []
+      setting.forEach(item => {
+        const { memberRankSettingId, ...more } = item
+        const id = memberRankSettingId ? memberRankSettingId[memberRankSettingId.length - 1] : null
+        tempConfig.push({
+          memberRankSettingId: id,
+          memberConfig: {
+            ...more
+          }
+        })
+      })
       return {
-        member_config: { ...res },
-        teachingMaterialId: tempArr
+        memberInfos: tempConfig
       };
     }
   }
@@ -270,8 +301,9 @@ export default {
 }
 .el-input,
 .el-select,
+.el-cascader,
 .el-cascader__dropdown {
-  width: 300px !important;
+  width: 100% !important;
 }
 .el-cascader-menu {
   width: 100%;

+ 111 - 2
src/views/organManager/components/openService.vue

@@ -91,12 +91,38 @@
             <div slot="append">元</div>
           </el-input>
         </el-form-item>
+        <el-form-item label="可用教材" prop="teachingMaterialId">
+          <el-cascader
+            v-model.trim="form.teachingMaterialId"
+            :disabled="isDisabledMember"
+            v-show="!isDisabledMember"
+            style="width: 300px !important"
+            :options="teachList"
+            :props="{ multiple: true }"
+            :show-all-levels="false"
+            collapse-tags
+            ref="cascader"
+            @change="onChange"
+            clearable
+          ></el-cascader>
+
+          <el-tag
+            :key="tag.id"
+            v-show="isDisabledMember"
+            v-for="tag in dynamicTags"
+            :disable-transitions="false"
+            @close="handleClose(tag)"
+          >
+            {{ tag.name }}
+          </el-tag>
+        </el-form-item>
       </el-form>
   </div>
 </template>
 
 <script>
 import { platformServeQueryPage, platformServeQueryModeDetail } from '@/views/platformManager/serviceManager/api'
+import { queryTree } from "../../accompaniment/api";
 import { paymentMode } from '@/constant'
 export default {
   props: ['type', 'data'],
@@ -112,29 +138,47 @@ export default {
         contractPrice: null,
         originalPrice: null,
         expiryCount: null,
-        payAmount: null
+        payAmount: null,
+        teachingMaterialId: [] // 可用教材
       },
       payState: null,
       productList: [],
       modeList: [],
       studentUpList: [], // 学员上限列表
+      teachList: [], // 教材列表
+      dynamicTags: []
     };
   },
   async mounted () {
     await this.__init()
     if(this.data) {
       const data = this.data
+      console.log(data,'111')
       this.payState = data.payState
       data.serveId ? (await this.onProductChange(data.serveId)) : null
       this.form = data
       this.form.serveMode = data.expiryUnit
       data.serveDetailId ? (await this.onModeChange(data.expiryUnit, 'none')) : null
+      let tempIdArr = [];
+      if (data.teachingMaterialId) {
+        const tempIds = data.teachingMaterialId?.split(",").map(i => Number(i));
+        tempIds.forEach(id => {
+          tempIdArr.push(this.formatParentId(id, this.teachList));
+        });
+      }
+      this.form.teachingMaterialId = tempIdArr
+      this.$nextTick(() => {
+        this.onChange();
+      });
     }
   },
   computed: {
     isDisabled() {
       return this.type == 'setting' || this.payState == 1 ? true : false
     },
+    isDisabledMember() {
+      return this.type == 'setting' ? true : false
+    },
     unitSuffix() {
       // 后辍默认为年
       return this.paymentMode[this.form.expiryUnit] || '年'
@@ -146,6 +190,60 @@ export default {
         const res = await platformServeQueryPage({ page: 1, rows: 999 })
         this.productList = res.data?.rows || []
       } catch(e) {}
+      try {
+        // 不管是添加、查看、修改都传-1
+        const tenantId = -1;
+        const res = await queryTree({ enable: 1, tenantId, queryType: 'ALL' });
+        const rows = res.data || [];
+        rows.forEach(item => {
+          let children = [];
+          item.label = item.name;
+          item.value = item.id;
+          let childList = item.sysMusicScoreCategoriesList
+            ? item.sysMusicScoreCategoriesList
+            : [];
+          if (childList.length > 0) {
+            childList.forEach(child => {
+              child.label = child.name;
+              child.value = child.id;
+              child.sysMusicScoreCategoriesList = [];
+              children.push(child);
+            });
+          }
+          item.children = children.length > 0 ? children : null;
+          this.teachList.push(item);
+        });
+      } catch (e) {
+        console.log(e);
+      }
+    },
+    formatParentId(id, list, ids = []) {
+      for (const item of list) {
+        if (item.sysMusicScoreCategoriesList) {
+          const cIds = this.formatParentId(
+            id,
+            item.sysMusicScoreCategoriesList,
+            [...ids, item.id]
+          );
+          if (cIds.includes(id)) {
+            return cIds;
+          }
+        }
+        if (item.id === id) {
+          return [...ids, id];
+        }
+      }
+      return ids;
+    },
+    onChange() {
+      let childNodes = this.$refs.cascader.getCheckedNodes(true);
+      this.dynamicTags = [];
+      childNodes.forEach(node => {
+        this.dynamicTags.push({
+          name: node.label,
+          id: node.value
+        });
+      });
     },
     async onProductChange(val) {
       const form = this.form
@@ -169,7 +267,15 @@ export default {
       return status
     },
     getValues() {
-      return this.form
+      const { teachingMaterialId, ...res } = this.form 
+      let tempArr = [];
+      teachingMaterialId.forEach(ids => {
+        tempArr.push(_.last(ids));
+      });
+      return {
+        ...res,
+        teachingMaterialId: tempArr
+      }
     },
     onModeChange(val, type) { // 付费模式改变时
       const form = this.form
@@ -202,4 +308,7 @@ export default {
 .el-input, .el-select {
   width: 300px !important;
 }
+.el-tag + .el-tag {
+  margin-left: 10px;
+}
 </style>

+ 15 - 7
src/views/organManager/organOperation.vue

@@ -20,7 +20,7 @@
         <!-- 产品定价 确认设置 -->
         <div v-show="[1, 2].includes(active)">
           <openService ref="openService" :data="productInfo" :type="getType" />
-          <memberSetting ref="memberSetting" :data="config" :type="getType" />
+          <memberSetting ref="memberSetting" :data="memberInfos" :type="getType" />
           <roomRules ref="roomRules" :data="config" :type="getType" />
           <rateSetting ref="rateSetting" :data="config" :type="getType" />
         </div>
@@ -50,6 +50,7 @@ export default {
       id: query.id,
       active: 0, // 当前第几步
       config: null,
+      memberInfos: null,
       productInfo: null,
       info: null,
       status: false,
@@ -67,10 +68,14 @@ export default {
           this.title = '修改机构'
         }
         const res = await tenantInfoInfo({ id: this.id })
-        const { config, productInfo, ...other } = res.data
-        const { theme, themeColor, corporateChops, corporateFinanceChops, ...con } = config
+        const { config, productInfo, memberInfos, ...other } = res.data
+        const { theme, themeColor, corporateChops, corporateFinanceChops, teachingMaterialId, ...con } = config
+        this.memberInfos = memberInfos
         this.config = { ...con }
-        this.productInfo = productInfo
+        this.productInfo = {
+          ...productInfo,
+          teachingMaterialId,
+        }
         this.info = { ...other, theme, themeColor, corporateChops, corporateFinanceChops }
         if(!this.info.recommender || this.info.recommender==0){
           this.info.recommender = null
@@ -102,6 +107,7 @@ export default {
           this.active += 1
         }
       } else if(this.active == 1) {
+        console.log(await this.$refs.memberSetting.getValues(), 'await this.$refs.memberSetting.getValues()')
         const openStatus = await this.$refs.openService.onSubmit()
         const memberStatus = await this.$refs.memberSetting.onSubmit()
         const ruleStatus = await this.$refs.roomRules.onSubmit()
@@ -125,15 +131,17 @@ export default {
         const memberData = await this.$refs.memberSetting.getValues()
         const ruleData = await this.$refs.roomRules.getValues()
         const rateData = await this.$refs.rateSetting.getValues()
-        const { member_config, teachingMaterialId } = memberData
+        // const { member_config, teachingMaterialId } = memberData
         const { theme, themeColor, corporateChops, corporateFinanceChops, ...con } = organData
         let config = {
-          member_config,
+          // member_config,
           ...ruleData
         }
+        const { teachingMaterialId, ...opens } = openData
         let params = {
           ...con,
-          productInfo: openData,
+          productInfo: { ...opens },
+          memberInfos: memberData.memberInfos,
           config: {
             theme,
             themeColor,