src/views/client/followupRecords/AddFollowupRecordsDialog.vue
@@ -9,6 +9,7 @@
      custom-class="iframe-dialog"
    >
      <el-form
      v-if="refreshFlag"
        ref="form"
        :model="editConfig.infomation"
        :rules="rules"
@@ -108,7 +109,12 @@
                      value-key="name"
                      @select="handleSelectClient('contact', $event)"
                      style="width: 100%"
                    ></el-autocomplete>
                    >
                      // 解决匹配不到提示无匹配数据
                      <template v-if="noData" slot-scope="{ item }">
                        <div class="default" @click.stop="stopClick">{{ item.name }}</div>
                      </template>
                    </el-autocomplete>
                    <div class="common-select-btn" @click="selClientClick('contact')">
                      <i class="el-icon-circle-plus-outline" title="选择"></i>
                    </div>
@@ -162,6 +168,7 @@
              <el-col v-if="isUnflod" :span="12">
                <el-form-item label="销售机会" prop="sale_chance_name">
                  <div class="custom-name">
                    <!-- :disabled="isChance" -->
                    <el-autocomplete
                      v-model="editConfig.infomation.sale_chance_name"
                      :fetch-suggestions="
@@ -172,17 +179,17 @@
                      value-key="name"
                      @select="handleSelectClient('chance', $event)"
                      style="width: 100%"
                      placeholder="请先选择客户名称"
                      :disabled="isChance"
                      placeholder="请选择销售机会"
                    ></el-autocomplete>
                    <div v-if="!isChance" class="common-select-btn" @click="selClientClick('chance')">
                    <!-- v-if="!isChance" -->
                    <div  class="common-select-btn" @click="selClientClick('chance')">
                      <i class="el-icon-circle-plus-outline"></i>
                    </div>
                    <!-- &&!isChance -->
                    <div
                      v-if="
                        editConfig.infomation.sale_chance_name &&
                        editConfig.infomation.sale_chance_name.length > 0 &&
                        !isChance
                        editConfig.infomation.sale_chance_name.length > 0
                      "
                      class="common-select-btn"
                      @click="clearupClient('chance')"
@@ -392,23 +399,15 @@
    clientList() {
      return this.$store.state.getClientName.clientList
    }
    // contactNamelist() {
    //   return this.$store.state.getClientName.contactNamelist
    // },
    // saleChancelist() {
    //   return this.$store.state.getClientName.saleChancelist
    // },
    // saleLeadlist() {
    //   return this.$store.state.getClientName.saleLeadlist
    // }
  },
  data() {
    return {
      refreshFlag: true,
      dialogWidth: "50%",
      editConfig: this.editContactsConfig,
      rules: {
        number: [{ required: true, validator: this.validateCheckCode, trigger: ["blur", "change"] }],
        member_id: [{ required: true, message: "请选择负责人", trigger: "change" }],
        member_id: [{ required: true, validator: this.validateMemberId, trigger: "change" }],
        record: [{ required: true, message: "请输入跟进记录", trigger: "blur" }],
        client_name: [{ required: true, validator: this.checkClient, trigger: "change" }],
        contact_name: [{ required: true, message: "请选择联系人姓名", trigger: "change" }],
@@ -462,17 +461,22 @@
      saleChanceId: this.editContactsConfig.infomation.sale_chance_id,
      saleLeadId: this.editContactsConfig.infomation.sales_leads_id,
      saleChancelist: [],
      isChance: true
      isChance: true,
      noData: false // 是否匹配到数据了
    }
  },
  created() {
    this.getChanceList(this.editConfig.infomation.client_id)
    if(this.editContactsConfig.title==="编辑"){
      this.isChance=false
    }
    this.$store.dispatch("geClient")
    // this.$store.dispatch("geContact")
    // this.$store.dispatch("geChance")
    // this.$store.dispatch("geLead")
    this.getCommonData()
    this.getContactInfoList()
    this.formInfo()
    if (this.editContactsConfig.title === "新建" && this.editContactsConfig.infomation?.client_name?.length > 0) {
      this.getContactList(this.editContactsConfig.infomation)
    }
  },
  watch: {
    "editContactsConfig.visible"(val) {
@@ -491,11 +495,30 @@
      }
      this.getRCodeStandardList()
    },
    /**
     * 强制刷新form组件
     * 外部更改表单值不会触发表单校验,导致即使有值夜被表单校验阻塞住
     */
     refresh() {
      this.refreshFlag = false
      requestAnimationFrame(() => {
        this.refreshFlag = true
      })
    },
    getCommonData() {
      getAllData().then((res) => {
        console.log(res)
        this.clientStatusOptions = res.data.client_status
        this.memberOptions = res.data.member
        if (this.editConfig.title === "新建") {
          let username = document.cookie.replace(/(?:(?:^|.*;\s*)username\s*=\s*([^;]*).*$)|^.*$/, "$1")
          this.memberOptions.map((item) => {
            if (item.username == username) {
              this.$set(this.editConfig.infomation, "member_id", item.id)
            }
          })
        }
        // this.dataProcess()
      })
    },
@@ -580,13 +603,22 @@
    },
    // 获取销售机会
    getChanceList(id) {
      getSaleChanceList({
        page: 1,
        pageSize: 15,
        search_map: {
      let params={}
      if(id){
        params={
          page: 0,
          pageSize: 0,
        }
        params.search_map={
          client_id: id
        }
      }).then((res) => {
      }else{
        params={
          page: 0,
          pageSize: 0,
        }
      }
      getSaleChanceList(params).then((res) => {
        if (res.code == 200) {
          this.saleChancelist = res.data.list
        }
@@ -604,7 +636,13 @@
      } else {
        restaurants = this.saleLeadlist
      }
      var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants
      var results = queryString ? restaurants?.filter(this.createStateFilter(queryString)) : restaurants
      console.log(results)
      this.noData = false
      if (results == undefined || results?.length <= 0) {
        results = [{ name: "无匹配数据" }]
        this.noData = true
      }
      cb(results)
    },
    createStateFilter(queryString) {
@@ -659,6 +697,9 @@
      } else if (value === "chance") {
        this.saleChanceId = item.id
        this.editConfig.infomation.sale_chance_name = item.name
        this.editConfig.infomation.client_name = item.client.name
        this.clientId = item.client.id
        this.getChanceList(this.clientId)
      } else {
        this.saleLeadId = item.id
        this.editConfig.infomation.sales_leads_name = item.name
@@ -668,8 +709,10 @@
      if (value === "client") {
        this.editSelectClientConfig.editVisible = true
      } else if (value === "contact") {
        this.editSelectContactConfig.clientId = this.clientId || 0
        this.editSelectContactConfig.editVisible = true
      } else if (value === "chance") {
        this.editSelectChanceConfig.clientId = this.clientId
        this.editSelectChanceConfig.editVisible = true
      } else {
        this.editSelectLeadConfig.editVisible = true
@@ -686,15 +729,18 @@
        this.editSelectContactConfig.search_map.client_id = row.id
        this.editSelectChanceConfig.search_map.client_id = row.id
        this.editSelectLeadConfig.search_map.name = row.name
        this.getContactList(row)
        this.getSalesLeadsList(row)
        this.clientId = row.id
        this.editConfig.infomation.client_name = row.name
        this.isChance = false
        this.getChanceList(row.id)
        this.getContactList(row)
        this.getSalesLeadsList(row)
        this.getChanceList(this.clientId)
      } else if (value === "chance") {
        this.editConfig.infomation.sale_chance_name = row.name
        this.saleChanceId = row.id
        this.editConfig.infomation.client_name = row.client.name
        this.clientId = row.client.id
        this.getChanceList(this.clientId)
      } else {
        this.editConfig.infomation.sales_leads_name = row.name
        this.saleLeadId = row.id
@@ -721,6 +767,7 @@
        this.editConfig.infomation.sales_leads_name = ""
        this.saleLeadId = 0
      }
      this.refresh()
    },
    // 添加附件
    addAnnexClick() {},
@@ -743,6 +790,16 @@
      } else {
        callback(new Error("请选择客户名称"))
      }
    },
    // 阻止可点击事件
    stopClick() {},
    // 销售负责人自定义校验规则
    validateMemberId(rule, value, callback) {
      if (this.editConfig.infomation?.member_id > 0) {
        callback()
      } else {
        callback(new Error("请输入负责人"))
      }
    }
  }
}