wallet.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <div class="app-container">
  3. <div class="sty" v-show="show">
  4. <el-page-header @back="goBack"> </el-page-header>
  5. </div>
  6. <br />
  7. <!-- 筛选条件 -->
  8. <div v-if="show2">
  9. <el-form
  10. ref="searchForm"
  11. :model="searchForm"
  12. :rules="rulesSearchForm"
  13. label-width="100px"
  14. size="small"
  15. label-position="left"
  16. >
  17. <el-row :gutter="20">
  18. <el-col :xs="24" :sm="12" :lg="6">
  19. <el-form-item label="经销商名称" prop="customerId">
  20. <el-select
  21. class="selectStyle"
  22. v-model="searchForm.customerId"
  23. placeholder="请选择"
  24. filterable
  25. >
  26. <el-option
  27. v-for="(v, i) in customerList"
  28. :key="i"
  29. :label="v.name"
  30. :value="v.id"
  31. >
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :xs="24" :sm="12" :lg="18">
  37. <el-form-item label="" class="fr">
  38. <el-button size="small" @click="resetFn">清空</el-button>
  39. <el-button size="small" type="primary" @click="searchFn"
  40. >搜索</el-button
  41. >
  42. </el-form-item>
  43. </el-col>
  44. </el-row>
  45. </el-form>
  46. </div>
  47. <el-row>
  48. <el-col :xs="24" :sm="12" :lg="12">
  49. <div class="styl">现金钱包</div>
  50. </el-col>
  51. <!-- <el-col :xs="24" :sm="12" :lg="12">
  52. <div class="fr">
  53. <el-button size="small" type="primary" @click="generateFn"
  54. >一键生成钱包</el-button
  55. >
  56. </div>
  57. </el-col> -->
  58. </el-row>
  59. <el-divider></el-divider>
  60. <!-- 列表 -->
  61. <div class="mymain-container">
  62. <div class="table">
  63. <el-table
  64. v-loading="listLoading"
  65. :data="walletList"
  66. element-loading-text="Loading"
  67. border
  68. fit
  69. highlight-current-row
  70. stripe
  71. show-summary
  72. :summary-method="$getSummaries"
  73. >
  74. <el-table-column
  75. align="center"
  76. label="经销商名称"
  77. prop="customerName"
  78. min-width="160"
  79. show-overflow-tooltip
  80. ></el-table-column>
  81. <el-table-column
  82. align="center"
  83. label="钱包"
  84. prop="name"
  85. min-width="160"
  86. show-overflow-tooltip
  87. ></el-table-column>
  88. <el-table-column
  89. align="right"
  90. label="余额"
  91. prop="amount"
  92. min-width="160"
  93. show-overflow-tooltip
  94. >
  95. <template slot-scope="scope">
  96. {{ scope.row.amount | numToFixed }}
  97. </template>
  98. </el-table-column>
  99. <el-table-column
  100. align="right"
  101. label="可用信用额度"
  102. prop="freeCreditAmount"
  103. min-width="160"
  104. show-overflow-tooltip
  105. >
  106. <template slot-scope="scope">
  107. {{ scope.row.freeCreditAmount | numToFixed }}
  108. </template>
  109. </el-table-column>
  110. <el-table-column
  111. align="right"
  112. label="已用信用额度"
  113. prop="usedCreditAmount"
  114. min-width="160"
  115. show-overflow-tooltip
  116. >
  117. <template slot-scope="scope">
  118. {{ scope.row.usedCreditAmount | numToFixed }}
  119. </template>
  120. </el-table-column>
  121. <el-table-column
  122. align="center"
  123. label="更新时间"
  124. prop="updateTime"
  125. min-width="160"
  126. show-overflow-tooltip
  127. ></el-table-column>
  128. </el-table>
  129. </div>
  130. </div>
  131. <span>返利钱包</span>
  132. <el-divider></el-divider>
  133. <!-- 列表 -->
  134. <div class="mymain-container">
  135. <div class="table">
  136. <el-table
  137. v-loading="listLoading"
  138. :data="rebateList"
  139. element-loading-text="Loading"
  140. border
  141. fit
  142. highlight-current-row
  143. stripe
  144. show-summary
  145. :summary-method="$getSummaries"
  146. >
  147. <el-table-column
  148. align="center"
  149. label="经销商名称"
  150. prop="customerName"
  151. min-width="160"
  152. show-overflow-tooltip
  153. ></el-table-column>
  154. <el-table-column
  155. align="center"
  156. label="返利钱包"
  157. prop="name"
  158. min-width="160"
  159. show-overflow-tooltip
  160. ></el-table-column>
  161. <el-table-column
  162. align="right"
  163. label="钱包余额"
  164. prop="amount"
  165. min-width="160"
  166. show-overflow-tooltip
  167. >
  168. <template slot-scope="scope">
  169. {{ scope.row.amount | numToFixed }}
  170. </template>
  171. </el-table-column>
  172. <el-table-column
  173. align="center"
  174. label="更新时间"
  175. prop="updateTime"
  176. min-width="160"
  177. show-overflow-tooltip
  178. ></el-table-column>
  179. <el-table-column
  180. align="center"
  181. label="操作"
  182. min-width="160"
  183. show-overflow-tooltip
  184. >
  185. <template v-slot="{ row }">
  186. <el-button
  187. v-if="$checkBtnRole('edit', $route.meta.roles)"
  188. type="text"
  189. class="textColor"
  190. @click="editFn(row)"
  191. >
  192. 修改
  193. </el-button>
  194. </template>
  195. </el-table-column>
  196. </el-table>
  197. </div>
  198. </div>
  199. <!-- 弹窗 -->
  200. <el-dialog
  201. title="配置返利比例"
  202. :visible.sync="dialogForm"
  203. width="30%"
  204. :show-close="false"
  205. :close-on-click-modal="false"
  206. >
  207. <el-form
  208. ref="addForm"
  209. :rules="rules"
  210. :model="addForm"
  211. label-width="100px"
  212. >
  213. <el-form-item label="返利比例" prop="rebateRate">
  214. <el-input
  215. v-model.number="addForm.rebateRate"
  216. oninput="if(value>100)value=100;if(value<0)value=0"
  217. ><i class="el-input__icon" slot="suffix">% </i></el-input
  218. >
  219. </el-form-item>
  220. </el-form>
  221. <div slot="footer" class="dialog-footer">
  222. <el-button @click="cancelFn">取 消</el-button>
  223. <el-button type="primary" @click="determineFn">确 定</el-button>
  224. </div>
  225. </el-dialog>
  226. </div>
  227. </template>
  228. <script>
  229. import { mapGetters } from "vuex";
  230. import {
  231. getfinanceInit,
  232. getWalletRebateRateUpdate,
  233. getCustomerList,
  234. } from "@/api/finance/wallet";
  235. import { getWalletCustomerList } from "@/api/finance/change_apply";
  236. export default {
  237. data() {
  238. return {
  239. isShow: JSON.parse(localStorage.getItem("supply_user")).isCustomer,
  240. show: false,
  241. show2: true,
  242. searchForm: {
  243. customerId: null,
  244. },
  245. customerList: [],
  246. listLoading: false, // 列表加载loading
  247. walletList: [],
  248. rebateList: [],
  249. addForm: {
  250. rebateRate: null,
  251. },
  252. dialogForm: false,
  253. rulesSearchForm: {
  254. customerId: [
  255. {
  256. required: true,
  257. message: "请选择经销商",
  258. trigger: "blur",
  259. },
  260. ],
  261. },
  262. rules: {
  263. rebateRate: [
  264. {
  265. required: true,
  266. message: "请输入返利比例",
  267. trigger: "blur",
  268. },
  269. ],
  270. },
  271. };
  272. },
  273. beforeRouteEnter(to, from, next) {
  274. // console.log(11112222);
  275. // console.log(to, from, next, 898);
  276. next((vm) => {
  277. // 这个时候组件还没有创建,所以要通过vm来访问
  278. if (
  279. from.path == "/finance/details/balance_sum" &&
  280. to.path == "/finance/details/wallet" &&
  281. vm.$route.query.id
  282. ) {
  283. //只有是从A进到B页面才执行
  284. // 将要执行的逻辑
  285. vm.show = true;
  286. vm.show2 = false;
  287. vm.getDataWallet({
  288. customerId: vm.$route.query.id,
  289. type: "COMMONLY",
  290. });
  291. vm.getDataRebate({
  292. customerId: vm.$route.query.id,
  293. type: "REBATE",
  294. });
  295. } else {
  296. if (vm.isShow) {
  297. vm.show2 = false;
  298. vm.getDataWallet({
  299. customerId: vm.customerId,
  300. type: "COMMONLY",
  301. });
  302. vm.getDataRebate({
  303. customerId: vm.customerId,
  304. type: "REBATE",
  305. });
  306. } else {
  307. vm.show = false;
  308. vm.show2 = true;
  309. vm.walletList = [];
  310. vm.rebateList = [];
  311. vm.$message("请选择经销商");
  312. vm.getCustomerDataList();
  313. }
  314. }
  315. });
  316. },
  317. created() {
  318. // console.log(this.$route.query.id, 11, this.customerId);
  319. // if (this.$route.query.id) {
  320. // this.getDataWallet({
  321. // customerId: this.$route.query.id,
  322. // type: "COMMONLY",
  323. // });
  324. // this.getDataRebate({
  325. // customerId: this.$route.query.id,
  326. // type: "REBATE",
  327. // });
  328. // } else {
  329. // if (this.isShow) {
  330. // this.getDataWallet({
  331. // customerId: this.customerId,
  332. // type: "COMMONLY",
  333. // });
  334. // this.getDataRebate({
  335. // customerId: this.customerId,
  336. // type: "REBATE",
  337. // });
  338. // } else {
  339. // this.$message("请选择经销商");
  340. // this.getCustomerDataList();
  341. // }
  342. // }
  343. },
  344. computed: {
  345. ...mapGetters(["customerId"]),
  346. },
  347. methods: {
  348. //清空
  349. resetFn() {
  350. this.$refs.searchForm.resetFields();
  351. },
  352. //搜索
  353. async searchFn() {
  354. await this.$refs.searchForm.validate();
  355. this.getDataWallet({
  356. customerId: this.searchForm.customerId,
  357. type: "COMMONLY",
  358. });
  359. this.getDataRebate({
  360. customerId: this.searchForm.customerId,
  361. type: "REBATE",
  362. });
  363. },
  364. //获取经销商列表
  365. async getCustomerDataList() {
  366. let res = await getCustomerList({
  367. pageNum: 1,
  368. pageSize: -1,
  369. });
  370. this.customerList = res.data.records;
  371. },
  372. //返回
  373. goBack() {
  374. this.$router.go(-1);
  375. this.$store.dispatch("tagsView/delView", this.$route);
  376. },
  377. //取消
  378. async cancelFn() {
  379. this.dialogForm = false;
  380. await this.$refs.addForm.clearValidate();
  381. },
  382. //确定
  383. async determineFn() {
  384. await this.$refs.addForm.validate();
  385. const res = this.addForm.rebateRate / 100;
  386. this.addForm.rebateRate = res;
  387. await getWalletRebateRateUpdate({ ...this.addForm });
  388. if (this.$route.query.id) {
  389. this.getDataRebate({
  390. customerId: this.$route.query.id,
  391. type: "REBATE",
  392. });
  393. } else {
  394. this.getDataRebate({
  395. customerId: this.searchForm.customerId,
  396. type: "REBATE",
  397. });
  398. }
  399. this.$message.success("修改成功");
  400. this.dialogForm = false;
  401. },
  402. //修改
  403. editFn(v) {
  404. this.addForm.customerWalletId = v.customerWalletId;
  405. this.addForm.rebateRate = v.rebateRate * 100;
  406. this.dialogForm = true;
  407. },
  408. // //一键生成
  409. // async generateFn() {
  410. // await getfinanceInit({ customerId: this.customerId });
  411. // this.getDataWallet();
  412. // this.getDataRebate();
  413. // this.$message.success("已生成");
  414. // },
  415. //
  416. async getDataRebate(data) {
  417. let res = await getWalletCustomerList(data);
  418. res.data.forEach((item) => {
  419. item.sums1 = [];
  420. item.sums2 = ["amount"];
  421. });
  422. this.rebateList = res.data;
  423. },
  424. async getDataWallet(data) {
  425. let res = await getWalletCustomerList(data);
  426. res.data.forEach((item) => {
  427. item.sums1 = [];
  428. item.sums2 = ["amount", "freeCreditAmount", "usedCreditAmount"];
  429. });
  430. this.walletList = res.data;
  431. },
  432. },
  433. };
  434. </script>
  435. <style lang="scss" scoped>
  436. .styl {
  437. padding-top: 14px;
  438. }
  439. .selectStyle {
  440. width: 100%;
  441. }
  442. </style>