123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- <template>
- <div class="app-container">
- <span>返利互转单</span>
- <el-divider></el-divider>
- <!-- 筛选条件 -->
- <div>
- <el-form ref="searchForm" :model="searchForm" label-width="100px" size="mini" label-position="left">
- <el-row :gutter="20">
- <el-col :xs="24" :sm="12" :lg="6">
- <el-form-item label="返利互转单号" prop="">
- <el-input disabled placeholder="系统自动生成"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6">
- <el-form-item label="单据日期" prop="theTime">
- <el-date-picker disabled class="dateStyle" placeholder="系统自动生成" type="datetime" value-format="yyyy-MM-dd HH:mm:ss">
- </el-date-picker>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6">
- <el-form-item label="制单人" prop="">
- <el-input v-model="searchForm.nickName" disabled></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6">
- <el-form-item label="经销商编号" prop="">
- <el-input disabled v-model="searchForm.customerNumber"></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :sm="12" :lg="6">
- <el-form-item label="经销商名称" prop="">
- <el-input disabled v-model="searchForm.customerName"></el-input>
- </el-form-item>
- </el-col>
- <!-- <el-col :xs="24" :sm="12" :lg="6">
- <el-form-item label="备注信息" prop="">
- <el-input placeholder="请输入"></el-input>
- </el-form-item>
- </el-col> -->
- </el-row>
- </el-form>
- </div>
- <!-- 列表 -->
- <div class="mymain-container">
- <div class="table">
- <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe>
- <el-table-column label="序号" type="index" align="left" width="100" show-overflow-tooltip></el-table-column>
- <el-table-column align="left" label="经销商编码" prop="customerNumber" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <div v-if="scope.$index == 0">{{ searchForm.customerNumber }}</div>
- <div v-if="scope.$index == 1">{{ scope.row.customerNumber }}</div>
- </template>
- </el-table-column>
- <el-table-column align="left" label="经销商名称" prop="customerName" min-width="260" show-overflow-tooltip>
- <template slot-scope="scope">
- <div v-if="scope.$index == 0">{{ searchForm.customerName }}</div>
- <el-select size="mini" class='dateStyle' @change="changeCustomerFn1($event, scope.$index, scope.row)" v-if="scope.$index == 1" filterable v-model="scope.row.customerId" placeholder="请选择">
- <el-option v-for="item in customerData" :key="item.id" :label="item.name" :value="item.id">
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column align="left" label="返利类型" prop="name" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-select size="mini" filterable v-model="scope.row.name" placeholder="请选择" @click.native="changeCustomerFn(scope.row, scope.$index)">
- <el-option v-for="item in scope.row.typeList" :key="item.customerWalletId" :label="item.name" :value="item.customerWalletId">
- </el-option>
- </el-select>
- </template>
- </el-table-column>
- <el-table-column align="left" label="返利金额" prop="" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input size="mini" type="number" v-model="scope.row.money"></el-input>
- </template>
- </el-table-column>
- <el-table-column align="left" label="备注" prop="" min-width="160" show-overflow-tooltip>
- <template slot-scope="scope">
- <el-input size="mini" v-model="scope.row.bz"></el-input>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- <!-- 按钮 -->
- <div class="btn-group clearfix">
- <div class="fl">
- <el-button type="primary" size="mini" @click="preservationFn">保存</el-button>
- <el-button type="primary" size="mini" @click="resetFn">重置</el-button>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { mapGetters } from "vuex";
- import {
- getUserInfo,
- getWalletCustomerList,
- getTransferAdd,
- getTransferSubmit,
- getCustomerGroupList,
- } from "@/api/finance/change_apply";
- export default {
- data() {
- return {
- listLoading: false, // 列表加载loading
- dataList: [
- {
- customerNumber: "",
- customerId: "",
- name: "",
- money: "",
- bz: "",
- },
- {
- customerNumber: "",
- customerId: "",
- name: "",
- money: "",
- bz: "",
- },
- ],
- searchForm: {
- customerId: "",
- customerName: "",
- nickName: "",
- customerNumber: "",
- },
- customerData: [], //经销商数据
- typeList: [], //返利类型数据
- // rules: {
- // theTime: [
- // {
- // required: true,
- // message: "请选择日期",
- // trigger: "change",
- // },
- // ],
- // },
- };
- },
- computed: {
- ...mapGetters(["userid"]),
- },
- created() {
- this.getUserInfoFn();
- this.getCustomerData();
- },
- methods: {
- //选择经销商名称事件
- async changeCustomerFn1(v, index, value) {
- // value.customerWalletId = "";
- // console.log(v);
- const res = await getWalletCustomerList({
- customerId: v,
- type: "REBATE",
- });
- // console.log(res, 7878);
- const res2 = this.customerData.filter((i) => i.id == v);
- // console.log(res2, 8888);
- this.$set(this.dataList[1], "customerNumber", res2[0].number);
- // this.$set(this.dataList[index], "customerName", res2[0].name);
- // this.$set(this.dataList[index], "walletList", res.data);
- },
- // func(arr, target) {
- // var obj = {};
- // for (var i = 0; i < arr.length; i++) {
- // var item = arr[i].money;
- // if (obj[item] === undefined) {
- // var x = target - item;
- // obj[x] = i;
- // } else {
- // return [obj[item], i];
- // }
- // }
- // return null;
- // },
- resetFn() {
- this.searchForm.theTime = null;
- this.dataList.forEach((v) => {
- v.money = "";
- v.bz = "";
- v.name = "";
- });
- this.dataList[1].customerId = "";
- },
- // //返利类型数据
- async changeCustomerFn(v, index) {
- if (v.customerId == "") {
- return;
- }
- v.name = "";
- let res = await getWalletCustomerList({
- customerId: v.customerId,
- type: "REBATE",
- });
- if (index == 1) {
- let aa = res.data.filter(
- (v) => v.customerWalletId != this.dataList[0].name
- );
- console.log(aa);
- this.$set(this.dataList[index], "typeList", aa);
- } else {
- this.$set(this.dataList[index], "typeList", res.data);
- }
- },
- // async typeFn(row) {
- // console.log(row);
- // let res = await getWalletCustomerList({
- // customerId: row.customerId,
- // type: "REBATE",
- // });
- // this.typeList = res.data;
- // },
- //查询同个集团的经销商数据
- async getCustomerData() {
- const res = await getCustomerGroupList();
- // console.log(res, 123214);
- this.customerData = res.data;
- },
- //保存
- async preservationFn() {
- let receiverWalletRebateId;
- let initiatorWalletRebateId;
- let initiatorRemark;
- let receiverRemark;
- let amount;
- await this.$refs.searchForm.validate();
- let aaa = this.dataList.find((v) => {
- if (v.money == "") {
- this.$message.error("请输入返利金额");
- return v;
- }
- if (v.customerId == "") {
- this.$message.error("请选择经销商");
- return v;
- }
- if (v.name == "") {
- this.$message.error("请选择返利类型");
- return v;
- }
- });
- if (aaa != undefined) {
- return;
- }
- if (
- Number(this.dataList[0].money) + Number(this.dataList[1].money) !=
- 0
- ) {
- this.$message.error("返利金额不等,请重新输入");
- return;
- }
- if (this.dataList[0].money > 0) {
- receiverWalletRebateId = this.dataList[0].name;
- initiatorWalletRebateId = this.dataList[1].name;
- initiatorRemark = this.dataList[1].bz;
- receiverRemark = this.dataList[0].bz;
- amount = this.dataList[0].money;
- } else {
- receiverWalletRebateId = this.dataList[1].name;
- initiatorWalletRebateId = this.dataList[0].name;
- initiatorRemark = this.dataList[0].bz;
- receiverRemark = this.dataList[1].bz;
- amount = this.dataList[1].money;
- }
- await getTransferAdd({
- theTime: this.searchForm.theTime,
- receiverWalletRebateId,
- initiatorWalletRebateId,
- receiverRemark,
- initiatorRemark,
- amount: amount * 1,
- });
- this.$router.push("/finance/rebate/change_list");
- this.$message.success("申请成功");
- },
- async getUserInfoFn() {
- const res = await getUserInfo({ adminUserId: this.userid });
- console.log(res, 1);
- this.searchForm.customerNumber = res.data.customerNumber;
- this.dataList[0].customerId = res.data.customerId;
- this.searchForm.customerName = res.data.customerName;
- this.searchForm.customerNumber = res.data.customerNumber;
- this.searchForm.nickName = res.data.nickName;
- // const res2 = await getWalletCustomerList({
- // customerId: res.data.customerId,
- // type: "REBATE",
- // });
- // console.log(res2, 5555);
- // res2.data.forEach((v) => {
- // v.money = "";
- // v.bz = "";
- // });
- // this.dataList = res2.data;
- // console.log(this.dataList);
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .dateStyle {
- width: 100%;
- }
- </style>
|