detailsPageEdit.vue 17 KB

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