addContactDialog.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form"
  4. :visible.sync="visible"
  5. v-if="visible"
  6. :title="title"
  7. width="80%"
  8. @close="cancel"
  9. >
  10. <el-tabs v-model="activeName" type="card">
  11. <el-tab-pane label="基本信息" name="base">
  12. <el-form
  13. label-width="100px"
  14. ref="form"
  15. :model="form"
  16. :rules="rules"
  17. style="margin-top: 30px"
  18. >
  19. <el-row>
  20. <el-col :span="8">
  21. <el-form-item label="客户名称" prop="name">
  22. <el-input placeholder="请输入" v-model="form.name"></el-input>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="8">
  26. <el-form-item label="客户代码" prop="serialNo">
  27. <el-input
  28. placeholder="请输入"
  29. v-model="form.serialNo"
  30. ></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="8">
  34. <el-form-item label="客户简称" prop="simpleName">
  35. <el-input
  36. placeholder="请输入"
  37. v-model="form.simpleName"
  38. ></el-input>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="8">
  42. <el-form-item label="授信额度" prop="authorizationLimit">
  43. <el-input
  44. placeholder="请输入"
  45. v-model.number="form.authorizationLimit"
  46. ></el-input>
  47. </el-form-item>
  48. </el-col>
  49. <el-col :span="8">
  50. <el-form-item label="地址" prop="addressId">
  51. <el-cascader
  52. clearable
  53. v-model="form.addressId"
  54. :options="options.cityDataLabel"
  55. ref="address"
  56. style="width: 100%"
  57. ></el-cascader>
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="8">
  61. <el-form-item label="详细地址" prop="address">
  62. <el-input
  63. placeholder="请输入"
  64. v-model="form.address"
  65. ></el-input>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="8">
  69. <el-form-item
  70. label="是否存在上级集团公司"
  71. prop="hasParentGroup"
  72. label-width="155px"
  73. >
  74. <el-radio v-model="form.hasParentGroup" :label="1">是</el-radio>
  75. <el-radio v-model="form.hasParentGroup" :label="0">否</el-radio>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="8">
  79. <el-form-item label="经营范围" prop="businessScope">
  80. <el-input
  81. placeholder="请输入"
  82. v-model="form.businessScope"
  83. ></el-input>
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="8">
  87. <el-form-item label="所属行业" prop="industry">
  88. <el-cascader
  89. :options="options.categoryData"
  90. v-model="form.industry"
  91. style="width: 100%"
  92. ref="industry"
  93. >
  94. </el-cascader>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="8">
  98. <el-form-item label="主营产品" prop="mainProduct">
  99. <el-input
  100. placeholder="请输入"
  101. v-model="form.mainProduct"
  102. ></el-input>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="8">
  106. <el-form-item label="企业类型" prop="companyCategoryId">
  107. <DictSelection
  108. dictName="企业类型"
  109. clearable
  110. v-model="form.companyCategoryId"
  111. >
  112. </DictSelection>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="8">
  116. <el-form-item label="单位电话" prop="phone">
  117. <el-input placeholder="请输入" v-model="form.phone"></el-input>
  118. </el-form-item>
  119. </el-col>
  120. <el-col :span="8">
  121. <el-form-item label="登记日期" prop="registerDate">
  122. <el-date-picker
  123. style="width: 100%"
  124. clearable
  125. v-model="form.registerDate"
  126. type="date"
  127. value-format="yyyy-MM-dd"
  128. placeholder="请选择日期"
  129. >
  130. </el-date-picker>
  131. </el-form-item>
  132. </el-col>
  133. <el-col :span="8">
  134. <el-form-item label="官方行业" prop="officialIndustry">
  135. <el-input
  136. placeholder="请输入"
  137. v-model="form.officialIndustry"
  138. ></el-input>
  139. </el-form-item>
  140. </el-col>
  141. <el-col :span="8">
  142. <el-form-item
  143. label="统一社会信用代码 "
  144. prop="unifiedSocialCreditCode"
  145. label-width="130px"
  146. >
  147. <el-input
  148. placeholder="请输入"
  149. v-model="form.unifiedSocialCreditCode"
  150. ></el-input>
  151. </el-form-item>
  152. </el-col>
  153. <el-col :span="8">
  154. <el-form-item prop="businessLicenseFile" label="营业执照附件">
  155. <fileUpload
  156. v-model="form.businessLicenseFiles"
  157. module="main"
  158. :showLib="false"
  159. :limit="1"
  160. />
  161. </el-form-item>
  162. </el-col>
  163. <el-col :span="16">
  164. <el-form-item label="备注" prop="remark">
  165. <el-input
  166. type="textarea"
  167. resize="none"
  168. v-model="form.remark"
  169. :rows="2"
  170. placeholder="请输入"
  171. size="small"
  172. ></el-input>
  173. </el-form-item>
  174. </el-col>
  175. </el-row>
  176. </el-form>
  177. </el-tab-pane>
  178. <el-tab-pane label="银行信息" name="bank">
  179. <ele-pro-table
  180. ref="table"
  181. :columns="bankColumns"
  182. :datasource="tableBankData"
  183. height="350px"
  184. :need-page="false"
  185. >
  186. <!-- 表头工具栏 -->
  187. <template v-slot:toolbar>
  188. <el-button type="primary" @click="addBank">添加</el-button>
  189. </template>
  190. <template v-slot:action="{ row, $index }">
  191. <el-link type="primary" @click="handleBankDel(row, $index)"
  192. >删除</el-link
  193. >
  194. </template>
  195. <template v-slot:accountName="{ row }">
  196. <el-input v-model="row.accountName" placeholder="请输入"></el-input>
  197. </template>
  198. <template v-slot:accountNo="{ row }">
  199. <el-input v-model="row.accountNo" placeholder="请输入"></el-input>
  200. </template>
  201. <template v-slot:bankName="{ row }">
  202. <el-input v-model="row.bankName" placeholder="请输入"></el-input>
  203. </template>
  204. <template v-slot:interbankNo="{ row }">
  205. <el-input v-model="row.interbankNo" placeholder="请输入"></el-input>
  206. </template>
  207. </ele-pro-table>
  208. </el-tab-pane>
  209. <el-tab-pane label="联系人信息" name="link">
  210. <ele-pro-table
  211. ref="linkTable"
  212. :columns="linkColumns"
  213. :datasource="tableLinkData"
  214. height="350px"
  215. :need-page="false"
  216. >
  217. <!-- 表头工具栏 -->
  218. <template v-slot:toolbar>
  219. <el-button type="primary" @click="addLink">添加</el-button>
  220. </template>
  221. <template v-slot:action="{ row, $index }">
  222. <el-link type="primary" @click="handleLinkDel(row, $index)"
  223. >删除</el-link
  224. >
  225. </template>
  226. <template v-slot:linkName="{ row }">
  227. <el-input v-model="row.linkName" placeholder="请输入"></el-input>
  228. </template>
  229. <template v-slot:mobilePhone="{ row }">
  230. <el-input v-model="row.mobilePhone" placeholder="请输入"></el-input>
  231. </template>
  232. <template v-slot:phone="{ row }">
  233. <el-input v-model="row.phone" placeholder="请输入"></el-input>
  234. </template>
  235. <template v-slot:email="{ row }">
  236. <el-input v-model="row.email" placeholder="请输入"></el-input>
  237. </template>
  238. <template v-slot:post="{ row }">
  239. <el-input v-model="row.post" placeholder="请输入"></el-input>
  240. </template>
  241. <template v-slot:ifChief="{ row }">
  242. <el-select v-model="row.ifChief" placeholder="请选择" class="w100">
  243. <el-option
  244. v-for="item in ifChiefList"
  245. :key="item.value"
  246. :label="item.label"
  247. :value="item.value"
  248. ></el-option>
  249. </el-select>
  250. </template>
  251. <template v-slot:status="{ row }">
  252. <DictSelection
  253. dictName="客户联系人状态"
  254. v-model="row.status"
  255. ></DictSelection>
  256. </template>
  257. <template v-slot:remark="{ row }">
  258. <el-input v-model="row.remark" placeholder="请输入"></el-input>
  259. </template>
  260. </ele-pro-table>
  261. </el-tab-pane>
  262. <el-tab-pane label="其他信息" name="other">
  263. <el-form
  264. label-width="100px"
  265. ref="otherForm"
  266. :model="otherForm"
  267. :rules="otherRules"
  268. style="margin-top: 30px"
  269. >
  270. <el-row>
  271. <el-col :span="8">
  272. <el-form-item label="结算方式" prop="settlementMode">
  273. <DictSelection
  274. dictName="结算方式"
  275. clearable
  276. v-model="otherForm.settlementMode"
  277. >
  278. </DictSelection>
  279. </el-form-item>
  280. </el-col>
  281. <el-col :span="8">
  282. <el-form-item label="税率" prop="taxRate">
  283. <el-input v-model.number="otherForm.taxRate">
  284. <template slot="append">%</template>
  285. </el-input>
  286. </el-form-item>
  287. </el-col>
  288. <el-col :span="8">
  289. <el-form-item label="折扣率" prop="discount">
  290. <el-input v-model.number="otherForm.discount">
  291. <template slot="append">%</template>
  292. </el-input>
  293. </el-form-item>
  294. </el-col>
  295. <el-col :span="8">
  296. <el-form-item
  297. label="分管部门:"
  298. prop="deptId"
  299. style="margin-bottom: 22px"
  300. >
  301. <deptSelect
  302. v-model="otherForm.deptId"
  303. @changeGroup="change_principalDep"
  304. placeholder="请选择分管部门"
  305. />
  306. </el-form-item>
  307. </el-col>
  308. <el-col :span="8">
  309. <el-form-item label="业务员:" prop="salesmanId">
  310. <personSelect
  311. ref="directorRef"
  312. v-model="otherForm.salesmanId"
  313. :init="false"
  314. />
  315. </el-form-item>
  316. </el-col>
  317. <el-col :span="8">
  318. <el-form-item label="寄件人" prop="sender">
  319. <el-input placeholder="请输入" v-model="otherForm.sender"></el-input>
  320. </el-form-item>
  321. </el-col>
  322. <el-col :span="8">
  323. <el-form-item label="寄件人电话" prop="senderPhone">
  324. <el-input
  325. placeholder="请输入"
  326. v-model.number="otherForm.senderPhone"
  327. ></el-input>
  328. </el-form-item>
  329. </el-col>
  330. <el-col :span="8">
  331. <el-form-item label="寄件人地址" prop="addressId">
  332. <el-cascader
  333. clearable
  334. v-model="otherForm.addressId"
  335. :options="options.cityDataLabel"
  336. ref="sendAddress"
  337. style="width: 100%"
  338. ></el-cascader>
  339. </el-form-item>
  340. </el-col>
  341. <el-col :span="8">
  342. <el-form-item label="寄件人详细地址" prop="address"
  343. label-width="130px">
  344. <el-input
  345. placeholder="请输入"
  346. v-model="otherForm.address"
  347. ></el-input>
  348. </el-form-item>
  349. </el-col>
  350. </el-row>
  351. </el-form>
  352. </el-tab-pane>
  353. </el-tabs>
  354. <div slot="footer" class="footer">
  355. <el-button type="primary" @click="save">保存</el-button>
  356. <el-button @click="cancel">返回</el-button>
  357. </div>
  358. </ele-modal>
  359. </template>
  360. <script>
  361. import {
  362. contactSave,
  363. contactUpdate,
  364. contactDetail
  365. } from '@/api/saleManage/contact';
  366. import {
  367. categoryData,
  368. CodeToText,
  369. TextToCode
  370. } from 'element-china-category-data';
  371. import fileUpload from '@/components/upload/fileUpload';
  372. import { cityDataLabel } from 'ele-admin/packages/utils/regions';
  373. import {
  374. uploadFile,
  375. removeFile
  376. } from '@/api/system/file/index.js';
  377. import dictMixins from '@/mixins/dictMixins';
  378. import deptSelect from '@/components/CommomSelect/dept-select.vue';
  379. import personSelect from '@/components/CommomSelect/person-select.vue';
  380. export default {
  381. props: {
  382. categoryId: String
  383. },
  384. mixins: [dictMixins],
  385. components: {
  386. fileUpload,
  387. deptSelect,
  388. personSelect
  389. },
  390. data() {
  391. return {
  392. visible: false,
  393. title: '',
  394. row: {},
  395. activeName: 'base',
  396. form: {
  397. address: '',
  398. addressId: 0,
  399. addressName: '',
  400. authorizationLimit: 0,
  401. businessLicenseFiles: [],
  402. businessLicenseFile: {},
  403. businessScope: '',
  404. categoryId: '',
  405. companyCategoryId: '',
  406. companyCategoryName: '',
  407. hasParentGroup: 0,
  408. industryCode: '',
  409. industryFullName: '',
  410. mainProduct: '',
  411. name: '',
  412. officialIndustry: '',
  413. phone: '',
  414. registerDate: '',
  415. remark: '',
  416. serialNo: '',
  417. simpleName: '',
  418. type: 1,
  419. unifiedSocialCreditCode: ''
  420. },
  421. otherForm: {
  422. settlementMode: '',
  423. settlementModeName: '',
  424. taxRate: 0,
  425. address: '',
  426. addressId: '',
  427. deptId: '',
  428. deptName: '',
  429. discount: 0,
  430. salesmanId: '',
  431. salesmanName: '',
  432. sender: '',
  433. senderPhone: ''
  434. },
  435. // removeBankList: [],
  436. // removeLinkList: [],
  437. tableBankData: [],
  438. tableLinkData: [],
  439. ifChiefList: [
  440. {
  441. value: 0,
  442. label: '非首要'
  443. },
  444. {
  445. value: `2`,
  446. label: '首要'
  447. }
  448. ],
  449. bankColumns: [
  450. {
  451. type: 'index',
  452. width: 55,
  453. align: 'center'
  454. },
  455. {
  456. label: '单位名称',
  457. prop: 'accountName',
  458. slot: 'accountName',
  459. action: 'accountName'
  460. },
  461. {
  462. label: '银行账号',
  463. prop: 'accountNo',
  464. slot: 'accountNo',
  465. action: 'accountNo'
  466. },
  467. {
  468. label: '开户行',
  469. prop: 'bankName',
  470. slot: 'bankName',
  471. action: 'bankName'
  472. },
  473. {
  474. label: '银行银联号',
  475. prop: 'interbankNo',
  476. prop: 'interbankNo',
  477. slot: 'interbankNo',
  478. action: 'interbankNo'
  479. },
  480. {
  481. action: 'action',
  482. slot: 'action',
  483. label: '操作'
  484. }
  485. ],
  486. linkColumns: [
  487. {
  488. type: 'index',
  489. width: 55,
  490. align: 'center'
  491. },
  492. {
  493. label: '联系人名称',
  494. prop: 'linkName',
  495. slot: 'linkName',
  496. action: 'linkName'
  497. },
  498. {
  499. label: '手机',
  500. prop: 'mobilePhone',
  501. slot: 'mobilePhone',
  502. action: 'mobilePhone'
  503. },
  504. {
  505. label: '电话',
  506. prop: 'phone',
  507. slot: 'phone',
  508. action: 'phone'
  509. },
  510. {
  511. label: '邮箱',
  512. prop: 'email',
  513. prop: 'email',
  514. slot: 'email',
  515. action: 'email'
  516. },
  517. {
  518. label: '职务',
  519. prop: 'post',
  520. prop: 'post',
  521. slot: 'post',
  522. action: 'post'
  523. },
  524. {
  525. label: '状态',
  526. prop: 'status',
  527. prop: 'status',
  528. slot: 'status',
  529. action: 'status'
  530. },
  531. {
  532. label: '是否首要',
  533. prop: 'ifChief',
  534. prop: 'ifChief',
  535. slot: 'ifChief',
  536. action: 'ifChief'
  537. },
  538. {
  539. label: '备注',
  540. prop: 'remark',
  541. prop: 'remark',
  542. slot: 'remark',
  543. action: 'remark'
  544. },
  545. {
  546. action: 'action',
  547. slot: 'action',
  548. label: '操作'
  549. }
  550. ],
  551. rules: {
  552. name: [
  553. { required: true, message: '请输入客户名称', trigger: 'blur' }
  554. ],
  555. authorizationLimit: [
  556. { required: true, message: '请输入授信额度', trigger: 'change' }
  557. ]
  558. },
  559. otherRules: {
  560. settlementMode: [
  561. { required: true, message: '请输入结算方式', trigger: 'blur' }
  562. ],
  563. taxRate: [
  564. { required: true, message: '请输入税率', trigger: 'change' }
  565. ]
  566. },
  567. options: {
  568. cityDataLabel,
  569. categoryData
  570. },
  571. // 提交状态
  572. loading: false,
  573. // 是否是修改
  574. isUpdate: false
  575. };
  576. },
  577. methods: {
  578. async open(type, row) {
  579. this.title = type;
  580. this.row = row;
  581. this.visible = true;
  582. if (type == '新建客户') {
  583. } else {
  584. this.isUpdate = true;
  585. this._getById(row.id);
  586. }
  587. },
  588. // 选择负责人部门
  589. change_principalDep(id, info) {
  590. this.otherForm.salesmanId = '';
  591. // 根据部门获取人员
  592. const params = { groupId: id };
  593. this.$nextTick(() => {
  594. this.$refs.directorRef.getList(params);
  595. });
  596. },
  597. addBank() {
  598. this.tableBankData.push({
  599. accountName: '',
  600. accountNo: '',
  601. bankName: '',
  602. interbankNo: ''
  603. });
  604. },
  605. addLink() {
  606. this.tableLinkData.push({
  607. linkName: '',
  608. mobilePhone: '',
  609. phone: '',
  610. email: '',
  611. post: '',
  612. status: '',
  613. ifChief: 0,
  614. remark: ''
  615. });
  616. },
  617. handleBankDel(row, index) {
  618. this.tableBankData.splice(index, 1);
  619. if (row?.id) {
  620. // this.removeBankList.push(row.id);
  621. }
  622. },
  623. handleLinkDel(row, index) {
  624. this.linkColumns.splice(index, 1);
  625. if (row?.id) {
  626. // this.removeLinkList.push(row.id);
  627. }
  628. },
  629. async save() {
  630. const isBaseValid = await this.$refs.form.validate();
  631. const isOtherValid = await this.$refs.form.validate();
  632. if (!isBaseValid || !isOtherValid) {
  633. return false;
  634. }
  635. this.loading = true;
  636. // 基本信息处理
  637. this.form.categoryId = this.categoryId;
  638. debugger
  639. if (this.$refs.address.getCheckedNodes()) {
  640. let node = this.$refs.address.getCheckedNodes()[0];
  641. if (node) {
  642. this.form.addressId = node.path.join();;
  643. this.form.addressName = node.pathLabels.join();
  644. }
  645. }
  646. if (this.$refs.industry.getCheckedNodes()) {
  647. let node = this.$refs.industry.getCheckedNodes()[0];
  648. if (node) {
  649. this.form.industryCode = node.path.join();;
  650. this.form.industryFullName = node.pathLabels.join();
  651. }
  652. }
  653. if (this.form.companyCategoryId) {
  654. this.form.companyCategoryName = this.getDictValue(
  655. '企业类型',
  656. this.form.companyCategoryId
  657. );
  658. }
  659. if (
  660. this.form.businessLicenseFiles &&
  661. this.form.businessLicenseFiles.length > 0
  662. ) {
  663. this.form.businessLicenseFile = this.form.businessLicenseFile[0];
  664. }
  665. // 其他信息处理
  666. if (this.form.settlementMode) {
  667. this.form.settlementModeName = this.getDictValue(
  668. '结算方式',
  669. this.form.settlementMode
  670. );
  671. }
  672. if (this.$refs.sendAddress.getCheckedNodes()) {
  673. let node = this.$refs.sendAddress.getCheckedNodes()[0];
  674. if (node) {
  675. this.otherForm.addressId = node.path.join();;
  676. this.otherForm.addressName = node.pathLabels.join();
  677. }
  678. }
  679. if (!this.isUpdate) {
  680. delete this.form.id;
  681. } else {
  682. // this.form.removeBankList = this.removeBankList;
  683. // this.form.removeLinkList = this.removeLinkList;
  684. }
  685. const data = {
  686. base: this.form,
  687. other: this.otherForm,
  688. bankList: this.tableBankData,
  689. linkList: this.tableLinkData
  690. };
  691. if (this.isUpdate) {
  692. contactUpdate(data)
  693. .then((res) => {
  694. this.loading = false;
  695. this.$message.success("修改成功");
  696. this.cancel();
  697. this.$emit('done');
  698. })
  699. .catch((e) => {
  700. this.loading = false;
  701. });
  702. } else {
  703. contactSave(data)
  704. .then((res) => {
  705. this.loading = false;
  706. this.$message.success("新增成功");
  707. this.cancel();
  708. this.$emit('done');
  709. })
  710. .catch((e) => {
  711. this.loading = false;
  712. });
  713. }
  714. },
  715. cancel() {
  716. this.visible = false;
  717. },
  718. async _getById(id) {
  719. const data = await contactDetail(id);
  720. this.form = data.base;
  721. this.otherForm = data.other;
  722. this.tableBankData = data.bankList;
  723. this.tableLinkData = data.linkList;
  724. },
  725. // 文件上传
  726. async handlSuccess(params) {
  727. let res = await uploadFile({
  728. multiPartFile: params.file,
  729. module: this.module
  730. });
  731. if (res?.data) {
  732. this.$emit('input', res.data);
  733. }
  734. },
  735. async clearImg() {
  736. await removeFile({ fileId: this.value.id });
  737. this.$emit('input', {});
  738. this.$refs.uploadRef.clearFiles();
  739. },
  740. // 限制上传的数量
  741. handleExceed(files, fileList) {
  742. this.$message.warning(`最多允许上传一张图片!`);
  743. }
  744. }
  745. };
  746. </script>