123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517 |
- <template>
- <div class="app-container">
- <div class="screen-container">
- <el-form
- ref="screenForm"
- :model="screenForm"
- size="small"
- label-position="left"
- >
- <el-row :gutter="20">
- <el-col :xs="24" :ms="6" :lg="6">
- <el-form-item label="" prop="mainName">
- <el-input
- v-model="screenForm.mainName"
- placeholder="返利品类"
- size="small"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :ms="6" :lg="6">
- <el-form-item label="" prop="saleTypeCode">
- <el-input
- v-model="screenForm.saleTypeCode"
- placeholder="销售类型编码"
- size="small"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :ms="6" :lg="6">
- <el-form-item label="" prop="saleTypeName">
- <el-input
- v-model="screenForm.saleTypeName"
- placeholder="销售类型名称"
- size="small"
- ></el-input>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :ms="6" :lg="6">
- <el-form-item prop="status">
- <el-select
- v-model="screenForm.status"
- placeholder="请选择"
- size="small"
- >
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :xs="24" :ms="18" :lg="18">
- <el-form-item>
- <el-button
- type="primary"
- size="small"
- v-if="$checkBtnRole('add', $route.meta.roles)"
- @click="(dialogVisible = true), (type = 1), getDictList()"
- >新增</el-button
- >
- <el-button type="primary" size="small" @click="submitScreenForm"
- >查询</el-button
- >
- <el-button type="primary" size="small" @click="resetScreenForm"
- >重置</el-button
- >
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- <div class="mymain-container">
- <el-table
- v-loading="listLoading"
- :data="dataList"
- element-loading-text="Loading"
- border
- fit
- highlight-current-row
- stripe
- >
- <el-table-column type="selection" width="55" align="center">
- </el-table-column>
- <template v-for="col in columns">
- <el-table-column
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- v-if="col.prop == 'status'"
- >
- <template slot-scope="scope">
- <el-switch
- v-model="scope.row.status"
- @change="handleSwitch($event, scope.row.walletRebateId)"
- :active-text="scope.row.status ? '已启用' : '已禁用'"
- >
- </el-switch>
- </template>
- </el-table-column>
- <el-table-column
- v-else
- align="center"
- :label="col.lable"
- :prop="col.prop"
- :min-width="col.widht"
- show-overflow-tooltip
- >
- </el-table-column>
- </template>
- <el-table-column
- align="center"
- fixed="right"
- label="操作"
- min-width="160"
- >
- <template slot-scope="scope">
- <el-button type="text" size="small" @click="hanleDateil(scope.row)"
- >查看</el-button
- >
- <el-button type="text" size="small" @click="hanleEdit(scope.row)" v-if="$checkBtnRole('edit', $route.meta.roles)"
- >编辑</el-button
- >
- <!-- <el-button type="text" size="small">编辑</el-button> -->
- </template>
- </el-table-column>
- </el-table>
- <!-- 分页 -->
- <div class="fr">
- <el-pagination
- @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- :current-page="currentPage"
- :page-sizes="[10, 20, 30, 50]"
- :page-size="10"
- layout="total, sizes, prev, pager, next, jumper"
- :total="listTotal"
- >
- </el-pagination>
- </div>
- </div>
- <div>
- <el-dialog
- :visible.sync="dialogVisible"
- width="50%"
- @close="hanelclose"
- title="返利类型"
- >
- <el-form
- :model="dialogForm"
- ref="dialogForm"
- :rules="rules"
- label-width="120px"
- :inline="false"
- size="normal"
- >
- <el-form-item label="返利使用钱包" prop="name">
- <el-input
- v-model="dialogForm.name"
- :readonly="type == 3"
- ></el-input>
- </el-form-item>
- <el-form-item label="销售类型名称" prop="saleTypeName">
- <el-select
- v-model="dialogForm.saleTypeCode"
- :disabled="type == 3"
- @change="handleChange"
- placeholder="请选择销售类型编码"
- >
- <el-option
- v-for="item in typeList"
- :key="item.sysDictId"
- :label="item.saleName"
- :value="item.saleCode"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="销售类型编码" prop="saleTypeCode">
- <el-input
- v-model="dialogForm.saleTypeCode"
- :readonly="true"
- ></el-input>
- </el-form-item>
- <el-form-item label="产品使用品类" prop="mainName">
- <el-input v-model="dialogForm.mainName" :readonly="true"></el-input>
- </el-form-item>
- <el-form-item label="返利折扣比例" prop="rebateRate">
- <el-input
- type="number"
- placeholder="例如0.1=1折"
- :readonly="type == 3"
- @change="handleNumber"
- v-model.number="dialogForm.rebateRate"
- ></el-input>
- </el-form-item>
- <el-form-item label="状态" prop="status">
- <el-switch
- v-model="dialogForm.status"
- :disabled="type == 3"
- :active-value="true"
- :inactive-value="false"
- :active-text="dialogForm.status ? '启用' : ''"
- >
- </el-switch>
- </el-form-item>
- </el-form>
- <template v-if="type !== 3">
- <span slot="footer" class="dialog-footer">
- <el-button @click="hanleCancel">取 消</el-button>
- <el-button type="primary" @click="handelInfo">确 定</el-button>
- </span>
- </template>
- </el-dialog>
- </div>
- </div>
- </template>
- <script>
- import Mixin from "@/mixin/index";
- import Pagination from "@/components/Pagination";
- import {
- addWallet,
- getDictList,
- getTypeList,
- updateWallet,
- getWalletList,
- getWalletDetail,
- getProductList,
- } from "@/api/policy_list";
- export default {
- mixins: [Mixin],
- data() {
- return {
- type: 0, // 0 1
- screenForm: {
- mainName: "",
- saleTypeCode: "",
- saleTypeName: "",
- status: "",
- },
- dialogForm: {
- name: "",
- mainName: "",
- mainId: "",
- saleTypeCode: "",
- saleTypeName: "",
- rebateRate: "",
- status: "",
- },
- dataList: [],
- columns: [
- {
- prop: "saleTypeCode",
- lable: "销售类型编码",
- widht: 160,
- },
- {
- prop: "saleTypeName",
- lable: "销售类型名称",
- widht: 160,
- },
- {
- prop: "mainName",
- lable: "产品大类",
- widht: 160,
- },
- {
- prop: "name",
- lable: "返利类型",
- widht: 160,
- },
- {
- prop: "rebateRate",
- lable: "返利折扣比例",
- widht: 160,
- },
- {
- prop: "status",
- lable: "状态",
- widht: 160,
- },
- {
- prop: "createBy",
- lable: "创建人",
- widht: 160,
- },
- {
- prop: "createTime",
- lable: "创建时间",
- widht: 160,
- },
- {
- prop: "updateBy",
- lable: "更新人",
- widht: 160,
- },
- {
- prop: "updateTime",
- lable: "更新时间",
- widht: 160,
- },
- ],
- options: [
- {
- value: "",
- label: "全部",
- },
- {
- value: 1,
- label: "已启用",
- },
- {
- value: 0,
- label: "已停用",
- },
- ],
- dictListData: [],
- typeList: [],
- rules: {
- name: [{ required: true, message: "请输入名称", trigger: "blur" }],
- saleTypeCode: [
- { required: true, message: "请选择编码", trigger: "blur" },
- ],
- rebateRate: [
- { required: true, message: "请输入比例", trigger: "blur" },
- ],
- },
- };
- },
- methods: {
- getList() {
- this.listLoading = true;
- const params = {
- pageNum: this.currentPage,
- pageSize: this.pageSize,
- mainName: this.screenForm.mainName,
- saleTypeCode: this.screenForm.saleTypeCode,
- saleTypeName: this.screenForm.saleTypeName,
- status: this.screenForm.status,
- };
- getWalletList(params).then((res) => {
- this.dataList = res.data.records;
- this.listTotal = res.data.total;
- this.listLoading = false;
- });
- getProductList({
- productCategoryName: "",
- productCategoryNumber: "",
- }).then((res) => {
- this.productList = res.data;
- });
- },
- handleChange(e) {
- console.log(e, this.typeList);
- this.typeList.find((k) => {
- if (e == k.saleCode) {
- this.dialogForm.saleTypeName = k.saleName;
- this.dialogForm.mainId = k.mainId;
- this.dialogForm.mainName = k.mainName;
- }
- });
- },
- handleNumber(e){
- console.log(e)
- if (Number(e)<0) {
- this.dialogForm.rebateRate = 0.1
- }else if(Number(e)>1){
- this.dialogForm.rebateRate = 0.9
- }else{
- this.dialogForm.rebateRate = e
- }
- },
- handleSwitch(e, walletRebateId) {
- updateWallet({
- walletRebateId,
- status: e,
- }).then((res) => {
- this.$successMsg("状态已更改");
- // this.hanleReset();
- });
- },
- hanleEdit(item) {
- console.log(item);
- this.dialogForm = {
- adminCompanyId: item.adminCompanyId,
- mainId: item.mainId,
- mainName: item.mainName,
- name: item.name,
- rebateRate: item.rebateRate,
- rabateSort: item.rabateSort,
- saleTypeCode: item.saleTypeCode,
- saleTypeId: item.saleTypeId,
- saleTypeName: item.saleTypeName,
- status: item.status,
- walletRebateId: item.walletRebateId,
- };
- this.getDictList();
- this.dialogVisible = true;
- },
- getDictList() {
- getDictList({
- sysDictEnum: "PRODUCT_TYPE",
- }).then((res) => {
- console.log(res);
- this.dictListData = res.data;
- });
- const params = {
- pageNum: 1,
- pageSize: 10,
- saleCode: "",
- saleName: "",
- status: "",
- };
- getTypeList(params).then((res) => {
- this.typeList = res.data.records;
- });
- },
- hanleDateil(item) {
- this.type = 3;
- this.dialogVisible = true;
- this.dialogForm = {
- ...item,
- };
- },
- hanelclose() {
- this.type = "";
- this.hanleReset();
- this.$refs.dialogForm.resetFields();
- },
- handelInfo() {
- console.log(this.$refs.dialogForm);
- this.$refs.dialogForm.validate((valid) => {
- if (valid) {
- if (this.type) {
- this.hanleScreen(this.dialogForm.mainId);
- const params = {
- ...this.dialogForm,
- };
- addWallet(params).then((res) => {
- console.log(res);
- this.$successMsg("添加成功");
- this.hanleReset();
- });
- } else {
- const upParams = {
- ...this.dialogForm,
- };
- updateWallet(upParams).then((res) => {
- this.$successMsg("修改成功");
- this.hanleReset();
- });
- }
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- hanleReset() {
- this.dialogForm = {
- name: "",
- mainId: "",
- mainName: "",
- saleTypeCode: "",
- saleTypeName: "",
- rabateRate: "",
- status: true,
- };
- // this.$refs.dialogForm.resetFields()
- this.dialogVisible = false;
- this.getList();
- },
- hanleCancel() {
- this.hanleReset();
- this.dialogVisible = false;
- },
- hanleScreen(code) {
- this.dictListData.find((k) => {
- if (k.dictCode == code) {
- this.dialogForm.mainId = k.dictCode;
- this.dialogForm.mainName = k.dictValue;
- return;
- }
- });
- },
- },
- components: {
- Pagination,
- },
- };
- </script>
- <style scoped>
- .el-switch.is-disabled {
- opacity: inherit;
- }
- ::v-deep .el-select {
- width: 100%;
- }
- </style>
|