Files
tangguo_admin/src/views/aiManagement/aiNovelList/index.vue
T
rootandClaude Opus 5 d999a5c0e6 Initial commit
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 12:02:35 +08:00

217 lines
4.9 KiB
Vue

<template>
<div class="ai-novel-list">
<ConfigTable
ref="ct"
:searchConfig="searchConfig"
:tableColumns="tableColumns"
:tableData="list"
:total="total"
@change="loadData"
@delete="delRow"
@edit="editRow"
></ConfigTable>
<EditStatus ref="editDialog" @sure="callEdit"></EditStatus>
</div>
</template>
<script>
import ConfigTable from "@/components/ConfigTable";
import { changeDate } from "@/utils/filter";
import transApi from "@/api/ai";
import LongText from "../../../components/LongText.vue";
import {
findLabel,
findStatusLabel,
findStatusType,
statusOptions,
} from "../aiImageToVideoList/config";
import TagEdit from "../aiImageToVideoList/components/TagEdit.vue";
import EditStatus from "../aiImageToVideoList/components/EditStatus.vue";
const modelOptions = [
{ label: "AI小艺", value: 1 },
{ label: "AI小萌", value: 2 },
];
const searchConfig = [
{ type: "input", placeholder: "请输入ID", key: "id" },
{
type: "select",
placeholder: "请选择状态",
key: "status",
options: statusOptions,
},
{ type: "input", placeholder: "请输入用户ID", key: "uid" },
{ type: "button", icon: "search", placeholder: "搜索", key: "search" },
];
const tableColumns = (_this) => [
{ name: "ID", key: "id", width: 220, fixed: "fixed" },
{ name: "用户ID", key: "uid" },
{
name: "故事情节",
key: "description",
component: LongText,
width: 220,
props: (val) => {
return { text: val };
},
},
{
name: "小说正文",
key: "content",
component: LongText,
width: 220,
props: (val) => {
return { text: val };
},
},
{
name: "状态",
key: "status",
component: TagEdit,
props(value, row) {
return {
type: findStatusType(value),
msg: value === 4 ? row.msg : "",
showEdit: value === 4,
onEdit() {
_this.editRow(row);
},
};
},
valueHandler: findStatusLabel,
},
{ name: "地点场景", key: "locationScene" },
{ name: "人物设定", key: "characterSetting" },
{ name: "细节说明", key: "details" },
{
name: "小说模型",
key: "modelType",
component: TagEdit,
valueHandler: (val) => findLabel(val, modelOptions),
},
{ name: "金币", key: "coin" },
{ name: "扣除金币个数", key: "debitAmountCoin" },
{ name: "扣除收益金币个数", key: "debitIncomeCoin" },
{
name: "备注",
key: "remark",
},
{
name: "创建时间",
key: "createdAt",
valueHandler: changeDate,
},
{
name: "更新时间",
key: "updatedAt",
valueHandler: changeDate,
},
{
name: "操作",
fixed: "right",
actions: [
{
action: "edit",
key: "refresh",
text: "退款",
hidden: (row) => row.status === 4 || row.status === 5,
},
"delete",
],
},
];
export default {
name: "AiNovelList",
components: { ConfigTable, EditStatus },
data() {
return {
searchConfig,
total: 0,
list: [],
appOpts: [],
};
},
computed: {
tableColumns() {
return tableColumns(this);
},
},
watch: {},
mounted() {},
methods: {
async loadData(params) {
try {
const newParams = {};
Object.keys(params).forEach((key) => {
if (params[key] !== "") newParams[key] = params[key];
});
const r = await transApi.getAiNovelList(newParams);
const data = r.data;
this.total = data.total;
this.list = data.list;
} catch (error) {
console.error("查询失败:", error);
}
},
async delRow(row) {
try {
await this.$confirm("您确定要删除该条数据吗?", "操作提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
});
const r = await transApi.delAiNovel({ id: row.id });
if (r.code === 200) {
this.$message.success("已删除");
this.$refs.ct.search();
} else {
this.$message.error(r.tip);
}
} catch (error) {
console.log(error);
}
},
async editRow(row) {
this.$refs.editDialog.open(row);
},
async callEdit(r) {
try {
console.log(r);
const res = await transApi.updateAiNovel(r.data);
if (res.code !== 200) {
this.$message.error(res.data);
} else {
this.$message.success(r.isEdit ? "退款成功" : "");
this.$refs.editDialog.close();
setTimeout(() => {
this.$refs.ct.search();
}, 200);
}
} catch (error) {
console.error("call edit error:", error);
}
},
},
};
</script>
<style lang="scss" scoped>
.ai-novel-list {
/deep/ .el-button {
padding: 9px 15px;
}
/deep/ .el-image {
width: 100px;
height: 100px;
img {
object-fit: contain;
}
}
}
</style>