Files
orico-officialWebsite-ts-admin/src/views/articleManagement/recycle/index.vue

83 lines
2.9 KiB
Vue

<!-- 文章回收 -->
<template>
<div class="table-box">
<ProTable
ref="proTableRef"
:formData="dataStore.formData"
:columns="dataStore.columns"
:request-api="getArticleTrashListApi"
:init-param="dataStore.initParam"
>
<template #image="scope">
<el-image :src="scope.row.image ? h + scope.row.image : ''" style="width: 60px; height: 60px" />
</template>
<template #status="scope">
<el-tag type="danger" effect="dark">{{ scope.row.status ? "删除" : "删除" }}</el-tag>
</template>
<template #operation="scope">
<el-button size="small" type="danger" @click="getArticleTrashDel(scope.row.id)">删除</el-button>
<el-button size="small" type="primary" @click="getArticleTrashRestore(scope.row.id)">恢复</el-button>
</template>
</ProTable>
</div>
</template>
<script setup lang="ts" name="articleRecycleListIndex">
import ProTable from "@/components/ProTable/index.vue";
import { messageBox } from "@/utils/messageBox";
import { useMsg } from "@/hooks/useMsg";
import { addLabelValue } from "@/utils/addLabelValue";
import { h } from "@/utils/url";
//列表接口
import { getArticleTrashListApi, getArticleTrashDelApi, getArticleTrashRestoreApi } from "@/api/modules/articleRecycle";
import { getArticleClassDataApi } from "@/api/modules/articleList";
//深拷贝方法
import { cloneDeep } from "lodash-es";
//表格和搜索條件
import { RULE_FORM, FORM_DATA, COLUMNS } from "./constant/index";
// 获取 ProTable 元素,调用其获取刷新数据方法(还能获取到当前查询参数,方便导出携带参数)
const proTableRef = ref<any>(null);
// 数据源
const dataStore = reactive<any>({
columns: COLUMNS, //列表配置项
initParam: cloneDeep(RULE_FORM), // 初始化搜索条件|重置搜索条件
ruleForm: cloneDeep(RULE_FORM), // 搜索參數
formData: FORM_DATA //搜索配置项
});
//恢复
const getArticleTrashRestore = async (id: any) => {
const result = await getArticleTrashRestoreApi(id);
if (result?.code === 0) {
const { msg } = result;
useMsg("success", msg);
proTableRef?.value?.getTableList();
}
};
//删除
const getArticleTrashDel = (id: any) => {
messageBox("你确定要删除?", async () => {
const result = await getArticleTrashDelApi(id);
if (result?.code === 0) {
const { msg } = result;
useMsg("success", msg);
proTableRef?.value?.getTableList();
}
});
};
//文章分类(搜索条件)
const getArticleClassData = async () => {
const result = await getArticleClassDataApi();
if (result?.code === 0) {
const { data } = result;
dataStore.formData[1].options = addLabelValue(data);
}
};
getArticleClassData();
</script>
<style scoped></style>
@/api/modules/articleRecycle