123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- <template>
- <div class="app-container">
- <div class="sty" v-show="show">
- <el-page-header @back="goBack"> </el-page-header>
- </div>
- <br />
- <!-- 筛选条件 -->
- <div v-if="show2">
- <el-form
- ref="searchForm"
- :model="searchForm"
- :rules="rulesSearchForm"
- label-width="100px"
- size="small"
- label-position="left"
- >
- <el-row :gutter="20">
- <el-col :xs="24" :sm="12" :lg="6">
- <el-form-item label="经销商名称" prop="customerId">
- <el-select
- class="selectStyle"
- v-model="searchForm.customerId"
- placeholder="请选择"
- filterable
- >
- <el-option
- v-for="(v, i) in customerList"
- :key="i"
- :label="v.name"
- :value="v.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="18">
- <el-form-item label="" class="fr">
- <el-button size="small" @click="resetFn">清空</el-button>
- <el-button size="small" type="primary" @click="searchFn"
- >搜索</el-button
- >
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <el-row>
- <el-col :xs="24" :sm="12" :lg="12">
- <div class="styl">现金钱包</div>
- </el-col>
- <!-- <el-col :xs="24" :sm="12" :lg="12">
- <div class="fr">
- <el-button size="small" type="primary" @click="generateFn"
- >一键生成钱包</el-button
- >
- </div>
- </el-col> -->
- </el-row>
- <el-divider></el-divider>
- <!-- 列表 -->
- <div class="mymain-container">
- <div class="table">
- <el-table
- v-loading="listLoading"
- :data="walletList"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- stripe
- show-summary
- :summary-method="$getSummaries"
- >
- <el-table-column
- align="center"
- label="经销商名称"
- prop="customerName"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="钱包"
- prop="name"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="right"
- label="余额"
- prop="amount"
- min-width="160"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- {{ scope.row.amount | numToFixed }}
- </template>
- </el-table-column>
- <el-table-column
- align="right"
- label="可用信用额度"
- prop="freeCreditAmount"
- min-width="160"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- {{ scope.row.freeCreditAmount | numToFixed }}
- </template>
- </el-table-column>
- <el-table-column
- align="right"
- label="已用信用额度"
- prop="usedCreditAmount"
- min-width="160"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- {{ scope.row.usedCreditAmount | numToFixed }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="更新时间"
- prop="updateTime"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- </el-table>
- </div>
- </div>
- <span>返利钱包</span>
- <el-divider></el-divider>
- <!-- 列表 -->
- <div class="mymain-container">
- <div class="table">
- <el-table
- v-loading="listLoading"
- :data="rebateList"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- stripe
- show-summary
- :summary-method="$getSummaries"
- >
- <el-table-column
- align="center"
- label="经销商名称"
- prop="customerName"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="返利钱包"
- prop="name"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="right"
- label="钱包余额"
- prop="amount"
- min-width="160"
- show-overflow-tooltip
- >
- <template slot-scope="scope">
- {{ scope.row.amount | numToFixed }}
- </template>
- </el-table-column>
- <el-table-column
- align="center"
- label="更新时间"
- prop="updateTime"
- min-width="160"
- show-overflow-tooltip
- ></el-table-column>
- <el-table-column
- align="center"
- label="操作"
- min-width="160"
- show-overflow-tooltip
- >
- <template v-slot="{ row }">
- <el-button
- v-if="$checkBtnRole('edit', $route.meta.roles)"
- type="text"
- class="textColor"
- @click="editFn(row)"
- >
- 修改
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <!-- 弹窗 -->
- <el-dialog
- title="配置返利比例"
- :visible.sync="dialogForm"
- width="30%"
- :show-close="false"
- :close-on-click-modal="false"
- >
- <el-form
- ref="addForm"
- :rules="rules"
- :model="addForm"
- label-width="100px"
- >
- <el-form-item label="返利比例" prop="rebateRate">
- <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
- >
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button @click="cancelFn">取 消</el-button>
- <el-button type="primary" @click="determineFn">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- import {
- getfinanceInit,
- getWalletRebateRateUpdate,
- getCustomerList,
- } from "@/api/finance/wallet";
- import { getWalletCustomerList } from "@/api/finance/change_apply";
- export default {
- data() {
- return {
- isShow: JSON.parse(localStorage.getItem("supply_user")).isCustomer,
- show: false,
- show2: true,
- searchForm: {
- customerId: null,
- },
- customerList: [],
- listLoading: false, // 列表加载loading
- walletList: [],
- rebateList: [],
- addForm: {
- rebateRate: null,
- },
- dialogForm: false,
- rulesSearchForm: {
- customerId: [
- {
- required: true,
- message: "请选择经销商",
- trigger: "blur",
- },
- ],
- },
- rules: {
- rebateRate: [
- {
- required: true,
- message: "请输入返利比例",
- trigger: "blur",
- },
- ],
- },
- };
- },
- beforeRouteEnter(to, from, next) {
- // console.log(11112222);
- // console.log(to, from, next, 898);
- next((vm) => {
- // 这个时候组件还没有创建,所以要通过vm来访问
- if (
- from.path == "/finance/details/balance_sum" &&
- to.path == "/finance/details/wallet" &&
- vm.$route.query.id
- ) {
- //只有是从A进到B页面才执行
- // 将要执行的逻辑
- vm.show = true;
- vm.show2 = false;
- vm.getDataWallet({
- customerId: vm.$route.query.id,
- type: "COMMONLY",
- });
- vm.getDataRebate({
- customerId: vm.$route.query.id,
- type: "REBATE",
- });
- } else {
- if (vm.isShow) {
- vm.show2 = false;
- vm.getDataWallet({
- customerId: vm.customerId,
- type: "COMMONLY",
- });
- vm.getDataRebate({
- customerId: vm.customerId,
- type: "REBATE",
- });
- } else {
- vm.show = false;
- vm.show2 = true;
- vm.walletList = [];
- vm.rebateList = [];
- vm.$message("请选择经销商");
- vm.getCustomerDataList();
- }
- }
- });
- },
- created() {
- // console.log(this.$route.query.id, 11, this.customerId);
- // if (this.$route.query.id) {
- // this.getDataWallet({
- // customerId: this.$route.query.id,
- // type: "COMMONLY",
- // });
- // this.getDataRebate({
- // customerId: this.$route.query.id,
- // type: "REBATE",
- // });
- // } else {
- // if (this.isShow) {
- // this.getDataWallet({
- // customerId: this.customerId,
- // type: "COMMONLY",
- // });
- // this.getDataRebate({
- // customerId: this.customerId,
- // type: "REBATE",
- // });
- // } else {
- // this.$message("请选择经销商");
- // this.getCustomerDataList();
- // }
- // }
- },
- computed: {
- ...mapGetters(["customerId"]),
- },
- methods: {
- //清空
- resetFn() {
- this.$refs.searchForm.resetFields();
- },
- //搜索
- async searchFn() {
- await this.$refs.searchForm.validate();
- this.getDataWallet({
- customerId: this.searchForm.customerId,
- type: "COMMONLY",
- });
- this.getDataRebate({
- customerId: this.searchForm.customerId,
- type: "REBATE",
- });
- },
- //获取经销商列表
- async getCustomerDataList() {
- let res = await getCustomerList({
- pageNum: 1,
- pageSize: -1,
- });
- this.customerList = res.data.records;
- },
- //返回
- goBack() {
- this.$router.go(-1);
- this.$store.dispatch("tagsView/delView", this.$route);
- },
- //取消
- async cancelFn() {
- this.dialogForm = false;
- await this.$refs.addForm.clearValidate();
- },
- //确定
- async determineFn() {
- await this.$refs.addForm.validate();
- const res = this.addForm.rebateRate / 100;
- this.addForm.rebateRate = res;
- await getWalletRebateRateUpdate({ ...this.addForm });
- if (this.$route.query.id) {
- this.getDataRebate({
- customerId: this.$route.query.id,
- type: "REBATE",
- });
- } else {
- this.getDataRebate({
- customerId: this.searchForm.customerId,
- type: "REBATE",
- });
- }
- this.$message.success("修改成功");
- this.dialogForm = false;
- },
- //修改
- editFn(v) {
- this.addForm.customerWalletId = v.customerWalletId;
- this.addForm.rebateRate = v.rebateRate * 100;
- this.dialogForm = true;
- },
- // //一键生成
- // async generateFn() {
- // await getfinanceInit({ customerId: this.customerId });
- // this.getDataWallet();
- // this.getDataRebate();
- // this.$message.success("已生成");
- // },
- //
- async getDataRebate(data) {
- let res = await getWalletCustomerList(data);
- res.data.forEach((item) => {
- item.sums1 = [];
- item.sums2 = ["amount"];
- });
- this.rebateList = res.data;
- },
- async getDataWallet(data) {
- let res = await getWalletCustomerList(data);
- res.data.forEach((item) => {
- item.sums1 = [];
- item.sums2 = ["amount", "freeCreditAmount", "usedCreditAmount"];
- });
- this.walletList = res.data;
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .styl {
- padding-top: 14px;
- }
- .selectStyle {
- width: 100%;
- }
- </style>
|