wallet.vue 13 KB

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