From feb5a669dced68415bc7e32f237f77bf9842fe8b Mon Sep 17 00:00:00 2001
From: WXL (wul) <wl_5969728@163.com>
Date: 星期三, 03 六月 2026 17:42:18 +0800
Subject: [PATCH] 测试完成

---
 src/components/optionalModule/index.vue |  208 +++++++++++++++++++++++++++++-----------------------
 1 files changed, 116 insertions(+), 92 deletions(-)

diff --git a/src/components/optionalModule/index.vue b/src/components/optionalModule/index.vue
index 1adc7f0..be43f16 100644
--- a/src/components/optionalModule/index.vue
+++ b/src/components/optionalModule/index.vue
@@ -28,8 +28,6 @@
       </el-form>
     </div>
 
-
-
     <!-- 妯℃澘閫夋嫨鎶藉眽 -->
     <el-drawer
       title="闂嵎鍐呭鍒楄〃"
@@ -52,6 +50,15 @@
               @keyup.enter.native="handleSearch"
             ></el-input>
           </el-form-item>
+          <el-form-item label="鎮h�呰寖鍥�" prop="status">
+            <el-cascader
+              v-model="scopetype"
+              placeholder="榛樿鍏ㄩ儴"
+              :options="sourcetype"
+              :props="{ expandTrigger: 'hover' }"
+              @change="handleChange"
+            ></el-cascader>
+          </el-form-item>
           <el-form-item>
             <el-button
               type="primary"
@@ -60,10 +67,7 @@
               @click="handleSearch"
               >鎼滅储</el-button
             >
-            <el-button
-              icon="el-icon-refresh"
-              size="medium"
-              @click="handleReset"
+            <el-button icon="el-icon-refresh" size="medium" @click="handleReset"
               >閲嶇疆</el-button
             >
           </el-form-item>
@@ -211,12 +215,9 @@
           <div class="preview-content">
             <div v-for="item in questionList" :key="item.sort">
               <!-- 鍗曢�� -->
-              <div
-                class="scriptTopic-dev"
-                v-if="item.scriptType == 1"
-              >
+              <div class="scriptTopic-dev" v-if="item.scriptType == 1">
                 <div class="dev-text">
-                  {{ item.sort }}銆乕鍗曢�塢<span>{{ item.scriptContent }}</span>
+                  {{ item.sort }}. [鍗曢�塢<span>{{ item.scriptContent }}</span>
                 </div>
                 <div class="dev-xx">
                   <el-radio-group v-model="item.remark" disabled>
@@ -232,12 +233,9 @@
               </div>
 
               <!-- 澶氶�� -->
-              <div
-                class="scriptTopic-dev"
-                v-if="item.scriptType == 2"
-              >
+              <div class="scriptTopic-dev" v-if="item.scriptType == 2">
                 <div class="dev-text">
-                  {{ item.sort }}銆乕澶氶�塢<span>{{ item.scriptContent }}</span>
+                  {{ item.sort }}. [澶氶�塢<span>{{ item.scriptContent }}</span>
                 </div>
                 <div class="dev-xx">
                   <el-checkbox-group v-model="item.qremark" disabled>
@@ -253,12 +251,9 @@
               </div>
 
               <!-- 濉┖ -->
-              <div
-                class="scriptTopic-dev"
-                v-if="item.scriptType == 4"
-              >
+              <div class="scriptTopic-dev" v-if="item.scriptType == 4">
                 <div class="dev-text">
-                  {{ item.sort }}銆乕闂瓟]<span>{{ item.scriptContent }}</span>
+                  {{ item.sort }}. [闂瓟]<span>{{ item.scriptContent }}</span>
                 </div>
                 <div class="dev-xx">
                   <el-input
@@ -282,11 +277,7 @@
         >
           閫夋嫨浣跨敤
         </el-button>
-        <el-button
-          v-else
-          type="primary"
-          @click="handleConfirmReplace"
-        >
+        <el-button v-else type="primary" @click="handleConfirmReplace">
           鏇挎崲浣跨敤
         </el-button>
       </span>
@@ -295,67 +286,86 @@
 </template>
 
 <script>
-import { getQtemplatelist, getQtemplateobj, getQtemplateclassify } from "@/api/AiCentre/index";
+import {
+  getSviLibTemplateByDeptCode,
+  getQtemplateobj,
+  getQtemplateclassify,
+} from "@/api/AiCentre/index";
 import store from "@/store";
 import pagination from "@/components/Pagination";
 
 export default {
   name: "TemplateSelector",
   components: {
-    pagination
+    pagination,
   },
   props: {
     // 褰撳墠閫変腑鐨勬ā鏉縄D
     value: {
       type: [String, Number],
-      default: null
+      default: null,
     },
     // 褰撳墠閫変腑鐨勬ā鏉垮悕绉�
     templateName: {
       type: String,
-      default: ''
+      default: "",
     },
     // 鏄惁鍙紪杈�
     isEditable: {
       type: Boolean,
-      default: true
+      default: true,
     },
     // 鏄惁鏄剧ず鍙橀噺閰嶇疆
     showVariableConfig: {
       type: Boolean,
-      default: true
+      default: true,
     },
     // 鏈嶅姟绫诲瀷锛岀敤浜庤繃婊ゆā鏉�
     serviceType: {
       type: [String, Number],
-      default: null
-    }
+      default: null,
+    },
   },
   data() {
     return {
       // 缁勪欢鐘舵��
       drawerVisible: false,
       previewVisible: false,
-      activeTab: 'basic',
+      activeTab: "basic",
       loading: false,
 
       // 妯℃澘鏁版嵁
       selectedTemplateId: null,
-      selectedTemplateName: '',
+      selectedTemplateName: "",
       selectedTemplateData: null,
-
+      scopetype: [],
       // 鍒楄〃鏁版嵁
       templateList: [],
       questionList: [],
       variableList: [],
       previewData: {},
-
+      sourcetype: [
+        {
+          value: 1,
+          label: "绉戝",
+          children: [],
+        },
+        {
+          value: 2,
+          label: "鐥呭尯",
+          children: [],
+        },
+        {
+          value: 3,
+          label: "鍏ㄩ儴",
+        },
+      ],
       // 鏌ヨ鍙傛暟
       queryParams: {
-        pageNum: 1,
-        pageSize: 10,
-        svyname: '',
-        isenable: ''
+        type: 1,
+        deptType: "1",
+        svyname: "",
+        deptCode: "",
       },
       total: 0,
 
@@ -364,7 +374,7 @@
       appraisalOptions: store.getters.appraiselist || [],
       usableOptions: [
         { value: "0", label: "鍙敤" },
-        { value: "1", label: "鍋滅敤" }
+        { value: "1", label: "鍋滅敤" },
       ],
 
       // 榛樿鍙橀噺
@@ -373,21 +383,21 @@
           name: "濮撳悕",
           value: "${name}",
           fill: "娲惧彂鏃惰嚜鍔ㄥ尮閰�",
-          default: true
+          default: true,
         },
         {
           name: "鍦板潃",
           value: "${dzz}",
           fill: "娲惧彂鏃惰嚜鍔ㄥ尮閰�",
-          default: true
+          default: true,
         },
         {
           name: "鏅鸿兘璇煶",
           value: "${dhh}",
           fill: "娲惧彂鏃惰嚜鍔ㄥ尮閰�",
-          default: true
-        }
-      ]
+          default: true,
+        },
+      ],
     };
   },
   watch: {
@@ -395,26 +405,36 @@
       immediate: true,
       handler(newVal) {
         this.selectedTemplateId = newVal;
-      }
+      },
     },
     templateName: {
       immediate: true,
       handler(newVal) {
-
         this.selectedTemplateName = newVal;
-      }
+      },
     },
     selectedTemplateId(newVal) {
-      this.$emit('input', newVal);
+      this.$emit("input", newVal);
     },
     selectedTemplateName(newVal) {
-      this.$emit('update:templateName', newVal);
-    }
+      this.$emit("update:templateName", newVal);
+    },
   },
   created() {
+    this.sourcetype[0].children = store.getters.belongDepts.map((dept) => {
+      return {
+        label: dept.deptName,
+        value: dept.deptCode,
+      };
+    });
+    this.sourcetype[1].children = store.getters.belongWards.map((dept) => {
+      return {
+        label: dept.districtName,
+        value: dept.districtCode,
+      };
+    });
     this.loadCategories();
-      this.handleSearch();
-
+    this.handleSearch();
   },
   methods: {
     // 鍔犺浇妯℃澘鍒嗙被
@@ -425,7 +445,7 @@
           this.categoryOptions = response.rows;
         }
       } catch (error) {
-        console.error('鍔犺浇鍒嗙被澶辫触:', error);
+        console.error("鍔犺浇鍒嗙被澶辫触:", error);
       }
     },
 
@@ -433,26 +453,29 @@
     async handleSearch() {
       try {
         this.loading = true;
-        const response = await getQtemplatelist(this.queryParams);
+        const response = await getSviLibTemplateByDeptCode(this.queryParams);
         if (response.code === 200) {
           this.templateList = response.rows;
           this.total = response.total;
         }
       } catch (error) {
-        console.error('鎼滅储妯℃澘澶辫触:', error);
-        this.$modal.msgError('鎼滅储妯℃澘澶辫触');
+        console.error("鎼滅储妯℃澘澶辫触:", error);
+        this.$modal.msgError("鎼滅储妯℃澘澶辫触");
       } finally {
         this.loading = false;
       }
     },
-
+    handleChange(value) {
+      this.queryParams.deptType = value[0].toString();
+      this.queryParams.deptCode = value.slice(-1)[0];
+    },
     // 閲嶇疆鎼滅储
     handleReset() {
       this.queryParams = {
         pageNum: 1,
         pageSize: 10,
-        svyname: '',
-        isenable: ''
+        svyname: "",
+        isenable: "",
       };
       this.handleSearch();
     },
@@ -480,7 +503,7 @@
           this.questionList = templateData.svyTemplateLibScripts || [];
 
           // 鍒濆鍖栭棶棰樼姸鎬�
-          this.questionList.forEach(item => {
+          this.questionList.forEach((item) => {
             item.qremark = [];
           });
 
@@ -491,8 +514,8 @@
           this.drawerVisible = false;
         }
       } catch (error) {
-        console.error('鍔犺浇妯℃澘璇︽儏澶辫触:', error);
-        this.$modal.msgError('鍔犺浇妯℃澘璇︽儏澶辫触');
+        console.error("鍔犺浇妯℃澘璇︽儏澶辫触:", error);
+        this.$modal.msgError("鍔犺浇妯℃澘璇︽儏澶辫触");
       } finally {
         this.loading = false;
       }
@@ -502,20 +525,20 @@
     extractVariables(scripts) {
       let variableList = [];
 
-      scripts.forEach(script => {
+      scripts.forEach((script) => {
         try {
-          const otherData = JSON.parse(script.otherdata || '[]');
-          otherData.forEach(item => {
+          const otherData = JSON.parse(script.otherdata || "[]");
+          otherData.forEach((item) => {
             if (item.default != 1) {
               variableList.push({
                 value: item.variate,
                 fill: "",
-                name: item.variatename
+                name: item.variatename,
               });
             }
           });
         } catch (e) {
-          console.warn('瑙f瀽otherdata澶辫触:', e);
+          console.warn("瑙f瀽otherdata澶辫触:", e);
         }
       });
 
@@ -523,9 +546,7 @@
       const uniqueVariables = variableList.filter(
         (obj, index, self) =>
           index ===
-          self.findIndex(
-            t => t.name === obj.name && t.value === obj.value
-          )
+          self.findIndex((t) => t.name === obj.name && t.value === obj.value)
       );
 
       this.variableList = [...this.transitionList, ...uniqueVariables];
@@ -534,7 +555,7 @@
     // 棰勮宸查�夋ā鏉�
     handlePreview() {
       if (!this.selectedTemplateId) {
-        this.$modal.msgWarning('璇峰厛閫夋嫨妯℃澘');
+        this.$modal.msgWarning("璇峰厛閫夋嫨妯℃澘");
         return;
       }
 
@@ -544,7 +565,7 @@
     // 纭閫夋嫨妯℃澘
     handleConfirmSelect() {
       if (!this.selectedTemplateData) {
-        this.$modal.msgWarning('璇峰厛閫夋嫨妯℃澘');
+        this.$modal.msgWarning("璇峰厛閫夋嫨妯℃澘");
         return;
       }
 
@@ -553,27 +574,29 @@
 
       // 杞崲鍙橀噺鏍煎紡
       const filteredVariables = this.variableList.filter(
-        item => item.name !== "濮撳悕" && item.name !== "鐢佃瘽" && item.name !== "鍦板潃"
+        (item) =>
+          item.name !== "濮撳悕" && item.name !== "鐢佃瘽" && item.name !== "鍦板潃"
       );
 
       const textParam = this.convertFormat2ToFormat1(filteredVariables);
 
       // 瑙﹀彂閫夋嫨浜嬩欢
-      this.$emit('select', {
+      this.$emit("select", {
         templateId: this.selectedTemplateId,
         templateName: this.selectedTemplateName,
         templateData: this.previewData,
         variableList: this.variableList,
-        textParam: textParam
+        textParam: textParam,
       });
 
       this.previewVisible = false;
-      this.$modal.msgSuccess('閫夋嫨妯℃澘鎴愬姛');
+      this.$modal.msgSuccess("閫夋嫨妯℃澘鎴愬姛");
     },
 
     // 纭鏇挎崲妯℃澘
     handleConfirmReplace() {
-      this.$modal.confirm('纭畾瑕佹浛鎹㈠綋鍓嶆ā鏉垮悧锛�')
+      this.$modal
+        .confirm("纭畾瑕佹浛鎹㈠綋鍓嶆ā鏉垮悧锛�")
         .then(() => {
           this.handleConfirmSelect();
         })
@@ -583,31 +606,31 @@
     // 鍙栨秷棰勮
     handleCancelPreview() {
       this.previewVisible = false;
-      this.$emit('cancel');
+      this.$emit("cancel");
     },
 
     // 鍏抽棴鎶藉眽
     handleDrawerClose(done) {
       done();
-      this.$emit('drawer-close');
+      this.$emit("drawer-close");
     },
 
     // 鍏抽棴棰勮
     handlePreviewClose(done) {
       done();
-      this.$emit('preview-close');
+      this.$emit("preview-close");
     },
 
     // 鍒犻櫎鍙橀噺
     handleVariableDelete(index, row) {
       this.variableList.splice(index, 1);
-      this.$emit('variable-delete', row);
+      this.$emit("variable-delete", row);
     },
 
     // 鍙橀噺鏍煎紡杞崲锛氭暟缁勮浆瀵硅薄
     convertFormat2ToFormat1(data) {
       let result = {};
-      data.forEach(item => {
+      data.forEach((item) => {
         let innerObj = {};
         innerObj[item.value] = item.fill;
         result[item.name] = innerObj;
@@ -623,7 +646,7 @@
         result.push({
           name: key,
           value: innerKey,
-          fill: data[key][innerKey]
+          fill: data[key][innerKey],
         });
       }
       return result;
@@ -640,20 +663,21 @@
     // 娓呴櫎閫夋嫨
     clear() {
       this.selectedTemplateId = null;
-      this.selectedTemplateName = '';
+      this.selectedTemplateName = "";
       this.selectedTemplateData = null;
       this.variableList = [...this.transitionList];
-      this.$emit('clear');
+      this.$emit("clear");
     },
 
     // 鑾峰彇鍙橀噺鏁版嵁
     getVariables() {
       const filteredVariables = this.variableList.filter(
-        item => item.name !== "濮撳悕" && item.name !== "鐢佃瘽" && item.name !== "鍦板潃"
+        (item) =>
+          item.name !== "濮撳悕" && item.name !== "鐢佃瘽" && item.name !== "鍦板潃"
       );
       return this.convertFormat2ToFormat1(filteredVariables);
-    }
-  }
+    },
+  },
 };
 </script>
 

--
Gitblit v1.9.3