customerFollow.vue 15.7 KB
Newer Older
yujinyao's avatar
yujinyao committed
1
<template>
yujinyao's avatar
yujinyao committed
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
<div class="customer-follow">
  <el-dialog  append-to-body :title="$t('客户跟进')" :visible.sync="customerFollow.dialogVisible" :before-close="customerFollowClose" width="900px">
    <el-form ref="customerFollowForm" :model="form" label-width="120px">
      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item :label="$t('编号')" prop="number">
            <el-input v-model="form.number" :placeholder="$t('请输入编号')" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('跟进状态')">
            <el-select v-model="form.status" :placeholder="$t('请选择')" disabled>
              <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_STATUS)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('客户编号')">
            <el-input v-model="form.customerId" :placeholder="$t('请输入客户编号')" disabled />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('跟进类型')" required>
25
            <el-select v-model="form.followType" clearable :placeholder="$t('请选择')" @change="handleFollowType" :disabled="isView">
yujinyao's avatar
yujinyao committed
26 27 28 29
              <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_TYPE)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
            </el-select>
          </el-form-item>
        </el-col>
余金瑶's avatar
余金瑶 committed
30 31
        <!--
        <el-col :span="13">
yujinyao's avatar
yujinyao committed
32 33 34 35
          <el-form-item :label="$t('报价单')">
            <el-input v-model="form.offerId" :placeholder="$t('请输入报价单')" disabled />
          </el-form-item>
        </el-col>
余金瑶's avatar
余金瑶 committed
36
        -->
yujinyao's avatar
yujinyao committed
37 38
        <el-col :span="12">
          <el-form-item :label="$t('跟进时间')" required>
39
            <el-date-picker v-model="form.followTime" clearable type="datetime" :placeholder="$t('请选择')" :disabled="isView" />
yujinyao's avatar
yujinyao committed
40 41 42 43
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('联系人')" required>
44 45
            <el-select v-model="form.contactId" clearable :placeholder="$t('请选择')" :disabled="isView" @change="changeContactUser">
              <el-option v-for="(item, index) in customerContactsList" :key="index" :label="item.name" :value="item.id">
yujinyao's avatar
yujinyao committed
46 47 48 49 50 51
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('客户经理')" required>
52
            <el-select v-model="form.followUserId" clearable :placeholder="$t('请选择')" :disabled="isView">
yujinyao's avatar
yujinyao committed
53 54 55 56 57 58
              <el-option v-for="item in serviceUserList" :key="item.id" :label="item.nickname" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
59 60
          <el-form-item :label="$t('跟进方式')" required>
            <dict-selector ref="dictMethod" v-model="form.followMethod" clearable :disabled="isView" :type="DICT_TYPE.CUSTOMER_FOLLOWUP_METHOD"></dict-selector>
yujinyao's avatar
yujinyao committed
61 62 63 64
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('上一级跟进单')" prop="parentNumber">
余金瑶's avatar
余金瑶 committed
65
            <el-input v-model="form.parentNumber" :placeholder="$t('请输入上一级跟进单')" disabled />
yujinyao's avatar
yujinyao committed
66 67 68 69
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('跟进结果')" prop="followMethod">
70
            <el-select v-model="form.resultType" clearable :placeholder="$t('请选择')" :disabled="isView">
yujinyao's avatar
yujinyao committed
71 72 73 74
              <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_FOLLOWUP_RESULT_TYPE)" :key="dict.value" :label="isChinese ? dict.label : dict.labelEn" :value="parseInt(dict.value)" />
            </el-select>
          </el-form-item>
        </el-col>
75
        <el-col :span="20">
yujinyao's avatar
yujinyao committed
76
          <el-form-item :label="$t('目的')" prop="purpose">
77
            <el-input type="textarea" :rows="2" v-model="form.purpose" :placeholder="$t('请输入目的')" maxlength="200" show-word-limit :disabled="isView" />
yujinyao's avatar
yujinyao committed
78 79 80 81
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item :label="$t('跟进情况')">
82
            <el-input rows="3" class="text_style" type="textarea" v-model="form.feedback" maxlength="500" show-word-limit :disabled="isView" />
yujinyao's avatar
yujinyao committed
83 84 85 86
          </el-form-item>
        </el-col>
        <el-col :span="20">
          <el-form-item :label="$t('附件')" prop="attatchment">
87
            <FileUpload :limit="5" :isShowTip="true" v-model="form.attatchment" :fileType="fileType" :disabled="isView" />
yujinyao's avatar
yujinyao committed
88 89
          </el-form-item>
        </el-col>
90
        <el-col :span="13">
yujinyao's avatar
yujinyao committed
91
          <el-form-item :label="$t('下次跟进时间')">
92
            <el-date-picker v-model="form.nextTime" type="datetime" :placeholder="$t('请选择')" :disabled="isView" @change="changeNextTime">
yujinyao's avatar
yujinyao committed
93 94 95
            </el-date-picker>
          </el-form-item>
        </el-col>
96 97
        <el-col :span="20">
          <el-form-item :label="$t('下一步计划')" prop="nextPlan">
98
            <el-input type="textarea" :rows="3" v-model="form.nextPlan" :placeholder="$t('请输入下一步计划')" maxlength="500" show-word-limit :disabled="isView" />
99
          </el-form-item>
100
        </el-col>
yujinyao's avatar
yujinyao committed
101 102
        <el-col :span="12">
          <el-form-item :label="$t('创建人')" prop="founder">
yujinyao's avatar
yujinyao committed
103
            <el-select v-model="form.creatorName" disabled :placeholder="$t('请选择')">
yujinyao's avatar
yujinyao committed
104 105 106 107 108 109 110
              <el-option v-for="item in allSimplList" :key="item.id" :label="item.nickname" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('创建时间')" prop="createTime">
yujinyao's avatar
yujinyao committed
111
            <el-date-picker v-model="form.createTime" type="datetime" disabled :placeholder="$t('请选择')">
yujinyao's avatar
yujinyao committed
112 113 114 115 116 117 118 119 120 121 122 123 124
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('最后更新人')">
            <el-select v-model="form.updaterName" disabled>
              <el-option v-for="item in allSimplList" :key="item.id" :label="item.nickname" :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('最后更新时间')">
yujinyao's avatar
yujinyao committed
125
            <el-date-picker v-model="form.updateTime" type="datetime" disabled :placeholder="$t('请选择')">
yujinyao's avatar
yujinyao committed
126 127 128 129 130
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
131 132 133 134
    <div slot="footer" class="dialog-footer" v-if="isView">
      <el-button type="warning" @click="customerFollowClose">{{$t('关 闭')}}</el-button>
    </div>
    <div slot="footer" class="dialog-footer" v-else>
yujinyao's avatar
yujinyao committed
135 136
      <el-button type="warning" @click="goBack">{{$t('返 回')}}</el-button>
      <el-button type="primary" @click="customerFollowSubmit(0)">{{$t('保 存')}}</el-button>
余金瑶's avatar
余金瑶 committed
137
      <el-button type="success" @click="customerFollowSubmit(1)" v-if="isEdit">{{$t('提交结果')}}</el-button>
yujinyao's avatar
yujinyao committed
138
    </div>
yujinyao's avatar
yujinyao committed
139
  </el-dialog>
yujinyao's avatar
yujinyao committed
140

141
  <customer-follow-select-offer  :customer-id="customerId" ref="customerFollowSelectOffer" @select="selectOffer" />
yujinyao's avatar
yujinyao committed
142 143

</div>
yujinyao's avatar
yujinyao committed
144 145 146
</template>

<script>
yujinyao's avatar
yujinyao committed
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
import {
  createCustomerFollow,
  getCustomerFollowPage,
  getCustomerFollowPage2,
  addCustomerFollow,
  getCustomerFollowList,
  editCustomerFollow
} from "@/api/ecw/customerFollow"
import { getOfferPage } from "@/api/ecw/offer"
import CustomerFollowSelectOffer from "./customerFollowSelectOffer";
import {
  DICT_TYPE,
  getDictDataLabel
} from '@/utils/dict'
import {
  getCustomerContactsListByCustomer
} from '@/api/ecw/customerContacts'
yujinyao's avatar
yujinyao committed
164 165 166 167 168
import {
  listAllSimpl,
  listServiceUser,
  listSimpleUsers,
} from "@/api/system/user";
yujinyao's avatar
yujinyao committed
169 170 171
import {
  parseTime
} from '@/utils/ruoyi'
172
import FileUpload from "@/components/FileUpload/fileUpload";
yujinyao's avatar
yujinyao committed
173
import {formatDate} from "@/utils/index";
yujinyao's avatar
yujinyao committed
174 175 176 177 178 179 180 181 182 183 184 185
export default {
  /**
   * 客户跟进
   * 客户投诉跟进
   */
  name: "CustomerFollow",
  props: {
    /**
     * 如果是客户投诉跟进,则id为客户投诉id;如果是客户跟进,则id为客户id
     */
    id: Number,
    customerId: Number,
yujinyao's avatar
yujinyao committed
186 187 188
    customerQuery: {
      type: Boolean,
      default: false
189 190
    },
    customerService: Number
yujinyao's avatar
yujinyao committed
191
  },
yujinyao's avatar
yujinyao committed
192 193 194 195
  components: {
    FileUpload,
    CustomerFollowSelectOffer
  },
yujinyao's avatar
yujinyao committed
196 197
  data() {
    return {
yujinyao's avatar
yujinyao committed
198
      fileType: ["doc", "xls", "ppt", "txt", "pdf", "png", "jpg", "jpeg"],
yujinyao's avatar
yujinyao committed
199 200 201 202 203 204 205 206 207 208
      DICT_TYPE,
      getDictDataLabel,
      parseTime,
      customerFollowList: [],
      serviceUserList: [],
      customerContactsList: [],

      customerFollow: {
        dialogVisible: false,
        form: {
yujinyao's avatar
yujinyao committed
209
          followType: '3'
yujinyao's avatar
yujinyao committed
210 211
        }
      },
yujinyao's avatar
yujinyao committed
212
      offerDialogVisible: true,
yujinyao's avatar
yujinyao committed
213
      form: {},
yujinyao's avatar
yujinyao committed
214 215 216
      pageNo: 1,
      pageSize: 10,
      total: 10,
yujinyao's avatar
yujinyao committed
217 218 219
      allSimplList: [],
      pickerOptions: {
        disabledDate(time) {
220 221
          return time.getTime() <= Date.now()
        },
yujinyao's avatar
yujinyao committed
222 223 224 225 226 227 228 229 230 231
      },
      isEdit: false,
      queryParams: {},
      followTime: [],
      nextTime: [],
      queryParams: {
        pageNo: 1,
        pageSize: 10
      },
      offerList: [],
232 233
      offerTotal: 0,
      isView: false
yujinyao's avatar
yujinyao committed
234 235 236
    }
  },
  computed: {
yujinyao's avatar
yujinyao committed
237
    isChinese() {
yujinyao's avatar
yujinyao committed
238 239 240 241
      return this.$i18n.locale === 'zh_CN'
    }
  },
  created() {
yujinyao's avatar
yujinyao committed
242
    this.init()
yujinyao's avatar
yujinyao committed
243 244 245 246 247 248 249 250
    // this.resetCustomerFollowForm()
    listServiceUser().then(r => {
      // console.log( r.data,'r.data跟进业务')
      this.serviceUserList = r.data
    })
    listAllSimpl().then((r) => {
      this.allSimplList = r.data;
    });
yujinyao's avatar
yujinyao committed
251 252
    // this.getCustomerFollowList()
    // this.reset()
yujinyao's avatar
yujinyao committed
253 254
  },
  methods: {
余金瑶's avatar
余金瑶 committed
255 256 257 258 259 260 261 262 263
    init() {
      if (!!this.customerId) getCustomerContactsListByCustomer({
        customerId: this.customerId
      }).then(r => {
        this.customerContactsList = r.data
        // this.form.customerId = this.customerId
        // this.form.bizId = this.id
      })
    },
yujinyao's avatar
yujinyao committed
264 265 266 267 268 269 270 271 272 273
    getOfferList() {
      getOfferPage(this.queryParams).then(response => {
        this.offerList = response.data.list;
        this.offerTotal = response.data.total;
      });
    },
    handleFollowType(val) {
      console.log(val)
      if (val == '2') {
        this.$refs['customerFollowSelectOffer'].offerDialogVisible = true
余金瑶's avatar
余金瑶 committed
274 275
      } else {
        this.form.offerId = undefined
yujinyao's avatar
yujinyao committed
276 277 278 279 280
      }
    },
    selectOffer(offerId) {
      this.form.offerId = offerId
    },
yujinyao's avatar
yujinyao committed
281 282 283
    reset() {
      this.form = {
        attatchment: undefined,
284
        contactId: undefined,
yujinyao's avatar
yujinyao committed
285
        contactName: undefined,
286
        contactPhone: undefined,
余金瑶's avatar
余金瑶 committed
287
        customerId: this.customerId,
yujinyao's avatar
yujinyao committed
288 289
        feedback: undefined,
        followMethod: undefined,
290
        followTime: new Date().getTime(),
yujinyao's avatar
yujinyao committed
291
        followType: undefined,
292
        followUserId: this.customerService,
yujinyao's avatar
yujinyao committed
293 294 295 296
        nextPlan: undefined,
        nextTime: undefined,
        number: undefined,
        offerId: undefined,
297
        parentId: undefined,
yujinyao's avatar
yujinyao committed
298 299 300 301
        parentNumber: undefined,
        purpose: undefined,
        resultType: undefined,
        status: undefined,
yujinyao's avatar
yujinyao committed
302
        creatorName: this.$store.getters.userId,
yujinyao's avatar
yujinyao committed
303
        createTime: new Date().getTime(),
yujinyao's avatar
yujinyao committed
304
        updaterName: this.$store.getters.userId,
yujinyao's avatar
yujinyao committed
305 306 307
        updateTime: new Date().getTime()
      };
    },
308 309 310 311 312 313 314 315 316 317
    changeNextTime(val) {
      if (val) {
        const curTime = new Date().getTime()
        const valTime = new Date(val).getTime()
        if (curTime > valTime) {
          this.form.nextTime = null
          this.$modal.msgError(this.$t("不能小于当前时间"))
        }
      }
    },
318 319 320 321 322 323 324 325 326 327 328 329 330 331
    changeContactUser(val) {
      if (val) {
        for(const item of this.customerContactsList) {
          if (item.id == val) {
            this.form.contactName = item.name
            // this.form.contactPhone = `+${item.areaCode}${item.phoneNew}`
            break
          }
        }
      } else {
        this.form.contactName = null
        this.form.contactPhone = null
      }
    },
yujinyao's avatar
yujinyao committed
332 333 334 335 336 337
    customerFollowSubmit(status) {
      console.log(this.form)
      this.$refs["customerFollowForm"].validate(valid => {
        if (!valid) {
          return
        }
yujinyao's avatar
yujinyao committed
338
        if (!this.form.followType) {
余金瑶's avatar
余金瑶 committed
339
          this.$modal.msgError(this.$t("请选择跟进类型"));
yujinyao's avatar
yujinyao committed
340 341
          return
        }
yujinyao's avatar
yujinyao committed
342
        if (!this.form.followTime) {
yujinyao's avatar
yujinyao committed
343 344 345
          this.$modal.msgError(this.$t('请选择跟进时间'));
          return
        }
yujinyao's avatar
yujinyao committed
346
        if (!this.form.contactName) {
yujinyao's avatar
yujinyao committed
347 348 349
          this.$modal.msgError(this.$t('请选择联系人'));
          return
        }
yujinyao's avatar
yujinyao committed
350
        if (!this.form.followUserId) {
余金瑶's avatar
余金瑶 committed
351
          this.$modal.msgError(this.$t('请选择客户经理'));
yujinyao's avatar
yujinyao committed
352 353
          return
        }
yujinyao's avatar
yujinyao committed
354
        if (!this.form.followMethod) {
yujinyao's avatar
yujinyao committed
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
          this.$modal.msgError(this.$t('请选择跟进方式'));
          return
        }

        if (status == 0) {
          this.saveSubmitData(status)
        } else {
          this.$confirm(this.$t('提交后无法修改'), this.$t('提示'), {
            confirmButtonText: this.$t('确定'),
            cancelButtonText: this.$t('取消'),
            type: 'warning'
          }).then(() => {
            this.saveSubmitData(status)
          })
        }
      })
    },
    saveSubmitData(status) {
yujinyao's avatar
yujinyao committed
373 374
      let func = this.form.id ? editCustomerFollow : addCustomerFollow
      func({
yujinyao's avatar
yujinyao committed
375
        ...this.form,
yujinyao's avatar
yujinyao committed
376 377
        followTime: this.form.followTime ? formatDate(this.form.followTime) : undefined,
        nextTime: this.form.nextTime ? formatDate(this.form.nextTime) : undefined,
yujinyao's avatar
yujinyao committed
378 379
        status
      }).then(r => {
yujinyao's avatar
yujinyao committed
380
        this.$message.success(this.$t("操作成功"))
余金瑶's avatar
余金瑶 committed
381
        this.$emit('refresh')
yujinyao's avatar
yujinyao committed
382 383 384 385 386 387 388 389 390 391 392 393
        this.customerFollowClose()
      })
    },
    goBack() {
      this.$confirm(this.$t('是否确认不保存信息'), this.$t('提示'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
        type: 'warning'
      }).then(() => {
        this.customerFollowClose()
      })
    },
yujinyao's avatar
yujinyao committed
394
    customerFollowClose() {
余金瑶's avatar
余金瑶 committed
395
      // this.resetCustomerFollowForm()
yujinyao's avatar
yujinyao committed
396 397 398 399 400 401 402
      this.customerFollow.dialogVisible = false
    },
    resetCustomerFollowForm() {
      this.reset()
      // this.$refs.dictType.changeValue(this.customerFollow.form.followType);
      this.$refs.dictMethod.changeValue(this.customerFollow.form.followMethod);
    },
yujinyao's avatar
yujinyao committed
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
    handleQuery() {
      this.pageNo = 1
      this.followTime = []
      this.getCustomerFollowList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams = {
        followType: null,
        followMethod: null,
        resultType: null,
        status: null
      };
      this.handleQuery();
    },
yujinyao's avatar
yujinyao committed
419
    getCustomerFollowList() {
yujinyao's avatar
yujinyao committed
420 421 422 423 424 425 426 427
      if (this.customerQuery) {
        getCustomerFollowList({
          customerId: this.customerId,
          pageNo: this.pageNo,
          pageSize: this.pageSize
        }).then(r => {
          this.$message.info(this.$t("操作成功"))
          this.$emit('refresh')
yujinyao's avatar
yujinyao committed
428
        })
yujinyao's avatar
yujinyao committed
429 430 431 432 433 434 435 436
      } else {
        getCustomerFollowPage2({
          bizId: this.id,
          followType: 3,
          pageNo: this.pageNo,
          pageSize: this.pageSize
        }).then(r => {
          this.$emit('refresh')
yujinyao's avatar
yujinyao committed
437 438 439
        })
      }
    },
440 441 442 443 444
    handleView(row) {
      this.isView = true
      this.form = row
      this.customerFollow.dialogVisible = true
    },
yujinyao's avatar
yujinyao committed
445
    handleAdd() {
446
      this.isView = false
yujinyao's avatar
yujinyao committed
447 448 449 450 451
      this.isEdit = false
      this.customerFollow.dialogVisible = true
      this.reset()
    },
    handleUpdate(row, flag) {
452
      this.isView = false
yujinyao's avatar
yujinyao committed
453 454
      this.isEdit = flag
      this.customerFollow.dialogVisible = true
余金瑶's avatar
余金瑶 committed
455 456 457 458 459 460 461 462
      if (flag) {
        this.form = row
      } else {
        this.form = {
          ...row,
          parentNumber: row.number
        }
      }
yujinyao's avatar
yujinyao committed
463 464 465 466 467 468
    },
  }
}
</script>

<style scoped>
yujinyao's avatar
yujinyao committed
469
.text_style{
余金瑶's avatar
余金瑶 committed
470
  white-space: pre-wrap;
yujinyao's avatar
yujinyao committed
471
}
yujinyao's avatar
yujinyao committed
472
</style>