addPotentialCustom.vue 5.79 KB
Newer Older
邓春圆's avatar
邓春圆 committed
1 2
<template>
 <div>
邓春圆's avatar
邓春圆 committed
3
   <el-dialog :title="$t('新建潜在客户信息')" :visible.sync="dialogTableVisible">
邓春圆's avatar
邓春圆 committed
4
    <el-form ref="form" :rules="rules" :model="form" label-width="100px"  style="padding: 0 20px;">
邓春圆's avatar
邓春圆 committed
5 6
      <el-form-item prop="name" :label="$t('客户姓名')">
        <el-input v-model="form.name"  :placeholder="$t('请输入客户姓名')"></el-input>
邓春圆's avatar
邓春圆 committed
7
      </el-form-item>
邓春圆's avatar
邓春圆 committed
8
      <el-form-item required :label="$t('联系方式')" >
邓春圆's avatar
邓春圆 committed
9 10 11 12 13 14 15 16 17 18 19 20 21
       <el-row :gutter="20">
         <el-col :span="4" >
           <el-form-item  prop="customerContacts[0].areaCode" >
             <area-code-selector v-model="form.customerContacts['0'].areaCode" />
           </el-form-item>
         </el-col>
         <el-col :span="10">
           <el-form-item prop="customerContacts[0].phoneNew">
             <el-input  style="width:100%;" v-model="form.customerContacts[0].phoneNew"  maxlength="11" :placeholder="$t('请输入联系方式')" />
           </el-form-item>
         </el-col>
       </el-row>
      </el-form-item>
邓春圆's avatar
邓春圆 committed
22
      <el-form-item prop="source" :label="$t('客户来源')">
邓春圆's avatar
邓春圆 committed
23 24 25 26 27
        <el-select  v-model="form.source" :placeholder="$t('请选择客户来源')">
          <el-option v-for="dict in getDictDatas(DICT_TYPE.CUSTOMER_SOURCE)"
                     :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
        </el-select>
      </el-form-item>
邓春圆's avatar
邓春圆 committed
28
        <el-form-item :label="$t('客户类别')" prop="type" >
邓春圆's avatar
邓春圆 committed
29 30
        <dict-selector v-model="form.type" :type="DICT_TYPE.CUSTOMER_TYPE" form-type="checkbox" multiple ></dict-selector>
      </el-form-item>
邓春圆's avatar
邓春圆 committed
31
      <el-form-item :label="$t('客户经理')" >
邓春圆's avatar
邓春圆 committed
32 33 34 35 36
        <el-select v-model="form.customerService" :placeholder="$t('请选择客户经理')">
          <el-option v-for="item in serviceUserList"
                     :key="item.id" :label="item.nickname" :value="item.id" />
        </el-select>
      </el-form-item>
邓春圆's avatar
邓春圆 committed
37
      <el-form-item :label="$t('公司名称')">
邓春圆's avatar
邓春圆 committed
38 39
        <el-input v-model="form.company" ></el-input>
      </el-form-item>
邓春圆's avatar
邓春圆 committed
40
      <el-form-item :label="$t('公司英文名称')">
邓春圆's avatar
邓春圆 committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
        <el-input v-model="form.companyEn" ></el-input>
      </el-form-item>
        <el-form-item :label="$t('主营类别')" prop="productType">
        <el-row :gutter="10">
          <el-col :span="11">
            <el-select v-model="form.productType" style="width: 100%"  @change="getProductListFn" :placeholder="$t('请选择产品类别')" >
              <el-option  :label="item.titleZh" :value="item.id" v-for="(item) in productTypeList" :key="item.id"/>
            </el-select>
          </el-col>
          <el-col :span="11">
            <el-select v-model="form.productId"  style="width: 100%"  :placeholder="$t('请选择')">
              <el-option :label="item.titleZh" :value="parseInt(item.id)" v-for="(item) in productList" :key="item.id"/>
            </el-select>
          </el-col>
        </el-row>
      </el-form-item>
邓春圆's avatar
邓春圆 committed
57
      <el-form-item :label="$t('询盘信息')" >
邓春圆's avatar
邓春圆 committed
58 59 60 61
        <el-input
          v-model="form.inquiry"
          type="textarea"
          :rows="3"
邓春圆's avatar
邓春圆 committed
62
          :placeholder="$t('请输入内容')">
邓春圆's avatar
邓春圆 committed
63 64 65 66
        </el-input>
      </el-form-item>
    </el-form>
     <div slot="footer" class="dialog-footer">
邓春圆's avatar
邓春圆 committed
67 68
       <el-button @click="dialogTableVisible = false">{{$t('取 消')}}</el-button>
       <el-button type="primary" @click="submit">{{$t('确 定')}}</el-button>
邓春圆's avatar
邓春圆 committed
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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
     </div>
   </el-dialog>
 </div>
</template>

<script>
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
import AreaCodeSelector from "@/components/AreaCodeSelector/index.vue";
import {listServiceUser} from "@/api/system/user";
import {getProductTypeList} from "@/api/ecw/productType";
import {getProductList} from "@/api/ecw/product";
import {createPotential} from "@/api/ecw/customer";

export default {
  name: "addPotentialCustom",
  methods: {
    getDictDatas,
    getProductListFn(val){
      getProductList({typeId:val}).then(r => {
        this.productList = r.data
      })
    },
    reset(){
      this.form = {
        name:undefined,
        customerContacts:[{areaCode:undefined,phoneNew:undefined,name:undefined,isDefault: 1}],
        source:undefined,
        type:[],
        customerService:undefined,
        company:undefined,
        companyEn:undefined,
        inquiry:undefined,
        productType:undefined,
        productId:undefined,
      }
    },
    submit(){
      this.$refs.form.validate((valId)=>{
         if (valId){
           let p = {...this.form}
           p.type = p.type.join(',')
           p.customerContacts[0].name = p.name + p.customerContacts[0].phoneNew
           createPotential(p).then(r => {
             if(r.code === 0){
               this.$emit('change');
               this.dialogTableVisible = false;
邓春圆's avatar
邓春圆 committed
115
               this.$message(this.$t('创建成功'));
邓春圆's avatar
邓春圆 committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
             }
           })
         }
      })

    },
  },
  components: {AreaCodeSelector},
  created() {
    this.reset()
    listServiceUser().then(r => {
      this.serviceUserList = r.data
    })
    getProductTypeList().then(r => {
      this.productTypeList = r.data
    })


  },
  computed: {
    DICT_TYPE() {
      return DICT_TYPE
    },
    rules(){
      return {
邓春圆's avatar
邓春圆 committed
141 142 143 144
            name:{ required:true,message:this.$t('请输入名称'),target:'blur' },
            customerContacts:[{areaCode:{required:true,message:this.$t('请输入区号。'),target:'blur'},phoneNew:{required:true,message:this.$t('请输入电话号码。'),target:'blur'} },],
            type:{ type:'array',  message:this.$t('请输入客户类别。'), required:true, target:['blur','change']},
            source:{message:this.$t('前请输入客户来源'),required:true,target:'change',type:'number'}
邓春圆's avatar
邓春圆 committed
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
      }
    }
  },

  data(){
    return {
      dialogTableVisible:false,
      serviceUserList:[],
      productTypeList:[],
      productList:[],
      form:{}
    }
  },

}
</script>

<style scoped>

</style>