clientsCEViews-29b7fe9d.js 11 KB

1
  1. import{u as ee,g as te,r as n,i as N,o as ae,e as u,n as j}from"./vendor-ef68d560.js";import{n as le,$ as w}from"./index-87faf287.js";import{L as se,g as G}from"./LJFrom-07b25d99.js";import"./LJUploadFiles-b544f68a.js";import"./qiNiu.config-a8af251c.js";import"./LJUploadImages-f6851c5c.js";const ie={__name:"clientsCEViews",setup(D){const a=ee(),e=te(),t=n(),l=n(),_=n(!1),m=n(e.query.type||"add"),S=n(e.query.status||""),b=n(null),h=n(e.query.clue||!1),y=n({}),v=n([]),x=n(m.value==="edit"?"\u7F16\u8F91\u5BA2\u6237":"\u65B0\u5EFA\u5BA2\u6237"),g=n(!1),F=n(null),T=n([]),R=n([]),C=n(!1),p=n([]),$=n(0),L=n([]),f=n({expected_order_time:"",intention_money:0}),I=n(!1),d=N({customer_id:null,company_id:w.getters.company,template_id:null,data:{}}),U=N({customer_id:[{required:!1,message:"\u8BF7\u9009\u62E9\u5BA2\u6237\u6A21\u677F",trigger:"change"}],template_id:[{required:!0,message:"\u8BF7\u9009\u62E9\u5BA2\u6237\u6A21\u677F",trigger:"change"}]});function q(){const r={offset:0,limit:9999,ordering:"-id",fileds:"id,name",del_flag:0,is_default:0};m.value=="add"?r.status=1:delete r.status,HTTP.get("used_customer_templates",r).then(o=>{o.code==0&&(y.value=o.data.results,h.value&&(d.template_id=y.value[0].id,H(d.template_id),HTTP.getReadById("customTemplate",d.template_id).then(i=>{if(i.code!==0)return u.exports.Message.error(i.msg);G(i.data).then(s=>{for(const c of s)c.value=e.query.row[c.key];k()}).catch(s=>{u.exports.Message.error(s)})})))})}const P=async()=>{const r={offset:0,limit:999,fileds:"id,name",company:w.getters.company,del_flag:0,customer_templates:d.template_id};await HTTP.get("customer_templates_member_level",r).then(o=>{o.code==0&&(R.value=o.data.results)})},H=async r=>{await P(),b.value=r,_.value=!1,v.value=[];const o=y.value.find(i=>i.id==r);G(o).then(i=>{if(S.value=="clue"){for(const s of i)s.value=e.query.row[s.key];v.value=i.map(s=>(s.value?s.disabled=!0:s.disabled=!1,s))}else v.value=i;v.value=v.value.filter(s=>s.is_hide==0),_.value=!0,T.value=i.filter(s=>s.value),k()}).catch(i=>{u.exports.Message.error(i)})};function A(){t.value.validate(r=>{if(!r)return l.value.validateForm();l.value.validateForm(o=>{if(!o)return;const i={...d,data:{...l.value.ruleForm,...f.value}};i.data.intention_level==0&&delete i.data.intention_level,i.label_id_list=[],L.value.map(s=>{i.label_id_list.push(s.id)}),h.value?(g.value=!0,i.customer_id=e.query.row.id,i.company_id=e.query.row.company,i.template_id=F.value,i.is_convert=!0,T.value.length>0&&T.value.map(s=>{i.data[s.key]=s.value}),HTTP.post("create_clue_customer",i).then(s=>{if(s.code!==0)return u.exports.Message({type:"error",message:s.msg});let c=[];c.push(e.query.row.id);const Z={customer_id_list:c,template_id:b.value};HTTP.post("convert_to_customers",Z).then(z=>{z.code==0?u.exports.Message({type:"success",message:"\u8F6C\u5316\u6210\u529F",duration:1500}):u.exports.Message.error(z.msg)}),setTimeout(M,1500)}).catch(s=>{g.value=!1,u.exports.Message({type:"error",message:s.msg||`${x.value}\u5931\u8D25`})})):(i.customer_id||delete i.customer_id,i.company_id=w.getters.company,g.value=!0,HTTP.post("create_customer",i).then(s=>{if(s.code!==0)return u.exports.Message({type:"error",message:s.msg});u.exports.Message({type:"success",message:`${x.value}\u6210\u529F\uFF01`,duration:1500}),setTimeout(M,1500)}).catch(s=>{g.value=!1,u.exports.Message({type:"error",message:s.msg||`${x.value}\u5931\u8D25`})}))})})}function k(){j(()=>{t.value.clearValidate(),l.value.clearValidate()})}function V(){j(()=>{t.value.resetFields(),l.value.resetFieldsForm()})}function M(){g.value=!1,V(),a.back()}function E(){HTTP.getReadById("customerList",e.query.id).then(r=>{const o=r.data;try{d.customer_id=o.id,d.company_id=o.company,d.template_id=o.customer_templates.id,f.value.member_level=o.member_level,f.value.intention_money=o.intention_money,f.value.expected_order_time=o.expected_order_time,f.value.intention_level=o.intention_level,o.customer_label&&(o.customer_label=o.customer_label.split(",").map(i=>{L.value.push({name:i})})),y.value=[o.customer_templates]}catch(i){}if(!d.template_id)return u.exports.Message({type:"error",message:"\u6A21\u677F\u4FE1\u606F\u7F3A\u5931",offset:"20px"});HTTP.getReadById("customTemplate",d.template_id).then(i=>{if(i.code!==0)return u.exports.Message.error(i.msg);G(i.data).then(s=>{for(const c of s)c.is_custom==1?c.value=o.customer_fields[c.key]:c.value=o[c.key],e.query.was_clue==1&&(c.value?c.disabled=!0:c.disabled=!1);v.value=s.filter(c=>c.is_hide==0),_.value=!0,k()}).catch(s=>{u.exports.Message.error(s)})})})}function J(){HTTP.getReadById("customerList",e.query.row.id).then(r=>{F.value=r.data.clue_customer_templates.id})}function K(){C.value=!0,B()}function O(){C.value=!1}function B(){const r={company_id:w.getters.company,templates_id:d.template_id};e.query.id&&(r.customer_id=e.query.id,delete r.templates_id,delete r.company_id),HTTP.post("get_customer_label",r).then(o=>{o.code==0&&(p.value=o.data.label_cate,o.data.customer_label.length>0?p.value.unshift({name:"\u5DF2\u9009\u6807\u7B7E",cate_label_list:o.data.customer_label}):p.value.unshift({name:"\u5DF2\u9009\u6807\u7B7E",cate_label_list:[]}))})}function Q(r){$.value=r}function W(r){r.is_choose=!r.is_choose,r.is_choose?p.value[0].cate_label_list.push(r):p.value[0].cate_label_list=p.value[0].cate_label_list.filter(o=>o.id!=r.id)}function X(){C.value=!1,L.value=p.value[0].cate_label_list}function Y(){f.intention_money=f.intention_money.replace(/[^0-9]/g,"")}return ae(()=>{q(),m.value==="edit"?(e.query.sala=="true"&&(I.value=!0),h.value?J():E()):q()}),{__sfc:!0,router:a,route:e,formRef:t,LJFromRef:l,LJFromRefShow:_,type:m,status:S,customerTemplateId:b,clue:h,customList:y,selectTemplate:v,title:x,isLoading:g,clueTemplateId:F,dataList:T,gradeList:R,dialogVisible:C,sortList:p,sortIndex:$,tagList:L,clientGrade:f,sala:I,form:d,rules:U,loadConfig:q,getGradeList:P,handleTemplate:H,submitForm:A,handleFromClearValidate:k,handleFormResetFies:V,resetForm:M,handleEditLoadConfig:E,getClueTemplateId:J,setLabel:K,handleClose:O,getTagList:B,getSortItem:Q,changeTag:W,submitTag:X,validateNumber:Y,LJFrom:se}}};var oe=function(){var a=this,e=a._self._c,t=a._self._setupProxy;return e("div",{staticClass:"clients-create-views"},[e("div",{staticClass:"title"},[e("div",{staticStyle:{"margin-left":"30px"}},[a._v(a._s(t.title)),t.type=="edit"?e("span",{staticStyle:{"margin-left":"10px","font-size":"12px",color:"#909399"}},[a._v("(*\u82E5\u6709\u7981\u7528\u5B57\u6BB5\uFF0C\u9700\u4FEE\u6539\u8BF7\u5230\u7EBF\u7D22\u8BE6\u60C5\u4E2D\u4FEE\u6539)")]):a._e()]),e("div",{staticStyle:{display:"flex","justify-content":"center","margin-right":"20px"}},[e("el-button",{on:{click:t.resetForm}},[a._v("\u53D6\u6D88")]),e("el-button",{attrs:{type:"primary",loading:t.isLoading},on:{click:t.submitForm}},[a._v("\u4FDD\u5B58")])],1)]),e("div",{staticClass:"detail-cont"},[e("el-divider"),e("div",{},[e("el-form",{ref:"formRef",attrs:{model:t.form,rules:t.rules,"label-width":"100px"}},[e("el-row",{staticClass:"form_header"},[e("el-col",{attrs:{span:12}},[t.status=="clue"?e("el-form-item",{staticStyle:{"margin-left":"20px"},attrs:{label:"\u5BA2\u6237\u6A21\u677F",prop:"template_id"}},[e("el-select",{staticStyle:{width:"50%"},attrs:{placeholder:"\u8BF7\u9009\u62E9",clearable:""},on:{change:t.handleTemplate},model:{value:t.form.template_id,callback:function(l){a.$set(t.form,"template_id",l)},expression:"form.template_id"}},a._l(t.customList,function(l){return e("el-option",{key:l.id,attrs:{label:l.name,value:l.id}})}),1)],1):e("el-form-item",{staticStyle:{"margin-left":"20px"},attrs:{label:"\u5BA2\u6237\u6A21\u677F",prop:"template_id"}},[e("el-select",{staticStyle:{width:"50%"},attrs:{disabled:t.type!="add",placeholder:"\u8BF7\u9009\u62E9",clearable:""},on:{change:t.handleTemplate},model:{value:t.form.template_id,callback:function(l){a.$set(t.form,"template_id",l)},expression:"form.template_id"}},a._l(t.customList,function(l){return e("el-option",{key:l.id,attrs:{label:l.name,value:l.id}})}),1)],1)],1)],1),t.LJFromRefShow?e("div",{staticClass:"form_header"},[e(t.LJFrom,{ref:"LJFromRef",staticStyle:{"margin-top":"20px","margin-bottom":"20px"},attrs:{templates:t.selectTemplate}}),t.sala?e("el-form-item",{staticStyle:{"margin-left":"20px"},attrs:{label:"\u6210\u5355\u65F6\u95F4"}},[e("el-date-picker",{staticStyle:{width:"25%"},attrs:{type:"date","value-format":"yyyy-MM-dd",placeholder:"\u9009\u62E9\u65E5\u671F"},model:{value:t.clientGrade.expected_order_time,callback:function(l){a.$set(t.clientGrade,"expected_order_time",l)},expression:"clientGrade.expected_order_time"}})],1):a._e(),t.sala?e("el-form-item",{staticStyle:{"margin-left":"20px"},attrs:{label:"\u9500\u552E\u91D1\u989D"}},[e("el-input",{staticStyle:{width:"25%"},attrs:{placeholder:"\u8BF7\u8F93\u5165\u5BA2\u6237\u91D1\u989D\u5907\u6CE8"},on:{input:t.validateNumber},model:{value:t.clientGrade.intention_money,callback:function(l){a.$set(t.clientGrade,"intention_money",l)},expression:"clientGrade.intention_money"}},[e("template",{slot:"append"},[a._v("\u5143")])],2)],1):a._e(),e("el-form-item",{staticStyle:{"margin-left":"20px"},attrs:{label:"\u5BA2\u6237\u7B49\u7EA7"}},[e("el-select",{staticStyle:{width:"25%"},attrs:{placeholder:"\u8BF7\u9009\u62E9",clearable:""},model:{value:t.clientGrade.member_level,callback:function(l){a.$set(t.clientGrade,"member_level",l)},expression:"clientGrade.member_level"}},a._l(t.gradeList,function(l){return e("el-option",{key:l.id,attrs:{label:l.name,value:l.id}})}),1)],1),e("el-form-item",{staticStyle:{"margin-left":"20px"},attrs:{label:"\u5BA2\u6237\u610F\u5411\u5EA6"}},[e("el-rate",{staticStyle:{"margin-top":"8px"},model:{value:t.clientGrade.intention_level,callback:function(l){a.$set(t.clientGrade,"intention_level",l)},expression:"clientGrade.intention_level"}})],1),e("el-form-item",{staticStyle:{"margin-left":"20px"},attrs:{label:"\u5BA2\u6237\u6807\u7B7E"}},[e("div",{staticStyle:{display:"flex"}},[a._l(t.tagList,function(l){return e("div",{staticClass:"tag-box-list"},[e("el-tag",[a._v(a._s(l.name))])],1)}),e("el-button",{attrs:{type:"primary",plain:"",size:"mini"},on:{click:t.setLabel}},[a._v("\u8BBE\u7F6E\u5BA2\u6237\u6807\u7B7E")])],2)])],1):a._e()],1)],1),e("el-dialog",{attrs:{title:"\u8BBE\u7F6E\u5BA2\u6237\u6807\u7B7E",visible:t.dialogVisible,width:"35%","append-to-body":!0,"modal-append-to-body":!1,"before-close":t.handleClose},on:{"update:visible":function(l){t.dialogVisible=l}}},[e("div",{staticClass:"tag-box"},[e("div",{staticClass:"tag-sort-list"},a._l(t.sortList,function(l,_){return e("div",{key:_,class:t.sortIndex==_?"tag-sort-item active":"tag-sort-item",on:{click:function(m){return t.getSortItem(_)}}},[e("span",{staticClass:"sort-name"},[a._v(a._s(l.name))]),e("span",[a._v(a._s(l.cate_label_list.filter(m=>m.is_choose).length))])])}),0),e("div",{staticClass:"tag-list"},a._l(t.sortList,function(l,_){return e("div",{key:_,staticClass:"tag-item"},[e("div",{staticClass:"tag-sort-name"},[a._v(a._s(l.name))]),e("div",{staticClass:"tag-item-list"},a._l(l.cate_label_list,function(m,S){return e("div",{class:m.is_choose?"tag-item-name active":"tag-item-name",on:{click:function(b){return t.changeTag(m)}}},[a._v(a._s(m.name))])}),0)])}),0)]),e("span",{staticClass:"dialog-footer",attrs:{slot:"footer"},slot:"footer"},[e("el-button",{on:{click:t.handleClose}},[a._v("\u53D6 \u6D88")]),e("el-button",{attrs:{type:"primary"},on:{click:t.submitTag}},[a._v("\u786E \u5B9A")])],1)])],1)])},re=[],ne=le(ie,oe,re,!1,null,"0c085d6b",null,null);const fe=ne.exports;export{fe as default};