index.vue 5.98 KB
Newer Older
1 2 3 4 5 6 7
<template>
  <div>
    <el-dialog
      append-to-body
      title="客户跟进"
      :visible.sync="customerFollow.dialogVisible"
      :close-on-click-modal="false"
我在何方's avatar
我在何方 committed
8
      :before-close="customerFollowClose"
9
      width="680px">
我在何方's avatar
我在何方 committed
10
      <el-form ref="customerFollowForm" :model="form" label-width="80px">
11 12 13
        <el-row :gutter="10">
          <el-col>
            <el-form-item label="跟进类型" required>
我在何方's avatar
我在何方 committed
14
              <dict-selector ref="dictTag" form-type="radio" v-model="form.followType" :type="DICT_TYPE.CUSTOMER_FOLLOW_TYPE"></dict-selector>
15 16 17 18
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="跟进时间" required>
我在何方's avatar
我在何方 committed
19
              <el-date-picker v-model="form.followTime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择跟进时间"></el-date-picker>
20 21 22 23
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="联系人" required>
我在何方's avatar
我在何方 committed
24
              <el-select v-model="form.contactName" placeholder="请选择">
25 26 27 28 29 30 31 32 33 34 35
                <el-option
                  v-for="(item, index) in customerContactsList"
                  :key="index"
                  :label="item.name"
                  :value="item.name">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="跟进业务" required>
我在何方's avatar
我在何方 committed
36
              <el-select v-model="form.followUserId" placeholder="请选择">
37 38 39 40 41 42 43 44 45 46 47
                <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">
            <el-form-item label="跟进方式" required>
我在何方's avatar
我在何方 committed
48
              <dict-selector ref='dictMethod' v-model="form.followMethod" :type="DICT_TYPE.CUSTOMER_FOLLOW_METHOD"></dict-selector>
49 50 51 52
            </el-form-item>
          </el-col>
          <el-col>
            <el-form-item label="客户反馈" required>
我在何方's avatar
我在何方 committed
53
              <el-input type="textarea" v-model="form.feedback"></el-input>
54 55 56 57
            </el-form-item>
          </el-col>
          <el-col>
            <el-form-item label="处理结果" required>
我在何方's avatar
我在何方 committed
58
              <el-input type="textarea" v-model="form.result"></el-input>
59 60 61 62 63
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <span slot="footer" class="dialog-footer">
我在何方's avatar
我在何方 committed
64
        <el-button @click="customerFollowClose">取 消</el-button>
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
        <el-button type="primary" @click="customerFollowSubmit">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import {createCustomerFollow, getCustomerFollowPage} from "@/api/ecw/customerFollow"
import { DICT_TYPE, getDictDataLabel } from '@/utils/dict'
import { getCustomerContactsListByCustomer } from '@/api/ecw/customerContacts'
import {listServiceUser} from "@/api/system/user"
import { parseTime } from '@/utils/ruoyi'
export default {
  /**
   * 客户跟进
   * 客户投诉跟进
   */
  name: "CustomerFollow",
  props: {
    /**
     * 如果是客户投诉跟进,则id为客户投诉id;如果是客户跟进,则id为客户id
     */
    id: Number,
    customerId: Number,
  },
  data() {
    return {
      DICT_TYPE,
      getDictDataLabel,
      parseTime,
      customerFollowList: [],
      serviceUserList: [],
      customerContactsList: [],
我在何方's avatar
我在何方 committed
98
      customerFollow:{
99 100
        dialogVisible: false,
      },
我在何方's avatar
我在何方 committed
101
      form: {}
102 103 104 105
    }
  },

  created() {
我在何方's avatar
我在何方 committed
106
    // this.resetCustomerFollowForm()
107 108
    if (!!this.customerId) getCustomerContactsListByCustomer({customerId: this.customerId}).then(r => {
      this.customerContactsList = r.data
我在何方's avatar
我在何方 committed
109
      // this.$set(form, 'customerId', this.customerId)
我在何方's avatar
我在何方 committed
110
      // this.customerFollow.form.customerId = this.customerId
111 112 113 114 115 116 117
    })
    listServiceUser().then(r => {
      this.serviceUserList = r.data
    })
  },
  methods: {
    customerFollowSubmit() {
我在何方's avatar
我在何方 committed
118
      console.log(this.form)
119 120 121 122
      this.$refs["customerFollowForm"].validate(valid => {
        if (!valid) {
          return
        }
我在何方's avatar
我在何方 committed
123
       if(!this.form.followType){
我在何方's avatar
我在何方 committed
124 125 126
          this.$modal.msgError("请选择跟进类型");
          return
        }
我在何方's avatar
我在何方 committed
127
        if(!this.form.followTime){
我在何方's avatar
我在何方 committed
128 129 130
          this.$modal.msgError("请选择跟进时间");
          return
        }
我在何方's avatar
我在何方 committed
131
        if(!this.form.contactName){
我在何方's avatar
我在何方 committed
132 133 134
          this.$modal.msgError("请选择联系人");
          return
        }
我在何方's avatar
我在何方 committed
135
        if(!this.form.followUserId){
我在何方's avatar
我在何方 committed
136 137 138
          this.$modal.msgError("请选择跟进业务");
          return
        }
我在何方's avatar
我在何方 committed
139
        if(!this.form.followMethod){
我在何方's avatar
我在何方 committed
140 141 142
          this.$modal.msgError("请选择跟进方式");
          return
        }
我在何方's avatar
我在何方 committed
143
        if(!this.form.feedback){
我在何方's avatar
我在何方 committed
144 145 146
          this.$modal.msgError("请输入客户反馈");
          return
        }
我在何方's avatar
我在何方 committed
147
        if(!this.form.result){
我在何方's avatar
我在何方 committed
148 149 150
          this.$modal.msgError("请输入处理结果");
          return
        }
我在何方's avatar
我在何方 committed
151 152 153
        this.$set(this.form, 'customerId', this.customerId)
        createCustomerFollow(this.form).then(r => {
          this.customerFollowClose()
154 155 156
        })
      })
    },
我在何方's avatar
我在何方 committed
157 158 159 160
    customerFollowClose(){
      this.resetCustomerFollowForm()
      this.customerFollow.dialogVisible = false
    },
161
    resetCustomerFollowForm() {
我在何方's avatar
我在何方 committed
162
      var form = {
我在何方's avatar
我在何方 committed
163
        "bizId":this.id,
164 165 166 167 168 169 170 171
        "contactName": undefined,
        "feedback": undefined,
        "followMethod": undefined,
        "followTime": undefined,
        "followType": undefined,
        "followUserId": undefined,
        "result": undefined
      }
我在何方's avatar
我在何方 committed
172 173 174
      this.form = Object.assign({},form)
      this.$refs.dictTag.changeValue(this.form.followType);
       this.$refs.dictMethod.changeValue(this.form.followMethod);
175 176 177 178 179
    },

  },
  watch:{
    customerId(val){
我在何方's avatar
我在何方 committed
180
      this.form.bizId = val;
181 182 183 184 185 186 187 188 189 190 191
      if (!!this.customerId) getCustomerContactsListByCustomer({customerId: this.customerId}).then(r => {
        this.customerContactsList = r.data
      })
    }
  }
}
</script>

<style scoped>

</style>