customerMerge.vue 18.6 KB
Newer Older
yujinyao's avatar
yujinyao committed
1 2 3
<template>
  <div class="customer-merge">
    <el-dialog append-to-body :title="$t('合并客户')" :visible.sync="dialogVisible" width="900px">
4
      <el-form ref="form" label-width="100px">
yujinyao's avatar
yujinyao committed
5 6 7 8
        <el-row :gutter="20">
          <el-col :span="12">
            <el-card class="box-card">
              <div slot="header" class="clearfix">
9 10 11 12
                <span>{{ $t('保留客户') }}</span>
                <el-button type="success" size="small" style="float: right" @click="selectCustomer(1)">
                  {{ $t('请选择') }}
                </el-button>
yujinyao's avatar
yujinyao committed
13 14
              </div>
              <el-form-item :label="$t('客户编号')+':'">
15
                {{ retainCustomer.number }}
yujinyao's avatar
yujinyao committed
16 17
              </el-form-item>
              <el-form-item :label="$t('客户名称')+':'">
18
                {{ $l(retainCustomer, "name") }}
yujinyao's avatar
yujinyao committed
19 20
              </el-form-item>
              <el-form-item :label="$t('客户经理')+':'">
21
                {{ retainCustomer.customerServiceName }}
yujinyao's avatar
yujinyao committed
22 23
              </el-form-item>
              <el-form-item :label="$t('创建时间')+':'">
24
                {{ parseTime(retainCustomer.createTime) }}
yujinyao's avatar
yujinyao committed
25 26
              </el-form-item>
              <el-form-item :label="$t('联系方式')+':'">
27
                +{{ retainCustomer.defaultContactPhone }}
yujinyao's avatar
yujinyao committed
28 29 30 31 32 33
              </el-form-item>
            </el-card>
          </el-col>
          <el-col :span="12">
            <el-card class="box-card">
              <div slot="header" class="clearfix">
34 35 36 37
                <span>{{ $t('​被合并客户-非主客户') }}</span>
                <el-button type="success" size="small" style="float: right" @click="selectCustomer(2)">
                  {{ $t('请选择') }}
                </el-button>
yujinyao's avatar
yujinyao committed
38 39
              </div>
              <el-form-item :label="$t('客户编号')+':'">
40
                {{ mergeCustomer.number }}
yujinyao's avatar
yujinyao committed
41 42
              </el-form-item>
              <el-form-item :label="$t('客户名称')+':'">
43
                {{ $l(mergeCustomer, "name") }}
yujinyao's avatar
yujinyao committed
44 45
              </el-form-item>
              <el-form-item :label="$t('客户经理')+':'">
46
                {{ mergeCustomer.customerServiceName }}
yujinyao's avatar
yujinyao committed
47 48
              </el-form-item>
              <el-form-item :label="$t('创建时间')+':'">
49
                {{ parseTime(mergeCustomer.createTime) }}
yujinyao's avatar
yujinyao committed
50 51
              </el-form-item>
              <el-form-item :label="$t('联系方式')+':'">
52
                +{{ mergeCustomer.defaultContactPhone }}
yujinyao's avatar
yujinyao committed
53 54 55 56 57 58
              </el-form-item>
            </el-card>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
59 60
        <el-button type="primary" @click="handleSubmit">{{ $t('确 定') }}</el-button>
        <el-button @click="dialogVisible = false">{{ $t('取 消') }}</el-button>
yujinyao's avatar
yujinyao committed
61 62
      </div>
    </el-dialog>
63

64 65
    <el-dialog append-to-body :title="$t('选择客户')" :visible.sync="customerDialogVisible"
               :close-on-click-modal="false" width="80%">
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="100px">
        <el-form-item :label="$t('客户编号')" prop="number">
          <el-input
            v-model.trim="queryParams.number"
            :placeholder="$t('请输入客户编号')"
            clearable
            @keyup.enter.native="handleQuery"
            @input="queryParams.number=queryParams.number.replace(/\s+/g, '')"
          />
        </el-form-item>
        <el-form-item :label="$t('客户名称')" prop="name">
          <el-input
            v-model.trim="queryParams.name"
            :placeholder="$t('请输入客户名称')"
            clearable
            @keyup.enter.native="handleQuery"
            @input="queryParams.name=queryParams.name.replace(/\s+/g, '')"
          />
        </el-form-item>
        <el-form-item :label="$t('区号')">
          <el-select
            v-model="queryParams.areaCode"
            :placeholder="$t('请选择区号')"
          >
            <el-option
              v-for="(item, index) in countryList"
              :key="index"
              :label="
                item.nameShort +
                (isChinese ? item.nameZh : item.nameEn) +
                ' +' +
                item.tel
              "
              :value="item.tel"
            />
          </el-select>
        </el-form-item>
        <el-form-item :label="$t('联系方式')">
          <el-input
            :placeholder="$t('请输入联系方式')"
            v-model.trim="queryParams.defaultContactPhone"
            @input="queryParams.defaultContactPhone=queryParams.defaultContactPhone.replace(/\s+/g, '')"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{
112 113 114
              $t("搜索")
            }}
          </el-button>
115
          <el-button icon="el-icon-refresh" @click="resetQuery">{{
116 117 118
              $t("重置")
            }}
          </el-button>
119 120
        </el-form-item>
      </el-form>
121
      <el-table :data="list" v-loading="loading" border size="mini">
122 123 124 125 126 127 128
        <el-table-column align="center" width="80">
          <template slot-scope="{row}">
            <el-radio v-model="customerId" :label="row.id">&nbsp;</el-radio>
          </template>
        </el-table-column>
        <el-table-column :label="$t('客户编号')" align="center">
          <template slot-scope="{ row }">
129 130
<!--            <el-link type="primary" @click.native="$router.push('/customer/query/' + row.id)">{{ row.number }}</el-link>-->
            {{ row.number }}
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
          </template>
        </el-table-column>
        <el-table-column :label="$t('客户名称')" align="center">
          <template slot-scope="{ row }">
            <p style="display: inline-block; white-space: pre-wrap">
              {{ $l(row, "name") }}
            </p>
            <el-tag v-if="row.isInOpenSea" size="mini">{{ $t("") }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          :label="$t('主联系人')"
          prop="defaultContactName"
        ></el-table-column>
        <el-table-column :label="$t('主联系方式')" prop="defaultContactPhone">
          <template v-slot="{ row }">
147
            +{{ row.defaultContactPhone }} <br/>
148 149 150 151 152 153
            <contacts :id="row.id">
              <el-button type="text">更多</el-button>
            </contacts>
          </template>
        </el-table-column>
        <el-table-column :label="$t('客户类别')" align="center">
154 155 156 157 158 159
          <template slot-scope="{ row }">
            {{ getDictDatas2(DICT_TYPE.CUSTOMER_TYPE, (row.type||'').split(',')).map(e => isChinese ? e.label : e.labelEn).join(', ')}}
<!--            <dict-tag-->
<!--              :type="DICT_TYPE.CUSTOMER_TYPE"-->
<!--              :value="scope.row.type"-->
<!--            />-->
160 161 162
          </template>
        </el-table-column>
        <el-table-column :label="$t('角色')" align="center">
zhengyi's avatar
zhengyi committed
163
          <template slot-scope="{ row }">
164 165 166 167 168
            {{ getDictDatas2(DICT_TYPE.CUSTOMER_ROLE, (row.roles || '').split(',')).map(e => isChinese ? e.label : e.labelEn).join(', ') }}
            <!--            <dict-tag-->
            <!--              :type="DICT_TYPE.CUSTOMER_ROLE"-->
            <!--              :value="scope.row.roles"-->
            <!--            />-->
169 170 171
          </template>
        </el-table-column>
        <el-table-column :label="$t('客户经理')" align="center" prop="customerServiceName"></el-table-column>
172 173
        <el-table-column :label="$t('国籍')" align="center" prop="country"
                         :formatter="countryFormatter"></el-table-column>
174 175 176 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
        <el-table-column :label="$t('出货渠道')" align="center">
          <template slot-scope="{ row }">
            {{ channel(row.transportType) }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('客户来源')">
          <template slot-scope="scope">
            <dict-tag
              :type="DICT_TYPE.CUSTOMER_SOURCE"
              :value="scope.row.source"
            />
          </template>
        </el-table-column>
        <el-table-column :label="$t('业务国家')">
          <template slot-scope="{ row }">
            {{ getBusiCountryNames(row.busiCountryIds) }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('常用提货网点')">
          <template slot-scope="{ row }">
            {{ getPickupPointNames(row.pickupPoints) }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('年度发货量')" align="center">
          <template slot-scope="{ row }">
            {{ row.weightYearly }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('主营类别')">
          <template slot-scope="{ row }">
            {{ getProductTypeNames(row.productType) }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('主要竞争对手')" prop="competitorNames">
        </el-table-column>
        <el-table-column :label="$t('年度发货次数')" align="center">
          <template slot-scope="{ row }">
            {{ row.numYearly }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('推介人')">
          <template slot-scope="{ row }">
            {{ getPromoterName(row.promoter) }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('入公海时间')" align="center" width="160">
          <template v-slot="{ row }">
221
            {{ parseTime(row.enterOpenSeaTime ? row.enterOpenSeaTime : row.estimateEnterOpenSeaTime) }}
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 255
          </template>
        </el-table-column>
        <el-table-column :label="$t('入仓确认')" align="center">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.arrivalConfirm == 1">{{ $t('') }}</el-tag>
            <el-tag type="info" v-else>{{ $t('') }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :label="$t('控货无收货人')" align="center">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.noConsignee">{{ $t('') }}</el-tag>
            <el-tag type="info" v-else>{{ $t('') }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :label="$t('默认付款')" align="center">
          <template slot-scope="scope">
            <el-tag type="success" v-if="scope.row.defaultPay">{{ $t('') }}</el-tag>
            <el-tag type="info" v-else>{{ $t('') }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column :label="$t('归属时间')" width="160" align="center">
          <template slot-scope="scope">
            {{ parseTime(scope.row.customerServiceConfirmedTime) }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('首次成交时间')" width="160" align="center">
          <template slot-scope="scope">
            {{ parseTime(scope.row.firstDealTime) }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('获取方式')" align="center">
          <template slot-scope="scope">
            <dict-tag
              :type="DICT_TYPE.CUSTOMER_GET_METHOD"
zhengyi's avatar
zhengyi committed
256
              :value="scope.row.getMethod"
257 258 259
            />
          </template>
        </el-table-column>
260
        <el-table-column :label="$t('创建人')" prop="createUsername" align="center">
261 262 263 264 265 266 267 268 269 270 271 272 273 274
        </el-table-column>
        <el-table-column :label="$t('创建时间')" align="center" width="160">
          <template slot-scope="scope">
            {{ parseTime(scope.row.createTime) }}
          </template>
        </el-table-column>
        <el-table-column :label="$t('最后更新时间')" align="center" width="160">
          <template slot-scope="scope">
            {{ parseTime(scope.row.updateTime) }}
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页组件 -->
      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
275
                  @pagination="getList"/>
276
      <div slot="footer" class="dialog-footer">
277
        <el-button type="primary" @click="confirm">{{ $t('确 定') }}</el-button>
278 279
      </div>
    </el-dialog>
yujinyao's avatar
yujinyao committed
280 281 282 283
  </div>
</template>

<script>
284 285
import {getCustomerPage, customerMergeCus} from "@/api/ecw/customer"
import {getDictDatas, DICT_TYPE, getDictDatas2} from "@/utils/dict"
286
import Contacts from "./contacts.vue";
zhengyi's avatar
zhengyi committed
287
import Template from "@/views/cms/template/index.vue";
288
import {getProductTypeList} from "@/api/ecw/productType";
289

yujinyao's avatar
yujinyao committed
290 291
export default {
  name: "CustomerMerge",
292
  components: {
zhengyi's avatar
zhengyi committed
293
    Template,
294 295
    Contacts
  },
yujinyao's avatar
yujinyao committed
296 297 298
  data() {
    return {
      dialogVisible: false,
299
      getDictDatas,
zhengyi's avatar
zhengyi committed
300
      getDictDatas2,
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
      DICT_TYPE,
      loading: false,
      customerId: null,
      customerDialogVisible: false,
      queryParams: {
        pageNo: 1,
        pageSize: 10
      },
      list: [],
      total: 0,
      type: 1,
      retainCustomer: {},
      mergeCustomer: {},
    }
  },
  props: {
    countryList: {
      type: Array,
      default: () => []
    },
    getNodeLists: {
      type: Array,
      default: () => []
    },
    productTypeList: {
      type: Array,
      default: () => []
    },
    customerSelectFn: {
      type: Array,
      default: () => []
yujinyao's avatar
yujinyao committed
332 333
    }
  },
334 335 336 337 338 339 340 341
  computed: {
    isChinese() {
      return this.$i18n.locale === "zh_CN";
    },
    channel() {
      return (val) => {
        return !!val
          ? this.getDictDatas(this.DICT_TYPE.ECW_CUSTOMER_TRANSPORT_TYPE)
342 343 344
            .filter((i) => (val.split(",") || []).includes(i.value))
            .map((i) => (this.isChinese ? i.label : i.labelEn))
            .join("")
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
          : "";
      };
    },
    getBusiCountryNames() {
      return (ids) => {
        if (ids) {
          const idsArr = ids.split(',')
          const strArr = []
          this.countryList.forEach(item => {
            if (idsArr.includes(item.id.toString())) {
              strArr.push(this.isChinese ? item.nameZh : item.nameEn)
            }
          })
          return strArr.length > 0 ? strArr.join(',') : null
        } else {
          return null
        }
      }
    },
    getPickupPointNames() {
      return (ids) => {
        if (ids) {
          const idsArr = ids.split(',')
          const strArr = []
          this.getNodeLists.forEach(item => {
            if (idsArr.includes(item.id.toString())) {
              strArr.push(this.isChinese ? item.titleZh : item.titleEn)
            }
          })
          return strArr.length > 0 ? strArr.join(',') : null
        } else {
          return null
        }
      }
    },
    getProductTypeNames() {
      return (ids) => {
        if (ids) {
383
          const idsArr = ids.toString().split(',')
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
          const strArr = []
          this.productTypeList.forEach(item => {
            if (idsArr.includes(item.id.toString())) {
              strArr.push(this.isChinese ? item.titleZh : item.titleEn)
            }
          })
          return strArr.length > 0 ? strArr.join(',') : null
        } else {
          return null
        }
      }
    },
    getPromoterName() {
      return (id) => {
        if (id) {
          let strName = ''
400
          for (const item of this.customerSelectFn) {
401 402 403 404 405 406 407 408 409 410 411 412 413
            if (item.id == id) {
              strName = item.name
              break
            }
          }
          return strName
        } else {
          return null
        }
      }
    }
  },
  created() {
414
    this.getList();
415
  },
yujinyao's avatar
yujinyao committed
416
  methods: {
417 418 419 420 421 422 423
    init() {
      this.retainCustomer = {}
      this.mergeCustomer = {}
    },
    selectCustomer(type) {
      this.type = type
      this.customerId = null
424 425 426 427
      this.queryParams = {
        pageNo: 1,
        pageSize: 10
      }
428
      this.customerDialogVisible = true
429
      this.getList();
430
    },
yujinyao's avatar
yujinyao committed
431
    handleSubmit() {
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
      if (!this.retainCustomer.id) {
        this.$message.error(this.$t("请选择保留客户"))
        return
      }
      if (!this.mergeCustomer.id) {
        this.$message.error(this.$t("请选择被合并客户"))
        return
      }
      if (this.mergeCustomer.id == this.retainCustomer.id) {
        this.$message.success(this.$t("保留客户和非主客户不能为同一客户"))
        return
      }
      this.$confirm('保留客户和非主客户,不能在两个不同的客户经理名下,请先确认两个客户在同一个客户经理名下,不允许提交当非主客户/保留客户在移交过程中,不允许合并?', '提示', {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消')
      }).then(() => {
        this.submitData()
      })
    },
    submitData() {
      const h = this.$createElement;
      this.$msgbox({
        title: '注意事项',
455
        message: h('div', {class: 'stips'}, [
456 457 458 459 460 461 462 463 464 465 466 467 468 469
          h('p', null, '1. 保留客户和非主客户,不能在两个不同的客户经理名下,请先确认两个客户在同一个客户经理名下'),
          h('p', null, '2. 被合并客户,提交后会直接删除'),
          h('p', null, '3. 合并后,非主客户的联系人,跟进记录,报价单,订单,客户投诉,品牌授权都迁移到保留客户中,其他信息不会迁移,如需要维护非主客户的客户档案信息到保留客户中,请先维护好再操作'),
        ]),
        showCancelButton: true,
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消')
      }).then(action => {
        if (action == 'confirm') {
          customerMergeCus({
            customerIdDeleted: this.mergeCustomer.id,
            customerIdSaved: this.retainCustomer.id
          }).then(_ => {
            this.$message.success(this.$t("操作成功"))
余金瑶's avatar
余金瑶 committed
470
            this.dialogVisible = false
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
            this.$emit('refresh')
          })
        }
      })
    },
    confirm() {
      if (this.customerId) {
        for (const row of this.list) {
          if (row.id == this.customerId) {
            if (this.type == 1) {
              this.retainCustomer = row
            } else {
              this.mergeCustomer = row
            }
            break
          }
        }
        this.customerDialogVisible = false
      } else {
        this.$message.error(this.$t("请选择客户"))
      }
    },
    countryFormatter(row, column, cellValue) {
      const country = this.countryList.find((e) => e.id === cellValue);
      return this.isChinese ? country?.nameZh : country?.nameEn;
    },
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams = {
        pageNo: 1,
        pageSize: 10
      }
      this.getList();
    },
    getList() {
      this.loading = true;
      getCustomerPage(this.queryParams).then((response) => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
515
      });
yujinyao's avatar
yujinyao committed
516 517 518
    }
  }
}
519
</script>