detailsPageEdit.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. <template>
  2. <div class="borderless">
  3. <div class="customer-head">
  4. <div class="customer-back">
  5. <!-- <i class="back-icon el-icon-arrow-left"></i><i style="font-style:normal">返回管理列表</i>-->
  6. <el-button
  7. type="danger"
  8. style="border: none;background: none;color: red"
  9. icon="el-icon-arrow-left"
  10. @click="backToList"
  11. >返回列表
  12. </el-button>
  13. </div>
  14. <div class="add-customer-btn">
  15. <el-button type="primary" @click="openFlow" size="small"
  16. >审 核
  17. </el-button>
  18. <el-button
  19. type="primary"
  20. :disabled="disabled"
  21. @click="editCustomer"
  22. size="small"
  23. >{{ form.id ? "确认修改" : "确认新增" }}
  24. </el-button>
  25. </div>
  26. </div>
  27. <div class="customer-main">
  28. <el-form
  29. :model="form"
  30. ref="form"
  31. label-width="100px"
  32. class="demo-ruleForm"
  33. >
  34. <containerTitle title="基础资料"></containerTitle>
  35. <basic-container>
  36. <el-row>
  37. <el-col
  38. v-for="(item, index) in basicData.column"
  39. :key="index"
  40. :span="item.span ? item.span : 8"
  41. >
  42. <el-form-item
  43. :label="item.label"
  44. :prop="item.prop"
  45. :rules="item.rules"
  46. >
  47. <avue-input-tree
  48. v-if="item.prop === 'corpsTypeId'"
  49. leaf-only
  50. multiple
  51. style="width: 100%;"
  52. size="small"
  53. :props="{ label: 'title' }"
  54. v-model="form[item.prop]"
  55. placeholder=" "
  56. type="tree"
  57. :dic="dic"
  58. ></avue-input-tree>
  59. <avue-input-tree
  60. v-else-if="item.prop === 'belongtoarea'"
  61. leaf-only
  62. multiple
  63. style="width: 100%;"
  64. size="small"
  65. :props="{ label: 'name', value: 'name' }"
  66. v-model="form[item.prop]"
  67. placeholder=" "
  68. type="tree"
  69. :dic="dicArea"
  70. ></avue-input-tree>
  71. <el-input
  72. type="age"
  73. v-else
  74. v-model="form[item.prop]"
  75. size="small"
  76. autocomplete="off"
  77. ></el-input>
  78. </el-form-item>
  79. </el-col>
  80. </el-row>
  81. </basic-container>
  82. <containerTitle title="联系方式"></containerTitle>
  83. <basic-container>
  84. <el-row>
  85. <el-col
  86. v-for="(item, index) in contactInformation.column"
  87. :key="index"
  88. :span="item.span ? item.span : 8"
  89. >
  90. <el-form-item
  91. :label="item.label"
  92. :prop="item.prop"
  93. :rules="item.rules"
  94. >
  95. <el-input
  96. type="age"
  97. v-model="form[item.prop]"
  98. size="small"
  99. autocomplete="off"
  100. ></el-input>
  101. </el-form-item>
  102. </el-col>
  103. </el-row>
  104. </basic-container>
  105. <containerTitle title="财务资料"></containerTitle>
  106. <basic-container>
  107. <el-row>
  108. <el-col
  109. v-for="(item, index) in financialInformation.column"
  110. :key="index"
  111. :span="item.span ? item.span : 8"
  112. >
  113. <el-form-item
  114. :label="item.label"
  115. :prop="item.prop"
  116. :rules="item.rules"
  117. >
  118. <el-switch
  119. v-if="item.prop === 'creditstatus'"
  120. v-model="form[item.prop]"
  121. active-value="0"
  122. inactive-value="1"
  123. active-text="开启"
  124. inactive-text="关闭"
  125. >
  126. </el-switch>
  127. <el-select
  128. v-else-if="item.prop === 'paymentType'"
  129. v-model="form[item.prop]"
  130. clearable
  131. filterable
  132. size="small"
  133. style="width: 100%;"
  134. >
  135. <el-option
  136. v-for="(item, index) in paymentOption"
  137. :key="index"
  138. :label="item.dictValue"
  139. :value="item.dictValue"
  140. ></el-option>
  141. </el-select>
  142. <el-input
  143. v-else
  144. type="age"
  145. v-model="form[item.prop]"
  146. size="small"
  147. autocomplete="off"
  148. ></el-input>
  149. </el-form-item>
  150. </el-col>
  151. </el-row>
  152. </basic-container>
  153. <containerTitle title="客户联系人"></containerTitle>
  154. <basic-container>
  155. <avue-crud
  156. :option="customerContact"
  157. v-model="contactsForm"
  158. :data="contactsData"
  159. @row-save="rowSave"
  160. @row-update="rowUpdate"
  161. @row-del="rowDel"
  162. ></avue-crud>
  163. </basic-container>
  164. <!-- <containerTitle title="客户优势项目"></containerTitle>
  165. <basic-container style="margin-bottom: 10px">
  166. <avue-crud
  167. :option="advantageProject"
  168. v-model="advantageProjectForm"
  169. :data="advantageProjectData"
  170. @row-save="rowSaveProject"
  171. @row-update="rowUpdateProject"
  172. @row-del="rowDelProject"
  173. ></avue-crud>
  174. </basic-container> -->
  175. <containerTitle title="客户开户行"></containerTitle>
  176. <basic-container>
  177. <avue-crud
  178. :option="bankOfDeposit"
  179. v-model="bankOfDepositForm"
  180. :data="bankOfDepositData"
  181. @row-save="rowSaveBankOfDeposit"
  182. @row-update="rowUpdateBankOfDeposit"
  183. @row-del="rowDelBankOfDeposit"
  184. ></avue-crud>
  185. </basic-container>
  186. </el-form>
  187. </div>
  188. <flow-dialog :switchDialog="switchDialog" @onClose="onClose()">
  189. <template slot="content"> </template>
  190. </flow-dialog>
  191. </div>
  192. </template>
  193. <script>
  194. import {
  195. customerList,
  196. typeSave,
  197. detail,
  198. deleteDetails,
  199. corpstypeTree,
  200. corpsattn,
  201. corpsbank,
  202. corpsfiles,
  203. corpsitem,
  204. areaTypeTree
  205. } from "@/api/basicData/customerInformation";
  206. import customerContact from "./configuration/customerContact.json";
  207. import advantageProject from "./configuration/advantageProject.json";
  208. import bankOfDeposit from "./configuration/bankOfDeposit.json";
  209. import flowDialog from "@/components/flow-dialog/main";
  210. import { supplierParameter} from "@/enums/management-type";
  211. export default {
  212. name: "detailsPage",
  213. data() {
  214. return {
  215. switchDialog: false,
  216. form: {},
  217. disabled: false,
  218. contactsForm: {},
  219. advantageProjectForm: {},
  220. bankOfDepositForm: {},
  221. contactsData: [],
  222. advantageProjectData: [],
  223. bankOfDepositData: [],
  224. dic: [],
  225. dicArea: [],
  226. customerContact: customerContact,
  227. advantageProject: advantageProject,
  228. bankOfDeposit: bankOfDeposit,
  229. contactInformation: {
  230. column: [
  231. {
  232. label: "联系人",
  233. prop: "attn",
  234. rules: [
  235. {
  236. required: false,
  237. message: "请输入联系人",
  238. trigger: "blur"
  239. }
  240. ]
  241. },
  242. {
  243. label: "联系电话",
  244. prop: "tel",
  245. rules: [
  246. {
  247. required: false,
  248. message: "请输入联系电话",
  249. trigger: "blur"
  250. }
  251. ]
  252. },
  253. {
  254. label: "职位",
  255. prop: "positoin",
  256. rules: [
  257. {
  258. required: false,
  259. message: "请输入联系电话",
  260. trigger: "blur"
  261. }
  262. ]
  263. },
  264. {
  265. label: "单位地址",
  266. prop: "addr",
  267. rules: [
  268. {
  269. required: false,
  270. message: "请输入单位地址",
  271. trigger: "blur"
  272. }
  273. ]
  274. },
  275. {
  276. label: "仓库地址",
  277. prop: "storageAddr",
  278. rules: [
  279. {
  280. required: false,
  281. message: "请输入仓库地址",
  282. trigger: "blur"
  283. }
  284. ]
  285. },
  286. {
  287. label: "分仓地址",
  288. prop: "subStorageAddr",
  289. rules: [
  290. {
  291. required: false,
  292. message: "请输入分仓地址",
  293. trigger: "blur"
  294. }
  295. ]
  296. }
  297. ]
  298. },
  299. financialInformation: {
  300. column: [
  301. {
  302. label: "账户名称",
  303. prop: "accountName",
  304. rules: [
  305. {
  306. required: false,
  307. message: " ",
  308. trigger: "blur"
  309. }
  310. ]
  311. },
  312. {
  313. label: "开户银行",
  314. prop: "accountBank",
  315. rules: [
  316. {
  317. required: false,
  318. message: " ",
  319. trigger: "blur"
  320. }
  321. ]
  322. },
  323. {
  324. label: "银行帐号",
  325. prop: "accountNo",
  326. rules: [
  327. {
  328. required: false,
  329. message: " ",
  330. trigger: "blur"
  331. }
  332. ]
  333. },
  334. {
  335. label: "外币账户名称",
  336. prop: "accountNameFcy",
  337. rules: [
  338. {
  339. required: false,
  340. message: " ",
  341. trigger: "blur"
  342. }
  343. ]
  344. },
  345. {
  346. label: "外币开户银行",
  347. prop: "accountBankFcy",
  348. rules: [
  349. {
  350. required: false,
  351. message: " ",
  352. trigger: "blur"
  353. }
  354. ]
  355. },
  356. {
  357. label: "外币银行账号",
  358. prop: "accountNoFcy",
  359. rules: [
  360. {
  361. required: false,
  362. message: " ",
  363. trigger: "blur"
  364. }
  365. ]
  366. },
  367. {
  368. label: "授信状态",
  369. prop: "creditstatus",
  370. rules: [
  371. {
  372. required: false,
  373. message: " ",
  374. trigger: "blur"
  375. }
  376. ]
  377. },
  378. {
  379. label: "授信等级",
  380. prop: "creditLevel",
  381. rules: [
  382. {
  383. required: false,
  384. message: " ",
  385. trigger: "blur"
  386. }
  387. ]
  388. },
  389. {
  390. label: "授信额度",
  391. prop: "creditGrant",
  392. rules: [
  393. {
  394. required: false,
  395. message: " ",
  396. trigger: "blur"
  397. }
  398. ]
  399. },
  400. {
  401. label: "授信天数",
  402. prop: "creditDay",
  403. rules: [
  404. {
  405. required: false,
  406. message: " ",
  407. trigger: "blur"
  408. }
  409. ]
  410. },
  411. {
  412. label: "授信利率",
  413. prop: "creditRate",
  414. rules: [
  415. {
  416. required: false,
  417. message: " ",
  418. trigger: "blur"
  419. }
  420. ]
  421. },
  422. {
  423. label: "FOB系数",
  424. prop: "coefficient"
  425. },
  426. {
  427. label: "付款方式",
  428. prop: "paymentType"
  429. }
  430. ]
  431. },
  432. basicData: {
  433. column: [
  434. {
  435. label: "编码",
  436. prop: "code",
  437. rules: [
  438. {
  439. required: true,
  440. message: " ",
  441. trigger: "blur"
  442. }
  443. ]
  444. },
  445. {
  446. label: "名称",
  447. prop: "cname",
  448. rules: [
  449. {
  450. required: true,
  451. message: " ",
  452. trigger: "blur"
  453. }
  454. ]
  455. },
  456. {
  457. label: "类别",
  458. prop: "corpsTypeId",
  459. rules: [
  460. {
  461. required: true,
  462. message: " ",
  463. trigger: "blur"
  464. }
  465. ]
  466. },
  467. {
  468. label: "企业类型",
  469. prop: "companytype",
  470. rules: [
  471. {
  472. required: false,
  473. message: " ",
  474. trigger: "blur"
  475. }
  476. ]
  477. },
  478. {
  479. label: "代理品牌",
  480. prop: "goodtypes",
  481. rules: [
  482. {
  483. required: false,
  484. message: " ",
  485. trigger: "blur"
  486. }
  487. ]
  488. },
  489. {
  490. label: "所属公司",
  491. prop: "belongtocompany",
  492. rules: [
  493. {
  494. required: false,
  495. message: " ",
  496. trigger: "blur"
  497. }
  498. ]
  499. },
  500. {
  501. label: "代理区域",
  502. prop: "belongtoarea",
  503. span: 24,
  504. mock: {
  505. type: "county"
  506. }
  507. },
  508. {
  509. label: "备注",
  510. prop: "remarks",
  511. span: 24,
  512. mock: {
  513. type: "county"
  514. }
  515. }
  516. ]
  517. },
  518. paymentOption: []
  519. };
  520. },
  521. components: {
  522. flowDialog
  523. },
  524. created() {
  525. corpstypeTree({ corpType: supplierParameter.code }).then(res => {
  526. this.dic = res.data.data;
  527. });
  528. areaTypeTree().then(res => {
  529. this.dicArea = res.data.data;
  530. });
  531. this.getWorkDicts("payment_term").then(res => {
  532. this.paymentOption = res.data.data;
  533. });
  534. if (this.$route.query.id) {
  535. let id = this.$route.query.id.replace(/\"/g, "");
  536. // let id = parseInt(this.$route.query.id)
  537. detail(id).then(res => {
  538. console.log(res.data.data);
  539. this.form = res.data.data;
  540. this.contactsData = this.form.corpsAttnList;
  541. this.bankOfDepositData = this.form.corpsBankList;
  542. this.advantageProjectData = this.form.corpsItems;
  543. delete this.form.corpsAttnList;
  544. delete this.form.corpsBankList;
  545. delete this.form.corpsItems;
  546. });
  547. } else {
  548. //新增时根据左侧选中树结构给客户类别赋值
  549. this.$set(this.form, "corpsTypeId", this.$route.query.treeDeptId);
  550. }
  551. },
  552. watch: {
  553. $route(to, from) {
  554. console.log(to, from);
  555. if (this.$route.query.id) {
  556. let id = JSON.parse(this.$route.query.id).replace(/\"/g, "");
  557. detail(id).then(res => {
  558. console.log(res.data.data);
  559. this.form = res.data.data;
  560. });
  561. } else {
  562. this.form = {};
  563. }
  564. }
  565. },
  566. methods: {
  567. //新增客户联系人保存触发
  568. rowSave(row, done, loading) {
  569. console.log(row, done, loading);
  570. this.contactsData.push(row);
  571. done();
  572. },
  573. //修改客户联系人触发
  574. rowUpdate(row, index, done, loading) {
  575. done(row);
  576. },
  577. //删除客户联系人触发
  578. rowDel(row, index, donerowDel) {
  579. this.$confirm("确定将选择数据删除?", {
  580. confirmButtonText: "确定",
  581. cancelButtonText: "取消",
  582. type: "warning"
  583. }).then(() => {
  584. // 数据回调进行刷新
  585. if (row.id) {
  586. corpsattn(row.id).then(res => {
  587. this.$message({
  588. type: "success",
  589. message: "操作成功!"
  590. });
  591. this.contactsData.splice(index, 1);
  592. });
  593. } else {
  594. this.$message({
  595. type: "success",
  596. message: "操作成功!"
  597. });
  598. this.contactsData.splice(index, 1);
  599. }
  600. });
  601. },
  602. //新增客户优势项目保存触发
  603. rowSaveProject(row, done, loading) {
  604. console.log(row, done, loading);
  605. this.advantageProjectData.push(row);
  606. done();
  607. },
  608. //修改客户优势项目触发
  609. rowUpdateProject(row, index, done, loading) {
  610. done(row);
  611. },
  612. //删除客户优势项目触发
  613. rowDelProject(row, index, donerowDel) {
  614. this.$confirm("确定将选择数据删除?", {
  615. confirmButtonText: "确定",
  616. cancelButtonText: "取消",
  617. type: "warning"
  618. }).then(() => {
  619. if (row.id) {
  620. corpsitem(row.id).then(res => {
  621. this.$message({
  622. type: "success",
  623. message: "操作成功!"
  624. });
  625. this.advantageProjectData.splice(index, 1);
  626. });
  627. } else {
  628. this.$message({
  629. type: "success",
  630. message: "操作成功!"
  631. });
  632. this.advantageProjectData.splice(index, 1);
  633. }
  634. });
  635. },
  636. //新增客户优势项目保存触发
  637. rowSaveBankOfDeposit(row, done, loading) {
  638. console.log(row, done, loading);
  639. this.bankOfDepositData.push(row);
  640. done();
  641. },
  642. //修改客户优势项目触发
  643. rowUpdateBankOfDeposit(row, index, done, loading) {
  644. done(row);
  645. },
  646. //删除客户优势项目触发
  647. rowDelBankOfDeposit(row, index, donerowDel) {
  648. this.$confirm("确定将选择数据删除?", {
  649. confirmButtonText: "确定",
  650. cancelButtonText: "取消",
  651. type: "warning"
  652. }).then(() => {
  653. if (row.id) {
  654. corpsbank(row.id).then(res => {
  655. this.$message({
  656. type: "success",
  657. message: "操作成功!"
  658. });
  659. this.bankOfDepositData.splice(index, 1);
  660. });
  661. } else {
  662. this.$message({
  663. type: "success",
  664. message: "操作成功!"
  665. });
  666. this.bankOfDepositData.splice(index, 1);
  667. }
  668. });
  669. },
  670. //修改提交触发
  671. editCustomer() {
  672. this.$refs["form"].validate(valid => {
  673. if (valid) {
  674. this.form.corpsAttnList = this.contactsData;
  675. this.form.corpsBankList = this.bankOfDepositData;
  676. this.form.corpsItems = this.advantageProjectData;
  677. if (typeof this.form.corpsTypeId == "object") {
  678. this.form.corpsTypeId = this.form.corpsTypeId.join(",");
  679. }
  680. this.disabled = true;
  681. if (this.form.belongtoarea) {
  682. this.form.belongtoarea = this.form.belongtoarea.toString();
  683. }
  684. this.form.corpType = supplierParameter.code;
  685. typeSave(this.form).then(res => {
  686. if (res.data.data === "error") {
  687. this.disabled = false;
  688. this.$message({
  689. showClose: true,
  690. message: res.data.msg,
  691. type: "error"
  692. });
  693. } else {
  694. this.$message({
  695. type: "success",
  696. message: this.form.id ? "修改成功!" : "新增成功!"
  697. });
  698. this.$router.$avueRouter.closeTag();
  699. this.$router.push({
  700. path: "/basicData/customerManagement/supplierMaterial/index",
  701. query: {}
  702. });
  703. }
  704. });
  705. } else {
  706. return false;
  707. }
  708. });
  709. },
  710. backToList() {
  711. this.$router.$avueRouter.closeTag();
  712. this.$router.push({
  713. path: "/basicData/customerManagement/supplierMaterial/index",
  714. query: {}
  715. });
  716. },
  717. openFlow() {
  718. this.switchDialog = !this.switchDialog;
  719. },
  720. onClose(val) {
  721. this.switchDialog = val;
  722. }
  723. }
  724. };
  725. </script>
  726. <style lang="scss" scoped>
  727. ::v-deep .el-form-item {
  728. margin-bottom: 0;
  729. }
  730. </style>