Browse Source

点播配置修改并新增部门选着

liupeng 13 giờ trước cách đây
mục cha
commit
44de2efb9b
1 tập tin đã thay đổi với 41 bổ sung28 xóa
  1. 41 28
      src/views/course/coursePlaySourceConfig/index.vue

+ 41 - 28
src/views/course/coursePlaySourceConfig/index.vue

@@ -179,29 +179,29 @@
         <el-form-item label="名称" prop="name">
           <el-input v-model="form.name" placeholder="请输入名称" />
         </el-form-item>
-<!--        <el-form-item label="所属公司" prop="companyId">-->
-<!--          <el-select-->
-<!--            v-model="form.companyId"-->
-<!--            filterable-->
-<!--            remote-->
-<!--            reserve-keyword-->
-<!--            placeholder="请输入公司名称搜索"-->
-<!--            :remote-method="searchCompanies"-->
-<!--            :loading="companySearchLoading"-->
-<!--            style="width: 220px"-->
-<!--            clearable-->
-<!--            size="small"-->
-<!--          >-->
-<!--            <el-option-->
-<!--              v-for="item in companyOptions"-->
-<!--              :key="item.dictValue"-->
-<!--              :label="item.dictLabel"-->
-<!--              :value="item.dictValue"-->
-<!--            />-->
-<!--          </el-select>-->
-<!--        </el-form-item>-->
         <el-form-item label="所属公司" prop="companyId">
-          <treeselect v-model="form.companyId" :options="deptOptions" :normalizer="normalizer"  placeholder="选择上级部门"   :disabled="(username !== 'admin' && title === '修改小程序配置')"  />
+          <el-select
+            v-model="form.companyId"
+            filterable
+            remote
+            reserve-keyword
+            placeholder="请输入公司名称搜索"
+            :remote-method="searchCompanies"
+            :loading="companySearchLoading"
+            style="width: 220px"
+            clearable
+            size="small"
+          >
+            <el-option
+              v-for="item in companyOptions"
+              :key="item.dictValue"
+              :label="item.dictLabel"
+              :value="item.dictValue"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="所属部门" prop="deptId">
+          <treeselect v-model="form.deptId" :options="deptOptions" :normalizer="normalizer"  placeholder="选择上级部门"   :disabled="(username !== 'admin' && title === '修改小程序配置')"  />
         </el-form-item>
         <el-form-item label="图标" prop="img">
           <image-upload v-model="form.img" :file-type='["png", "jpg", "jpeg"]' :limit="1"/>
@@ -386,24 +386,37 @@ export default {
         this.companySearchLoading = false;
       });
     },
-    companyNameFormatter(row) {
+    companyNameFormatter(row){
+      let company = this.formatterCompanyOptions.filter(item => item.dictValue === row.companyId)[0];
+      return company ? company.dictLabel : '';
+    },
+    departmentNameFormatter(row) {
+      // 容错处理:检查必要参数
+      if (!this.deptOptions || !this.deptOptions.length || !row.deptId) {
+        return '';
+      }
+
+      // 使用 deptId 匹配(与表格 prop 保持一致)
+      const targetId = String(row.deptId);
+
       // 递归查找树形结构中的部门
-      const findDept = (depts, targetId) => {
+      const findDept = (depts) => {
         for (const dept of depts) {
           // 先检查当前节点
-          if (String(dept.deptId) === String(row.companyId)) {
+          if (String(dept.deptId) === targetId) {
             return dept;
           }
           // 如果有子节点,递归查找
           if (dept.children && dept.children.length > 0) {
-            const found = findDept(dept.children, targetId);
+            const found = findDept(dept.children);
             if (found) return found;
           }
         }
         return null;
       };
-      const company = findDept(this.deptOptions, row.companyId);
-      return company?.deptName || '';
+
+      const dept = findDept(this.deptOptions);
+      return dept?.deptName || '';
     },
 
     // 获取开关配置