detailsPage.vue 32 KB

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