index.vue 38.7 KB
Newer Older
1 2 3 4 5
<template>
  <div class="app-container">

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
6
      <el-form-item :label="$t('客户编号')" prop="number">
Marcus's avatar
Marcus committed
7
        <el-input v-model="queryParams.number" :placeholder="$t('请输入客户编号')" clearable @keyup.enter.native="handleQuery"/>
8
      </el-form-item>
9
      <el-form-item :label="$t('客户名称')" prop="name">
Marcus's avatar
Marcus committed
10
        <el-input v-model="queryParams.name" :placeholder="$t('请输入客户名称')" clearable @keyup.enter.native="handleQuery"/>
11
      </el-form-item>
12 13
      <el-form-item :label="$t('客户等级')" prop="level">
        <el-select clearable  v-model="queryParams.level" :placeholder="$t('请选择客户等级')" clearable size="small">
14
          <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_LEVEL)"
15
                       :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value"/>
16 17
        </el-select>
      </el-form-item>
18 19
      <el-form-item :label="$t('联系方式')">
        <el-input :placeholder="$t('请输入联系方式')" v-model="queryParams.defaultContactPhone"></el-input>
20
      </el-form-item>
21
      <el-form-item :label="$t('客户类别')" prop="level">
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
22
        <dict-selector clearable :type="DICT_TYPE.CUSTOMER_TYPE"   v-model="queryParams.type"  ></dict-selector>
23
      </el-form-item>
24 25
      <el-form-item :label="$t('客户经理')" prop="customerService">
        <el-select clearable  v-model="queryParams.customerService" :placeholder="$t('请选择客户经理')" clearable size="small">
26 27 28 29
          <el-option v-for="dict in customerServiceList"
                     :key="dict.id" :label="dict.nickname" :value="dict.id"/>
        </el-select>
      </el-form-item>
30
      <el-form-item :label="$t('客户来源')" prop="source">
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
31
        <el-select clearable  v-model="queryParams.source" :placeholder="$t('请选择客户来源')" size="small">
32
          <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_SOURCE)"
33
                       :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value"/>
34 35
        </el-select>
      </el-form-item>
36
      <el-form-item :label="$t('国家')" prop="source">
dcy's avatar
dcy committed
37
        <el-select clearable  v-model="queryParams.country" :placeholder="$t('请选择国家')">
38
          <el-option v-for="dict in countryList"
39
                     :key="dict.id" :label=" isChinese ? dict.nameZh : dict.nameEn" :value="parseInt(dict.id)" />
40 41
        </el-select>
      </el-form-item>
42 43
      <el-form-item :label="$t('客户状态')" prop="status">
        <el-select clearable  v-model="queryParams.status" :placeholder="$t('请选择客户状态')" clearable size="small">
44
          <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_STATUS)"
45
                       :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value"/>
46 47
        </el-select>
      </el-form-item>
48
      <el-form-item :label="$t('创建时间')">
49 50 51 52
        <el-date-picker
          type="datetimerange"
          clearable  v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
          range-separator="-" :start-placeholder="$t('开始日期')" :end-placeholder="$t('结束日期')" />
53
      </el-form-item>
54
      <el-form-item :label="$t('信用等级')" prop="department">
dcy's avatar
dcy committed
55
        <el-select clearable  v-model="queryParams.creditLevel" >
56
          <el-option  v-for="(item,index) in creditList" :label="isChinese ?  item.nameZh : item.nameEn" :key="index" :value="item.id" ></el-option>
57
        </el-select>
邓春圆's avatar
邓春圆 committed
58
      </el-form-item>
59
       <el-form-item  :label="$t('市场获客')" prop="department">
邓春圆's avatar
邓春圆 committed
60
        <dict-selector clearable  :type="DICT_TYPE.ECW_CUSTOMER_RESOURCE_TYPE" v-model="queryParams.resourceType" formatter="number"></dict-selector>
61
      </el-form-item>
62
      <el-form-item>
63 64
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{$t('搜索')}}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{$t('重置')}}</el-button>
65 66 67 68 69 70
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
邓春圆's avatar
邓春圆 committed
71 72
        <el-button v-if="path === '/customer/potential'" type="primary" plain icon="el-icon-plus" size="mini" @click="handleAddPotential">{{$t('新增潜在客户')}}</el-button>
        <el-button v-else type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
邓春圆's avatar
邓春圆 committed
73
                   v-hasPermi="[ selectAuthorityFn('ecw:customer:create')]">{{$t('新增')}}</el-button>
74
      </el-col>
75
      <el-col :span="1.5" >
76
        <el-button :disabled="selectCustomerList.length === 0"  type="primary" size="mini" @click="transferShow = true;"
邓春圆's avatar
邓春圆 committed
77
                   v-hasPermi="[selectAuthorityFn('ecw:customer:batch-transfer')]">{{$t('批量移交')}}</el-button>
78
      </el-col>
79 80
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
邓春圆's avatar
邓春圆 committed
81
                   v-hasPermi="[selectAuthorityFn('ecw:customer:export')]">{{$t('导出')}}</el-button>
82
      </el-col>
83
      <el-col :span="1.5">
84 85
<!--        <el-button :disabled="!selectCustomerList.length" @click="setChangeCustomerAir(true)" v-if="$route.path === '/customer/customer'" type="primary" plain  size="mini"  :loading="exportLoading"-->
<!--                   v-hasPermi="['ecw:customer:transport']" >{{$t('设为空运客户')}}</el-button>-->
86 87
      </el-col>
      <el-col :span="1.5">
88 89
<!--        <el-button :disabled="!selectCustomerList.length" @click="setChangeCustomerAir(false)" v-if="$route.path === '/customer/customer'" type="primary" plain  size="mini"  :loading="exportLoading"-->
<!--                   v-hasPermi="['ecw:customer:transport']">{{$t('设为非空运客户')}}</el-button>-->
90
      </el-col>
邓春圆's avatar
邓春圆 committed
91
      <el-col :span="1.5">
92
        <el-button v-hasPermi="['ecw:customer:fcl']" :disabled="!selectCustomerList.length" @click="setFullContainerLoad(true)" v-if="$route.path === '/customer/customer'" type="primary" plain  size="mini"  :loading="exportLoading">{{$t('设置海运整柜客户')}}</el-button>
邓春圆's avatar
邓春圆 committed
93 94
      </el-col>
      <el-col :span="1.5">
95
        <el-button  v-hasPermi="['ecw:customer:fcl-mistake']" :disabled="!selectCustomerList.length"  @click="setFullContainerLoad(false)" v-if="$route.path === '/customer/customer'" type="primary" plain  size="mini"  :loading="exportLoading"
邓春圆's avatar
邓春圆 committed
96 97
        >{{$t('设置海运非整柜客户')}}</el-button>
      </el-col>
98
      <el-col :span="1.5">
99
        <el-button v-has-permi="[selectAuthorityFn('ecw:customer:create-potential')]" v-if="path === '/customer/customer'" type="primary" plain icon="el-icon-plus" size="mini" @click="handleAddPotential">{{$t('新增潜在客户')}}</el-button>
100
      </el-col>
101 102 103 104
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
105 106 107 108 109
    <el-table ref="multipleTable" v-loading="loading" :data="list"   @selection-change="handleSelectionChange">
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
110 111
      <el-table-column :label="$t('客户编号')" align="center" prop="number" >
        <template v-slot="{row}">
112
          {{row.number}}
113 114
        </template>
      </el-table-column>
115 116
      <el-table-column :label="$t('客户名称')" align="center" prop="name">
        <template slot-scope="{row}">
117
          <p style="display:inline-block;white-space:pre-wrap;">{{$l(row, 'name')}}</p>
118
          <el-tag v-if="row.isInOpenSea" size="mini">{{ $t('') }}</el-tag>
119 120 121
        </template>
      </el-table-column>

122
      <el-table-column :label="$t('客户等级')" align="center" prop="vipLevelNameZh">
123 124 125 126
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.CUSTOMER_LEVEL" :value="scope.row.level" />
        </template>
      </el-table-column>
邓春圆's avatar
邓春圆 committed
127
      <el-table-column :label="$t('信用等级')" :prop="isChinese ? 'creditLevelNameZh' : 'creditLevelNameEn'"></el-table-column>
128
      <el-table-column :label="$t('客户状态')" align="center" prop="status">
129 130 131 132
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.CUSTOMER_STATUS" :value="scope.row.status" />
        </template>
      </el-table-column>
133
      <el-table-column :label="$t('主联系人')" prop="defaultContactName"></el-table-column>
dcy's avatar
dcy committed
134 135
      <el-table-column :label="$t('主联系方式')" prop="defaultContactPhone">
        <template v-slot="{row}">
136 137
          +{{row.defaultContactPhone}} <br/>
          <contacts :id="row.id" >
138
            <el-button  type="text">更多</el-button>
139
          </contacts>
dcy's avatar
dcy committed
140 141
        </template>
      </el-table-column>
142
      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" width="180">
143 144 145 146
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
147
      <el-table-column :label="$t('入公海时间')" align="center" prop="createTime" width="180">
148 149
        <template  v-slot = {row}>
          <span>{{ parseTime(row.enterOpenSeaTime ? row.enterOpenSeaTime : row.estimateEnterOpenSeaTime )  }}</span>
150 151
        </template>
      </el-table-column>
152
      <el-table-column :label="$t('客户经理')" align="center" prop="customerServiceName">
153
      </el-table-column>
154
      <el-table-column :label="$t('出货渠道')">
155
        <template slot-scope="{row}">
156
          {{channel(row.transportType)}}
157 158
        </template>
      </el-table-column>
159 160
      <el-table-column :label="$t('国家')" align="center" prop="country" :formatter="countryFormatter"></el-table-column>
      <el-table-column :label="$t('操作')" align="center" class-name="small-padding fixed-width">
161
        <template slot-scope="scope">
dcy's avatar
dcy committed
162 163
<!--          <el-button size="mini" type="text" v-show="'development' === env && scope.row.isInOpenSea"  @click="seasPond(scope.row)"-->
<!--                     v-hasPermi="['ecw:customer:query']">{{$t('掉入公海池')}}</el-button>-->
Marcus's avatar
Marcus committed
164
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)"
165
                     v-hasPermi="[selectAuthorityFn('ecw:customer:index-query')]">{{$t('查看')}}</el-button>
166
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
邓春圆's avatar
邓春圆 committed
167
                     v-hasPermi="[selectAuthorityFn('ecw:customer:update')]">{{$t('修改')}}</el-button>
168
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
邓春圆's avatar
邓春圆 committed
169 170 171 172
                     v-hasPermi="[selectAuthorityFn('ecw:customer:delete')]">{{$t('删除')}}</el-button>
          <el-button size="mini" v-has-permi="[selectAuthorityFn('ecw:customer:follow-up')]" type="text" icon="el-icon-collection" @click="followUp(scope.row)">{{$t('跟进')}}</el-button>
          <el-button size="mini" v-has-permi="[selectAuthorityFn('ecw:customer:customer-complaint')]" type="text" icon="el-icon-user" @click="complaint(scope.row)">{{$t('客诉')}}</el-button>
          <el-button :disabled="scope.row.isInOpenSea" v-has-permi="[selectAuthorityFn('ecw:customer:postpone')]" size="mini" type="text" icon="el-icon-user" @click="delay(scope.row)">{{$t('延期')}}</el-button>
173 174 175 176 177 178 179 180
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>

    <!-- 对话框(添加 / 修改) -->
181
    <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body :close-on-click-modal="false">
182 183 184
      <el-form ref="form" :model="form" :rules="rules" label-width="150px">
        <el-row :gutter="10">
          <el-col :span="12">
Marcus's avatar
Marcus committed
185 186
            <el-form-item :label="$t('客户名称')" prop="name">
              <el-input v-model="form.name" :placeholder="$t('请输入客户名称')" />
187 188 189
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
190 191
            <el-form-item :label="$t('国家')" prop="country">
              <el-select v-model="form.country" :placeholder="$t('请选择国家')">
Marcus's avatar
Marcus committed
192
                <el-option v-for="dict in getDictDatas(DICT_TYPE.COUNTRY)"
193
                           :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
194 195 196 197
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
198 199
            <el-form-item :label="$t('客户等级')" prop="level">
              <el-select v-model="form.level" :placeholder="$t('请选择客户等级')">
200
                <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_LEVEL)"
201
                           :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
202 203 204 205
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
206 207
            <el-form-item :label="$t('联系地址')" prop="address">
              <el-input v-model="form.address" :placeholder="$t('请输入联系地址')" />
208 209 210
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
211 212
            <el-form-item :label="$t('客户类别')" prop="type">
              <el-select v-model="form.type" :placeholder="$t('请选择客户类别')">
213
                <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_TYPE)"
214
                           :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value" />
215 216 217
              </el-select>
            </el-form-item>
          </el-col>
218
<!--          <el-col :span="12">-->
Marcus's avatar
Marcus committed
219 220
<!--            <el-form-item :label="$t('所属代理')" prop="agentId">-->
<!--              <el-select v-model="form.agentId" :placeholder="$t('请选择所属代理')">-->
221 222 223 224 225
<!--                <el-option v-for="dict in getDictDatas(DICT_TYPE.COMMON_STATUS)"-->
<!--                           :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />-->
<!--              </el-select>-->
<!--            </el-form-item>-->
<!--          </el-col>-->
226
          <el-col :span="12">
Marcus's avatar
Marcus committed
227 228
            <el-form-item :label="$t('常用提货网点')" prop="pickupPoint">
              <el-select v-model="form.pickupPoint" :placeholder="$t('请输入常用提货网点')">
229 230
                <el-option v-for="node in nodeList"
                           :key="node.value" :label="node.label" :value="node.value" />
231 232 233 234
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
235

Marcus's avatar
Marcus committed
236 237
            <el-form-item :label="$t('公司名称')" prop="company">
              <el-input v-model="form.company" :placeholder="$t('请输入公司名称')" />
238 239 240
            </el-form-item>
          </el-col>
          <el-col :span="12">
241

Marcus's avatar
Marcus committed
242
            <el-form-item :label="$t('客户生日')" prop="birthday">
243 244 245 246
              <el-date-picker
                v-model="form.birthday"
                type="date"
                value-format="timestamp"
Marcus's avatar
Marcus committed
247
                :placeholder="$t('请输入客户生日')">
248
              </el-date-picker>
249 250 251
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
252
            <el-form-item :label="$t('主营类别')" prop="productType">
253 254
              <el-row :gutter="10">
               <el-col :span="11">
Marcus's avatar
Marcus committed
255 256
                 <el-select v-model="form.productType" :placeholder="$t('请选择产品类别')">
<!--                   <el-option :label="$t('请选择字典生成')" value="" />-->
257 258 259
                 </el-select>
               </el-col>
                <el-col :span="11">
Marcus's avatar
Marcus committed
260 261
                  <el-select v-model="form.productType" :placeholder="$t('请选择主营类别')">
<!--                    <el-option :label="$t('请选择字典生成')" value="" />-->
262 263 264
                  </el-select>
                </el-col>
              </el-row>
265 266 267
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
268 269
            <el-form-item :label="$t('客户来源')" prop="source">
              <el-select v-model="form.source" :placeholder="$t('请选择客户来源')">
270
                <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_SOURCE)"
271
                           :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
272 273 274 275
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
276 277
            <el-form-item :label="$t('结算方式')" prop="balance">
              <el-select v-model="form.balance" :placeholder="$t('请选择结算方式')">
278
                <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_BALANCE)"
279
                           :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
280 281 282 283
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
284 285
            <el-form-item :label="$t('客户经理')" prop="customerService">
              <el-select v-model="form.customerService" :placeholder="$t('请选择客户经理')">
286 287
                <el-option v-for="dict in customerServiceList"
                           :key="dict.id" :label="dict.nickname" :value="dict.id" />
288 289 290 291
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
292
            <el-form-item :label="$t('图片')" prop="picture">
293
              <upload v-model="form.picture" :limit="1"></upload>
294
            </el-form-item>
295

296 297
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
298
            <el-form-item :label="$t('客户状态')" prop="status">
299

Marcus's avatar
Marcus committed
300
              <el-select v-model="form.status" :placeholder="$t('请选择客户状态')">
301
                <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_STATUS)"
302
                           :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
303 304 305 306
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
307 308
            <el-form-item :label="$t('推介人')" prop="promoter">
              <el-input v-model="form.promoter" :placeholder="$t('请输入推介人')" />
309 310 311
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
312 313
            <el-form-item :label="$t('创建人')" prop="founder">
              <el-input v-model="form.founder" :placeholder="$t('请输入创建人')" />
314 315 316
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
317
            <el-form-item :label="$t('创建时间')" prop="founder">
318 319 320 321
              <el-date-picker
                v-model="form.createTime"
                type="datetime"
                value-format="timestamp"
Marcus's avatar
Marcus committed
322
                :placeholder="$t('选择创建时间')">
323
              </el-date-picker>
324 325 326
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
327 328
            <el-form-item :label="$t('备注')" prop="remarks">
              <el-input v-model="form.remarks" :placeholder="$t('请输入备注')" />
329 330 331
            </el-form-item>
          </el-col>
          <el-col :span="24">
Marcus's avatar
Marcus committed
332
            <el-form-item :label="$t('到仓确认')" prop="arrivalConfirm">
333 334 335 336
              <el-switch v-model="form.arrivalConfirm" :active-value="0" :inactive-value="1" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
邓春圆's avatar
邓春圆 committed
337 338
            <el-form-item :label="$t('重货标准(CBM)')" prop="weightUnit">
              <el-input v-model="form.weightUnit" :placeholder="$t('请输入重货标准(CBM)')" />
339 340
            </el-form-item>
          </el-col>
341
          <el-col :span="24">
Marcus's avatar
Marcus committed
342
            <el-form-item :label="$t('指定线路')" prop="line">
343 344 345 346 347 348 349 350
              <el-switch v-model="showLine"></el-switch>
              <el-table
                v-show="showLine"
                border
                :data="form.customerLines"
                style="width: 500px">
                <el-table-column
                  prop="departureId"
Marcus's avatar
Marcus committed
351
                  :label="$t('始发地')">
352 353 354
                </el-table-column>
                <el-table-column
                  prop="objectiveId"
Marcus's avatar
Marcus committed
355
                  :label="$t('目的地')">
356 357 358 359
                </el-table-column>
              </el-table>
            </el-form-item>
          </el-col>
360
        </el-row>
361

黄卓's avatar
黄卓 committed
362 363
        <el-card class="box-card">
          <div slot="header" class="clearfix">
Marcus's avatar
Marcus committed
364
            <span>{{ $t('联系人') }}</span>
黄卓's avatar
黄卓 committed
365
            <el-button style="float: right;" size="small" type="primary" @click="form.customerContacts.push({department: undefined})">+</el-button>
黄卓's avatar
黄卓 committed
366 367 368 369 370 371 372
          </div>
          <el-table
            :data="form.customerContacts"
            style="width: 100%"
          >
            <el-table-column
              prop="department"
Marcus's avatar
Marcus committed
373
              :label="$t('部门')"
黄卓's avatar
黄卓 committed
374 375
              width=""
            >
黄卓's avatar
黄卓 committed
376
              <template v-slot="{ row, column, $index }">
Marcus's avatar
Marcus committed
377
                <el-input v-model="row.department" :placeholder="$t('请输入部门')" size="mini"/>
黄卓's avatar
黄卓 committed
378
              </template>
黄卓's avatar
黄卓 committed
379 380 381
            </el-table-column>
            <el-table-column
              prop="position"
Marcus's avatar
Marcus committed
382
              :label="$t('职位')"
黄卓's avatar
黄卓 committed
383 384
              width=""
            >
黄卓's avatar
黄卓 committed
385
              <template v-slot="{row}">
Marcus's avatar
Marcus committed
386
                <el-input v-model="row.position" :placeholder="$t('请输入职位')" size="mini"/>
黄卓's avatar
黄卓 committed
387
              </template>
黄卓's avatar
黄卓 committed
388 389 390
            </el-table-column>
            <el-table-column
              prop="name"
Marcus's avatar
Marcus committed
391
              :label="$t('联系人')"
黄卓's avatar
黄卓 committed
392
            >
Marcus's avatar
Marcus committed
393
              <template v-slot:header>{{ $t('联系人') }}<span style="color: #ff0000">*</span>
394
              </template>
黄卓's avatar
黄卓 committed
395
              <template v-slot="{row}">
Marcus's avatar
Marcus committed
396
                <el-input v-model="row.name" :placeholder="$t('请输入联系人')" size="mini"/>
黄卓's avatar
黄卓 committed
397
              </template>
黄卓's avatar
黄卓 committed
398 399 400
            </el-table-column>
            <el-table-column
              prop="areaCode"
Marcus's avatar
Marcus committed
401
              :label="$t('区号')"
黄卓's avatar
黄卓 committed
402
            >
Marcus's avatar
Marcus committed
403
              <template v-slot:header>{{ $t('区号') }}<span style="color: #ff0000">*</span>
404
              </template>
黄卓's avatar
黄卓 committed
405
              <template v-slot="{row}">
Marcus's avatar
Marcus committed
406
                <el-select v-model="row.areaCode" :placeholder="$t('请选择区号')">
黄卓's avatar
黄卓 committed
407
                  <el-option v-for="dict in getDictDatas(DICT_TYPE.AREA_CODE)"
408
                             :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
黄卓's avatar
黄卓 committed
409 410
                </el-select>
              </template>
黄卓's avatar
黄卓 committed
411 412
            </el-table-column>
            <el-table-column
黄卓's avatar
黄卓 committed
413
              prop="phoneNew"
Marcus's avatar
Marcus committed
414
              :label="$t('联系方式')"
黄卓's avatar
黄卓 committed
415
            >
Marcus's avatar
Marcus committed
416
              <template v-slot:header>{{ $t('联系方式') }}<span style="color: #ff0000">*</span>
417
              </template>
黄卓's avatar
黄卓 committed
418
              <template v-slot="{row}">
Marcus's avatar
Marcus committed
419
                <el-input v-model="row.phoneNew" :placeholder="$t('请输入联系方式')" size="mini"/>
黄卓's avatar
黄卓 committed
420
              </template>
黄卓's avatar
黄卓 committed
421 422 423
            </el-table-column>
            <el-table-column
              prop=""
Marcus's avatar
Marcus committed
424
              :label="$t('关联账号')"
黄卓's avatar
黄卓 committed
425 426 427 428
            >
            </el-table-column>
            <el-table-column
              prop="social"
Marcus's avatar
Marcus committed
429
              :label="$t('社交软件')"
黄卓's avatar
黄卓 committed
430
            >
黄卓's avatar
黄卓 committed
431
              <template v-slot="{row}">
Marcus's avatar
Marcus committed
432
                <el-select v-model="row.social" :placeholder="$t('请选择社交软件')">
黄卓's avatar
黄卓 committed
433
                  <el-option v-for="dict in getDictDatas(DICT_TYPE.SOCIAL)"
434
                             :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
黄卓's avatar
黄卓 committed
435 436
                </el-select>
              </template>
黄卓's avatar
黄卓 committed
437 438 439
            </el-table-column>
            <el-table-column
              prop="socialNumber"
Marcus's avatar
Marcus committed
440
              :label="$t('社交软件号码')"
黄卓's avatar
黄卓 committed
441
            >
黄卓's avatar
黄卓 committed
442
              <template v-slot="{row}">
Marcus's avatar
Marcus committed
443
                <el-input v-model="row.socialNumber" :placeholder="$t('请输入社交软件号码')" size="mini"/>
黄卓's avatar
黄卓 committed
444
              </template>
黄卓's avatar
黄卓 committed
445 446 447
            </el-table-column>
            <el-table-column
              prop="email"
Marcus's avatar
Marcus committed
448
              :label="$t('邮箱')"
黄卓's avatar
黄卓 committed
449
            >
黄卓's avatar
黄卓 committed
450
              <template v-slot="{row}">
Marcus's avatar
Marcus committed
451
                <el-input v-model="row.email" :placeholder="$t('请输入邮箱')" size="mini"/>
黄卓's avatar
黄卓 committed
452
              </template>
黄卓's avatar
黄卓 committed
453 454 455
            </el-table-column>
            <el-table-column
              prop="isDefault"
Marcus's avatar
Marcus committed
456
              :label="$t('设为默认')"
黄卓's avatar
黄卓 committed
457
            >
黄卓's avatar
黄卓 committed
458
              <template v-slot="{row}">
Marcus's avatar
Marcus committed
459
                <el-select v-model="row.isDefault" :placeholder="$t('设为默认')">
黄卓's avatar
黄卓 committed
460 461 462 463
                  <el-option v-for="dict in getDictDatas(DICT_TYPE.IS_DEFAULT)"
                             :key="dict.value" :label="dict.label" :value="parseInt(dict.isDefault)" />
                </el-select>
              </template>
黄卓's avatar
黄卓 committed
464 465 466
            </el-table-column>
            <el-table-column
              prop="name"
Marcus's avatar
Marcus committed
467
              :label="$t('操作')"
黄卓's avatar
黄卓 committed
468
            >
黄卓's avatar
黄卓 committed
469
              <template v-slot="{ row, column, $index }">
Marcus's avatar
Marcus committed
470
                <el-button type="danger" @click="form.customerContacts.splice($index, 1)">{{ $t('删除') }}</el-button>
黄卓's avatar
黄卓 committed
471
              </template>
黄卓's avatar
黄卓 committed
472 473 474 475
            </el-table-column>
          </el-table>
        </el-card>

476 477
        <el-row :gutter="10" style="margin-top: 15px">
          <el-col :span="12">
Marcus's avatar
Marcus committed
478 479
            <el-form-item :label="$t('发票抬头')" prop="invoiceTitle">
              <el-input v-model="form.invoiceTitle" :placeholder="$t('请输入发票抬头')" />
480 481 482
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
483 484
            <el-form-item :label="$t('纳税人识别号')" prop="licenseNumber">
              <el-input v-model="form.licenseNumber" :placeholder="$t('请输入纳税人识别号')" />
485 486 487
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
488 489
            <el-form-item :label="$t('开户行')" prop="bank">
              <el-input v-model="form.bank" :placeholder="$t('请输入开户行')" />
490 491 492
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
493 494
            <el-form-item :label="$t('账户')" prop="bankNumber">
              <el-input v-model="form.bankNumber" :placeholder="$t('请输入账户')" />
495 496 497
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
498 499
            <el-form-item :label="$t('项目')" prop="project">
              <el-input v-model="form.project" :placeholder="$t('请输入项目')" />
500 501 502
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
503 504
            <el-form-item :label="$t('开票地址')" prop="billingAddress">
              <el-input v-model="form.billingAddress" :placeholder="$t('请输入开票地址')" />
505 506 507
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
508 509
            <el-form-item :label="$t('开票电话')" prop="billingTell">
              <el-input v-model="form.billingTell" :placeholder="$t('请输入开票电话')" />
510 511 512
            </el-form-item>
          </el-col>
          <el-col :span="12">
Marcus's avatar
Marcus committed
513 514
            <el-form-item :label="$t('税率')" prop="taxRate">
              <el-input v-model="form.taxRate" :placeholder="$t('请输入税率')" />
515 516 517
            </el-form-item>
          </el-col>
        </el-row>
518 519
      </el-form>
      <div slot="footer" class="dialog-footer">
520 521
        <el-button type="primary" @click="submitForm">{{$t('确 定')}}</el-button>
        <el-button @click="cancel">{{$t('取 消')}}</el-button>
522 523
      </div>
    </el-dialog>
524 525
    <customer-follow-list :customer-id="customerId" :id="customerId" ref="CustomerFollowList"></customer-follow-list>
    <customer-complaints :customer-id="customerId" ref="customerComplaints"></customer-complaints>
526
    <transfer-customer :show.sync="transferShow" :customer-ids.sync="selectCustomerList"></transfer-customer>
邓春圆's avatar
邓春圆 committed
527
    <add-potential-custom ref="potentialCustom"  @change="getList" ></add-potential-custom>
528

529 530 531 532
  </div>
</template>

<script>
533
import {
邓春圆's avatar
邓春圆 committed
534 535 536 537 538 539 540 541 542 543
  createCustomer,
  updateCustomer,
  deleteCustomer,
  getCustomer,
  getCustomerPage,
  exportCustomerExcel,
  testEnterToOpenSea,
  getCustomerDeptPage,
  changeCustomerAir,
  getPotential,
544
  setChangeCustomerFcl, potentialExportExcel, deptExportExcel
545
} from "@/api/ecw/customer";
546 547 548 549
import { getDictDatas, DICT_TYPE } from '@/utils/dict';
import {CommonStatusEnum} from '@/utils/constants'
import { uploadFile } from "@/api/infra/file";

550 551
import upload from '@/components/ImageUpload'
import {getNodeList} from "@/api/ecw/node"
552 553
import CustomerFollowList from "@/components/CustomerFollowList"
import customerComplaints from "@/components/customerComplaints"
dcy's avatar
dcy committed
554
import {listServiceUser} from "@/api/system/user";
555
import { getCountryListAll } from '@/api/ecw/country'
556 557
import {getCreditPage} from "@/api/customer/credit";
import {customerExportExcel} from "@/api/ecw/customer";
558
import transferCustomer from "@/views/ecw/customer/transferCustomer";
559
import Template from "@/views/cms/template/index.vue";
邓春圆's avatar
邓春圆 committed
560
import AddPotentialCustom from "@/views/ecw/customer/addPotentialCustom.vue";
561
import Contacts from "@/views/ecw/customer/components/contacts.vue";
562 563

export default {
564
  name: "EcwCustomerIndex",
565
  components: {
566
    Contacts,
邓春圆's avatar
邓春圆 committed
567
    AddPotentialCustom,
568
    Template,
569 570
    upload,
    CustomerFollowList,
571 572
    customerComplaints,
    transferCustomer
573 574 575
  },
  data() {
    return {
576
      env:process.env.NODE_ENV,
577 578
      getDictDatas,
      DICT_TYPE,
579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 客户列表
      list: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      dateRangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        number: null,
        name: null,
        level: null,
        source: null,
        customerService: null,
        status: null,
        department: null,
dcy's avatar
dcy committed
605 606
        creditLevel:null,
        country:null,
邓春圆's avatar
邓春圆 committed
607
        resourceType:null,
608 609
      },
      // 表单参数
黄卓's avatar
黄卓 committed
610
      form: {},
611 612
      // 表单校验
      rules: {
613 614 615 616
        name: [{ required: true, message: this.$t('客户名称不能为空'), trigger: "blur" }],
        country: [{ required: true, message: this.$t('国家不能为空'), trigger: "blur" }],
        level: [{ required: true, message: this.$t('客户等级不能为空'), trigger: "blur" }],
        type: [{ required: true, message: this.$t('客户类别不能为空'), trigger: "blur" }],
Marcus's avatar
Marcus committed
617
        // createTime: [{ required: true, message: this.$t("创建时间不能为空"), trigger: "blur" }],
618 619 620 621
        source: [{ required: true, message: this.$t('客户来源不能为空'), trigger: "blur" }],
        customerService: [{ required: true, message: this.$t('客户经理不能为空'), trigger: "blur" }],
        status: [{ required: true, message: this.$t('客户状态不能为空'), trigger: "blur" }],
        founder: [{ required: true, message: this.$t('创建人不能为空'), trigger: "blur" }],
622 623 624
      },
      // 网点
      nodeList: [],
625 626
      showLine: false,
      customerId:undefined,
627
      customerServiceList:[],
628 629 630 631
      countryList: [],
      creditList:[],
      selectCustomerList:[],
      transferShow:false
632 633
    };
  },
634
  computed:{
邓春圆's avatar
邓春圆 committed
635 636 637
    path(){
      return this.$route.path
    },
638 639 640 641 642 643 644
    channel(){
      return (val)=>{
        return !!val ? this.getDictDatas(this.DICT_TYPE.ECW_CUSTOMER_TRANSPORT_TYPE).filter(i => (val.split(',') || []).includes(i.value)).map(i => this.isChinese ? i.label : i.labelEn ).join('') :''
      }
    },
    isChinese(){
      return this.$i18n.locale === 'zh_CN'
邓春圆's avatar
邓春圆 committed
645 646 647 648 649 650 651
    },
    authorityFn(){
      let i = ''
      switch (this.$route.path){
        case '/customer/department-customers':
          i = 'dep-'
          break;
652 653 654
        case '/customer/potential':
          i = 'pot-'
          break;
邓春圆's avatar
邓春圆 committed
655 656 657 658 659
      }
      return i
    },
    selectAuthorityFn(){
      return (val)=>{
邓春圆's avatar
邓春圆 committed
660
           let t = val.split(":")
邓春圆's avatar
邓春圆 committed
661
           t[t.length - 1] = this.authorityFn + t[t.length - 1]
662
        console.log( t.join(":"))
邓春圆's avatar
邓春圆 committed
663 664
           return t.join(":")
      }
665 666 667 668 669 670 671 672 673 674
    }
  },
  watch:{
    selectCustomerList(val){
      if(val.length === 0){
        this.getList()
        this.$refs.multipleTable.clearSelection();
      }
    },
  },
675
  created() {
676 677 678
    getCreditPage({page:1,rows:999}).then(r => {
      this.creditList = r.data.list
    })
679
    this.getList();
dcy's avatar
dcy committed
680 681 682
    listServiceUser().then(r=>{
      this.customerServiceList = r.data;
    })
683 684 685
    getCountryListAll().then(r => {
      this.countryList = r.data
    })
686
  },
687 688 689
  activated(){
    this.getList();
  },
690
  methods: {
邓春圆's avatar
邓春圆 committed
691 692 693 694 695 696 697 698 699 700 701 702 703
    // 设置整柜
    setFullContainerLoad(isFcl){
      setChangeCustomerFcl({
        "customerIdList": this.selectCustomerList,
        isFcl
      }).then(r =>{
        if(r.code === 0){
          this.$message.success(isFcl ? '设置客户为海运整柜成功!' : '设置客户为非海运整柜成功!')
          this.selectCustomerList = []
          this.getList()
        }
      })
    },
704 705 706 707 708 709 710 711
    // 设置空运客户
    setChangeCustomerAir(isAir){
      changeCustomerAir({
        customerIdList:this.selectCustomerList,
        isAir
      }).then(r =>{
        console.log(r)
        if(r.code === 0){
邓春圆's avatar
邓春圆 committed
712
          this.$message.success(isAir ? '设为空运客户成功!' : '设为非空运客户成功!')
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728
          this.selectCustomerList = []
          this.getList()
        }
      })
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    complaint(row){
      this.customerId = row.id;
     this.$nextTick(()=>{
       this.$refs.customerComplaints.handleAdd();
     })
    },
729 730
    countryFormatter(row, column, cellValue) {
      const country = this.countryList.find((e) => e.id === cellValue)
邓春圆's avatar
邓春圆 committed
731
      return this.isChinese ? country?.nameZh : country?.nameEn
732
    },
733 734 735 736 737 738 739 740 741 742
    delay(row){

      this.$router.push({path:'/customer/delay',query:{id:row.id}})
    },
    followUp(row){
      this.customerId = row.id;
     this.$nextTick(()=>{
       this.$refs.CustomerFollowList.customerFollow.dialogVisible = true;
     })
    },
743 744 745 746 747
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
748
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime', false);
749
      // 执行查询
邓春圆's avatar
邓春圆 committed
750 751 752 753 754 755
      switch (this.$route.path){
        case '/customer/customer' :
          getCustomerPage(params).then(this.setData);
          break;
        case '/customer/department-customers':
          getCustomerDeptPage(params).then(this.setData);
邓春圆's avatar
邓春圆 committed
756
          break;
邓春圆's avatar
邓春圆 committed
757 758 759
        case '/customer/potential':
          getPotential(params).then(this.setData)
          break;
邓春圆's avatar
邓春圆 committed
760 761 762
      }

    },
763 764 765 766 767 768
    /** 新增按钮操作 */
    handleAdd() {
      this.$router.push('/customer/add-edit/0')
      // this.reset();
      // this.open = true;
      // this.title = this.$t("添加客户");
769
    },
邓春圆's avatar
邓春圆 committed
770 771 772 773
    // 新增潜在客户
    handleAddPotential(){
          this.$refs.potentialCustom.dialogTableVisible = true;
    },
774 775 776 777 778 779 780 781 782 783 784 785 786 787
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
      const name = row.name;
      const number = row.number;
      this.$modal.confirm(this.$t('是否确认删除客户编号为"') + number + this.$t('"的数据项?')).then(function() {
          return deleteCustomer(id);
        }).then(() => {
          this.getList();
          this.$modal.msgSuccess(this.$t('删除成功'));
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
788
      let func = null;
邓春圆's avatar
邓春圆 committed
789 790 791 792 793 794 795
      let title = ''
      switch (this.$route.path){
        case '/customer/customer' :
         func = customerExportExcel
         title =  '是否确认导出所有客户数据项?'
          break;
        case '/customer/department-customers':
796 797
          func = deptExportExcel
          title =  '是否确认导出部门客户数据项?'
邓春圆's avatar
邓春圆 committed
798 799
          break;
        case '/customer/potential':
800 801
          func = potentialExportExcel
          title =  '是否确认导出潜在客户数据项?'
邓春圆's avatar
邓春圆 committed
802 803 804 805 806 807 808 809
          break;
      }

      // // 执行导出
      this.$modal.confirm(this.$t(title)).then(() => {
        func().then(r =>{
          this.$message.success(this.$t('已加入导出队列,请稍后在下载日志中下载'))
        })
810 811 812 813 814 815 816 817 818 819 820 821
        }).catch(() => {});
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    handleSelectionChange(val){
      this.selectCustomerList = val.map(i => i.id);
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
822 823
      console.log(row.id)
      this.$router.push('/customer/add-edit/' + row.id)
824 825 826 827 828 829 830 831 832 833 834
      // this.reset();
      // const id = row.id;
      // getCustomer(id).then(response => {
      //   this.form = { ...this.form, ...response.data };
      //   this.open = true;
      //   this.title = this.$t("修改客户");
      // });
    },
    /** 查看按钮操作 */
    handleView(row) {
      this.$router.push('/customer/query/' + row.id)
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        number: undefined,
        name: undefined,
        level: undefined,
        country: undefined,
        type: undefined,
        agentId: undefined,
        company: undefined,
        address: undefined,
        productType: undefined,
        productId: undefined,
        pickupPoint: undefined,
        memberId: undefined,
        birthday: undefined,
        balance: undefined,
        source: undefined,
        picture: undefined,
        customerService: undefined,
黄卓's avatar
黄卓 committed
857
        customerContacts: [],
858
        customerLines: [],
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880
        promoter: undefined,
        status: undefined,
        founder: undefined,
        department: undefined,
        invoiceTitle: undefined,
        licenseNumber: undefined,
        bank: undefined,
        bankNumber: undefined,
        project: undefined,
        billingAddress: undefined,
        billingTell: undefined,
        taxRate: undefined,
        remarks: undefined,
        arrivalConfirm: undefined,
        weightUnit: undefined,
      };
      this.resetForm("form");
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreateTime = [];
      this.resetForm("queryForm");
dcy's avatar
dcy committed
881 882 883 884 885 886 887 888 889 890 891 892 893
      this.queryParams = {
        pageNo: 1,
        pageSize: 10,
        number: null,
        name: null,
        level: null,
        source: null,
        customerService: null,
        status: null,
        department: null,
        creditLevel:null,
        country:null,
      }
894 895
      this.handleQuery();
    },
896 897 898 899 900 901 902 903 904
    /** 调入公海池测试用 */
    seasPond(row) {
      testEnterToOpenSea(row.id).then(r => {
         if(r.code === 0){
           this.$t('调入公海池成功!')
           this.getList();
         }
      })
    },
905 906 907 908 909
    setData(response){
      console.log(response,'response')
      this.list = response.data.list;
      this.total = response.data.total;
      this.loading = false;
910 911 912 913 914
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
915
          // return;
916 917 918 919
        }
        // 修改的提交
        if (this.form.id != null) {
          updateCustomer(this.form).then(response => {
920
            this.$modal.msgSuccess(this.$t('修改成功'));
921 922 923 924 925 926 927
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
        createCustomer(this.form).then(response => {
928
          this.$modal.msgSuccess(this.$t('新增成功'));
929 930 931 932 933 934 935 936
          this.open = false;
          this.getList();
        });
      });
    }
  }
};
</script>