Bläddra i källkod

SOP规则新增订单 SOP关联已购标签和关联商品

wjj 1 månad sedan
förälder
incheckning
df788cbb4e
3 ändrade filer med 388 tillägg och 7 borttagningar
  1. 261 1
      src/views/qw/sop/addSop.vue
  2. 96 4
      src/views/qw/sop/updateSop.vue
  3. 31 2
      src/views/qw/sopTemp/updateSopTemp.vue

+ 261 - 1
src/views/qw/sop/addSop.vue

@@ -149,6 +149,65 @@
             </el-radio-group>
             <Tip :title="'含全部标签:客户要完全一对一匹配上选择标签,ps:多一个少一个都不行 \r\n含任意标签:客户只要有一个标签匹配上即可'" />
           </el-form-item>
+          <el-form-item label="是否关联商品" prop="isProduct" v-if="form.type != 3 && form.filterMode == 1">
+            <el-radio-group @input="isProductChange" v-model="form.isProduct">
+              <el-radio
+                :label="0"
+              >否
+              </el-radio>
+              <el-radio
+                :label="1"
+              >是
+              </el-radio>
+            </el-radio-group>
+            <Tip title="关联商品的发送给销售或者医生,且标签只能选择一个" />
+          </el-form-item>
+          <el-form-item v-if="form.isProduct == 1" label="普通商品" prop="packageId">
+            <el-select style="width: 400px; min-width: 300px;" filterable multiple  v-model="selectProductList" placeholder="请选择关联商品">
+              <el-option v-for="dict in productList" :key="dict.dictValue" :label="dict.dictLabel"
+                     :value="parseInt(dict.dictValue)" />
+            </el-select>
+          </el-form-item>
+          <el-form-item v-if="form.isProduct == 1" label="已购标签" prop="tags">
+            <div @click="hangleProductChangeTags()"
+                 style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;width: 390px">
+              <div style="min-height: 35px; max-height: 200px; overflow-y: auto;">
+                <el-tag type="success"
+                        closable
+                        :disable-transitions="false"
+                        v-for="list in this.productTagsChangeSelectList"
+                        :key="list.tagId"
+                        @close="handleCloseProductTags(list)"
+                        style="margin: 3px;"
+                >{{ list.name }}
+                </el-tag>
+              </div>
+            </div>
+            <Tip title="选择进入SOP任务的标签" />
+          </el-form-item>
+          <el-form-item v-if="form.isProduct == 1" label="升单商品" prop="packageId">
+            <el-select style="width: 400px; min-width: 300px;" filterable multiple  v-model="selectUpsellProductList" placeholder="请选择升单商品">
+              <el-option v-for="dict in productList" :key="dict.dictValue" :label="dict.dictLabel"
+                     :value="parseInt(dict.dictValue)" />
+            </el-select>
+          </el-form-item>
+          <el-form-item v-if="form.isProduct == 1" label="升单已购标签" prop="tags">
+            <div @click="hangleUpsellProductChangeTags()"
+                 style="cursor: pointer; border: 1px solid #e6e6e6; background-color: white; overflow: hidden; flex-grow: 1;width: 390px">
+              <div style="min-height: 35px; max-height: 200px; overflow-y: auto;">
+                <el-tag type="success"
+                        closable
+                        :disable-transitions="false"
+                        v-for="list in this.upsellProductTagsChangeSelectList"
+                        :key="list.tagId"
+                        @close="handleCloseUpsellProductTags(list)"
+                        style="margin: 3px;"
+                >{{ list.name }}
+                </el-tag>
+              </div>
+            </div>
+            <Tip title="选择进入SOP任务的标签" />
+          </el-form-item>
           <el-form-item label="选择的标签" prop="tags">
             <!--            <el-select v-model="tags" remote multiple placeholder="请选择" filterable  style="width: 100%;">-->
             <!--              <el-option-->
@@ -468,6 +527,7 @@ import SopTemp from '@/views/qw/sopTemp/sopTemp.vue'
 import { allListTagGroup } from '@/api/qw/tagGroup'
 import {searchTags} from "../../../api/qw/tag";
 import Tip from '@/components/Tip'
+import { allPackage } from "@/api/store/package";
 
 export default {
   name: "addSop",
@@ -510,6 +570,10 @@ export default {
       outTagsIdsChangeSelectList: null,
       //添加的标签
       addTagsIdsChangeSelectList: null,
+      //商品已购标签
+      productTagsChangeSelectList: null,
+      //升单商品已购标签
+      upsellProductTagsChangeSelectList: null,
       //标签弹窗选择
       tagChange: {
         open: false,
@@ -566,6 +630,7 @@ export default {
         expiryTime: 4,
         isAutoSop: 1,
         autoSopTime: {autoSopType: 2, autoStartTime: '00:00', autoEndTime: '24:00', autoSopSend: 2},
+        isProduct: 0,
       },
       userSelectList: [],
       qwUserIds: [],
@@ -589,7 +654,10 @@ export default {
         startTime: [{required: true, message: "开始时间不能为空", trigger: "submit"}],
         tempId: [{required: true, message: "模板不能为空", trigger: "submit"}],
         openCommentStatus:[{ required: true, message: '开启评论/弹幕不能为空', trigger: 'change' }]
-      }
+      },
+      productList:[],
+      selectProductList:[],
+      selectUpsellProductList:[],
     };
   },
   created() {
@@ -623,6 +691,9 @@ export default {
     sopListWxUserGroup().then(response => {
       this.wxUserGroupList = response.rows;
     });
+    allPackage().then(res => {
+      this.productList = res.rows;
+    });
   },
   watch: {
     userSelectList(newList) {
@@ -631,6 +702,14 @@ export default {
   },
   methods: {
 
+    isProductChange(){
+      //this.tagsIdsChangeSelectList = [];
+      this.selectProductList = [];
+      this.selectUpsellProductList = [];
+      this.upsellProductTagsChangeSelectList = [];
+      this.productTagsChangeSelectList = [];
+    },
+
     //刷新部分数据
     refreshData(row) {
 
@@ -696,6 +775,11 @@ export default {
         if (!this.tagsIdsChangeSelectList || this.tagsIdsChangeSelectList.length === 0) {
           return this.$message('请选择标签');
         }
+        console.log("tah",this.tagsIdsChangeSelectList)
+        if(this.form.isProduct === 1 && this.tagsIdsChangeSelectList.length > 1) {
+          this.tagsIdsChangeSelectList = [];
+          return this.$message("关联商品标签不能有多个,请重新选择");
+        }
 
       } else if (type == 2) {
 
@@ -723,6 +807,62 @@ export default {
           return this.$message('请选择标签');
         }
 
+      } else if (type == 3) {
+        for (let i = 0; i < this.tagGroupList.length; i++) {
+          for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
+            if (this.tagGroupList[i].tag[x].isSelected === true) {
+
+              if (!this.productTagsChangeSelectList) {
+                this.tagsIdsChangeSelectList = [];
+              }
+
+              // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
+              let tagExists = this.productTagsChangeSelectList.some(
+                tag => tag.id === this.tagGroupList[i].tag[x].id
+              );
+
+              // 如果 tag 不存在于 tagListFormIndex[index] 中,则新增
+              if (!tagExists) {
+                this.productTagsChangeSelectList.push(this.tagGroupList[i].tag[x]);
+              }
+            }
+          }
+        }
+        if (!this.productTagsChangeSelectList || this.productTagsChangeSelectList.length === 0) {
+          return this.$message('请选择已购标签');
+        }
+        if(this.form.isProduct === 1 && this.productTagsChangeSelectList.length > 1) {
+          this.productTagsChangeSelectList = [];
+          return this.$message("已购标签不能有多个,请重新选择");
+        }
+      } else if (type == 4) {
+        for (let i = 0; i < this.tagGroupList.length; i++) {
+          for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
+            if (this.tagGroupList[i].tag[x].isSelected === true) {
+
+              if (!this.upsellProductTagsChangeSelectList) {
+                this.tagsIdsChangeSelectList = [];
+              }
+
+              // 检查当前 tag 是否已经存在于 tagListFormIndex[index] 中
+              let tagExists = this.upsellProductTagsChangeSelectList.some(
+                tag => tag.id === this.tagGroupList[i].tag[x].id
+              );
+
+              // 如果 tag 不存在于 tagListFormIndex[index] 中,则新增
+              if (!tagExists) {
+                this.upsellProductTagsChangeSelectList.push(this.tagGroupList[i].tag[x]);
+              }
+            }
+          }
+        }
+        if (!this.upsellProductTagsChangeSelectList || this.upsellProductTagsChangeSelectList.length === 0) {
+          return this.$message('请选择升单已购标签');
+        }
+        if(this.form.isProduct === 1 && this.upsellProductTagsChangeSelectList.length > 1) {
+          this.upsellProductTagsChangeSelectList = [];
+          return this.$message("升单已购标签不能有多个,请重新选择");
+        }
       }
       this.changeTagDialog.open = false;
     },
@@ -769,6 +909,43 @@ export default {
       }
     },
 
+    //选择已购标签
+    hangleProductChangeTags() {
+
+      this.changeTagDialog.title = "选择已购标签"
+      this.changeTagDialog.open = true;
+      this.changeTagDialog.type = 3;
+
+      // 获取 tagListFormIndex 中的所有 tagId,用于快速查找
+      const selectedTagIds = new Set(
+        (this.productTagsChangeSelectList || []).map(tagItem => tagItem?.tagId)
+      );
+      for (let i = 0; i < this.tagGroupList.length; i++) {
+        for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
+          this.tagGroupList[i].tag[x].isSelected = selectedTagIds.has(this.tagGroupList[i].tag[x].tagId);
+        }
+      }
+
+    },
+    //选择升单已购标签
+    hangleUpsellProductChangeTags() {
+
+      this.changeTagDialog.title = "选择升单已购标签"
+      this.changeTagDialog.open = true;
+      this.changeTagDialog.type = 4;
+
+      // 获取 tagListFormIndex 中的所有 tagId,用于快速查找
+      const selectedTagIds = new Set(
+        (this.upsellProductTagsChangeSelectList || []).map(tagItem => tagItem?.tagId)
+      );
+      for (let i = 0; i < this.tagGroupList.length; i++) {
+        for (let x = 0; x < this.tagGroupList[i].tag.length; x++) {
+          this.tagGroupList[i].tag[x].isSelected = selectedTagIds.has(this.tagGroupList[i].tag[x].tagId);
+        }
+      }
+
+    },
+
     //选择排除标签
     hangleChangeAddTags() {
       this.changeTagDialog.title = "选择排除的标签"
@@ -803,6 +980,22 @@ export default {
         this.outTagsIdsChangeSelectList = [...this.outTagsIdsChangeSelectList];
       }
     },
+    //删除一些商品已购的标签
+    handleCloseProductTags(list) {
+      const ls = this.productTagsChangeSelectList.findIndex(t => t.tagId === list.tagId);
+      if (ls !== -1) {
+        this.productTagsChangeSelectList.splice(ls, 1);
+        this.productTagsChangeSelectList = [...this.productTagsChangeSelectList];
+      }
+    },
+    //删除一些升单商品已购的标签
+    handleCloseUpsellProductTags(list) {
+      const ls = this.upsellProductTagsChangeSelectList.findIndex(t => t.tagId === list.tagId);
+      if (ls !== -1) {
+        this.upsellProductTagsChangeSelectList.splice(ls, 1);
+        this.upsellProductTagsChangeSelectList = [...this.upsellProductTagsChangeSelectList];
+      }
+    },
     //查询模板
     selectListSopTemp(type) {
       if(this.form.filterMode == 2){
@@ -918,6 +1111,7 @@ export default {
         isRating: null,
         autoSopTime: {autoSopType: 2, autoStartTime: '00:00', autoEndTime: '24:00', autoSopSend: 2},
         openCommentStatus: 0,
+        isProduct: 0,
       };
       this.resetForm("form");
       this.tags = null;
@@ -974,6 +1168,7 @@ export default {
               return this.$message.error("请选择员工")
             }
 
+            
 
             if (this.tagsIdsChangeSelectList != null && this.tagsIdsChangeSelectList.length > 0) {
 
@@ -1010,6 +1205,71 @@ export default {
               });
               this.form.excludeTags = this.form.excludeTags.join(",");
             }
+            if(this.form.isProduct === 1) {
+              if (this.selectProductList.length > 0) {
+                if(!this.form.productIds) {
+                  this.form.productIds = [];
+                } else {
+                  this.form.productIds = [];
+                }
+                this.selectProductList.forEach(id => {
+                  this.form.productIds.push(id);
+                })
+                this.form.productIds = this.form.productIds.join(',');
+              } else {
+                return this.$message.error("请选择关联商品")
+              }
+              if (this.selectUpsellProductList.length > 0) {
+                if(!this.form.upsellProductIds) {
+                  this.form.upsellProductIds = [];
+                } else {
+                  this.form.upsellProductIds = [];
+                }
+                this.selectUpsellProductList.forEach(id => {
+                  this.form.upsellProductIds.push(id);
+                })
+                this.form.upsellProductIds = this.form.upsellProductIds.join(',');
+              } else {
+                return this.$message.error("请选择升单商品")
+              }
+              if (this.productTagsChangeSelectList != null && this.productTagsChangeSelectList.length > 0) {
+
+                if (!this.form.productTag) {
+                  this.form.productTag = []; // 如果未定义,初始化
+                } else {
+                  this.form.productTag = []; // 清空已有数据
+                }
+
+                // 遍历并添加 tagId
+                this.productTagsChangeSelectList.forEach(tag => {
+                  if (tag.tagId) { // 确保 tagId 存在
+                  this.form.productTag.push(tag.tagId);
+                  }
+                });
+                this.form.productTag = this.form.productTag.join(",");
+              } else {
+                return this.$message.error("选择已购标签不能为空!!请选择筛选的标签")
+              }
+              if (this.upsellProductTagsChangeSelectList != null && this.upsellProductTagsChangeSelectList.length > 0) {
+
+                if (!this.form.upsellProductTag) {
+                  this.form.upsellProductTag = []; // 如果未定义,初始化
+                } else {
+                  this.form.upsellProductTag = []; // 清空已有数据
+                }
+
+                // 遍历并添加 tagId
+                this.upsellProductTagsChangeSelectList.forEach(tag => {
+                  if (tag.tagId) { // 确保 tagId 存在
+                  this.form.upsellProductTag.push(tag.tagId);
+                  }
+                });
+                this.form.upsellProductTag = this.form.upsellProductTag.join(",");
+              } else {
+                return this.$message.error("升单已购标签不能为空!!请选择筛选的标签")
+              }
+            }
+            
 
           }
           this.form.qwUserIds = this.userSelectList.join(",");

+ 96 - 4
src/views/qw/sop/updateSop.vue

@@ -113,7 +113,49 @@
               >含任意标签</el-radio>
             </el-radio-group>
           </el-form-item>
-          <el-form-item label="选择的标签" prop="tags">
+          <el-form-item label="是否关联商品" prop="isProduct" v-if="form.type != 3 && form.filterMode == 1">
+            <el-radio-group @input="isProductChange" v-model="form.isProduct">
+              <el-radio
+                :label="0"
+              >否
+              </el-radio>
+              <el-radio
+                :label="1"
+              >是
+              </el-radio>
+            </el-radio-group>
+          </el-form-item>
+          <el-form-item v-if="form.isProduct == 1" label="关联商品" >
+            <el-select style="width: 400px; min-width: 300px;" filterable multiple  v-model="selectProductList" placeholder="请选择关联商品">
+              <el-option v-for="dict in productList" :key="dict.dictValue" :label="dict.dictLabel"
+                     :value="String(dict.dictValue)" />
+            </el-select>
+          </el-form-item>
+          <el-form-item v-if="form.isProduct === 1" label="已购标签" prop="productTag">
+            <el-select  v-model="form.productTag" remote  placeholder="请选择" filterable  style="width: 400px; min-width: 300px;">
+              <el-option
+                v-for="dict in tagList"
+                :label="dict.name"
+                :value="dict.tagId">
+              </el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item v-if="form.isProduct == 1" label="升单商品" >
+            <el-select style="width: 400px; min-width: 300px;" filterable multiple  v-model="selectUpsellProductList" placeholder="请选择升单商品">
+              <el-option v-for="dict in productList" :key="dict.dictValue" :label="dict.dictLabel"
+                     :value="String(dict.dictValue)" />
+            </el-select>
+          </el-form-item>
+          <el-form-item v-if="form.isProduct === 1" label="升单已购标签" prop="productTag">
+            <el-select  v-model="form.upsellProductTag" remote  placeholder="请选择" filterable  style="width: 400px; min-width: 300px;">
+              <el-option
+                v-for="dict in tagList"
+                :label="dict.name"
+                :value="dict.tagId">
+              </el-option>
+            </el-select>
+          </el-form-item>
+          <el-form-item  label="选择的标签" prop="tags">
             <el-select v-model="tags" remote multiple placeholder="请选择" filterable  style="width: 100%;">
               <el-option
                 v-for="dict in tagList"
@@ -121,8 +163,8 @@
                 :value="dict.tagId">
               </el-option>
             </el-select>
-
           </el-form-item>
+          
           <el-form-item label="排除的标签" prop="excludeTags">
             <el-select v-model="excludeTags" remote multiple placeholder="请选择" filterable  style="width: 100%;">
               <el-option
@@ -353,6 +395,7 @@ import {sopListWxUserGroup} from "@/api/wxUser/wxUserGroup";
 import source from "echarts/src/data/Source";
 import SopTemp from "@/views/qw/sopTemp/sopTemp.vue";
 import Tip from "../../../components/Tip/index.vue";
+import { allPackage } from "@/api/store/package";
 // import { ElMessageBox } from 'element-plus';
 export default {
   name: "updateSop",
@@ -431,7 +474,10 @@ export default {
         sendType:[ { required: true, message: "不能为空", trigger: "submit" }],
         startTime:[ { required: true, message: "开始时间不能为空", trigger: "submit" }],
         tempId:[ { required: true, message: "模板不能为空", trigger: "submit" }],
-      }
+      },
+      productList:[],
+      selectProductList:[],
+      selectUpsellProductList:[],
     };
   },
   created() {
@@ -461,6 +507,10 @@ export default {
       this.courseList = response.list;
     });
 
+    allPackage().then(res => {
+      this.productList = res.rows;
+    });
+
   },
   watch:{
     userSelectList(newList) {
@@ -468,6 +518,11 @@ export default {
     }
   },
   methods: {
+    isProductChange(){
+      //this.tags = [];
+      this.selectProductList = [];
+      this.selectUpsellProductList = [];
+    },
     submitUpdateQwUser(){
       this.form.qwUserIds = this.userSelectList.join(",");
       const data ={
@@ -649,6 +704,11 @@ export default {
         if (this.form.tags!==''&&this.form.tags!=null){
           this.tags = this.form.tags.split(",");
         }
+        if(this.form.isProduct === 1) {
+          this.selectProductList = this.form.productIds.split(',');
+          this.selectUpsellProductList = this.form.upsellProductIds.split(',');
+        }
+        
         this.form.status = response.data.status.toString();
         if (this.form.excludeTags!==''&&this.form.excludeTags!=null){
           this.excludeTags = this.form.excludeTags.split(",");
@@ -660,7 +720,6 @@ export default {
         listSopTemp({id:this.form.tempId}).then(response => {
           this.tempList = response.rows;
         });
-
         this.refreshData(this.form.corpId);
 
         this.title = "修改企微sop";
@@ -721,6 +780,7 @@ export default {
 
     /** 提交按钮 */
     submitForm() {
+      
       this.$refs["form"].validate(valid => {
         if (valid) {
           if(this.userSelectList.length<=0){
@@ -732,16 +792,48 @@ export default {
           }else {
             return this.$message.error("选择得标签不能为空!!请选择筛选的标签")
           }
+          
           if (this.excludeTags!=null){
             this.form.excludeTags=(this.excludeTags).toString()
           }
 
+          if (this.form.isProduct === 1) {
+            if (this.selectProductList.length > 0) {
+                if(!this.form.productIds) {
+                  this.form.productIds = [];
+                } else {
+                  this.form.productIds = [];
+                }
+                this.selectProductList.forEach(id => {
+                  this.form.productIds.push(id);
+                })
+                this.form.productIds = this.form.productIds.join(',');
+              } else {
+                return this.$message.error("请选择关联商品")
+              }
+              if (this.selectUpsellProductList.length > 0) {
+                if(!this.form.upsellProductIds) {
+                  this.form.upsellProductIds = [];
+                } else {
+                  this.form.upsellProductIds = [];
+                }
+                this.selectUpsellProductList.forEach(id => {
+                  this.form.upsellProductIds.push(id);
+                })
+                this.form.upsellProductIds = this.form.upsellProductIds.join(',');
+              } else {
+                return this.$message.error("请选择升单商品")
+              }
+          }
+
 
           this.form.setting=JSON.stringify(this.setting)
 
           this.form.autoSopTime.updateTime=this.formatDateTo24HourString(new Date());
 
           this.form.autoSopTime=JSON.stringify(this.form.autoSopTime)
+          console.log("form",this.form)
+          //return;
           if (this.form.id != null) {
 
 

+ 31 - 2
src/views/qw/sopTemp/updateSopTemp.vue

@@ -142,8 +142,26 @@
                                     <el-radio :label="2">课程</el-radio>
                                     <el-radio :label="4">AI触达</el-radio>
                                     <el-radio :label="5">打标签</el-radio>
+                                    <el-radio :label="6">订单</el-radio>
                                   </el-radio-group>
                                 </el-form-item>
+                                <el-form-item label="是否已购"  v-if="content.type == 6 ">
+                                  <el-select  v-model="content.isBuy"
+                                             placeholder="请选择" size="mini"
+                                             style=" margin-right: 10px;" >
+                                    <el-option label="未购" :value="1"></el-option>
+                                    <el-option label="已购" :value="2"></el-option>
+                                  </el-select>
+                                </el-form-item>
+                                <el-form-item label="推送类别"  v-if="content.type == 6 ">
+                                  <el-select  v-model="content.orderSendType"
+                                             placeholder="请选择" size="mini"
+                                             style=" margin-right: 10px;" >
+                                    <el-option label="销售" :value="1"></el-option>
+                                    <el-option label="医生" :value="2"></el-option>
+                                    <el-option label="销售和医生" :value="3"></el-option>
+                                  </el-select>
+                                </el-form-item>
                                 <el-form-item label="课程" v-if="content.type == 2 && form.sendType != 5" required>
                                   <el-select :disabled="formType == 3 || form.sendType == 11 || !roles.includes('edit_sop_temp_content')" v-model="content.courseId"
                                              placeholder="请选择课程" style=" margin-right: 10px;" size="mini" remote
@@ -247,7 +265,7 @@
 
                                 <div v-for="(setList, setIndex) in content.setting" :key="setIndex"
                                      style="background-color: #fdfdfd; border: 1px solid #e6e6e6; margin-bottom: 20px;"
-                                     v-if="content.type != 4 && content.type != 5">
+                                     v-if="content.type != 4 && content.type != 5 && content.type != 6">
                                   <el-row style="padding-bottom: 20px">
                                     <el-col :span="22">
                                       <el-form  :model="setList" label-width="70px">
@@ -1083,6 +1101,7 @@ export default {
       });
     },
     checkData(data) {
+      console.log("da",data)
       if (this.form.sendType != 4) {
 
         for (let j = 0; j < data.content.length; j++) {
@@ -1109,7 +1128,7 @@ export default {
             }
           }
 
-          if (data.content[j].type != 4 && data.content[j].type != 5) {
+          if (data.content[j].type != 4 && data.content[j].type != 5 && data.content[j].type != 6) {
             for (let k = 0; k < data.content[j].setting.length; k++) {
               if (data.content[j].setting[k].contentType == 1 && (data.content[j].setting[k].value == null || data.content[j].setting[k].value == "")) {
                 this.$message.error("内容不能为空")
@@ -1172,6 +1191,16 @@ export default {
               this.$message.error("AI触达不能为空")
               return false;
             }
+          } else if (data.content[j].type == 6) {
+            console.log("data",data.content[j])
+            if (data.content[j].isBuy == null || data.content[j].isBuy == '') {
+              this.$message.error("是否已购不能为空")
+              return false;
+            }
+            if (data.content[j].orderSendType == null || data.content[j].orderSendType == '') {
+              this.$message.error("推送类别不能为空")
+              return false;
+            }
           }
         }
       } else {