<template>
|
<!--
|
作者
|
时间:2025-09-12
|
描述:用户-激活码列表
|
-->
|
<div class="user">
|
<!-- 搜索区域 -->
|
<div class="common-level-rail">
|
<el-form :inline="true" :model="formInline" class="demo-form-inline">
|
<el-form-item label="激活码">
|
<el-input v-model="formInline.activation_code" placeholder="激活码"></el-input>
|
</el-form-item>
|
<el-form-item label="状态">
|
<el-select v-model="formInline.status" placeholder="请选择状态">
|
<el-option label="全部" value="-1"></el-option>
|
<el-option label="未使用" value="0"></el-option>
|
<el-option label="已使用" value="1"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="类型">
|
<el-select v-model="formInline.type" placeholder="请选择类型">
|
<el-option label="全部" value="-1"></el-option>
|
<el-option label="产品" value="10"></el-option>
|
<el-option label="项目" value="20"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item>
|
<el-button size="small" type="primary" @click="onSubmit">查询</el-button>
|
<el-button size="small" @click="onReset">重置</el-button>
|
</el-form-item>
|
</el-form>
|
</div>
|
|
<!--内容-->
|
<div class="product-content">
|
<div class="table-wrap">
|
<el-table size="small" :data="tableData" border style="width: 100%" v-loading="loading">
|
<el-table-column prop="activation_code_id" label="ID"></el-table-column>
|
<el-table-column prop="activation_code" label="激活码"></el-table-column>
|
<el-table-column prop="status" label="状态">
|
<template slot-scope="scope">
|
<el-tag :type="scope.row.status == 0 ? 'primary' : 'success'">
|
{{ scope.row.status == 0 ? '未使用' : '已使用' }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="type" label="类型">
|
<template slot-scope="scope">
|
<el-tag :type="scope.row.type == 10 ? 'primary' : 'warning'">
|
{{ scope.row.type == 10 ? '产品' : '项目' }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="is_shipment" label="发货状态">
|
<template slot-scope="scope">
|
<el-tag :type="scope.row.is_shipment == 1 ? 'primary' : 'warning'">
|
{{ scope.row.is_shipment == 1 ? '已发货' : '未发货' }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column prop="" label="所属用户">
|
<template slot-scope="scope">
|
<div>{{ scope.row.user?scope.row.user.nickName:'--' }}</div>
|
<div class="gray9">ID:({{ scope.row.user?scope.row.user.user_id:'--' }})</div>
|
</template>
|
</el-table-column>
|
<el-table-column prop="" label="所属订单">
|
<template slot-scope="scope">
|
<div>{{ scope.row.order?scope.row.order.order_no:'--' }}</div>
|
<div class="gray9">ID:({{ scope.row.order?scope.row.order.order_id:'--' }})</div>
|
</template>
|
</el-table-column>
|
|
<el-table-column prop="" label="使用用户">
|
<template slot-scope="scope">
|
<div>{{ scope.row.useUser?scope.row.useUser.nickName:'--' }}</div>
|
<div class="gray9">{{ scope.row.useUser?'ID:('+scope.row.useUser.user_id+')':'--' }}</div>
|
</template>
|
</el-table-column>
|
<el-table-column prop="" label="使用订单">
|
<template slot-scope="scope">
|
<div>{{ scope.row.useOrder?scope.row.useOrder.order_no:'--' }}</div>
|
<div class="gray9">{{ scope.row.useOrder?'ID:('+scope.row.useOrder.order_id+')':'--' }}</div>
|
</template>
|
</el-table-column>
|
<el-table-column prop="use_time" label="使用时间">
|
<template slot-scope="scope">
|
{{ scope.row.use_time ? scope.row.use_time : '-' }}
|
</template>
|
</el-table-column>
|
<el-table-column prop="create_time" label="创建时间">
|
<template slot-scope="scope">
|
{{ scope.row.create_time }}
|
</template>
|
</el-table-column>
|
<el-table-column fixed="right" label="操作" width="170">
|
<template slot-scope="scope">
|
<el-button v-if="scope.row.status == 0 " @click="changeStatus(scope.row)" type="text" size="small" v-auth="'/user/activation/markAsUsed'">已使用</el-button>
|
<el-button v-if="scope.row.status == 0&&scope.row.status == 0" @click="upIsShipment(scope.row)" type="text" size="small" v-auth="'/user/activation/upIsShipment'">{{scope.row.is_shipment == 0 ? '发货' : '不发货'}}</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</div>
|
|
<!--分页-->
|
<div class="pagination">
|
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" background
|
:current-page="curPage" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
|
:total="totalDataNumber" :page-sizes="[10, 20, 50, 100]">
|
</el-pagination>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import UserApi from '@/api/user.js';
|
export default {
|
name: "ActivationList",
|
data() {
|
return {
|
/*是否加载完成*/
|
loading: true,
|
/*列表数据*/
|
tableData: [],
|
/*一页多少条*/
|
pageSize: 20,
|
/*一共多少条数据*/
|
totalDataNumber: 0,
|
/*当前是第几页*/
|
curPage: 1,
|
/*搜索表单数据模型*/
|
formInline: {
|
activation_code: '',
|
status: '',
|
type: ''
|
}
|
};
|
},
|
created() {
|
/*获取列表*/
|
this.getTableList();
|
},
|
methods: {
|
/*选择第几页*/
|
handleCurrentChange(val) {
|
this.curPage = val;
|
this.loading = true;
|
this.getTableList();
|
},
|
|
/*每页多少条*/
|
handleSizeChange(val) {
|
this.curPage = 1;
|
this.pageSize = val;
|
this.getTableList();
|
},
|
|
/*获取列表*/
|
getTableList() {
|
let self = this;
|
let Params = {};
|
Params.page = self.curPage;
|
Params.list_rows = self.pageSize;
|
|
// 添加搜索条件
|
if (self.formInline.activation_code) {
|
Params.activation_code = self.formInline.activation_code;
|
}
|
if (self.formInline.status !== '') {
|
Params.status = self.formInline.status;
|
}
|
if (self.formInline.type !== '') {
|
Params.type = self.formInline.type;
|
}
|
|
// TODO: 需要添加激活码列表接口
|
// 暂时使用用户列表接口作为示例
|
UserApi.activationCodelist(Params, true)
|
.then(data => {
|
self.loading = false;
|
self.tableData = data.data.list.data || [];
|
self.totalDataNumber = data.data.list.total || 0;
|
})
|
.catch(error => {
|
self.loading = false;
|
console.error('获取激活码列表失败:', error);
|
});
|
},
|
|
/*搜索*/
|
onSubmit() {
|
this.curPage = 1;
|
this.getTableList();
|
},
|
|
/*重置搜索条件*/
|
onReset() {
|
this.formInline.activation_code = '';
|
this.formInline.status = '';
|
this.formInline.type = '';
|
this.curPage = 1;
|
this.getTableList();
|
},
|
/*修改状态*/
|
changeStatus(row, value) {
|
let self = this;
|
let msg = '';
|
let ids = '';
|
self.$confirm('确定要将该激活码改为已使用吗?', '提示', {
|
type: 'warning'
|
})
|
.then(() => {
|
UserApi.activationChangeStatus({
|
activation_code: row.activation_code
|
}).then(data => {
|
self.$message({
|
message: '操作成功',
|
type: 'success'
|
});
|
self.getTableList();
|
});
|
});
|
},
|
/*修改发货状态*/
|
upIsShipment(row) {
|
let self = this;
|
let msg = '';
|
let ids = '';
|
self.$confirm('确定要将该激活码改为'+(row.is_shipment == 0 ? '已发货' : '未发货')+'状态吗?', '提示', {
|
type: 'warning'
|
})
|
.then(() => {
|
UserApi.activationUpIsShipment({
|
activation_code: row.activation_code
|
}).then(data => {
|
self.$message({
|
message: '操作成功',
|
type: 'success'
|
});
|
self.getTableList();
|
});
|
});
|
},
|
}
|
};
|
</script>
|
|
<style scoped>
|
.user {
|
background: #fff;
|
padding: 20px;
|
margin: 20px;
|
border-radius: 5px;
|
}
|
|
.common-level-rail {
|
margin-bottom: 20px;
|
}
|
|
.product-content {
|
margin-top: 20px;
|
}
|
|
.table-wrap {
|
margin-bottom: 20px;
|
}
|
|
.pagination {
|
display: flex;
|
justify-content: flex-end;
|
}
|
</style>
|