This commit is contained in:
Vinjor 2025-03-18 16:54:33 +08:00
parent 03b6ec660e
commit e9883f8e58
2 changed files with 89 additions and 18 deletions

View File

@ -10,17 +10,18 @@ export function listCardRights(query) {
}
// 查询会员卡权益详细
export function getCardRights(id) {
export function getCardRights(query) {
return request({
url: '/base/cardRights/' + id,
method: 'get'
url: '/base/cardRights/getByCardId',
method: 'get',
params: query
})
}
// 新增会员卡权益
// 保存会员卡权益
export function addCardRights(data) {
return request({
url: '/base/cardRights',
url: '/base/cardRights/saveAndUpdate',
method: 'post',
data: data
})

View File

@ -57,17 +57,17 @@
v-hasPermi="['base:card:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['base:card:remove']"
>删除</el-button>
</el-col>
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="danger"-->
<!-- plain-->
<!-- icon="el-icon-delete"-->
<!-- size="mini"-->
<!-- :disabled="multiple"-->
<!-- @click="handleDelete"-->
<!-- v-hasPermi="['base:card:remove']"-->
<!-- >删除</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="warning"-->
@ -120,6 +120,13 @@
v-hasPermi="['base:card:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdateRights(scope.row)"
>权益分配</el-button>
<el-button
v-if="scope.row.isSystem==0"
size="mini"
type="text"
icon="el-icon-delete"
@ -163,7 +170,7 @@
<el-row>
<el-col :span="12">
<el-form-item label="系统内置" prop="isSystem">
<el-select v-model="form.isSystem" placeholder="请选择是否系统内置">
<el-select v-model="form.isSystem" disabled placeholder="请选择是否系统内置">
<el-option
v-for="dict in dict.type.true_or_false"
:key="dict.value"
@ -235,11 +242,34 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
<!-- 添加或修改会员卡权益对话框 -->
<el-dialog :title="titleRights" :visible.sync="openRights" width="800px" append-to-body>
<el-table v-loading="loading" :data="rightsList" @selection-change="handleSelectionChange">
<el-table-column label="权益名称" align="center" prop="name" />
<el-table-column label="权益值" align="center" >
<template slot-scope="scope">
<el-checkbox v-if="scope.row.rightsType=='01' && 1==scope.row.rightsValue" v-model="scope.row.rightsValue">支持</el-checkbox>
<el-checkbox v-if="scope.row.rightsType=='01' && (0==scope.row.rightsValue || null==scope.row.rightsValue)" v-model="scope.row.rightsValue">不支持</el-checkbox>
<div v-if="scope.row.rightsType=='02'" style="display: flex;justify-content: center;align-items: center;">
<el-tooltip class="item" effect="dark" content="填0代表不限制" placement="top-end">
<i class="el-icon-warning-outline"></i>
</el-tooltip>
<el-input v-model="scope.row.rightsValue" type="number" style="width: 200px" placeholder="请输入限制数量" />
</div>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFormRights"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listCard, getCard, delCard, addCard, updateCard } from "@/api/base/card";
import { getCardRights ,addCardRights} from "@/api/base/cardRights";
export default {
name: "Card",
@ -264,6 +294,10 @@ export default {
title: "",
//
open: false,
// -
titleRights: "",
// -
openRights: false,
//
queryParams: {
pageNum: 1,
@ -274,6 +308,8 @@ export default {
},
//
form: {},
//
rightsList:[],
//
rules: {
cardName: [
@ -310,6 +346,7 @@ export default {
//
cancel() {
this.open = false;
this.openRights = false;
this.reset();
},
//
@ -320,7 +357,7 @@ export default {
userType: null,
content: null,
sort: null,
isSystem: null,
isSystem: 0,
image: null,
monthPrice: null,
quarterPrice: null,
@ -367,6 +404,24 @@ export default {
this.title = "修改会员卡";
});
},
/** 修改权益操作 */
handleUpdateRights(row) {
let params = {
id:row.id,
userType:row.userType,
}
getCardRights(params).then(response => {
this.rightsList = response.data;
this.rightsList.map(item=>{
if("01"==item.rightsType){
//
item.rightsValue= 1 ==item.rightsValue?true:false
}
})
this.openRights = true;
this.titleRights = "修改会员卡权益";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
@ -387,6 +442,21 @@ export default {
}
});
},
/** 提交按钮 */
submitFormRights() {
let postData = JSON.parse(JSON.stringify(this.rightsList))
postData.map(item=>{
if("01"==item.rightsType){
//
item.rightsValue= true ==item.rightsValue?1:0
}
})
addCardRights(postData).then(response => {
this.$modal.msgSuccess("保存成功");
this.openRights = false;
});
console.log(this.rightsList,"rightsList")
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;