addContactDialog.vue 28 KB

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