index.vue 16.8 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>
88 89
      <el-table-column :label="$t('客户名称')" align="center" prop="name" >
        <template v-slot="{row}">
90
          <p style="display:inline-block;white-space: pre-wrap;">{{$l(row, 'name')}}</p>
91 92
        </template>
      </el-table-column>
dcy's avatar
dcy committed
93
      <el-table-column :label="$t('客户等级')" align="center" prop="vipLevelNameZh">
94 95 96 97
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.CUSTOMER_LEVEL" :value="scope.row.level" />
        </template>
      </el-table-column>
邓春圆's avatar
邓春圆 committed
98
      <el-table-column :label="$t('信用等级')" :prop="isChinese ? 'creditLevelNameZh' : 'creditLevelNameEn' "></el-table-column>
dcy's avatar
dcy committed
99
      <el-table-column :label="$t('客户状态')" align="center" prop="status">
100 101 102 103
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.CUSTOMER_STATUS" :value="scope.row.status" />
        </template>
      </el-table-column>
dcy's avatar
dcy committed
104
      <el-table-column :label="$t('主联系人')" prop="defaultContactName"></el-table-column>
dcy's avatar
dcy committed
105 106 107 108 109
      <el-table-column :label="$t('主联系方式')" prop="defaultContactPhone">
        <template v-slot="{row}">
          +{{row.defaultContactPhone}}
        </template>
      </el-table-column>
dcy's avatar
dcy committed
110
      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" width="180">
111 112 113 114
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
115
      <el-table-column :label="$t('预计入公海时间')" align="center" prop="createTime" width="180">
116
        <template  v-slot = {row}>
117
          <span>{{ parseTime(row.estimateEnterOpenSeaTime )  }}</span>
118 119
        </template>
      </el-table-column>
邓春圆's avatar
邓春圆 committed
120
      <el-table-column :label="$t('客户经理')" align="center" prop="customerServiceName">
121
      </el-table-column>
dcy's avatar
dcy committed
122 123
      <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">
124 125
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)"
邓春圆's avatar
邓春圆 committed
126
                     v-hasPermi="['ecw:customer:my-query']">{{$t('查看')}}</el-button>
127
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
邓春圆's avatar
邓春圆 committed
128 129
                     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
130
          <el-button size="mini" type="text" icon="el-icon-user"
邓春圆's avatar
邓春圆 committed
131
                     v-hasPermi="['ecw:customer:my-customer-complaint']" @click="complaint(scope.row)">{{$t('客诉')}}</el-button>
132
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
邓春圆's avatar
邓春圆 committed
133 134
                     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>
135 136 137 138 139 140 141 142
        </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>
143
    <transfer-customer :show.sync="show" :customer-ids.sync="selectCustomerList"></transfer-customer>
144 145 146 147 148
  </div>

</template>

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

437 438 439
  }
};
</script>