add.vue 32 KB

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