changeCustomer.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. <template>
  2. <div>
  3. <el-button size="mini" :type="disabled || data.status === '已无效' || data.status === '已过期'?'':'primary'" @click="onShow" :disabled="disabled || data.status === '已无效' || data.status === '已过期'" >转化客户</el-button>
  4. <el-drawer
  5. title="转化为客户"
  6. :visible.sync="drawer"
  7. size="600px"
  8. direction="rtl"
  9. :show-close="false"
  10. append-to-body
  11. @close="onClose">
  12. <div class="drawer__panel">
  13. <el-row :gutter="20">
  14. <el-form :model="form" :rules="rules" ref="form" label-width="100px" label-position="right" size="mini">
  15. <el-col :span="20">
  16. <el-form-item label="客户名称:" prop="enterprisename_customer">
  17. <el-input v-model="form.enterprisename_customer" placeholder="请输入客户名称" style="width: 100%"></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="4">
  21. <businessInquiry ref="businessRef" :keyword="form.enterprisename_customer"
  22. @businessData="businessSelect"></businessInquiry>
  23. </el-col>
  24. <el-col :span="24">
  25. <el-form-item label="企业简称:" prop="abbreviation">
  26. <el-input v-model="form.abbreviation" placeholder="请输入企业简称" style="width: 100%"></el-input>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="24" >
  30. <el-form-item label="客户类型:" prop="type">
  31. <el-select v-model="form.type" placeholder="请选择客户类型" style="width: 100%">
  32. <el-option
  33. v-for="item in options.type"
  34. :key="item.value"
  35. :label="item.value"
  36. :value="item.value">
  37. <!-- <span style="float: left">{{ item.value }}</span>
  38. <span v-if="item.remarks !== ''" style="float: right; color: #8492a6; font-size: 10px">{{ item.remarks }}</span>-->
  39. <span style="float: left">{{ item.value }}</span>
  40. <span style="float: right; color: #8492a6; font-size: 12px">{{ item.remarks?item.remarks:'暂无描述' }}</span>
  41. </el-option>
  42. </el-select>
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="24">
  46. <el-form-item label="客户等级:" prop="grade">
  47. <el-select v-model="form.grade" placeholder="请选择客户等级" style="width: 100%">
  48. <el-option
  49. v-for="item in options.customerGrade"
  50. :key="item.rowindex"
  51. :label="item.value "
  52. :value="item.value">
  53. <span style="float: left">{{ item.value }}</span>
  54. <span style="float: right; color: #8492a6; font-size: 12px">{{ item.remarks?item.remarks:'暂无描述' }}</span>
  55. </el-option>
  56. </el-select>
  57. </el-form-item>
  58. </el-col>
  59. <el-col :span="24">
  60. <el-form-item label="客户分类:" prop="customergrade">
  61. <el-select v-model="form.customergrade" placeholder="请选择客户分类" style="width: 100%">
  62. <el-option
  63. v-for="item in options.customerClassification"
  64. :key="item.rowindex"
  65. :label="item.value "
  66. :value="item.value">
  67. <span style="float: left">{{ item.value }}</span>
  68. <span style="float: right; color: #8492a6; font-size: 12px">{{ item.remarks?item.remarks:'暂无描述' }}</span>
  69. </el-option>
  70. </el-select>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="24">
  74. <el-form-item label="客户行业:" prop="industry">
  75. <el-select
  76. ref="sle"
  77. style="width:100%;"
  78. v-model="form.industry"
  79. multiple
  80. placeholder="请选择所属行业"
  81. size="mini"
  82. >
  83. <el-option
  84. v-for="item in options.industryData"
  85. :key="item.value"
  86. :label="item.value"
  87. :value="item.value"
  88. >
  89. <span style="float: left">{{ item.value }}</span>
  90. <span style="float: right; color: #8492a6; font-size: 12px">{{ item.remarks?item.remarks:'暂无描述' }}</span>
  91. </el-option>
  92. </el-select>
  93. </el-form-item>
  94. </el-col>
  95. <el-col :span="24">
  96. <el-form-item label="联系人:" prop="contactsinfo.name">
  97. <contactsNewTemplate ownertable="" ownerid="" @contactData="contactData" :name="form.contactsinfo.name" @inputChange="inputChange"></contactsNewTemplate>
  98. </el-form-item>
  99. </el-col>
  100. <el-col :span="24" v-if="isPhone">
  101. <el-form-item label="联系方式:" prop="contactsinfo.phonenumber">
  102. <el-button-group>
  103. <!-- <el-button type="primary" size="mini" @click="phoneChang('手机')">手机号</el-button>
  104. <el-button type="" size="mini" @click="phoneChang('座机')">座机电话</el-button>-->
  105. <el-radio v-model="isPhone" :label="true" @change="phoneChang('手机')">手机号</el-radio>
  106. <el-radio v-model="isPhone" :label="false" @change="phoneChang('座机')">座机电话</el-radio>
  107. </el-button-group>
  108. <el-input v-model="form.contactsinfo.phonenumber" placeholder="请输入手机号" style="width: 100%;margin-top: 10px" @input="telephoneChange('手机')"></el-input>
  109. </el-form-item>
  110. </el-col>
  111. <el-col :span="24" v-if="!isPhone">
  112. <el-form-item label="联系方式:" prop="contactsinfo.telephone">
  113. <el-button-group>
  114. <!-- <el-button type="" size="mini" @click="phoneChang('手机')">手机号</el-button>
  115. <el-button type="primary" size="mini" @click="phoneChang('座机')">座机电话</el-button>-->
  116. <el-radio v-model="isPhone" :label="true" @change="phoneChang('手机')">手机号</el-radio>
  117. <el-radio v-model="isPhone" :label="false" @change="phoneChang('座机')">座机电话</el-radio>
  118. </el-button-group>
  119. <div style="width: 100%">
  120. <el-input v-model="areaCode" placeholder="请输入区号" style="width:25%;margin-top: 10px" @input="telephoneChange('座机')"></el-input>
  121. <span style="color: #999999">——</span>
  122. <el-input v-model="telephone" placeholder="请输入座机电话" style="width:68%;margin-top: 10px" @input="telephoneChange('座机')"></el-input>
  123. </div>
  124. </el-form-item>
  125. </el-col>
  126. <el-col :span="24">
  127. <el-form-item label="税号:" prop="taxno">
  128. <el-input v-model="form.taxno" placeholder="请输入企业税号" style="width: 100%"></el-input>
  129. </el-form-item>
  130. </el-col>
  131. <el-col :span="24">
  132. <el-form-item label="法人:" prop="contact">
  133. <el-input v-model="form.contact" placeholder="请输入法人信息" style="width: 100%"></el-input>
  134. </el-form-item>
  135. </el-col>
  136. <el-col :span="24">
  137. <el-form-item label="联系电话:" prop="phonenumber">
  138. <el-input v-model="form.phonenumber" placeholder="请输入联系电话" style="width: 100%"></el-input>
  139. </el-form-item>
  140. </el-col>
  141. <el-col :span="24">
  142. <el-form-item label="省市县:" prop="province">
  143. <el-cascader
  144. style="width: 100%"
  145. v-model="value"
  146. :options="basicData.data().areaData"
  147. @change="cascaderChange" clearable>
  148. </el-cascader>
  149. </el-form-item>
  150. </el-col>
  151. <el-col :span="24">
  152. <el-form-item label="详细地址:" prop="address">
  153. <el-input v-model="form.address" placeholder="请输入企业地址" style="width: 100%"></el-input>
  154. </el-form-item>
  155. </el-col>
  156. <el-col :span="24">
  157. <el-form-item label="上级企业:" prop="superiorenterprisename">
  158. <el-popover
  159. placement="bottom"
  160. width="700"
  161. trigger="click"
  162. v-model="customerShow"
  163. @show="customerList">
  164. <el-input
  165. style="width:300px;margin-bottom: 10px"
  166. placeholder="请输入内容"
  167. v-model="customerParam.content.where.condition"
  168. clearable
  169. @clear="customerList(customerParam.content.pageNumber = 1)"
  170. size="mini"
  171. @keyup.enter.native="customerList(customerParam.content.pageNumber = 1)">
  172. <i slot="prefix" class="el-icon-search" @click="customerList(customerParam.content.pageNumber = 1)"></i>
  173. </el-input>
  174. <el-table :data="customer.customerData" @row-click="customerData" height="396px" :header-cell-style="{background:'#EEEEEE',color:'#333'}" size="mini">
  175. <el-table-column
  176. label="客户编号"
  177. width="75">
  178. <template slot-scope="scope">
  179. <span style="margin-left: 10px">{{ scope.row.sa_customersid?scope.row.sa_customersid:'--' }}</span>
  180. </template>
  181. </el-table-column>
  182. <el-table-column
  183. label="客户名称"
  184. width="260">
  185. <template slot-scope="scope">
  186. <span style="margin-left: 10px">{{ scope.row.enterprisename?scope.row.enterprisename:'--'}}</span>
  187. </template>
  188. </el-table-column>
  189. <el-table-column
  190. label="地址"
  191. >
  192. <template slot-scope="scope">
  193. <span style="margin-left: 10px">{{ scope.row.address?scope.row.address:'--' }}</span>
  194. </template>
  195. </el-table-column>
  196. </el-table>
  197. <div class="container normal-panel" style="text-align:right">
  198. <el-pagination
  199. background
  200. small
  201. @size-change="handleSizeChangeCustomer"
  202. @current-change="handleCurrentChangeCustomer"
  203. :page-sizes="[10,20,50,100,]"
  204. layout="total,sizes, prev, pager, next, jumper"
  205. :current-page="customer.currentPage"
  206. :total="customer.total">
  207. </el-pagination>
  208. </div>
  209. <el-input slot="reference" :readonly="true" v-model="form.superiorenterprisename" autocomplete="off" placeholder="请选择客户" @input="selectCustomer"></el-input>
  210. </el-popover>
  211. </el-form-item>
  212. </el-col>
  213. <el-col :span="24">
  214. <el-form-item label="客户来源:" prop="source">
  215. <selectTemp ref="sourceRef" placeholder="请选择来源" payload="cluesource" @selectChange="selectSource" :cluesource="form.source"></selectTemp>
  216. </el-form-item>
  217. </el-col>
  218. <el-col :span="24">
  219. <el-form-item label="归属经销商:" prop="sa_agentsid">
  220. <el-popover
  221. v-model="agentsShow"
  222. placement="bottom"
  223. trigger="click"
  224. width="700"
  225. @show="queryAgents">
  226. <el-input
  227. v-model="agentsParam.content.where.condition"
  228. clearable
  229. placeholder="请输入内容"
  230. size="mini"
  231. style="width:300px;margin-bottom: 10px"
  232. @clear="queryAgents(agentsParam.content.pageNumber = 1)"
  233. @keyup.enter.native="queryAgents(agentsParam.content.pageNumber = 1)">
  234. <i slot="prefix" class="el-icon-search"
  235. @click="queryAgents(agentsParam.content.pageNumber = 1)"></i>
  236. </el-input>
  237. <el-table :data="agents.agentsData" :header-cell-style="{background:'#EEEEEE',color:'#333'}"
  238. height="396px"
  239. size="mini" @row-click="agentsData">
  240. <el-table-column
  241. label="经销商编码"
  242. width="100">
  243. <template slot-scope="scope">
  244. <span style="margin-left: 10px">{{ scope.row.agentnum ? scope.row.agentnum : '--' }}</span>
  245. </template>
  246. </el-table-column>
  247. <el-table-column
  248. label="经销商名称"
  249. width="260">
  250. <template slot-scope="scope">
  251. <span
  252. style="margin-left: 10px">{{
  253. scope.row.enterprisename ? scope.row.enterprisename : '--'
  254. }}</span>
  255. </template>
  256. </el-table-column>
  257. <el-table-column
  258. label="地址"
  259. >
  260. <template slot-scope="scope">
  261. <span style="margin-left: 10px">{{ scope.row.address ? scope.row.address : '--' }}</span>
  262. </template>
  263. </el-table-column>
  264. </el-table>
  265. <div class="container normal-panel" style="text-align:right">
  266. <el-pagination
  267. :current-page="agents.currentPage"
  268. :page-sizes="[20,50,100,]"
  269. :total="agents.total"
  270. background
  271. layout="total,sizes, prev, pager, next, jumper"
  272. small
  273. @size-change="handleSizeChangeAgent"
  274. @current-change="handleCurrentChangeAgent">
  275. </el-pagination>
  276. </div>
  277. <el-input slot="reference" v-model="form.agentname" :readonly="true" autocomplete="off"
  278. placeholder="请选择经销商" @input="selectAgents"></el-input>
  279. </el-popover>
  280. </el-form-item>
  281. </el-col>
  282. </el-form>
  283. </el-row>
  284. </div>
  285. <div class="fixed__btn__panel">
  286. <el-button size="small" @click="onClose" class="normal-btn-width inline-16">取 消</el-button>
  287. <duplicateCheck :data="form" ref="check" @checkSuccess="checkSuccess" @onSuccess="onClose" @onCheck="onCheck"></duplicateCheck>
  288. <el-button size="small" type="primary" @click="onSave" class="normal-btn-width">确 定</el-button>
  289. </div>
  290. </el-drawer>
  291. </div>
  292. </template>
  293. <script>
  294. import businessMessage from '@/components/businessMessage/index'
  295. import duplicateCheck from "@/components/duplicatesCheck/customerChangeCheck";
  296. import contactsNewTemplate from '@/template/contactsNewTemplate/index'
  297. import businessInquiry from '@/template/businessInquiry/index'
  298. export default {
  299. props: ["disabled", "data"],
  300. name: "changeCustomer",
  301. components: {businessMessage, duplicateCheck, contactsNewTemplate, businessInquiry},
  302. data() {
  303. return {
  304. activeName: 'first',
  305. drawer: false,
  306. customerShow: false,
  307. checkResults: '',
  308. rules: {
  309. phonenumber: [
  310. {required: true, message: '请输入手机号码', trigger: 'change'},
  311. // {pattern: /^1[3-9]\d{9}$/, message: '请输入正确手机号码', trigger: 'change'}
  312. ],
  313. enterprisename_customer: [
  314. { required: true, message: '请输入客户名称', trigger: 'blur' },
  315. ],
  316. roleids: [
  317. { required: true, message: '请选择授权角色', trigger: 'change' }
  318. ],
  319. type: [
  320. { required: true, message: '请选择客户类型', trigger: 'change' }
  321. ],
  322. contact: [
  323. { required: false, message: '请输入法人', trigger: 'change,blur' },
  324. ],
  325. telephone: [
  326. { required: false, message: '请输入联系电话', trigger: 'change,blur' },
  327. { pattern:/^1[3-9]\d{9}$/, message: '请输入正确手机号码',trigger: 'change' }
  328. ],
  329. province: [
  330. { required: true, message: '请选择省市县', trigger: 'change,blur' },
  331. ],
  332. source: [
  333. { required: true, message: '请选择客户来源', trigger: 'change' },
  334. ],
  335. 'contactsinfo.name':[
  336. { required: true, message: '请输入联系人姓名', trigger: 'change,blur' }
  337. ],
  338. 'contactsinfo.phonenumber': [
  339. { required: true, message: '请输入联系电话', trigger: 'change' },
  340. { pattern:/^1[3-9]\d{9}$/, message: '请输入正确手机号码',trigger: 'change' }
  341. ],
  342. 'contactsinfo.telephone': [
  343. { required: true, message: '请输入座机电话', trigger: 'change' },
  344. { pattern:/^0\d{2,3}-\d{7,8}$/, message: '请输入正确座机电话',trigger: 'change' }
  345. ],
  346. },
  347. form:{
  348. "sat_orderclueid": '',
  349. "enterprisename_customer":'',
  350. "sa_customersid": 0, //新增是传0
  351. "parentid": 0, //上级客户ID,默认或没有上级的时候传0
  352. "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
  353. "enterprisename": "", //客户名称(企业名称)
  354. "type": "", //客户类型
  355. "source": "", //客户来源
  356. "province": "", //非必填,可选
  357. "city": "", //非必填,可选
  358. "county": "", //非必填,可选
  359. "address": "", //非必填,可选
  360. "abbreviation": "", //非必填,可选
  361. "taxno": "", //税号,非必填,可选
  362. "grade": '', // 客户等级(商户等级)
  363. "industry": [], //非必填,可选,所属行业
  364. "contact": "", //非必填,可选
  365. "phonenumber": "", //非必填,可选
  366. "customergrade": "", //客户等级
  367. "contactsinfo": {
  368. "name": "",
  369. "telephone": "",
  370. "phonenumber": "",
  371. "sys_phonebookid":""
  372. },
  373. },
  374. customerParam:{
  375. "id": 20220920083901,
  376. "content": {
  377. "pageNumber": 1,
  378. "pageSize": 10,
  379. "where": {
  380. "condition": "",
  381. "type":6,
  382. "sa_projectid":""
  383. }
  384. }
  385. },
  386. customer:{
  387. customerData:[],
  388. total:0,
  389. currentPage:0,
  390. },
  391. value:'',
  392. options:{
  393. type:[],
  394. parentCustomers:[],
  395. gradeData:[],
  396. industryData:[],
  397. customerGrade:[],
  398. customerClassification:[],
  399. distributor:[]
  400. },
  401. isPhone:true,
  402. enterpriseContact:{
  403. param:{
  404. "content": {
  405. "sys_enterpriseid": '',
  406. "pageNumber": 1,
  407. "pageSize": 20,
  408. "where": {
  409. "condition": ""
  410. }
  411. },
  412. "id": 20221219193002,
  413. },
  414. listData:[],
  415. total:0,
  416. currentPage:0,
  417. show:false
  418. },
  419. myContacts:{
  420. param:{
  421. "id": 20221219161202,
  422. "content": {
  423. "pageNumber": 1,
  424. "pageSize": 20,
  425. "ownertable":'sa_customers',
  426. "ownerid":'',
  427. "where": {
  428. "condition": ""
  429. }
  430. }
  431. },
  432. listData:[],
  433. total:0,
  434. currentPage:0,
  435. show:false
  436. },
  437. areaCode:'',
  438. telephone:'',
  439. agentsShow: false,
  440. agentsParam: {
  441. "id": 20230214162602,
  442. "content": {
  443. "hrid": '',
  444. "pageNumber": 1,
  445. "pageSize": 20,
  446. "where": {
  447. "condition": ""
  448. }
  449. }
  450. },
  451. agents: {
  452. agentsData: [],
  453. total: 0,
  454. currentPage: 0,
  455. },
  456. }
  457. },
  458. methods:{
  459. onShow(){
  460. this.drawer = true
  461. this.form = Object.assign({},this.form,this.data)
  462. this.form.phonenumber = ''
  463. this.form.source = this.form.cluesource
  464. this.value = [this.form.province,this.form.city,this.form.county]
  465. this.form.contactsinfo.name = this.data.name
  466. /*this.form.contactsinfo.phonenumber = this.data.phonenumber*/
  467. if (this.data.phonenumber.indexOf('-') != '-1'){
  468. this.isPhone = false
  469. this.areaCode = this.data.phonenumber.substring(0,this.data.phonenumber.indexOf('-'))
  470. this.telephone = this.data.phonenumber.substring(this.areaCode.length+1)
  471. this.form.contactsinfo.telephone = this.areaCode + '-' + this.telephone
  472. this.form.contactsinfo.phonenumber = ''
  473. }else {
  474. this.isPhone = true
  475. this.form.contactsinfo.phonenumber = this.data.phonenumber
  476. this.form.contactsinfo.telephone = ''
  477. this.areaCode = ''
  478. this.telephone = ''
  479. }
  480. this.gradeList()
  481. this.industryList()
  482. this.typeList()
  483. this.queryCustomerGrade()
  484. this.enterpriseContactList()
  485. },
  486. /*查重检查*/
  487. onCheck(){
  488. this.$refs.form.validate((valid) => {
  489. if (!valid) return false
  490. this.$refs.check.queryRule()
  491. })
  492. },
  493. /*自动查重判断*/
  494. duplicateCheck(){
  495. this.$refs.form.validate(async (valid) => {
  496. if (!valid) return false
  497. const res = await this.$api.requested({
  498. "id": 20221208172002,
  499. "content": {
  500. "sa_customersid":0,
  501. "enterprisename":this.form.enterprisename_customer,
  502. "taxno":this.form.taxno,
  503. "address":this.form.address
  504. },
  505. })
  506. if (res.data.length !== 0){
  507. console.log("重复")
  508. }
  509. this.checkResults = res.data.length
  510. this.onSave()
  511. })
  512. },
  513. onSave(){
  514. this.form.enterprisename = this.form.enterprisename_customer
  515. this.$refs.form.validate((valid) => {
  516. if (!valid) return false
  517. this.$refs.check.creatShow = true
  518. this.$refs.check.queryRule()
  519. })
  520. },
  521. async setTag(id){
  522. const res = await this.$api.requested({
  523. "id": 20220929090901,
  524. "content": {
  525. "ownertable":"sa_customers",
  526. "ownerid":id,
  527. "datatag":[
  528. "疑似重复",
  529. ]
  530. }
  531. })
  532. this.$emit('onChangeCustomer')
  533. this.$refs['form'].resetFields();
  534. this.form = {
  535. "sat_orderclueid": '',
  536. "enterprisename_customer":'',
  537. "sa_customersid": 0, //新增是传0
  538. "parentid": 0, //上级客户ID,默认或没有上级的时候传0
  539. "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
  540. "enterprisename": "", //客户名称(企业名称)
  541. "type": "", //客户类型
  542. "source": "", //客户来源
  543. "province": "", //非必填,可选
  544. "city": "", //非必填,可选
  545. "county": "", //非必填,可选
  546. "address": "", //非必填,可选
  547. "abbreviation": "", //非必填,可选
  548. "taxno": "", //税号,非必填,可选
  549. "grade": '', // 客户等级(商户等级)
  550. "industry": "", //非必填,可选,所属行业
  551. "contact": "", //非必填,可选
  552. "phonenumber": "", //非必填,可选
  553. "customergrade": "", //客户等级
  554. }
  555. this.drawer = false
  556. this.checkResults = ''
  557. this.value = ''
  558. },
  559. onSubmit(){
  560. this.form.enterprisename = this.form.enterprisename_customer
  561. this.$refs.form.validate(async (valid)=>{
  562. if (!valid) return false
  563. const res = await this.$api.requested({
  564. "id": 20221216184302,
  565. "content": this.form,
  566. })
  567. this.tool.showMessage(res,()=>{
  568. if (this.checkResults === 0){
  569. this.$emit('onChangeCustomer')
  570. this.$refs['form'].resetFields();
  571. this.form = {
  572. }
  573. this.drawer = false
  574. this.checkResults = ''
  575. this.value = ''
  576. }else {
  577. this.setTag(res.data.sa_customersid)
  578. }
  579. })
  580. })
  581. },
  582. onClose(){
  583. this.$refs['form'].resetFields();
  584. this.isPhone = true
  585. this.drawer = false
  586. this.checkResults = ''
  587. this.value = ''
  588. this.areaCode = ''
  589. this.telephone = ''
  590. this.$emit('onChangeCustomer')
  591. },
  592. /*获取工商信息*/
  593. businessSelect(val, regProvince) {
  594. this.$confirm('是否以查询的工商信息更新客户信息?', '提示', {
  595. confirmButtonText: '确定',
  596. cancelButtonText: '取消',
  597. type: 'warning'
  598. }).then(() => {
  599. this.$refs.businessRef.businessShow = false;
  600. this.form.enterprisename_customer = val.companyName;
  601. this.form.enterprisename = val.companyName;
  602. this.form.address = val.address === "-" ? '' : val.address;
  603. this.form.taxno = val.taxNum;
  604. this.value = [regProvince, val.regCity, val.regArea];
  605. this.form.province = regProvince;
  606. this.form.city = val.regCity;
  607. this.form.county = val.regArea;
  608. this.form.contact = val.legalPerson;
  609. this.form.phonenumber = val.phone
  610. }).catch(() => {
  611. this.$refs.businessRef.businessShow = false;
  612. this.$message({
  613. type: 'info',
  614. message: '已取消更新'
  615. });
  616. })
  617. },
  618. /*省市县*/
  619. cascaderChange(val) {
  620. this.form.province = val[0]
  621. if (val.length === 1)
  622. return this.form = Object.assign({}, this.form, {province: val[0], city: '', county: ''});
  623. this.form = Object.assign({}, this.form, {province: val[0], city: val[1], county: val[2]});
  624. this.$refs.form.validateField('province')
  625. },
  626. /*客户分类*/
  627. async gradeList(){
  628. const siteid = JSON.parse(sessionStorage.getItem('active_account')).siteid
  629. const res = await this.$api.requested({
  630. "classname": "sysmanage.develop.optiontype.optiontype",
  631. "method": "optiontypeselect",
  632. "content": {
  633. "pageNumber": 1,
  634. "pageSize": 20,
  635. "typename": "customergrade",
  636. "parameter": {
  637. "siteid": siteid
  638. }
  639. }
  640. })
  641. /*for (var i=0;i<res.data.length; i++){
  642. if (res.data[i].remarks !== ''){
  643. this.options.gradeData[i] = res.data[i].value + "——" + res.data[i].remarks
  644. }else{
  645. this.options.gradeData[i] = res.data[i].value
  646. }
  647. }*/
  648. this.options.customerClassification = res.data
  649. },
  650. /*客户等级*/
  651. queryCustomerGrade(){
  652. this.$store.dispatch('optiontypeselect','agentgrade').then(res=>{
  653. this.options.customerGrade = res.data
  654. })
  655. },
  656. /*行业列表*/
  657. async industryList(){
  658. const siteid = JSON.parse(sessionStorage.getItem('active_account')).siteid
  659. const res = await this.$api.requested({
  660. "classname": "sysmanage.develop.optiontype.optiontype",
  661. "method": "optiontypeselect",
  662. "content": {
  663. "pageNumber": 1,
  664. "pageSize": 20,
  665. "typename": "industry",
  666. "parameter": {
  667. "siteid": siteid
  668. }
  669. }
  670. })
  671. this.options.industryData = res.data
  672. },
  673. async customerList(){
  674. const res = await this.$api.requested(this.customerParam)
  675. this.customer.customerData = res.data
  676. this.customer.total = res.total
  677. this.customer.currentPage = res.pageNumber
  678. },
  679. selectCustomer(){
  680. this.customerParam.content.where.condition = this.form.superiorenterprisename
  681. this.customerList()
  682. },
  683. /*客户选择信息*/
  684. customerData(val){
  685. this.form.parentid = val.sa_customersid
  686. this.form.superiorenterprisename = val.enterprisename
  687. this.customerShow = false
  688. },
  689. /*客户分页*/
  690. handleSizeChangeCustomer(val) {
  691. // console.log(`每页 ${val} 条`);
  692. this.customerParam.content.pageSize = val
  693. this.customerList()
  694. },
  695. handleCurrentChangeCustomer(val) {
  696. // console.log(`当前页: ${val}`);
  697. this.customerParam.content.pageNumber = val
  698. this.customerList()
  699. },
  700. /*客户类型列表*/
  701. async typeList(){
  702. const siteid = JSON.parse(sessionStorage.getItem('active_account')).siteid
  703. const res = await this.$api.requested({
  704. "classname": "sysmanage.develop.optiontype.optiontype",
  705. "method": "optiontypeselect",
  706. "content": {
  707. "pageNumber": 1,
  708. "pageSize": 20,
  709. "typename": "customertypemx",
  710. "parameter": {
  711. "siteid": siteid
  712. }
  713. }
  714. })
  715. this.options.type = res.data
  716. },
  717. checkSuccess(val){
  718. this.checkResults = val
  719. },
  720. phoneChang(val){
  721. if (val === '座机'){
  722. this.isPhone = false
  723. }else {
  724. this.isPhone = true
  725. }
  726. },
  727. searchData(){
  728. this.changeTab()
  729. },
  730. changeTab(){
  731. this.enterpriseContactList()
  732. this.myContactList()
  733. },
  734. /*企业联系人*/
  735. async enterpriseContactList(){
  736. this.enterpriseContact.param.content.where.condition = this.form.contactsinfo.name
  737. this.enterpriseContact.param.content.sys_enterpriseid = 0
  738. const res = await this.$api.requested(this.enterpriseContact.param)
  739. this.enterpriseContact.listData = res.data
  740. this.enterpriseContact.total = res.total
  741. this.enterpriseContact.currentPage = res.pageNumber
  742. },
  743. /*选择企业联系人*/
  744. enterpriseContactSelect(val){
  745. this.form.contactsinfo.name = val.name
  746. this.form.contactsinfo.oldcontactsid = val.contactsid
  747. if (val.phonenumber.indexOf('-') != '-1'){
  748. this.isPhone = false
  749. this.areaCode = val.phonenumber.substring(0,val.phonenumber.indexOf('-'))
  750. this.telephone = val.phonenumber.substring(this.areaCode.length+1)
  751. this.form.contactsinfo.telephone = this.areaCode + '-' + this.telephone
  752. this.form.contactsinfo.phonenumber = ''
  753. }else {
  754. this.isPhone = true
  755. this.form.contactsinfo.phonenumber = val.phonenumber
  756. this.form.contactsinfo.telephone = ''
  757. this.areaCode = ''
  758. this.telephone = ''
  759. }
  760. this.enterpriseContact.show = false
  761. },
  762. handleSizeChangeEnterprise(val) {
  763. // console.log(`每页 ${val} 条`);
  764. this.enterpriseContact.param.content.pageSize = val
  765. this.enterpriseContactList()
  766. },
  767. handleCurrentChangeEnterprise(val) {
  768. // console.log(`当前页: ${val}`);
  769. this.enterpriseContact.param.content.pageNumber = val
  770. this.enterpriseContactList()
  771. },
  772. /*我的联系人*/
  773. async myContactList(){
  774. this.myContacts.param.content.where.condition = this.form.contactsinfo.name
  775. this.myContacts.param.content.sys_enterpriseid = 0
  776. this.myContacts.param.content.ownerid = 0
  777. const res = await this.$api.requested(this.myContacts.param)
  778. this.myContacts.listData = res.data
  779. this.myContacts.total = res.total
  780. this.myContacts.currentPage = res.pageNumber
  781. },
  782. /*选择我的联系人*/
  783. myContactSelect(val){
  784. this.form.contactsinfo.oldcontactsid = 0
  785. this.form.contactsinfo.name = val.name
  786. if (val.phonenumber.indexOf('-') != '-1'){
  787. this.isPhone = false
  788. this.areaCode = val.phonenumber.substring(0,val.phonenumber.indexOf('-'))
  789. this.telephone = val.phonenumber.substring(this.areaCode.length+1)
  790. this.form.contactsinfo.telephone = this.areaCode + '-' + this.telephone
  791. this.form.contactsinfo.phonenumber = ''
  792. }else {
  793. this.isPhone = true
  794. this.form.contactsinfo.phonenumber = val.phonenumber
  795. this.form.contactsinfo.telephone = ''
  796. }
  797. this.enterpriseContact.show = false
  798. },
  799. handleSizeChangeMy(val) {
  800. // console.log(`每页 ${val} 条`);
  801. this.myContacts.param.content.pageSize = val
  802. this.myContactList()
  803. },
  804. handleCurrentChangeMy(val) {
  805. // console.log(`当前页: ${val}`);
  806. this.myContacts.param.content.pageNumber = val
  807. this.myContactList()
  808. },
  809. telephoneChange(val){
  810. if (val === '座机'){
  811. this.form.contactsinfo.phonenumber = ''
  812. this.form.contactsinfo.telephone = this.areaCode + '-' + this.telephone
  813. }else {
  814. this.form.contactsinfo.telephone = ''
  815. this.areaCode = ''
  816. this.telephone = ''
  817. }
  818. },
  819. inputChange(val){
  820. this.form.contactsinfo.name = val
  821. },
  822. contactData(val){
  823. this.form.contactsinfo.name = val.name
  824. this.form.contactsinfo.sys_phonebookid = val.sys_phonebookid
  825. if (val.phonenumber.indexOf('-') != '-1'){
  826. this.isPhone = false
  827. this.areaCode = val.phonenumber.substring(0,val.phonenumber.indexOf('-'))
  828. this.telephone = val.phonenumber.substring(this.areaCode.length+1)
  829. this.form.contactsinfo.telephone = this.areaCode + '-' + this.telephone
  830. this.form.contactsinfo.phonenumber = ''
  831. }else {
  832. this.isPhone = true
  833. this.form.contactsinfo.phonenumber = val.phonenumber
  834. this.form.contactsinfo.telephone = ''
  835. }
  836. },
  837. /*所属经销商*/
  838. async queryAgents() {
  839. var sessionData = sessionStorage.getItem('active_account')
  840. this.agentsParam.content.hrid = JSON.parse(sessionData).hrid
  841. const res = await this.$api.requested(this.agentsParam)
  842. this.agents.agentsData = res.data
  843. this.agents.total = res.total
  844. this.agents.currentPage = res.pageNumber
  845. },
  846. selectAgents() {
  847. this.agentsParam.content.where.condition = this.form.agentname
  848. this.queryAgents()
  849. },
  850. /*客户分页*/
  851. handleSizeChangeAgent(val) {
  852. // console.log(`每页 ${val} 条`);
  853. this.agentsParam.content.pageSize = val
  854. this.queryAgents()
  855. },
  856. handleCurrentChangeAgent(val) {
  857. // console.log(`当前页: ${val}`);
  858. this.agentsParam.content.pageNumber = val
  859. this.queryAgents()
  860. },
  861. agentsData(val) {
  862. this.form.sa_agentsid = val.sa_agentsid
  863. this.form.agentname = val.enterprisename
  864. this.agentsShow = false
  865. },
  866. selectSource(data){
  867. this.form.source = data
  868. }
  869. },
  870. mounted() {
  871. }
  872. }
  873. </script>
  874. <style scoped>
  875. /deep/.el-input__prefix {
  876. display: flex;
  877. align-items: center;
  878. }
  879. </style>