detailsPage.vue 28 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003
  1. <template>
  2. <div>
  3. <div class="borderless">
  4. <div class="customer-head">
  5. <div class="customer-back">
  6. <el-button type="danger" style="border: none;background: none;color: red" icon="el-icon-arrow-left" @click="backToList"
  7. >返回列表
  8. </el-button>
  9. </div>
  10. <div class="add-customer-btn">
  11. <el-button type="primary" size="small" @click="editCustomer">
  12. 保存数据
  13. </el-button>
  14. <el-button class="el-button--small-yh" :type="form.enableOrNot == 0 ? 'primary' : ''" size="small" v-if="form.id" @click="editEnable">
  15. {{ form.enableOrNot == 0 ? "启用" : "禁用" }}
  16. </el-button>
  17. </div>
  18. </div>
  19. <trade-card title="基础资料" style="margin-top: 60px" v-loading="loadingBtn">
  20. <avue-form ref="form" class="trading-form" v-model="form" :option="option">
  21. <template slot="corpsTypeIdLabel">
  22. <span style="color: #409EFF;cursor: pointer" @click="corpTypeVisible = true">
  23. 客户分类
  24. </span>
  25. </template>
  26. <template slot="corpsTypeId">
  27. <avue-input-tree v-model="form.corpsTypeId" :disabled="option.disabled" placeholder="请选择客户分类" :dic="corpTypeList" :props="props">
  28. </avue-input-tree>
  29. </template>
  30. <tempalte slot="salesmanName">
  31. <dic-select
  32. v-model="form.salesmanName"
  33. placeholder="业务员"
  34. label="name"
  35. @selectChange="dicChange('salesmanName', $event)"
  36. :disabled="option.disabled"
  37. url="/blade-user/factoryUserList"
  38. :filterable="true"
  39. dataName="name"
  40. >
  41. </dic-select>
  42. </tempalte>
  43. <tempalte slot="deliveryWarehouseName">
  44. <dic-select
  45. v-model="form.deliveryWarehouseName"
  46. placeholder="发货仓库"
  47. label="cname"
  48. res="records"
  49. url="/gubersail-admin/storageDesc/list?current=1&size=5"
  50. :filterable="true"
  51. :remote="true"
  52. dataName="cname"
  53. @selectChange="dicChange('deliveryWarehouseName', $event)"
  54. :disabled="option.disabled"
  55. ></dic-select>
  56. </tempalte>
  57. <tempalte slot="label">
  58. <dic-select
  59. :key="labelKey"
  60. v-model="form.label"
  61. placeholder="门店标签"
  62. label="label"
  63. res="records"
  64. url="/gubersail-admin/corpslabel/list?current=1&size=5"
  65. :filterable="true"
  66. :remote="true"
  67. dataName="label"
  68. :disabled="option.disabled"
  69. ></dic-select>
  70. </tempalte>
  71. <tempalte slot="brandName">
  72. <dic-select
  73. v-model="form.brandName"
  74. placeholder="品牌"
  75. label="cname"
  76. url="/gubersail-admin/brandDesc/listAllV1?type=PP"
  77. :filterable="true"
  78. @selectChange="dicChange('brandName', $event)"
  79. :multiple="true"
  80. :disabled="option.disabled"
  81. dataType="string"
  82. ></dic-select>
  83. </tempalte>
  84. <template slot="labelLabel">
  85. <span style="color: #409EFF;cursor: pointer" @click="labelVisible = true">
  86. 门店标签
  87. </span>
  88. </template>
  89. </avue-form>
  90. </trade-card>
  91. <trade-card title="客户联系人" v-loading="loadingBtn">
  92. <avue-crud
  93. ref="crudTwo"
  94. :option="customerContactBack"
  95. v-model="contactsForm"
  96. :data="contactsData"
  97. @row-save="rowSave"
  98. @row-update="rowUpdate"
  99. @row-del="rowDelTwo"
  100. >
  101. <template slot-scope="{ type, size, row, disabled, index }" slot="menu">
  102. <el-button
  103. :size="size"
  104. :disabled="disabled"
  105. :type="type"
  106. :icon="row.$cellEdit ? 'el-icon-plus' : 'el-icon-edit'"
  107. @click="$refs.crudTwo.rowEdit(row, index)"
  108. >{{ row.$cellEdit ? "确认" : "修改" }}
  109. </el-button>
  110. <el-button icon="el-icon-delete" :size="size" :disabled="disabled" :type="type" @click="rowDelTwo(row, index)">删除 </el-button>
  111. <el-button icon="el-icon-check" :size="size" :type="type" @click="creatingUsers(row)">创建用户 </el-button>
  112. </template>
  113. </avue-crud>
  114. </trade-card>
  115. <trade-card title="地址信息" v-loading="loadingBtn">
  116. <avue-crud :option="option2" ref="crud" :data="data" @row-save="rowSave" @row-update="rowUpdate">
  117. <template slot="headerSerial">
  118. <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow" :disabled="detailData.status == 1" circle></el-button>
  119. </template>
  120. <template slot="menuLeft">
  121. <el-button type="primary" icon="el-icon-plus" size="small" @click.stop="addRow">录入明细 </el-button>
  122. </template>
  123. <template v-if="!row.$cellEdit" slot-scope="{ type, size, row, index, disabled }" slot="menu">
  124. <el-button
  125. :size="size"
  126. :disabled="disabled"
  127. :type="type"
  128. :icon="row.$cellEdit ? 'el-icon-plus' : 'el-icon-edit'"
  129. @click="$refs.crud.rowCell(row, index)"
  130. >{{ row.$cellEdit ? "确认" : "修改" }}
  131. </el-button>
  132. <el-button icon="el-icon-delete" :size="size" :disabled="disabled" :type="type" @click="rowDel(row, index)">删除 </el-button>
  133. </template>
  134. <template slot="defaultAddres" slot-scope="{ row, index, disabled }">
  135. <el-switch active-value="1" inactive-value="0" :disabled="disabled" v-model="row.defaultAddres" @change="addressUnique(row, index)">
  136. </el-switch>
  137. </template>
  138. </avue-crud>
  139. </trade-card>
  140. <containerTitle title="上传附件"></containerTitle>
  141. <c-upload
  142. v-loading="loadingBtn"
  143. typeUpload="CD"
  144. deleteUrl="/api/gubersail-admin/corpsfiles/remove"
  145. :data="corpsFiles"
  146. display
  147. :enumerationValue="35.1"
  148. :disabled="detailData.status == 1"
  149. :mainImageType="true"
  150. ></c-upload>
  151. <el-dialog
  152. title="设置客户分类"
  153. v-dialogDrag
  154. :visible.sync="corpTypeVisible"
  155. class="avue-dialog"
  156. width="80%"
  157. append-to-body
  158. @closed="corpTypeClosed"
  159. >
  160. <span>
  161. <corp-type v-if="corpTypeVisible"></corp-type>
  162. </span>
  163. <div class="avue-dialog__footer">
  164. <el-button @click="corpTypeVisible = false" size="mini">取 消</el-button>
  165. <el-button @click="addCorpType" type="primary" size="mini">确 定</el-button>
  166. </div>
  167. </el-dialog>
  168. </div>
  169. <el-dialog title="设置门店标签" v-dialogDrag :visible.sync="labelVisible" class="avue-dialog" width="80%" append-to-body @closed="labelClosed">
  170. <span>
  171. <corp-label v-if="labelVisible"></corp-label>
  172. </span>
  173. <div class="avue-dialog__footer">
  174. <el-button @click="labelVisible = false" size="mini">取 消</el-button>
  175. <el-button @click="addLabel" type="primary" size="mini">确 定</el-button>
  176. </div>
  177. </el-dialog>
  178. <el-dialog title="创建用户" :visible.sync="dialogVisibleBt" append-to-body width="60%">
  179. <avue-form v-if="dialogVisibleBt" ref="formDataTwo" v-model="formDataTwo" :option="optionData"> </avue-form>
  180. <span slot="footer" class="dialog-footer">
  181. <el-button @click="dialogVisibleBt = false">取 消</el-button>
  182. <el-button type="primary" @click="confirmSynchronizationTwo">确 定</el-button>
  183. </span>
  184. </el-dialog>
  185. </div>
  186. </template>
  187. <script>
  188. import {
  189. getDetails,
  190. getCorpType,
  191. submit,
  192. customerList,
  193. areaTypeTree,
  194. itemDel,
  195. corpsattn,
  196. editenable,
  197. getUserByRole,
  198. getBrandDesc,
  199. creatingUsersTwo
  200. } from "@/api/store/customerInformation";
  201. import { getRoleTree } from "@/api/system/role";
  202. import { getDeptTree } from "@/api/system/dept";
  203. import { getPostList } from "@/api/system/post";
  204. import corpType from "./components/index.vue";
  205. import corpLabel from "./components/label.vue";
  206. import website from "@/config/website";
  207. import dicSelect from "@/components/dicSelect/main.vue";
  208. import { getToken } from "@/util/auth";
  209. export default {
  210. name: "index",
  211. data() {
  212. return {
  213. labelKey: Date.now(),
  214. labelVisible: false,
  215. propsCk: {
  216. label: "cname",
  217. value: "id"
  218. },
  219. props: {
  220. label: "title",
  221. value: "value"
  222. },
  223. optionData: {
  224. span: 8,
  225. menuBtn: false,
  226. column: [
  227. {
  228. label: "所属角色",
  229. prop: "roleId",
  230. multiple: true,
  231. type: "tree",
  232. dicData: [],
  233. props: {
  234. label: "title"
  235. },
  236. checkStrictly: true,
  237. slot: true,
  238. rules: [
  239. {
  240. required: true,
  241. message: "请选择所属角色",
  242. trigger: "click"
  243. }
  244. ]
  245. },
  246. {
  247. label: "所属部门",
  248. prop: "deptId",
  249. type: "tree",
  250. multiple: true,
  251. dicData: [],
  252. props: {
  253. label: "title"
  254. },
  255. checkStrictly: true,
  256. slot: true,
  257. rules: [
  258. {
  259. required: true,
  260. message: "请选择所属部门",
  261. trigger: "click"
  262. }
  263. ]
  264. },
  265. {
  266. label: "所属岗位",
  267. prop: "postId",
  268. type: "tree",
  269. multiple: true,
  270. dicData: [],
  271. props: {
  272. label: "postName",
  273. value: "id"
  274. },
  275. rules: [
  276. {
  277. required: true,
  278. message: "请选择所属岗位",
  279. trigger: "click"
  280. }
  281. ]
  282. }
  283. ]
  284. },
  285. dialogVisibleBt: false,
  286. formDataTwo: false,
  287. customerContact: {},
  288. contactsForm: {},
  289. contactsData: [],
  290. corpTypeList: [],
  291. corpTypeVisible: false,
  292. loadingBtn: false,
  293. form: {
  294. ifLimitAmount: "0"
  295. },
  296. form4: {},
  297. data: [],
  298. data2: [],
  299. option: {
  300. menuBtn: false,
  301. span: 6,
  302. column: [
  303. {
  304. label: "客户名称",
  305. prop: "cname",
  306. rules: [
  307. {
  308. required: true,
  309. message: "",
  310. trigger: "blur"
  311. }
  312. ]
  313. },
  314. {
  315. label: "客户分类",
  316. prop: "corpsTypeId",
  317. rules: [
  318. {
  319. required: true,
  320. message: " ",
  321. trigger: "blur"
  322. }
  323. ]
  324. },
  325. {
  326. label: "电话",
  327. prop: "tel"
  328. },
  329. {
  330. label: "业务员",
  331. prop: "salesmanName",
  332. rules: [
  333. {
  334. required: true,
  335. message: " ",
  336. trigger: "blur"
  337. }
  338. ]
  339. },
  340. {
  341. label: "发货仓库",
  342. prop: "deliveryWarehouseName",
  343. rules: [
  344. {
  345. required: true,
  346. message: " ",
  347. trigger: "blur"
  348. }
  349. ]
  350. },
  351. {
  352. label: "商城价格",
  353. prop: "priceSystem",
  354. filterable: true,
  355. type: "select",
  356. dicUrl: "/api/blade-system/dict-biz/dictionary?code=mall_price",
  357. props: {
  358. label: "dictValue",
  359. value: "dictKey"
  360. },
  361. rules: [
  362. {
  363. required: true,
  364. message: " ",
  365. trigger: "blur"
  366. }
  367. ]
  368. },
  369. {
  370. label: "积分余额",
  371. prop: "pointsBalance",
  372. type: "number",
  373. controls: false,
  374. precision: 2,
  375. disabled: true
  376. },
  377. {
  378. label: "品牌",
  379. prop: "brandName",
  380. rules: [
  381. {
  382. message: "请选择品牌",
  383. trigger: "click"
  384. }
  385. ]
  386. },
  387. {
  388. label: "门店标签",
  389. prop: "label"
  390. },
  391. {
  392. label: "店面属性",
  393. prop: "storeAttributes"
  394. },
  395. {
  396. label: "连锁属性",
  397. prop: "chainAttribute"
  398. },
  399. {
  400. label: "签约级别",
  401. prop: "signingLevel"
  402. },
  403. {
  404. label: "签约条数",
  405. prop: "signingNumber"
  406. },
  407. {
  408. label: "签约期限起",
  409. prop: "signingPeriodStart",
  410. type: "month",
  411. format: "yyyy-MM",
  412. valueFormat: "yyyy-MM-01 00:00:00"
  413. },
  414. {
  415. label: "签约期限止",
  416. prop: "signingPeriodEnd",
  417. type: "month",
  418. format: "yyyy-MM",
  419. valueFormat: "yyyy-MM-01 00:00:00"
  420. },
  421. {
  422. label: "营业执照",
  423. prop: "businessLicenseUrl",
  424. type: "upload",
  425. listType: "picture-img",
  426. fileType: "img", //img/video/audio
  427. propsHttp: {
  428. res: "data",
  429. url: "link"
  430. },
  431. action: "/api/blade-resource/oss/endpoint/put-file",
  432. headers: { "Blade-Auth": "Bearer " + getToken() }
  433. },
  434. {
  435. label: "备注",
  436. prop: "remarks",
  437. type: "textarea",
  438. minRows: 2,
  439. span: 24
  440. }
  441. ]
  442. },
  443. option2: {
  444. align: "center",
  445. index: true,
  446. addBtnText: "录入明细",
  447. refreshBtn: false,
  448. dialogDrag: true,
  449. addBtn: false,
  450. span: 8,
  451. height: 300,
  452. editBtn: false,
  453. delBtn: false,
  454. menuWidth: 140,
  455. dialogTop: 25,
  456. dialogWidth: "80%",
  457. addRowBtn: false,
  458. cellBtn: true,
  459. rowKey: "index",
  460. cancelBtn: false,
  461. columnBtn: false,
  462. // saveBtn:false,
  463. column: [
  464. {
  465. label: "联系人",
  466. prop: "contacts",
  467. cell: true,
  468. rules: [
  469. {
  470. required: true,
  471. message: " ",
  472. trigger: "blur"
  473. }
  474. ]
  475. },
  476. {
  477. label: "电话",
  478. prop: "tel",
  479. cell: true,
  480. rules: [
  481. {
  482. required: true,
  483. message: " ",
  484. trigger: "blur"
  485. }
  486. ]
  487. },
  488. {
  489. label: "地址",
  490. prop: "belongtoarea",
  491. dicData: [],
  492. dataType: "string",
  493. type: "cascader",
  494. props: {
  495. label: "name",
  496. value: "name"
  497. },
  498. rules: [
  499. {
  500. required: true,
  501. message: " ",
  502. trigger: "blur"
  503. }
  504. ],
  505. filterable: true,
  506. cell: true
  507. },
  508. {
  509. label: "详细地址",
  510. prop: "detailedAddress",
  511. cell: true,
  512. rules: [
  513. {
  514. required: true,
  515. message: " ",
  516. trigger: "blur"
  517. }
  518. ]
  519. },
  520. {
  521. label: "备注",
  522. prop: "remarks",
  523. cell: true
  524. },
  525. {
  526. label: "默认地址",
  527. prop: "defaultAddres",
  528. display: false,
  529. width: 100
  530. }
  531. ]
  532. },
  533. option3: {},
  534. option4: {
  535. menuBtn: false,
  536. labelWidth: 80,
  537. column: [
  538. {
  539. label: "分类名称",
  540. prop: "cname",
  541. rules: [
  542. {
  543. required: true,
  544. message: "",
  545. trigger: "blur"
  546. }
  547. ],
  548. span: 24
  549. },
  550. {
  551. label: "上级类型",
  552. prop: "parentId",
  553. dicData: [],
  554. type: "tree",
  555. props: {
  556. label: "cname",
  557. value: "id"
  558. },
  559. span: 24
  560. }
  561. ]
  562. },
  563. corpsFiles: [],
  564. customerContactBack: {
  565. align: "center",
  566. index: true,
  567. addBtnText: "录入明细",
  568. refreshBtn: false,
  569. dialogDrag: true,
  570. addBtn: true,
  571. span: 8,
  572. height: 300,
  573. addRowBtn: false,
  574. editBtn: false,
  575. delBtn: false,
  576. menuWidth: 200,
  577. dialogTop: 25,
  578. dialogWidth: "80%",
  579. columnBtn: false,
  580. column: [
  581. {
  582. label: "联系人",
  583. prop: "cname",
  584. cell: true,
  585. rules: [
  586. {
  587. required: true,
  588. message: " ",
  589. trigger: "blur"
  590. }
  591. ]
  592. },
  593. {
  594. label: "电话",
  595. prop: "tel",
  596. cell: true,
  597. rules: [
  598. {
  599. required: true,
  600. message: " ",
  601. trigger: "blur"
  602. }
  603. ]
  604. },
  605. // {
  606. // label: "登录用户id",
  607. // prop: "userId",
  608. // cell: true
  609. // },
  610. {
  611. label: "备注",
  612. prop: "remarks",
  613. cell: true
  614. }
  615. ]
  616. },
  617. userObj: {}
  618. };
  619. },
  620. components: { corpType, dicSelect, corpLabel },
  621. props: {
  622. detailData: {
  623. type: Object
  624. }
  625. },
  626. async created() {
  627. if (this.detailData.id) {
  628. this.getDetail(this.detailData.id);
  629. }
  630. if (this.detailData.status == 1) {
  631. this.option.disabled = true;
  632. }
  633. if (!website.tenantMode) {
  634. this.initData(website.tenantId);
  635. } else {
  636. this.initData();
  637. }
  638. this.getCorpType();
  639. this.getAllWorkDicts();
  640. this.userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;
  641. },
  642. activated() {
  643. setTimeout(() => {
  644. this.$nextTick(() => {
  645. this.$refs.crud.doLayout();
  646. });
  647. }, 100);
  648. },
  649. methods: {
  650. dicChange(name, row) {
  651. if (name == "salesmanName") {
  652. if (row) {
  653. this.form.salesmanId = row.id;
  654. } else {
  655. this.form.salesmanId = null;
  656. this.form.salesmanName = null;
  657. }
  658. }
  659. if (name == "brandName") {
  660. if (row) {
  661. this.form.brandId = row.ids;
  662. this.form.brandName = row.names;
  663. } else {
  664. this.form.brandId = null;
  665. this.form.brandName = null;
  666. }
  667. }
  668. if (name == "deliveryWarehouseName") {
  669. if (row) {
  670. this.form.deliveryWarehouseId = row.id;
  671. } else {
  672. this.form.deliveryWarehouseId = null;
  673. this.form.deliveryWarehouseName = null;
  674. }
  675. }
  676. },
  677. // 启用或禁用
  678. editEnable() {
  679. let data = this.form;
  680. editenable({ id: data.id, enableOrNot: data.enableOrNot ? 0 : 1 }).then(res => {
  681. this.$message({
  682. type: "success",
  683. message: data.enableOrNot ? "禁用成功!" : "启用成功!"
  684. });
  685. this.getDetail(this.detailData.id);
  686. // this.$set(this.form, 'enableOrNot', data.enableOrNot == 1 ? 0 : 1)
  687. });
  688. },
  689. addressUnique(row, index) {
  690. for (let item in this.data) {
  691. if (index != item) {
  692. if (this.data[item].defaultAddres == 1) {
  693. this.$message.warning("默认地址只能唯一");
  694. return (row.defaultAddres = 0);
  695. }
  696. }
  697. }
  698. },
  699. initData(tenantId) {
  700. getRoleTree(tenantId).then(res => {
  701. const column = this.findObject(this.optionData.column, "roleId");
  702. column.dicData = res.data.data;
  703. });
  704. getDeptTree(tenantId).then(res => {
  705. const column = this.findObject(this.optionData.column, "deptId");
  706. column.dicData = res.data.data;
  707. });
  708. getPostList(tenantId).then(res => {
  709. const column = this.findObject(this.optionData.column, "postId");
  710. column.dicData = res.data.data;
  711. });
  712. },
  713. //确认创建用户
  714. confirmSynchronizationTwo() {
  715. this.$refs.formDataTwo.validate((valid, done) => {
  716. done();
  717. if (valid) {
  718. let data = JSON.parse(JSON.stringify(this.formDataTwo));
  719. data.deptId = data.deptId.join(",");
  720. data.roleId = data.roleId.join(",");
  721. data.postId = data.postId.join(",");
  722. creatingUsersTwo({
  723. ...data,
  724. id: this.formRow.id
  725. }).then(res => {
  726. this.dialogVisibleBt = false;
  727. this.formDataTwo = {};
  728. this.$message.success("创建用户成功,默认帐号:手机号。默认密码:123456");
  729. this.getDetail(this.form.id);
  730. });
  731. } else {
  732. return false;
  733. }
  734. });
  735. },
  736. getAllWorkDicts() {
  737. customerList({ corpType: "KH" }).then(res => {
  738. this.findObject(this.option4.column, "parentId").dicData = res.data.data.records;
  739. });
  740. this.findObject(this.option2.column, "belongtoarea").dicData = JSON.parse(localStorage.getItem("areaTypeTree"))
  741. ? JSON.parse(localStorage.getItem("areaTypeTree"))
  742. : [];
  743. },
  744. getDetail(id) {
  745. this.loadingBtn = true;
  746. getDetails({ id: id })
  747. .then(res => {
  748. if (res.data.data.enableOrNot == 1) {
  749. this.$set(this.option, "disabled", true);
  750. } else {
  751. this.$set(this.option, "disabled", false);
  752. }
  753. this.data = res.data.data.corpsAddrList;
  754. this.corpsFiles = res.data.data.corpsFilesList;
  755. this.contactsData = res.data.data.corpsAttnList;
  756. this.form = res.data.data;
  757. })
  758. .finally(() => {
  759. this.loadingBtn = false;
  760. });
  761. },
  762. addRow() {
  763. this.data.push({ $cellEdit: true });
  764. },
  765. rowDel(row, index) {
  766. this.$confirm("确定删除数据?", {
  767. confirmButtonText: "确定",
  768. cancelButtonText: "取消",
  769. type: "warning"
  770. }).then(() => {
  771. if (row.id) {
  772. itemDel(row.id).then(res => {
  773. this.$message({
  774. type: "success",
  775. message: "删除成功!"
  776. });
  777. this.data.splice(index, 1);
  778. });
  779. } else {
  780. this.$message({
  781. type: "success",
  782. message: "删除成功!"
  783. });
  784. this.data.splice(index, 1);
  785. }
  786. });
  787. },
  788. addRow2() {
  789. this.data2.push({ $cellEdit: true, type: 1 });
  790. },
  791. rowCell2(row, index) {
  792. if (row.$cellEdit == true) {
  793. this.$set(row, "$cellEdit", false);
  794. } else {
  795. this.$set(row, "$cellEdit", true);
  796. }
  797. },
  798. rowDe2(row, index) {
  799. this.$confirm("确定删除数据?", {
  800. confirmButtonText: "确定",
  801. cancelButtonText: "取消",
  802. type: "warning"
  803. }).then(() => {
  804. if (row.id) {
  805. // itemDel(row.id).then(res => {
  806. // this.$message({
  807. // type: "success",
  808. // message: "删除成功!"
  809. // });
  810. // this.data2.splice(index, 1);
  811. // });
  812. } else {
  813. this.$message({
  814. type: "success",
  815. message: "删除成功!"
  816. });
  817. this.data2.splice(index, 1);
  818. }
  819. });
  820. },
  821. corpTypeClosed() {
  822. // this.reload = Math.random();
  823. // this.form4 = this.$options.data().form4
  824. },
  825. getCorpType() {
  826. getCorpType({ corpType: "KH" }).then(res => {
  827. this.corpTypeList = res.data.data;
  828. });
  829. },
  830. addCorpType() {
  831. this.getCorpType();
  832. this.corpTypeVisible = false;
  833. },
  834. addLabel() {
  835. this.labelKey = Date.now();
  836. this.labelVisible = false;
  837. },
  838. //修改提交触发
  839. editCustomer() {
  840. this.$refs.form.validate((valid, done) => {
  841. done();
  842. if (valid) {
  843. if (this.contactsData.length == 0) return this.$message.error("请添加客户联系人");
  844. if (this.data.length == 0) return this.$message.error("请添加地址信息");
  845. if (this.corpsFiles.filter(item => item.mainImage == 1).length > 1) return this.$message.error("附件主图只允许选一个");
  846. this.loadingBtn = true;
  847. if (!this.form.id) {
  848. this.form.checkStatus = "通过";
  849. }
  850. submit({
  851. ...this.form,
  852. code: this.form.cname,
  853. corpType: "KH",
  854. corpsAddrList: this.data,
  855. corpsFilesList: this.corpsFiles,
  856. corpsAttnList: this.contactsData,
  857. billType: 1
  858. })
  859. .then(res => {
  860. this.$message.success("保存成功");
  861. this.form = res.data.data;
  862. this.data = res.data.data.corpsAddrList;
  863. this.corpsFiles = res.data.data.corpsFilesList;
  864. this.getDetail(res.data.data.id);
  865. if (!this.form.id) {
  866. //添加成功后默认启用
  867. let data = this.form;
  868. editenable({ id: res.data.data.id, enableOrNot: data.enableOrNot ? 0 : 1 }).then(res => {
  869. this.$set(this.form, "enableOrNot", data.enableOrNot == 1 ? 0 : 1);
  870. });
  871. }
  872. })
  873. .finally(() => {
  874. this.loadingBtn = false;
  875. });
  876. } else {
  877. return false;
  878. }
  879. });
  880. },
  881. creatingUsers(row) {
  882. console.log("row", row);
  883. if (!row.id) {
  884. this.$message.error("请保存数据");
  885. }
  886. if (!row.cname || !row.tel) {
  887. this.$message.error("请完善联系人和电话");
  888. }
  889. if (!row.id) {
  890. this.$message.error("请保存数据");
  891. }
  892. if (row.userId) {
  893. this.$message.error("已创建,请勿重复操作");
  894. }
  895. this.$confirm("是否创建用户?", "提示", {
  896. confirmButtonText: "确定",
  897. cancelButtonText: "取消",
  898. type: "warning"
  899. }).then(() => {
  900. creatingUsersTwo({
  901. id: row.id
  902. }).then(res => {
  903. this.$message.success("创建用户成功,默认帐号:手机号。默认密码:123456");
  904. this.getDetail(this.form.id);
  905. });
  906. });
  907. },
  908. //新增客户联系人保存触发
  909. rowSave(row, done, loading) {
  910. if (this.data.length == 1) {
  911. this.$set(row, "defaultAddres", "1");
  912. }
  913. done(row);
  914. },
  915. //修改客户联系人触发
  916. rowUpdate(row, index, done, loading) {
  917. done(row);
  918. },
  919. //删除客户联系人触发
  920. rowDelTwo(row, index, donerowDel) {
  921. this.$confirm("确定将选择数据删除?", {
  922. confirmButtonText: "确定",
  923. cancelButtonText: "取消",
  924. type: "warning"
  925. }).then(() => {
  926. // 数据回调进行刷新
  927. if (row.id) {
  928. corpsattn(row.id).then(res => {
  929. this.$message({
  930. type: "success",
  931. message: "操作成功!"
  932. });
  933. this.contactsData.splice(index, 1);
  934. });
  935. } else {
  936. this.$message({
  937. type: "success",
  938. message: "操作成功!"
  939. });
  940. this.contactsData.splice(index, 1);
  941. }
  942. });
  943. },
  944. //返回列表
  945. backToList() {
  946. this.$emit("goBack");
  947. }
  948. }
  949. };
  950. </script>
  951. <style lang="scss" scoped>
  952. .trading-form ::v-deep .el-form-item {
  953. margin-bottom: 8px !important;
  954. }
  955. ::v-deep .el-dialog__body {
  956. padding: 0px 20px 15px 20px;
  957. }
  958. ::v-deep .el-form-item__error {
  959. display: none !important;
  960. }
  961. .el-dialog ::v-deep .el-form-item__error {
  962. display: none !important;
  963. }
  964. .img-form ::v-deep .el-form-item {
  965. height: 150px;
  966. line-height: 150px;
  967. margin-bottom: 8px !important;
  968. }
  969. .img-form ::v-deep .avue-upload__icon {
  970. font-size: 20px;
  971. width: 150px;
  972. height: 150px;
  973. line-height: 150px;
  974. }
  975. ::v-deep .el-table .cell {
  976. padding: 0 2px !important;
  977. }
  978. ::v-deep .avue-crud .el-table .el-form-item__label {
  979. left: -1px;
  980. }
  981. .addressTabs {
  982. display: flex;
  983. justify-content: center;
  984. span {
  985. width: 100px;
  986. font-size: 18px;
  987. font-weight: 600;
  988. text-align: center;
  989. }
  990. }
  991. </style>