index.vue 16.6 KB
Newer Older
1 2 3 4 5 6

<template>
  <div class="app-container">

    <!-- 搜索工作栏 -->
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
dcy's avatar
dcy committed
7
      <el-form-item :label="$t('客户编号')" prop="number">
8
        <el-input v-model="queryParams.number" :placeholder="$t('请输入客户编号')" clearable @keyup.enter.native="handleQuery"/>
9
      </el-form-item>
dcy's avatar
dcy committed
10
      <el-form-item :label="$t('客户名称')" prop="name">
11
        <el-input v-model="queryParams.name" :placeholder="$t('请输入客户名称')" clearable @keyup.enter.native="handleQuery"/>
12
      </el-form-item>
dcy's avatar
dcy committed
13
      <el-form-item :label="$t('客户等级')" prop="level">
14
        <el-select clearable  v-model="queryParams.level" :placeholder="$t('请选择客户等级')" clearable size="small">
15
          <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_LEVEL)"
16
                     :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value"/>
17 18
        </el-select>
      </el-form-item>
dcy's avatar
dcy committed
19 20
      <el-form-item :label="$t('联系方式')">
        <el-input :placeholder="$t('请输入联系方式')" v-model="queryParams.defaultContactPhone"></el-input>
21
      </el-form-item>
dcy's avatar
dcy committed
22
      <el-form-item :label="$t('客户类别')" prop="level">
dcy's avatar
dcy committed
23
        <dict-selector :type="DICT_TYPE.CUSTOMER_TYPE"  v-model="queryParams.type"></dict-selector>
24
      </el-form-item>
dcy's avatar
dcy committed
25 26
      <el-form-item :label="$t('客户来源')" prop="source">
        <el-select clearable  v-model="queryParams.source" :placeholder="$t('请选择客户来源')" clearable size="small">
27
          <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_SOURCE)"
28
                     :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value"/>
29 30
        </el-select>
      </el-form-item>
dcy's avatar
dcy committed
31
      <el-form-item :label="$t('国家')" prop="source">
dcy's avatar
dcy committed
32
        <el-select clearable  v-model="queryParams.country" :placeholder="$t('请选择国家')">
33
          <el-option v-for="dict in countryList"
34
                     :key="dict.id" :label=" isChinese ? dict.nameZh : dict.nameEn " :value="parseInt(dict.id)" />
35 36
        </el-select>
      </el-form-item>
dcy's avatar
dcy committed
37 38
      <el-form-item :label="$t('客户状态')" prop="status">
        <el-select clearable  v-model="queryParams.status" :placeholder="$t('请选择客户状态')" clearable size="small">
39
          <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_STATUS)"
40
                     :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="dict.value"/>
41 42
        </el-select>
      </el-form-item>
dcy's avatar
dcy committed
43
      <el-form-item :label="$t('创建时间')">
44 45
        <el-date-picker clearable  v-model="dateRangeCreateTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss"
                        type="datetimerange" range-separator="-" :start-placeholder="$t('开始日期')" :end-placeholder="$t('结束日期')" />
46
      </el-form-item>
47

dcy's avatar
dcy committed
48
      <el-form-item :label="$t('信用等级')" prop="department">
dcy's avatar
dcy committed
49
        <el-select clearable  v-model="queryParams.creditLevel" >
50
          <el-option  v-for="(item,index) in creditList" :label="isChinese ? item.nameZh : item.nameEn" :key="index" :value="item.id" ></el-option>
51 52
        </el-select>
      </el-form-item>
53 54 55
      <el-form-item  :label="$t('市场获客')" prop="department">
        <dict-selector clearable  :type="DICT_TYPE.ECW_CUSTOMER_RESOURCE_TYPE" v-model="queryParams.marketType" formatter="number"></dict-selector>
      </el-form-item>
56
      <el-form-item>
dcy's avatar
dcy committed
57 58
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">{{$t('搜索')}}</el-button>
        <el-button icon="el-icon-refresh" @click="resetQuery">{{$t('重置')}}</el-button>
59 60 61 62 63 64 65
      </el-form-item>
    </el-form>

    <!-- 操作工具栏 -->
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
邓春圆's avatar
邓春圆 committed
66
                   v-hasPermi="['ecw:customer:my-create']">{{$t('新增')}}</el-button>
67 68 69
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" :loading="exportLoading"
邓春圆's avatar
邓春圆 committed
70
                   v-hasPermi="['ecw:customer:my-export']">{{$t('导出')}}</el-button>
71 72 73 74 75
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
76 77 78 79 80
    <el-table ref="multipleTable" v-loading="loading" :data="list" @selection-change="handleSelectionChange">
      <el-table-column
        type="selection"
        width="55">
      </el-table-column>
81 82 83 84 85 86 87
      <el-table-column :label="$t('客户编号')" align="center" prop="number" >
        <template v-slot="{row}">
          <router-link :to="'/customer/query/' + row.id">
            {{row.number}}
          </router-link>
        </template>
      </el-table-column>
dcy's avatar
dcy committed
88 89
      <el-table-column :label="$t('客户名称')" align="center" prop="name" />
      <el-table-column :label="$t('客户等级')" align="center" prop="vipLevelNameZh">
90 91 92 93
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.CUSTOMER_LEVEL" :value="scope.row.level" />
        </template>
      </el-table-column>
邓春圆's avatar
邓春圆 committed
94
      <el-table-column :label="$t('信用等级')" :prop="isChinese ? 'creditLevelNameZh' : 'creditLevelNameEn' "></el-table-column>
dcy's avatar
dcy committed
95
      <el-table-column :label="$t('客户状态')" align="center" prop="status">
96 97 98 99
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.CUSTOMER_STATUS" :value="scope.row.status" />
        </template>
      </el-table-column>
dcy's avatar
dcy committed
100
      <el-table-column :label="$t('主联系人')" prop="defaultContactName"></el-table-column>
dcy's avatar
dcy committed
101 102 103 104 105
      <el-table-column :label="$t('主联系方式')" prop="defaultContactPhone">
        <template v-slot="{row}">
          +{{row.defaultContactPhone}}
        </template>
      </el-table-column>
dcy's avatar
dcy committed
106
      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" width="180">
107 108 109 110
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
111
      <el-table-column :label="$t('预计入公海时间')" align="center" prop="createTime" width="180">
112
        <template  v-slot = {row}>
113
          <span>{{ parseTime(row.estimateEnterOpenSeaTime )  }}</span>
114 115
        </template>
      </el-table-column>
邓春圆's avatar
邓春圆 committed
116
      <el-table-column :label="$t('客户经理')" align="center" prop="customerServiceName">
117
      </el-table-column>
dcy's avatar
dcy committed
118 119
      <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">
120 121
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)"
邓春圆's avatar
邓春圆 committed
122
                     v-hasPermi="['ecw:customer:my-query']">{{$t('查看')}}</el-button>
123
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
邓春圆's avatar
邓春圆 committed
124 125
                     v-hasPermi="['ecw:customer:my-update']">{{$t('修改')}}</el-button>
          <el-button size="mini" v-hasPermi="['ecw:customer:my-follow-up']" type="text" icon="el-icon-collection" @click="followUp(scope.row)">{{$t('跟进')}}</el-button>
dcy's avatar
dcy committed
126
          <el-button size="mini" type="text" icon="el-icon-user"
邓春圆's avatar
邓春圆 committed
127
                     v-hasPermi="['ecw:customer:my-customer-complaint']" @click="complaint(scope.row)">{{$t('客诉')}}</el-button>
128
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
邓春圆's avatar
邓春圆 committed
129 130
                     v-hasPermi="['ecw:customer:my-delete']">{{$t('删除')}}</el-button>
          <el-button v-has-permi="['ecw:customer:my-postpone']" :disabled="scope.row.isInOpenSea" size="mini" type="text" icon="el-icon-user" @click="delay(scope.row)">{{$t('延期')}}</el-button>
131 132 133 134 135 136 137 138
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
                @pagination="getList"/>
    <customer-follow-list ref="customerFollowList" :customer-id="customerId" :id="customerId"></customer-follow-list>
    <customer-complaints ref="customerComplaint" :customer-id.sync="customerId"></customer-complaints>
139
    <transfer-customer :show.sync="show" :customer-ids.sync="selectCustomerList"></transfer-customer>
140 141 142 143 144
  </div>

</template>

<script>
145 146 147 148 149 150 151
import {
  createCustomer,
  updateCustomer,
  deleteCustomer,
  getMyCustomerService,
  mineExporteExcel
} from "@/api/ecw/customer";
152 153 154 155
import { getDictDatas, DICT_TYPE } from '@/utils/dict';
import upload from '@/components/ImageUpload'
import customerFollowList from "@/components/CustomerFollowList";
import customerComplaints from "@/components/customerComplaints";
156 157 158 159
import {listServiceUser} from "@/api/system/user";
import {getCountryListAll} from "@/api/ecw/country";
import {getCreditPage} from "@/api/customer/credit";
import transferCustomer from "@/views/ecw/customer/transferCustomer";
160
export default {
161
    name: "EcwMycustomerserviceIndex",
162 163 164
  components: {
    upload,
    customerFollowList,
165 166
    customerComplaints,
    transferCustomer
167
  },
邓春圆's avatar
邓春圆 committed
168 169 170 171 172
  computed:{
    isChinese(){
      return this.$i18n.locale === 'zh_CN'
    },
  },
173 174
  data() {
    return {
175 176 177 178
      show:false,
      creditList:[],
      countryList:[],
      customerServiceList:[],
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
      getDictDatas,
      DICT_TYPE,
      // 遮罩层
      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
207 208
        creditLevel:null,
        country:null,
209
        marketType: null,
210 211 212 213 214
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
dcy's avatar
dcy committed
215 216 217 218
        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
219
        // createTime: [{ required: true, message: this.$t("创建时间不能为空"), trigger: "blur" }],
dcy's avatar
dcy committed
220 221 222
        source: [{ required: true, message: this.$t('客户来源不能为空'), trigger: "blur" }],
        status: [{ required: true, message: this.$t('客户状态不能为空'), trigger: "blur" }],
        founder: [{ required: true, message: this.$t('创建人不能为空'), trigger: "blur" }],
223 224 225 226 227
      },
      // 网点
      nodeList: [],
      showLine: false,
      customerId:undefined,
228
      selectCustomerList:[],
229 230
    };
  },
231 232 233
  activated  () {
    this.getList();
  },
234 235 236 237 238
  created() {
    this.getList();
    // getNodeList().then(r => {
    //   this.nodeList = r.data
    // })
239 240 241 242 243 244 245 246 247
    getCreditPage({page:1,rows:999}).then(r => {
      this.creditList = r.data.list
    })
    listServiceUser().then(r=>{
      this.customerServiceList = r.data;
    })
    getCountryListAll().then(r => {
      this.countryList = r.data
    })
248 249
  },
  methods: {
250 251 252
    handleSelectionChange(val){
      this.selectCustomerList = val.map(i => i.id);
    },
我在何方's avatar
我在何方 committed
253 254 255
    delay(row){
      this.$router.push({path:'/customer/delay',query:{id:row.id}})
    },
256 257
    countryFormatter(row, column, cellValue) {
      const country = this.countryList.find((e) => e.id === cellValue)
邓春圆's avatar
邓春圆 committed
258
      return this.isChinese ?  country?.nameZh : country?.nameEn
259
    },
260 261 262 263 264
    /** 查询列表 */
    getList() {
      this.loading = true;
      // 处理查询参数
      let params = {...this.queryParams};
265
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime', false);
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 297 298 299 300 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
      // 执行查询
      getMyCustomerService(params).then(response => {
        this.list = response.data.list;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 取消按钮 */
    cancel() {
      this.open = false;
      this.reset();
    },
    /** 表单重置 */
    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,
        customerContacts: [],
        customerLines: [],
        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");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRangeCreateTime = [];
      this.resetForm("queryForm");
dcy's avatar
dcy committed
328 329 330 331 332 333 334 335 336 337 338 339 340
      this.queryParams = {
        pageNo: 1,
        pageSize: 10,
        number: null,
        name: null,
        level: null,
        source: null,
        customerService: null,
        status: null,
        department: null,
        creditLevel:null,
        country:null,
      }
341 342 343 344
      this.handleQuery();
    },
    /** 新增按钮操作 */
    handleAdd() {
345
      this.$router.push({path:'/customer/add-edit/0',query:{isCustomerServiceConfirmed:true,}})
346 347
      // this.reset();
      // this.open = true;
Marcus's avatar
Marcus committed
348
      // this.title = this.$t("添加客户");
349 350 351 352 353 354 355 356 357 358 359 360 361
    },
    /** 查看按钮操作 */
    handleView(row) {
      this.$router.push('/customer/query/' + row.id)
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.$router.push('/customer/edit/' + row.id)
      // this.reset();
      // const id = row.id;
      // getCustomer(id).then(response => {
      //   this.form = { ...this.form, ...response.data };
      //   this.open = true;
Marcus's avatar
Marcus committed
362
      //   this.title = this.$t("修改客户");
363 364 365 366 367 368 369 370 371 372 373
      // });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (!valid) {
          // return;
        }
        // 修改的提交
        if (this.form.id != null) {
          updateCustomer(this.form).then(response => {
dcy's avatar
dcy committed
374
            this.$modal.msgSuccess(this.$t('修改成功'));
375 376 377 378 379 380 381
            this.open = false;
            this.getList();
          });
          return;
        }
        // 添加的提交
        createCustomer(this.form).then(response => {
dcy's avatar
dcy committed
382
          this.$modal.msgSuccess(this.$t('新增成功'));
383 384 385 386 387 388 389 390
          this.open = false;
          this.getList();
        });
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const id = row.id;
391
      this.$modal.confirm(this.$t('是否确认删除客户编号为"') + row.number + this.$t('"的数据项?')).then(function() {
392 393 394
        return deleteCustomer(id);
      }).then(() => {
        this.getList();
dcy's avatar
dcy committed
395
        this.$modal.msgSuccess(this.$t('删除成功'));
396 397 398 399 400 401 402 403 404 405
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      // 处理查询参数
      let params = {...this.queryParams};
      params.pageNo = undefined;
      params.pageSize = undefined;
      this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
      // 执行导出
406
      this.$modal.confirm(this.$t('是否确认导出我的客户数据项?')).then(() => {
407
        this.exportLoading = true;
408
        return mineExporteExcel(params);
409
      }).then(response => {
dcy's avatar
dcy committed
410
        this.$download.excel(response, `${this.$t('我的客户列表')}.xls`);
411 412 413 414 415 416 417
        this.exportLoading = false;
      }).catch(() => {});
    },
    followUp(row){
      this.customerId = row.id
      this.$refs['customerFollowList'].customerFollow.dialogVisible = true;
    },
dcy's avatar
dcy committed
418
    complaint(row){
419 420 421 422 423
      this.customerId = row.id;
      this.$nextTick(()=>{
        this.$refs['customerComplaint'].handleAdd()
      })
    }
424 425 426 427 428 429 430 431 432
  },
  watch:{
    selectCustomerList(val){
      if(val.length === 0){
        this.getList()
        this.$refs.multipleTable.clearSelection();
      }
    },

433 434 435
  }
};
</script>