Преглед изворни кода

销售端新增查询未绑定企微userId的信息采集用户列表

cgp пре 3 недеља
родитељ
комит
59307e82da

+ 8 - 1
src/api/hisStore/collection.js

@@ -67,4 +67,11 @@ export function getWxaCodeCollectionUnLimit(collectionId,appId) {
     url: '/hisStore/collection/getWxaCodeCollectionUnLimit/'+collectionId+"/"+appId,
     method: 'get',
   })
-}
+}
+
+export function getSalesHasCollectionPermission() {
+  return request({
+    url: '/hisStore/collection/getSalesHasCollectionPermission',
+    method: 'get',
+  })
+}

+ 27 - 45
src/views/qw/collectionUnBind/addCollectionDialog.vue

@@ -101,7 +101,7 @@
 import { questionOptions, getAnswer } from "@/api/hisStore/answer";
 import { allPrivatePackage } from "@/api/store/package";
 import { options } from "@/api/course/coursePlaySourceConfig";
-import { getWxaCodeCollectionUnLimit } from "@/api/hisStore/collection";
+import { getWxaCodeCollectionUnLimit, getSalesHasCollectionPermission } from "@/api/hisStore/collection";
 import { createSimpleUserInfo } from "@/api/qw/collectionUnBind";
 
 export default {
@@ -125,12 +125,10 @@ export default {
       if (value.length < 1 || value.length > 20) {
         return callback(new Error('姓名长度在 1 到 20 个字符'));
       }
-      // 校验不能包含数字
       const numberRegex = /[0-9]/;
       if (numberRegex.test(value)) {
         return callback(new Error('姓名不能包含数字'));
       }
-      //校验只能包含中文、英文和空格
       const nameRegex = /^[\u4e00-\u9fa5a-zA-Z\s]+$/;
       if (!nameRegex.test(value)) {
         return callback(new Error('姓名只能包含中文、英文和空格'));
@@ -138,11 +136,10 @@ export default {
       callback();
     };
     return {
-      // ========== 新增:答案修改标识相关字段 ==========
-      originalAnswers: null,      // 保存原始 answers 数据
-      isAnswersModified: 0,       // 0-未修改, 1-已修改
-      isSalesProxyFill: true,     // 控制问题是否可编辑(新增模式默认可编辑)
-      // =============================================
+      // ========== 答案修改标识相关字段 ==========
+      originalAnswers: null,
+      isAnswersModified: 0,
+      isSalesProxyFill: true,
 
       dialogVisible: false,
       sourceList: [],
@@ -168,6 +165,8 @@ export default {
       qrCodeTitle: "用户信息采集分享",
       qrCodeName: null,
       codeImage: null,
+      // 新增:加载状态
+      permissionLoading: false,
       rules: {
         appId: [
           {required: true, message: '请选择分享的小程序', trigger: 'change'}
@@ -218,11 +217,9 @@ export default {
     dialogTitle() {
       return "新增信息采集";
     },
-    // ========== 新增:计算属性,判断问题区域是否可编辑 ==========
     canEditAnswers() {
       return this.isSalesProxyFill === true;
     }
-    // ======================================================
   },
   watch: {
     visible: {
@@ -234,25 +231,38 @@ export default {
       },
       immediate: true
     },
-    // ========== 新增:监听 answers 的变化,判断是否修改 ==========
     'form.answers': {
       handler(newVal) {
         if (this.originalAnswers) {
-          // 比较是否修改,修改则设为1,未修改设为0
           this.isAnswersModified = this.isAnswersEqual(this.originalAnswers, newVal) ? 0 : 1;
         }
       },
       deep: true
     }
-    // ========================================================
   },
   created() {
     this.getQuestionOptions();
     this.getAllPrivatePackge();
     this.getSourceOptions();
+    // ==========获取销售代填权限配置 ==========
+    this.fetchSalesProxyFillPermission();
+    // ==============================================
   },
   methods: {
-    // ========== 新增:深度比较方法 ==========
+    // ==========获取销售代填权限 ==========
+    async fetchSalesProxyFillPermission() {
+      this.permissionLoading = true;
+      try {
+        const res = await getSalesHasCollectionPermission();
+        this.isSalesProxyFill = res.data === true;
+      } catch (error) {
+        console.error('获取销售代填权限失败:', error);
+        this.isSalesProxyFill = true;
+      } finally {
+        this.permissionLoading = false;
+      }
+    },
+
     isAnswersEqual(original, current) {
       if (!original || !current) return original === current;
       if (original.length !== current.length) return false;
@@ -261,16 +271,12 @@ export default {
         const origAnswer = original[i];
         const currAnswer = current[i];
 
-        // 比较 value 数组
         if (!origAnswer.value || !currAnswer.value) {
           if (origAnswer.value !== currAnswer.value) return false;
         } else {
           if (origAnswer.value.length !== currAnswer.value.length) return false;
-
-          // 排序后比较(因为顺序可能不影响业务逻辑)
           const sortedOrig = [...origAnswer.value].sort((a, b) => a - b);
           const sortedCurr = [...currAnswer.value].sort((a, b) => a - b);
-
           for (let j = 0; j < sortedOrig.length; j++) {
             if (sortedOrig[j] !== sortedCurr[j]) return false;
           }
@@ -278,7 +284,6 @@ export default {
       }
       return true;
     },
-    // ======================================
 
     initDialog() {
       this.resetFormData();
@@ -338,11 +343,9 @@ export default {
         this.privatePackageOptions = res.rows;
       });
     },
-    // 选择问答模板
     selectQuestion(val) {
       if (!val) return;
 
-      // 显示加载提示
       const loading = this.$loading({
         lock: true,
         text: '加载问题模板中...',
@@ -353,7 +356,6 @@ export default {
       getAnswer(val).then(response => {
         loading.close();
 
-        // 获取 answers 数组
         let questions = [];
         if (response.data && response.data.answers) {
           questions = response.data.answers;
@@ -368,7 +370,6 @@ export default {
           return;
         }
 
-        // 构建 answers 数组
         const answers = questions.map(item => ({
           title: item.title,
           options: item.options || [],
@@ -377,13 +378,10 @@ export default {
           flag: item.flag || false
         }));
 
-        // ========== 新增:保存原始 answers 的深拷贝 ==========
+        // 保存原始 answers
         this.originalAnswers = JSON.parse(JSON.stringify(answers));
-        this.isAnswersModified = 0; // 初始化为未修改
-        this.isSalesProxyFill = true; // 新增模式,问题区域可编辑
-        // ====================================================
+        this.isAnswersModified = 0;
 
-        // 保留用户已填写的基础信息
         const preservedFields = {
           userName: this.form.userName,
           userPhoneFour: this.form.userPhoneFour,
@@ -394,7 +392,6 @@ export default {
           appId: this.form.appId
         };
 
-        // 更新表单
         this.form = {
           ...preservedFields,
           questionId: val,
@@ -412,12 +409,9 @@ export default {
         this.$message.error('获取问题模板失败,请稍后重试');
       });
     },
-    // ========== 新增:答案修改时的回调 ==========
     onAnswerChange() {
-      // isAnswersModified 会通过 watch 自动更新
       console.log('答案已修改,修改标识:', this.isAnswersModified);
     },
-    // =========================================
 
     resetFormData() {
       this.form = {
@@ -436,27 +430,20 @@ export default {
         remark: '',
         appId: null
       };
-      // ========== 新增:重置标识相关字段 ==========
       this.originalAnswers = null;
       this.isAnswersModified = 0;
-      this.isSalesProxyFill = true;
-      // ==========================================
     },
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
-          // 构建提交数据
           const submitData = {
             ...this.form,
             companyId: this.extraParams.companyId,
             companyUserId: this.extraParams.companyUserId,
             source: 'pc',
-            // ========== 新增:添加修改标识 ==========
-            fillFlag: this.isAnswersModified  // 0-未修改,1-已修改
-            // ======================================
+            fillFlag: this.isAnswersModified
           };
 
-          // 如果未关联产品疗法,清除相关字段
           if (submitData.isPackage !== 1) {
             delete submitData.packageId;
             delete submitData.payType;
@@ -469,13 +456,11 @@ export default {
 
           const appId = this.form.appId;
 
-          // 调用你的新增接口
           createSimpleUserInfo(submitData).then(res => {
             this.$message.success("新增成功");
             this.dialogVisible = false;
             this.$emit('success');
             this.$emit('update:visible', false);
-            // 成功后生成分享二维码
             if (res.data) {
               this.handleShare(res.data, appId);
             }
@@ -493,6 +478,3 @@ export default {
   }
 };
 </script>
-
-<style scoped>
-</style>

+ 15 - 7
src/views/qw/externalContact/collection.vue

@@ -99,7 +99,7 @@
 import { questionOptions, getAnswer } from "@/api/hisStore/answer";
 import { allPrivatePackage } from "@/api/store/package";
 import { options } from "@/api/course/coursePlaySourceConfig";
-import { getInfo, addCollection, updateCollection, getWxaCodeCollectionUnLimit } from "@/api/hisStore/collection";
+import { getInfo, addCollection, updateCollection, getWxaCodeCollectionUnLimit,getSalesHasCollectionPermission } from "@/api/hisStore/collection";
 
 export default {
   name: "collection",
@@ -210,7 +210,9 @@ export default {
     this.getAllPrivatePackge();
     options().then(res => {
       this.sourceList = res.data;
-    })
+    });
+    // ==========获取销售代填权限配置 ==========
+    this.fetchSalesProxyFillPermission();
   },
   computed: {
     // 计算属性:判断问题区域是否可编辑
@@ -231,7 +233,16 @@ export default {
     }
   },
   methods: {
-    // 新增:用于接收主页面传来的公司id和销售id
+    async fetchSalesProxyFillPermission() {
+      try {
+        const res = await getSalesHasCollectionPermission();
+        this.isSalesProxyFill = res.data === true;
+      } catch (error) {
+        console.error('获取销售代填权限失败:', error);
+        this.isSalesProxyFill = true;
+      }
+    },
+    //用于接收主页面传来的公司id和销售id
     setExtraParams(params) {
       console.log('【collection】接收到 extraParams:', params);
       this.extraParams = { ...params };
@@ -307,8 +318,7 @@ export default {
 
       // 保存原始数据的深拷贝
       this.originalAnswers = JSON.parse(JSON.stringify(processedAnswers));
-      this.isAnswersModified = 0; // 初始化为未修改
-      this.isSalesProxyFill = data.isSalesProxyFill === true;
+      this.isAnswersModified = 0;
 
       this.form = {
         ...this.form,
@@ -346,7 +356,6 @@ export default {
         remark: ''
       };
       this.extraParams = { companyId: null, companyUserId: null };
-      this.isSalesProxyFill = true;
       this.originalAnswers = null;
       this.isAnswersModified = 0; // 重置为未修改
     },
@@ -399,7 +408,6 @@ export default {
         amount: null,
         id: null
       };
-      this.isSalesProxyFill = true;
       // 查询该用户+该模板下是否有历史采集记录
       if (this.userId && val) {
         getInfo({ userId: this.userId, questionId: val }).then(res => {