detailsPageEdit.vue 17 KB

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