logListCustomerCommon.vue 15 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13

<template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <el-form size="small" :inline="true" label-width="100px">
          <div class="search-z">
            <el-form-item :label="$t('联系人')" prop="contactName">
              <el-input v-model.trim="followForm.contactName" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item :label="$t('联系方式')" prop="contactPhone">
              <el-input v-model.trim="followForm.contactPhone" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
zhengyi's avatar
zhengyi committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27
            <el-form-item :label="$t('跟进类型')">
              <dict-selector clearable :type="DICT_TYPE.CUSTOMER_FOLLOWUP_TYPE" v-model="followForm.followType" @input="handleQuery"></dict-selector>
            </el-form-item>
            <el-form-item :label="$t('销售阶段')">
              <dict-selector clearable :type="DICT_TYPE.CUSTOMER_FOLLOWUP_SALE_STAGE" v-model="followForm.saleStage" @input="handleQuery"></dict-selector>
            </el-form-item>
            <el-form-item :label="$t('编号')" prop="number" v-show="showSearch">
              <el-input v-model.trim="followForm.number" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item :label="$t('报价单号')" prop="offerNumber" v-show="showSearch">
              <el-input v-model.trim="followForm.offerNumber" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>

            <el-form-item :label="$t('客户经理')" prop="followUserIds" v-show="showSearch">
28 29
              <user-selector v-model="followForm.followUserIds" multiple clearable @input="handleQuery" />
            </el-form-item>
zhengyi's avatar
zhengyi committed
30
            <el-form-item :label="$t('关联跟进记录')" prop="parentNumber" v-show="showSearch">
31 32 33
              <el-input v-model.trim="followForm.parentNumber" clearable @keyup.enter.native="handleQuery" />
            </el-form-item>

zhengyi's avatar
zhengyi committed
34
            <el-form-item :label="$t('跟进方式')" v-show="showSearch">
35 36
              <dict-selector clearable :type="DICT_TYPE.CUSTOMER_FOLLOWUP_METHOD" v-model="followForm.followMethod" @input="handleQuery"></dict-selector>
            </el-form-item>
zhengyi's avatar
zhengyi committed
37 38

            <!-- <el-form-item :label="$t('跟进结果')">
39 40 41
              <el-select clearable v-model="followForm.resultType" :placeholder="$t('请选择')" size="small" @change="handleQuery">
                <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_RESULT_TYPE)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value" />
              </el-select>
zhengyi's avatar
zhengyi committed
42 43
            </el-form-item> -->
            <el-form-item :label="$t('跟进状态')" v-show="showSearch">
44 45 46 47 48 49
              <el-select clearable v-model="followForm.status" :placeholder="$t('请选择')" size="small" @change="handleQuery">
                <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_STATUS)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value" />
              </el-select>
            </el-form-item>
          </div>
          <div class="search-time">
zhengyi's avatar
zhengyi committed
50
            <el-form-item :label="$t('创建时间')" v-show="showSearch">
51 52
              <el-date-picker v-model="followFormTmp.createTime" type="datetimerange" range-separator="-" :start-placeholder="$t('开始日期')" :end-placeholder="$t('结束日期')" value-format="yyyy-MM-dd HH:mm:ss" @change="handleQuery"> </el-date-picker>
            </el-form-item>
zhengyi's avatar
zhengyi committed
53
            <el-form-item :label="$t('跟进时间')" v-show="showSearch">
54 55
              <el-date-picker v-model="followFormTmp.followTime" type="datetimerange" range-separator="-" :start-placeholder="$t('开始日期')" :end-placeholder="$t('结束日期')" value-format="yyyy-MM-dd HH:mm:ss" @change="handleQuery"> </el-date-picker>
            </el-form-item>
zhengyi's avatar
zhengyi committed
56
            <el-form-item :label="$t('下次跟进时间')" v-show="showSearch">
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
              <el-date-picker v-model="followFormTmp.nextTime" type="datetimerange" range-separator="-" :start-placeholder="$t('开始日期')" :end-placeholder="$t('结束日期')" value-format="yyyy-MM-dd HH:mm:ss" @change="handleQuery"> </el-date-picker>
            </el-form-item>
            <el-form-item style="padding-left: 20px; width: auto">
              <div class="flex-c-c">
                <el-button type="primary" icon="el-icon-search" @click="getCustomerFollowupList">{{ $t("搜索") }} </el-button>
                <el-button type="primary" @click="reset">{{ $t("重置") }} </el-button>
              </div>
            </el-form-item>
          </div>
        </el-form>
      </div>

      <!-- 操作工具栏 -->
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="success" @click="handleAdd" v-hasPermi="['ecw:customer:follow-create']">{{ $t("新增") }} </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button type="warning" @click="handleExport" v-hasPermi="['ecw:customer:follow-export']">
            {{ $t("导出") }}
          </el-button>
        </el-col>
zhengyi's avatar
zhengyi committed
79
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getCustomerFollowupList"></right-toolbar>
80 81 82
      </el-row>
      <el-table ref="multipleTable" :data="customerFollowList" v-loading="loading" @selection-change="handleSelectionChange" style="width: 100%">
        <el-table-column type="selection" width="55" fixed></el-table-column>
zhengyi's avatar
zhengyi committed
83
        <el-table-column prop="number" :label="$t('编号')" align="center" fixed :width="120">
84 85 86 87
          <template slot-scope="scope">
            <a href="javascript:void(0)" @click="handleCustomerFollowLink(scope.row)" class="link-type">{{ scope.row.number }}</a>
          </template>
        </el-table-column>
zhengyi's avatar
zhengyi committed
88 89 90 91 92 93 94 95
        <el-table-column prop="followType" :label="$t('跟进类型')" :formatter="(row, column, cellValue) => getDictDataLabel(DICT_TYPE.CUSTOMER_FOLLOWUP_TYPE, cellValue)" :width="120"></el-table-column>
        <el-table-column prop="offerNumber" :label="$t('报价单号')" :width="120">
          <template slot-scope="{ row }">
            <el-link type="primary" @click.native="$router.push('/offer/detail?offerId=' + row.offerId)" v-if="row.offerNumber">{{ row.offerNumber }}</el-link>
          </template>
        </el-table-column>
        <el-table-column prop="followTime" :label="$t('跟进时间')" :formatter="(row, column, cellValue) => parseTime(cellValue)" :width="120"></el-table-column>
        <el-table-column prop="customerNumber" :label="$t('客户编号')" :width="120">
96 97 98 99
          <template slot-scope="scope">
            <a href="javascript:void(0)" @click="handleCustomerViewLink(scope.row)" class="link-type">{{ scope.row.customerNumber }}</a>
          </template>
        </el-table-column>
zhengyi's avatar
zhengyi committed
100 101 102 103 104 105 106 107 108
        <el-table-column prop="contactName" :label="$t('联系人')" :width="120"></el-table-column>
        <el-table-column prop="contactPhone" :label="$t('联系方式')" :width="120"></el-table-column>
        <el-table-column prop="followUserName" :label="$t('客户经理')" :width="120"></el-table-column>
        <el-table-column prop="followMethod" :label="$t('跟进方式')" :formatter="(row, column, cellValue) => getDictDataLabel(DICT_TYPE.CUSTOMER_FOLLOWUP_METHOD, cellValue)" :width="120"></el-table-column>
        <el-table-column prop="purpose" :label="$t('目的')" :width="240"></el-table-column>
        <el-table-column prop="feedback" :label="$t('跟进情况')" :width="240"></el-table-column>
        <el-table-column prop="saleStage" :label="$t('销售阶段')" :formatter="(row, column, cellValue) => getDictDataLabel(DICT_TYPE.CUSTOMER_FOLLOWUP_SALE_STAGE, cellValue)" :width="120"></el-table-column>
        <!-- <el-table-column prop="resultType" :label="$t('跟进结果')" :formatter="(row, column, cellValue) => getDictDataLabel(DICT_TYPE.CUSTOMER_FOLLOWUP_RESULT_TYPE, cellValue)"></el-table-column> -->
        <el-table-column :label="$t('下次跟进时间')" align="center" :width="120">
109 110 111 112
          <template slot-scope="scope">
            {{ parseTime(scope.row.nextTime) }}
          </template>
        </el-table-column>
zhengyi's avatar
zhengyi committed
113 114
        <el-table-column :label="$t('关联跟进记录')" align="center" prop="parentNumber" :width="120"></el-table-column>
        <el-table-column prop="nextPlan" :label="$t('下次计划')" align="center" :width="240"></el-table-column>
115 116 117 118 119
        <el-table-column :label="$t('跟进状态')" align="center">
          <template slot-scope="scope">
            {{ getDictDataLabel(DICT_TYPE.CUSTOMER_FOLLOWUP_STATUS, scope.row.status) }}
          </template>
        </el-table-column>
zhengyi's avatar
zhengyi committed
120 121
        <el-table-column prop="creatorName" :label="$t('创建人')" align="center" :width="120"></el-table-column>
        <el-table-column :label="$t('创建时间')" align="center" :width="120">
122 123 124 125
          <template slot-scope="scope">
            {{ parseTime(scope.row.createTime) }}
          </template>
        </el-table-column>
zhengyi's avatar
zhengyi committed
126 127
        <el-table-column prop="updaterName" :label="$t('最后更新人')" align="center" :width="120"></el-table-column>
        <el-table-column :label="$t('最后更新时间')" align="center" :width="120">
128 129 130 131
          <template slot-scope="scope">
            {{ parseTime(scope.row.updateTime) }}
          </template>
        </el-table-column>
zhengyi's avatar
zhengyi committed
132
        <el-table-column :width="180" :label="$t('操作')" align="center" fixed="right" class-name="small-padding fixed-width">
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" v-if="!scope.row.status" @click="handleCustomerFollow(scope.row)" v-hasPermi="['ecw:customer:follow-update']">{{ $t("编辑") }} </el-button>
            <el-button size="mini" type="text" icon="el-icon-collection" @click="handleCustomerFollow(scope.row, true)" v-has-permi="['ecw:customer:follow-add-plan']">{{ $t("增加计划") }} </el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination :total="customerFollowTotal" :page.sync="followForm.pageNo" :limit.sync="followForm.pageSize" @pagination="getCustomerFollowupList" />
    </el-card>
    <customer-follow ref="customerFollow" @close="customerFollowVisible = false" @handleCustomerFollowAdd="handleCustomerFollowAdd" @refresh="handleQuery" v-if="customerFollowVisible" :customer-id="customerId" :customerService="customerService" :customerNumber="customerNumber" />
    <customer-follow-update-status :show.sync="updateStatus" :followup-ids.sync="selectCustomerFollowList" @refresh="handleQuery"></customer-follow-update-status>
  </div>
</template>

<script>
import { getCustomerFollowupList, exportCustomerFollowup } from "@/api/ecw/customerFollow"
import { getDictDatas, DICT_TYPE, getDictDatas2 } from "@/utils/dict"
import CustomerFollow from "@/views/ecw/customer/components/customerFollow"
import UserSelector from "@/components/UserSelector"
import customerFollowUpdateStatus from "@/views/ecw/customer/components/customerFollowUpdateStatus.vue"
export default {
  name: "logListCustomerCommon",
  components: { customerFollowUpdateStatus, UserSelector, CustomerFollow },
  props: ["customerId", "offerId", "customerService", "customerNumber"],
  data() {
    return {
      // 遮罩层
      loading: true,
      getDictDatas,
      getDictDatas2,
      DICT_TYPE,
      updateStatus: false,
      customerFollowVisible: false,
zhengyi's avatar
zhengyi committed
165 166
      // 显示搜索条件
      showSearch: false,
167 168 169 170 171 172 173 174
      customerFollowTotal: 0,
      customerFollowList: [],
      selectCustomerFollowList: [],
      followForm: {
        pageNo: 1,
        pageSize: 10
      },
      followFormTmp: {
175
        createTime: ["", ""],
176
        followTime: ["", ""],
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
        nextTime: ["", ""]
      }
    }
  },
  created() {
    this.handleQuery()
  },
  updated() {
    this.$nextTick(() => {
      this.$refs.multipleTable.doLayout()
    })
  },
  computed: {
    // selectAuthorityFn() {
    //   return (val) => {
    //     let t = val.split(":")
    //     t[t.length - 1] = this.authorityFn + t[t.length - 1]
    //     console.log(t.join(":"))
    //     return t.join(":")
    //   }
    // },
    isChinese() {
      return this.$i18n.locale === "zh_CN"
    },
    customerId_offerId() {
      return `${this.customerId}_${this.offerId}`
    }
  },
  watch: {
    selectCustomerFollowList(val) {
      if (val.length === 0) {
        this.getCustomerFollowupList()
        this.$refs.multipleTable.clearSelection()
      }
    },
    customerId_offerId() {
      this.handleQuery()
    }
  },
  methods: {
    handleSelectionChange(val) {
      this.selectCustomerFollowList = val.map((i) => i.id)
    },
    handleCustomerFollowAdd(row) {
      this.customerFollowVisible = false
      setTimeout(() => {
        this.customerFollowVisible = true
        this.$nextTick((_) => {
          this.$refs["customerFollow"].handleUpdate(row, true)
        })
      }, 100)
    },
    handleCustomerFollow(row, flag) {
      this.customerFollowVisible = true
      this.$nextTick((_) => {
        this.$refs["customerFollow"].handleUpdate(row, flag)
      })
    },
    handleAdd() {
      this.customerFollowVisible = true
      this.$nextTick(() => {
        this.$refs["customerFollow"].handleAdd()
      })
    },

    handleCustomerFollowLink(row) {
      this.customerFollowVisible = true
      this.$nextTick((_) => {
        this.$refs["customerFollow"].handleView(row)
      })
    },
    handleCustomerViewLink(row) {
      this.$router.push(`/customer/query/${row.customerId}`)
    },
    formatQuery() {
      let obj = {}
      obj.customerId = this.customerId || null
      obj.offerId = this.offerId || null
255 256
      obj.beginCreateTime = this.followFormTmp.createTime[0]
      obj.endCreateTime = this.followFormTmp.createTime[1]
257 258
      obj.beginFollowTime = this.followFormTmp.followTime[0]
      obj.endFollowTime = this.followFormTmp.followTime[1]
259 260
      obj.beginNextTime = this.followFormTmp.nextTime[0]
      obj.endNextTime = this.followFormTmp.nextTime[1]
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
      return obj
    },
    handleQuery() {
      console.log(this.followForm)

      this.followForm.pageNo = 1
      this.customerFollowTotal = 0
      this.customerFollowList = []
      this.getCustomerFollowupList()
    },
    /** 跟进记录导出按钮操作 */
    handleExport() {
      // 执行导出
      this.$modal.confirm(this.$t("是否确认导出客户跟进记录数据项?")).then(() => {
        exportCustomerFollowup({
          ...this.followForm,
          ...this.formatQuery(),
          pageNo: null,
          pageSize: null
        }).then((r) => {
          this.$message.success(this.$t("已加入导出队列,请稍后在下载日志中下载"))
        })
      })
    },
    getCustomerFollowupList() {
      this.loading = true
      getCustomerFollowupList({
        ...this.followForm,
        ...this.formatQuery()
      }).then((r) => {
        this.customerFollowList = r.data.list
        this.customerFollowTotal = r.data.total
        this.loading = false
      })
    },
    reset() {
297
      this.followFormTmp.createTime = ["", ""]
298
      this.followFormTmp.followTime = ["", ""]
299 300 301 302 303 304 305 306 307 308
      this.followFormTmp.nextTime = ["", ""]
      this.followForm = {
        pageNo: 1,
        pageSize: 10
      }
      this.getCustomerFollowupList()
    }
  }
}
</script>