wallet.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <div class="app-container">
  3. <div v-show="show" class="sty">
  4. <el-page-header @back="goBack" />
  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 v-model="searchForm.customerId" class="selectStyle" placeholder="请选择" filterable>
  14. <el-option v-for="(v, i) in customerList" :key="i" :label="v.name" :value="v.id" />
  15. </el-select>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :xs="24" :sm="12" :lg="18">
  19. <el-form-item label="" class="fr">
  20. <el-button size="mini" @click="resetFn">清空</el-button>
  21. <el-button size="mini" type="primary" @click="searchFn">搜索</el-button>
  22. </el-form-item>
  23. </el-col>
  24. </el-row>
  25. </el-form>
  26. </div>
  27. <!-- 按钮 -->
  28. <div class="btn-group clearfix">
  29. <div class="fr">
  30. <el-button type="primary" size="mini" @click="exportFn">导出</el-button>
  31. </div>
  32. </div>
  33. <el-row>
  34. <el-col :xs="24" :sm="12" :lg="12">
  35. <div class="styl">现金钱包</div>
  36. </el-col>
  37. <!-- <el-col :xs="24" :sm="12" :lg="12">
  38. <div class="fr">
  39. <el-button size="small" type="primary" @click="generateFn"
  40. >一键生成钱包</el-button
  41. >
  42. </div>
  43. </el-col> -->
  44. </el-row>
  45. <el-divider />
  46. <!-- 列表 -->
  47. <div class="mymain-container">
  48. <div class="table">
  49. <el-table v-loading="listLoading" @row-dblclick="fnJump($event,'COMMONLY')" :data="walletList" element-loading-text="Loading" border fit highlight-current-row stripe show-summary :summary-method="$getSummaries">
  50. <template>
  51. <el-table-column align="left" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip>
  52. <template slot-scope="scope">
  53. <CopyButton :copy-text="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 />
  58. <el-table-column align="left" label="更新时间" prop="updateTime" min-width="160" show-overflow-tooltip />
  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. </template>
  75. </el-table>
  76. </div>
  77. </div>
  78. <span>返利钱包</span>
  79. <el-divider />
  80. <!-- 列表 -->
  81. <div class="mymain-container">
  82. <div class="table">
  83. <el-table v-loading="listLoading" :data="rebateList" @row-dblclick="fnJump($event,'REBATE')" element-loading-text="Loading" border fit highlight-current-row stripe show-summary :summary-method="$getSummaries">
  84. <el-table-column align="left" label="经销商名称" prop="customerName" min-width="160" show-overflow-tooltip>
  85. <template slot-scope="scope">
  86. <CopyButton :copy-text="scope.row.customerName" />
  87. <span>{{ scope.row.customerName }}</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column align="left" label="返利钱包" prop="name" min-width="160" show-overflow-tooltip />
  91. <el-table-column align="left" label="更新时间" prop="updateTime" min-width="160" show-overflow-tooltip />
  92. <el-table-column align="right" label="钱包余额" prop="amount" min-width="160" show-overflow-tooltip>
  93. <template slot-scope="scope">
  94. {{ scope.row.amount | numToFixed }}
  95. </template>
  96. </el-table-column>
  97. <!-- <el-table-column
  98. align="center"
  99. label="操作"
  100. min-width="160"
  101. show-overflow-tooltip
  102. >
  103. <template v-slot="{ row }">
  104. <el-button
  105. v-if="$checkBtnRole('edit', $route.meta.roles)"
  106. type="text"
  107. class="textColor"
  108. @click="editFn(row)"
  109. >
  110. 修改
  111. </el-button>
  112. </template>
  113. </el-table-column> -->
  114. </el-table>
  115. </div>
  116. </div>
  117. <!-- 弹窗 -->
  118. <el-dialog title="配置返利比例" :visible.sync="dialogForm" width="30%" :show-close="false" :close-on-click-modal="false">
  119. <el-form ref="addForm" :rules="rules" :model="addForm" label-width="100px">
  120. <el-form-item label="返利比例" prop="rebateRate">
  121. <el-input v-model.number="addForm.rebateRate" oninput="if(value>100)value=100;if(value<0)value=0"><i slot="suffix" class="el-input__icon">% </i></el-input>
  122. </el-form-item>
  123. </el-form>
  124. <div slot="footer" class="dialog-footer">
  125. <el-button @click="cancelFn">取 消</el-button>
  126. <el-button type="primary" @click="determineFn">确 定</el-button>
  127. </div>
  128. </el-dialog>
  129. <!-- 导出弹窗 -->
  130. <el-dialog title="导出" :visible.sync="dialogExportForm" width="30%" :show-close="false" :close-on-click-modal="false">
  131. <el-form ref="exportForm" :rules="exportRules" :model="exportForm" label-width="120px">
  132. <el-form-item label="编码范围" prop="">
  133. <div class="fanwei">
  134. <el-input v-model="exportForm.startCustomerId" type="number" />
  135. <span>——</span>
  136. <el-input v-model="exportForm.endCustomerId" type="number" />
  137. </div>
  138. </el-form-item>
  139. </el-form>
  140. <div slot="footer" class="dialog-footer">
  141. <el-button @click="exportCancelFn">取 消</el-button>
  142. <el-button type="primary" @click="exportOKFn">确 定</el-button>
  143. </div>
  144. </el-dialog>
  145. </div>
  146. </template>
  147. <script>
  148. import { mapGetters } from 'vuex'
  149. import { getCustomerList, getWalletRebateRateUpdate } from '@/api/finance/wallet'
  150. import { downloadFiles } from '@/utils/util'
  151. import { getWalletCustomerList } from '@/api/finance/change_apply'
  152. export default {
  153. data() {
  154. return {
  155. dialogExportForm: false,
  156. exportRules: {},
  157. exportForm: {
  158. endCustomerId: '',
  159. startCustomerId: ''
  160. },
  161. isShow: JSON.parse(localStorage.getItem('supply_user')).isCustomer,
  162. show: false,
  163. show2: true,
  164. searchForm: {
  165. customerId: null
  166. },
  167. customerList: [],
  168. listLoading: false, // 列表加载loading
  169. walletList: [],
  170. rebateList: [],
  171. addForm: {
  172. rebateRate: null
  173. },
  174. dialogForm: false,
  175. rulesSearchForm: {
  176. customerId: [
  177. {
  178. required: true,
  179. message: '请选择经销商',
  180. trigger: 'blur'
  181. }
  182. ]
  183. },
  184. rules: {
  185. rebateRate: [
  186. {
  187. required: true,
  188. message: '请输入返利比例',
  189. trigger: 'blur'
  190. }
  191. ]
  192. }
  193. }
  194. },
  195. beforeRouteEnter(to, from, next) {
  196. // console.log(11112222);
  197. // console.log(to, from, next, 898);
  198. next((vm) => {
  199. // 这个时候组件还没有创建,所以要通过vm来访问
  200. if (
  201. from.path == '/finance/details/balance_sum' &&
  202. to.path == '/finance/details/wallet' &&
  203. vm.$route.query.id
  204. ) {
  205. // 只有是从A进到B页面才执行
  206. // 将要执行的逻辑
  207. vm.show = true
  208. vm.show2 = false
  209. vm.getDataWallet({
  210. customerId: vm.$route.query.id,
  211. type: 'COMMONLY'
  212. })
  213. vm.getDataRebate({
  214. customerId: vm.$route.query.id,
  215. type: 'REBATE'
  216. })
  217. } else {
  218. if (vm.isShow) {
  219. vm.show2 = false
  220. vm.getDataWallet({
  221. customerId: vm.customerId,
  222. type: 'COMMONLY'
  223. })
  224. vm.getDataRebate({
  225. customerId: vm.customerId,
  226. type: 'REBATE'
  227. })
  228. } else {
  229. vm.show = false
  230. vm.show2 = true
  231. vm.walletList = []
  232. vm.rebateList = []
  233. vm.$message('请选择经销商')
  234. vm.getCustomerDataList()
  235. }
  236. }
  237. })
  238. },
  239. created() {
  240. // console.log(this.$route.query.id, 11, this.customerId);
  241. // if (this.$route.query.id) {
  242. // this.getDataWallet({
  243. // customerId: this.$route.query.id,
  244. // type: "COMMONLY",
  245. // });
  246. // this.getDataRebate({
  247. // customerId: this.$route.query.id,
  248. // type: "REBATE",
  249. // });
  250. // } else {
  251. // if (this.isShow) {
  252. // this.getDataWallet({
  253. // customerId: this.customerId,
  254. // type: "COMMONLY",
  255. // });
  256. // this.getDataRebate({
  257. // customerId: this.customerId,
  258. // type: "REBATE",
  259. // });
  260. // } else {
  261. // this.$message("请选择经销商");
  262. // this.getCustomerDataList();
  263. // }
  264. // }
  265. },
  266. computed: {
  267. ...mapGetters(['customerId'])
  268. },
  269. methods: {
  270. fnJump({customerId},type){
  271. this.$router.push(`/finance/details/standbook_list?status=${type}&customerId=${customerId}`)
  272. },
  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. const 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. const 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. const 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>