shop.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954
  1. <template>
  2. <basic-container>
  3. <el-dialog @close="dialogShow=false" append-to-body :close-on-click-modal="false" :visible.sync="dialogShow"
  4. :destroy-on-close="true"
  5. :title="dialogTitle" fullscreen>
  6. <shop-member v-if="dialogTitle=='店铺会员'" ref="refName" :operateId="operateId"></shop-member>
  7. <shop-bills v-if="dialogTitle=='账单流水'" ref="refName" :operateId="operateId"></shop-bills>
  8. <shop-joinrecord v-if="dialogTitle=='参加的活动'" ref="refName" :operateId="operateId"></shop-joinrecord>
  9. <shop-withdrawrec v-if="dialogTitle=='提现记录'" ref="refName" :operateId="operateId"></shop-withdrawrec>
  10. <shop-product-fee v-if="dialogTitle=='产品费率'" ref="refName" :operateId="operateId"></shop-product-fee>
  11. <shop-info v-if="dialogTitle=='查看'" ref="refName" :operateId="operateId"></shop-info>
  12. </el-dialog>
  13. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :permission="permissionList"
  14. :before-open="beforeOpen" v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave"
  15. @row-del="rowDel"
  16. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  17. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
  18. @on-load="onLoad">
  19. <template slot="shopInfo" slot-scope="scope">
  20. <div style="display: flex;">
  21. <div style="display: flex;justify-content: center;align-items: center;">
  22. <el-avatar size="large" :src="scope.row.cover"></el-avatar>
  23. </div>
  24. <div style="padding: 10px;">
  25. <div>商店名称:{{ scope.row.name }}</div>
  26. <div>负责人姓名:{{ scope.row.personName }}</div>
  27. <div>联系方式:{{ scope.row.personTel }}</div>
  28. </div>
  29. </div>
  30. </template>
  31. <template slot-scope="scope" slot="dataInfo">
  32. <div style="display: flex;justify-content: space-around;">
  33. <div class="">
  34. <div>
  35. 会员数量:
  36. <div
  37. style="background-color: #3296fa;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  38. {{ scope.row.memberCount }}
  39. </div>
  40. </div>
  41. <div>
  42. 账户余额:
  43. <div
  44. style="background-color: #00aa7f;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  45. {{ scope.row.balance }}
  46. </div>
  47. </div>
  48. <div>
  49. 账单应收:
  50. <div
  51. style="background-color: #ffaa7f;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  52. {{ scope.row.charge }}
  53. </div>
  54. </div>
  55. </div>
  56. <div style="margin-left: 120rpx;">
  57. <div>
  58. 可提现金额:
  59. <div
  60. style="background-color: #00aa7f;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  61. {{ scope.row.withdrawCharge }}
  62. </div>
  63. </div>
  64. <div>
  65. 店铺销量:
  66. <div
  67. style="background-color: #ffaa7f;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  68. {{ scope.row.sales }}
  69. </div>
  70. </div>
  71. <div>
  72. 店铺评分:
  73. <div
  74. style="background-color: #3296fa;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  75. {{ scope.row.score }}
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <template slot-scope="scope" slot="pointData">
  82. <div style="display: flex;">
  83. <div>
  84. 积分数量:
  85. <div
  86. style="background-color: #3296fa;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  87. {{ scope.row.point }}
  88. </div>
  89. </div>
  90. <div>
  91. 积分价值:
  92. <div
  93. style="background-color: #00aa7f;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  94. {{ scope.row.totalValue }}
  95. </div>
  96. </div>
  97. </div>
  98. <div>
  99. 积分兑率:
  100. <div
  101. style="background-color: #ffaa7f;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  102. {{ scope.row.pointRate }}
  103. </div>
  104. </div>
  105. <div>
  106. 消费1元赠送多少积分:
  107. <div
  108. style="background-color: #00aa7f;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">
  109. {{ scope.row.sendPointUnit }}
  110. </div>
  111. </div>
  112. </template>
  113. <template slot="agentInfo" slot-scope="scope" v-if="scope.row.agenter && scope.row.agenter!=-1">
  114. <div style="display: flex;">
  115. <div style="display: flex;justify-content: center;align-items: center;">
  116. <el-avatar size="large" :src="scope.row.agentAvatar"></el-avatar>
  117. </div>
  118. <div style="padding: 10px;">
  119. <div>代理人姓名:{{ scope.row.agentName }}</div>
  120. <div>代理人id:{{ scope.row.agenter }}</div>
  121. </div>
  122. </div>
  123. </template>
  124. <template slot="labelKey" slot-scope="scope">
  125. <el-tag v-for="(item,index) of scope.row.labelKey.split(',')" :key="index">
  126. {{ item }}
  127. </el-tag>
  128. </template>
  129. <template slot="location" slot-scope="scope">
  130. {{ scope.row.location }}
  131. </template>
  132. <template slot="cover" slot-scope="scope">
  133. <el-image :src="scope.row.cover" :style="{maxHeight:'50px',maxWidth:'50px'}"></el-image>
  134. </template>
  135. <template slot="logo" slot-scope="scope">
  136. <el-image :src="scope.row.logo" :style="{maxHeight:'50px',maxWidth:'50px'}"></el-image>
  137. </template>
  138. <template slot="shopPic" slot-scope="scope">
  139. <el-image :src="scope.row.shopPic" :style="{maxHeight:'50px',maxWidth:'50px'}"></el-image>
  140. </template>
  141. <template slot="menuLeft">
  142. <el-button type="primary" size="small" @click="generateListAndDownload">导出数据</el-button>
  143. <el-button type="danger" size="small" icon="el-icon-delete" plain v-if="permission.shop_delete"
  144. @click="handleDelete">删 除
  145. </el-button>
  146. </template>
  147. <!-- 操作菜单 -->
  148. <template slot-scope="scope" slot="menu">
  149. <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
  150. @click.stop="handleShopInfo(scope.row)">查 看
  151. </el-button>
  152. <!-- <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
  153. @click.stop="openDialog(scope.row.id,'店铺会员')">店铺会员
  154. </el-button>
  155. <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
  156. @click.stop="openDialog(scope.row.id,'账单流水')">账单流水
  157. </el-button>
  158. <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
  159. @click.stop="openDialog(scope.row.id,'参加的活动')">参加的活动
  160. </el-button>
  161. <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
  162. @click.stop="openDialog(scope.row.id,'提现记录')">提现记录
  163. </el-button>
  164. <el-button v-if="userInfo.role_name === 'administrator'" type="text" size="small" icon="el-icon-edit" plain
  165. class="none-border"
  166. @click.stop="openDialog(scope.row.id,'产品费率')" :disabled="$isEmpty(scope.row.merchantNo)">产品费率
  167. </el-button>-->
  168. </template>
  169. </avue-crud>
  170. </basic-container>
  171. </template>
  172. <script>
  173. import {add, getDetail, getList, remove, update} from "@/api/ldt_shop/shop";
  174. import {mapGetters} from "vuex";
  175. import {getDictionary} from "@/api/system/dictbiz";
  176. import {getLazyTree} from "@/api/base/region";
  177. import shopMember from "./comps/shop-member.vue"
  178. import shopBills from "./comps/shop-bills.vue"
  179. import shopJoinrecord from "./comps/shop-joinrecord.vue"
  180. import shopWithdrawrec from "./comps/shop-withdrawrec.vue"
  181. import shopProductFee from "./comps/shop-product-fee"
  182. import ShopInfo from "./shop-info";
  183. import moment from "_moment@2.29.1@moment";
  184. export default {
  185. components: {
  186. ShopInfo,
  187. shopMember, shopBills, shopJoinrecord, shopWithdrawrec, shopProductFee
  188. },
  189. data() {
  190. return {
  191. //弹框
  192. dialogShow: false,
  193. operateId: '',
  194. dialogTitle: '',
  195. form: {},
  196. query: {},
  197. loading: true,
  198. page: {
  199. pageSize: 10,
  200. currentPage: 1,
  201. total: 0
  202. },
  203. selectionList: [],
  204. option: {
  205. height: 'auto',
  206. calcHeight: 30,
  207. tip: false,
  208. searchShow: true,
  209. searchMenuSpan: 6,
  210. border: true,
  211. index: true,
  212. viewBtn: false,
  213. selection: true,
  214. addBtn: false,
  215. dialogClickModal: false,
  216. labelWidth: 170,
  217. column: [{
  218. prop: "shopInfo",
  219. slot: true,
  220. width: 250,
  221. display: false,
  222. label: "店铺信息"
  223. },
  224. {
  225. width: 220,
  226. prop: "agentInfo",
  227. label: "代理人信息",
  228. hide: true,
  229. slot: true,
  230. },
  231. {
  232. prop: "dataInfo",
  233. slot: true,
  234. width: 400,
  235. display: false,
  236. label: "数据统计"
  237. },
  238. {
  239. prop: "pointData",
  240. slot: true,
  241. width: 300,
  242. display: false,
  243. label: "积分统计"
  244. },
  245. {
  246. label: "商店名称",
  247. prop: "name",
  248. search: true,
  249. hide: true,
  250. rules: [{
  251. required: true,
  252. message: "请输入商店名称",
  253. trigger: "blur"
  254. }]
  255. },
  256. {
  257. label: "店铺评分",
  258. hide: true,
  259. prop: "score",
  260. },
  261. {
  262. label: "代理人",
  263. prop: "agenter",
  264. hide: true,
  265. display: false,
  266. rules: [{
  267. required: true,
  268. message: "请输入代理人",
  269. trigger: "blur"
  270. }]
  271. },
  272. {
  273. label: "商场id",
  274. prop: "mallId",
  275. hide: true,
  276. display: false,
  277. disabled: true,
  278. rules: [{
  279. required: true,
  280. message: "请输入商场id",
  281. trigger: "blur"
  282. }]
  283. },
  284. {
  285. label: "负责人",
  286. prop: "personName",
  287. search: true,
  288. hide: true,
  289. rules: [{
  290. required: true,
  291. message: "请输入负责人",
  292. trigger: "blur"
  293. }]
  294. },
  295. {
  296. label: "联系方式",
  297. hide: true,
  298. prop: "personTel",
  299. rules: [{
  300. required: true,
  301. message: "请输入联系方式",
  302. trigger: "blur"
  303. }]
  304. },
  305. {
  306. label: "商店封面",
  307. prop: "cover",
  308. hide: true,
  309. type: 'upload',
  310. dataType: "string",
  311. listType: 'picture-img',
  312. span: 24,
  313. propsHttp: {
  314. res: 'data',
  315. url: 'link'
  316. },
  317. canvasOption: {
  318. text: 'avue',
  319. ratio: 0.1
  320. },
  321. tip: '只能上传jpg/png文件,且不超过500kb',
  322. action: '/api/blade-resource/oss/endpoint/put-file',
  323. rules: [{
  324. required: true,
  325. message: "请上传商店封面",
  326. trigger: "blur"
  327. }]
  328. },
  329. {
  330. label: "商店logo",
  331. hide: true,
  332. prop: "logo",
  333. type: 'upload',
  334. dataType: "string",
  335. listType: 'picture-img',
  336. span: 24,
  337. propsHttp: {
  338. res: 'data',
  339. url: 'link'
  340. },
  341. canvasOption: {
  342. text: 'avue',
  343. ratio: 0.1
  344. },
  345. tip: '只能上传jpg/png文件,且不超过500kb',
  346. action: '/api/blade-resource/oss/endpoint/put-file',
  347. rules: [{
  348. required: true,
  349. message: "请上传商店logo",
  350. trigger: "blur"
  351. }]
  352. },
  353. {
  354. label: "父标签",
  355. hide: true,
  356. display: false,
  357. prop: "labelParentIds",
  358. rules: [{
  359. required: true,
  360. message: "请输入父标签ids,逗号分割",
  361. trigger: "blur"
  362. }]
  363. },
  364. {
  365. label: "商店标签",
  366. prop: "labelKey",
  367. display: false,
  368. type: "select",
  369. overHidden: true,
  370. maxHeight: "50px",
  371. dicData: [],
  372. multiple: true,
  373. props: {
  374. label: "dictValue",
  375. value: "dictKey"
  376. },
  377. rules: [{
  378. required: true,
  379. message: "请输入商店标签key",
  380. trigger: "blur"
  381. }]
  382. },
  383. {
  384. label: "销量",
  385. prop: "sales",
  386. hide: true,
  387. type: "number",
  388. rules: [{
  389. required: true,
  390. message: "请输入销量",
  391. trigger: "blur"
  392. }]
  393. },
  394. {
  395. label: "店铺图片",
  396. prop: "shopPic",
  397. type: 'upload',
  398. hide: true,
  399. dataType: "string",
  400. listType: 'picture-img',
  401. span: 24,
  402. propsHttp: {
  403. res: 'data',
  404. url: 'link'
  405. },
  406. canvasOption: {
  407. text: 'avue',
  408. ratio: 0.1
  409. },
  410. tip: '只能上传jpg/png文件,且不超过500kb',
  411. action: '/api/blade-resource/oss/endpoint/put-file',
  412. rules: [{
  413. required: true,
  414. message: "请上传店铺图片",
  415. trigger: "blur"
  416. }]
  417. },
  418. {
  419. label: "1 积分等于多少元",
  420. prop: "pointRate",
  421. type: "number",
  422. hide: true,
  423. rules: [{
  424. required: true,
  425. message: "1 积分等于多少元",
  426. trigger: "blur"
  427. }]
  428. },
  429. {
  430. label: "积分",
  431. prop: "point",
  432. display: false,
  433. hide: true,
  434. type: "number",
  435. rules: [{
  436. required: true,
  437. message: "请输入积分",
  438. trigger: "blur"
  439. }]
  440. },
  441. {
  442. label: "账户余额",
  443. hide: true,
  444. prop: "balance",
  445. type: "number",
  446. display: false,
  447. rules: [{
  448. required: true,
  449. message: "请输入账户余额",
  450. trigger: "blur"
  451. }]
  452. },
  453. {
  454. label: "提现密码",
  455. prop: "secret",
  456. type: "password",
  457. hide: true,
  458. display: false,
  459. rules: [{
  460. required: true,
  461. message: "请输入提现密码",
  462. trigger: "blur"
  463. }]
  464. },
  465. {
  466. label: "是否启用会员中心",
  467. prop: "isOpenMember",
  468. type: "radio",
  469. hide: true,
  470. dicData: [{
  471. label: '否',
  472. value: 0
  473. }, {
  474. label: '是',
  475. value: 1
  476. }],
  477. rules: [{
  478. required: true,
  479. message: "请输入是否启用会员中心",
  480. trigger: "blur"
  481. }]
  482. },
  483. {
  484. label: "邮箱",
  485. hide: true,
  486. prop: "email",
  487. rules: [{
  488. required: true,
  489. message: "请输入邮箱",
  490. trigger: "blur"
  491. }]
  492. },
  493. {
  494. label: "总价值",
  495. prop: "totalValue",
  496. display: false,
  497. hide: true,
  498. type: "number",
  499. rules: [{
  500. required: true,
  501. message: "请输入总价值",
  502. trigger: "blur"
  503. }]
  504. },
  505. {
  506. label: "可提现金额",
  507. prop: "withdrawCharge",
  508. type: "number",
  509. hide: true,
  510. display: false,
  511. rules: [{
  512. required: true,
  513. message: "请输入可提现金额",
  514. trigger: "blur"
  515. }]
  516. },
  517. {
  518. label: "会员数量",
  519. prop: "memberCount",
  520. type: "number",
  521. hide: true,
  522. display: false,
  523. rules: [{
  524. required: true,
  525. message: "请输入会员数量",
  526. trigger: "blur"
  527. }]
  528. },
  529. {
  530. label: "标语",
  531. prop: "slogan",
  532. hide: true,
  533. rules: [{
  534. required: true,
  535. message: "请输入标语,逗号分割",
  536. trigger: "blur"
  537. }]
  538. },
  539. {
  540. label: "审核状态",
  541. prop: "auditStatus",
  542. display: false,
  543. dicData: [
  544. {
  545. label: "待商场审核",
  546. value: "WAITING_MALL"
  547. },
  548. {
  549. label: "待平台审核",
  550. value: "WAITING_PLATFORM"
  551. },
  552. {
  553. label: "审核通过",
  554. value: "PASS"
  555. },
  556. {
  557. label: "审核失败",
  558. value: "FAIL"
  559. },
  560. {
  561. label: "已停用",
  562. value: "stop"
  563. },
  564. ],
  565. rules: [{
  566. required: true,
  567. message: "请输入审核状态",
  568. trigger: "blur"
  569. }]
  570. },
  571. {
  572. label: "审核意见",
  573. prop: "auditAdvice",
  574. hide: true,
  575. display: false,
  576. rules: [{
  577. required: true,
  578. message: "请输入审核意见",
  579. trigger: "blur"
  580. }]
  581. },
  582. {
  583. label: "账单应收",
  584. prop: "charge",
  585. display: false,
  586. hide: true,
  587. type: "number",
  588. rules: [{
  589. required: true,
  590. message: "请输入账单应收",
  591. trigger: "blur"
  592. }]
  593. },
  594. {
  595. label: "参加活动的id",
  596. prop: "activityId",
  597. hide: true,
  598. display: false,
  599. rules: [{
  600. required: true,
  601. message: "请输入参加活动的id",
  602. trigger: "blur"
  603. }]
  604. },
  605. {
  606. label: "消费 1 元赠送多少积分",
  607. prop: "sendPointUnit",
  608. hide: true,
  609. type: "number",
  610. rules: [{
  611. required: true,
  612. message: "消费 1 元赠送多少积分",
  613. trigger: "blur"
  614. }]
  615. },
  616. {
  617. label: "经度",
  618. prop: "longitude",
  619. hide: true,
  620. display: false,
  621. disabled: true,
  622. rules: [{
  623. required: true,
  624. message: "请输入经度",
  625. trigger: "blur"
  626. }]
  627. },
  628. {
  629. label: "纬度",
  630. prop: "latitude",
  631. hide: true,
  632. display: false,
  633. disabled: true,
  634. rules: [{
  635. required: true,
  636. message: "请输入纬度",
  637. trigger: "blur"
  638. }]
  639. },
  640. {
  641. label: "区域编码",
  642. prop: "locationCode",
  643. hide: true,
  644. display: false,
  645. disabled: true,
  646. rules: [{
  647. required: true,
  648. message: "请输入区域编码",
  649. trigger: "blur"
  650. }]
  651. },
  652. {
  653. label: "详细地址",
  654. prop: "address",
  655. rules: [{
  656. required: true,
  657. message: "请输入详细地址",
  658. trigger: "blur"
  659. }]
  660. },
  661. {
  662. label: '所在地区',
  663. prop: 'location',
  664. type: "cascader",
  665. props: {
  666. label: 'name',
  667. value: 'code'
  668. },
  669. lazy: true,
  670. dataType: "string",
  671. lazyLoad: this.region,
  672. rules: [{
  673. required: true,
  674. message: "请选择所在地区",
  675. trigger: "blur"
  676. }]
  677. },
  678. ]
  679. },
  680. data: []
  681. };
  682. },
  683. watch: {
  684. 'form.labelKey'(val) {
  685. if (val !== undefined) {
  686. const labelJson = []
  687. const col = this.option.column.find((col) => {
  688. return col.prop === "labelKey";
  689. });
  690. for (const item of val.split(",")) {
  691. col.dicData.forEach(key => {
  692. if (key.dictKey === item) {
  693. labelJson.push(key)
  694. return;
  695. }
  696. })
  697. }
  698. this.form.labelJson = JSON.stringify(labelJson);
  699. }
  700. },
  701. 'form.address'(val) {
  702. if (val !== undefined && val !== null) {
  703. const split = val.split(",");
  704. if (split.length === 3) {
  705. this.form.longitude = split[0];
  706. this.form.latitude = split[1];
  707. this.form.address = split[2];
  708. }
  709. }
  710. }
  711. },
  712. computed: {
  713. ...mapGetters(["userInfo", "permission"]),
  714. permissionList() {
  715. return {
  716. addBtn: this.vaildData(this.permission.shop_add, false),
  717. viewBtn: this.vaildData(this.permission.shop_view, false),
  718. delBtn: this.vaildData(this.permission.shop_delete, false),
  719. editBtn: this.vaildData(this.permission.shop_edit, false)
  720. };
  721. },
  722. ids() {
  723. let ids = [];
  724. this.selectionList.forEach(ele => {
  725. ids.push(ele.id);
  726. });
  727. return ids.join(",");
  728. }
  729. },
  730. created() {
  731. this.initData();
  732. },
  733. methods: {
  734. handleShopInfo(row) {
  735. //跳链接方式
  736. // this.$router.push(`/work/process/shopInfo/handle/${row.id}`);
  737. this.dialogShow = true;
  738. this.dialogTitle = "商户信息";
  739. this.operateId = row.id;
  740. this.dialogTitle = "查看";
  741. },
  742. openDialog(id, name) {
  743. this.dialogTitle = name
  744. this.operateId = id
  745. this.dialogShow = true
  746. if (this.canReset) {
  747. this.$refs.refName.refreshChange()
  748. }
  749. this.canReset = true
  750. },
  751. initData() {
  752. getDictionary({
  753. code: "business_label"
  754. }).then(res => {
  755. const col = this.option.column.find((col) => {
  756. return col.prop === "labelKey";
  757. });
  758. col.dicData = res.data.data;
  759. });
  760. },
  761. rowSave(row, done, loading) {
  762. add(row).then(() => {
  763. this.onLoad(this.page);
  764. this.$message({
  765. type: "success",
  766. message: "操作成功!"
  767. });
  768. done();
  769. }, error => {
  770. loading();
  771. window.console.log(error);
  772. });
  773. },
  774. rowUpdate(row, index, done, loading) {
  775. update(row).then(() => {
  776. this.onLoad(this.page);
  777. this.$message({
  778. type: "success",
  779. message: "操作成功!"
  780. });
  781. done();
  782. }, error => {
  783. loading();
  784. console.log(error);
  785. });
  786. },
  787. rowDel(row) {
  788. this.$confirm("确定将选择数据删除?", {
  789. confirmButtonText: "确定",
  790. cancelButtonText: "取消",
  791. type: "warning"
  792. })
  793. .then(() => {
  794. return remove(row.id);
  795. })
  796. .then(() => {
  797. this.onLoad(this.page);
  798. this.$message({
  799. type: "success",
  800. message: "操作成功!"
  801. });
  802. });
  803. },
  804. handleDelete() {
  805. if (this.selectionList.length === 0) {
  806. this.$message.warning("请选择至少一条数据");
  807. return;
  808. }
  809. this.$confirm("确定将选择数据删除?", {
  810. confirmButtonText: "确定",
  811. cancelButtonText: "取消",
  812. type: "warning"
  813. })
  814. .then(() => {
  815. return remove(this.ids);
  816. })
  817. .then(() => {
  818. this.onLoad(this.page);
  819. this.$message({
  820. type: "success",
  821. message: "操作成功!"
  822. });
  823. this.$refs.crud.toggleSelection();
  824. });
  825. },
  826. beforeOpen(done, type) {
  827. if (["edit", "view"].includes(type)) {
  828. getDetail(this.form.id).then(res => {
  829. this.form = res.data.data;
  830. });
  831. }
  832. done();
  833. },
  834. searchReset() {
  835. this.query = {};
  836. this.onLoad(this.page);
  837. },
  838. searchChange(params, done) {
  839. this.query = params;
  840. this.page.currentPage = 1;
  841. this.onLoad(this.page, params);
  842. done();
  843. },
  844. selectionChange(list) {
  845. this.selectionList = list;
  846. },
  847. selectionClear() {
  848. this.selectionList = [];
  849. this.$refs.crud.toggleSelection();
  850. },
  851. currentChange(currentPage) {
  852. this.page.currentPage = currentPage;
  853. },
  854. sizeChange(pageSize) {
  855. this.page.pageSize = pageSize;
  856. },
  857. refreshChange() {
  858. this.onLoad(this.page, this.query);
  859. },
  860. region(node, resolve) {
  861. let stop_level = 2;
  862. let level = node.level;
  863. let data = node.data || {}
  864. let parentCode = data.id;
  865. let list = [];
  866. if (level > 0) {
  867. let col = this.option.column.find((item) => {
  868. return item.prop === "location";
  869. });
  870. col.region[level - 1] = data.id;
  871. if (level > 2) {
  872. this.form.locationCode = col.region.join(',');
  873. }
  874. }
  875. let callback = () => {
  876. resolve((list || []).map(ele => {
  877. return Object.assign(ele, {
  878. leaf: level >= stop_level
  879. })
  880. }));
  881. }
  882. if (level == 0) {
  883. getLazyTree().then(res => {
  884. list = res.data.data;
  885. callback()
  886. })
  887. }
  888. if (level == 1) {
  889. getLazyTree(parentCode).then(res => {
  890. list = res.data.data;
  891. callback()
  892. })
  893. } else if (level == 2) {
  894. getLazyTree(parentCode).then(res => {
  895. list = res.data.data;
  896. callback()
  897. })
  898. } else {
  899. callback()
  900. }
  901. },
  902. showMap() {
  903. this.$refs.map.click();
  904. },
  905. onLoad(page, params = {}) {
  906. this.loading = true;
  907. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  908. const data = res.data.data;
  909. this.page.total = data.total;
  910. this.data = data.records;
  911. this.loading = false;
  912. this.selectionClear();
  913. });
  914. },
  915. generateListAndDownload() {
  916. const filterArray = ["店铺信息","代理人信息","数据统计","积分统计"];
  917. this.$Export.excel({
  918. title: `商户数据导出-${moment().format("yyyy-MM-DD HH:mm:ss")}`,
  919. columns: this.option.column.filter(ele=>{
  920. return filterArray.indexOf(ele.label)===-1;
  921. }),
  922. data: this.selectionList.length!==0?this.selectionList:this.data
  923. });
  924. }
  925. }
  926. };
  927. </script>
  928. <style lang="scss">
  929. .tag {
  930. background-color: #00aa00;
  931. color: white;
  932. border-radius: 5px;
  933. margin: 10px;
  934. padding: 0 10px 0 10px;
  935. display: inline;
  936. }
  937. </style>