update
This commit is contained in:
@@ -1,26 +1,48 @@
|
||||
<script setup>
|
||||
import {reactive, ref} from "vue";
|
||||
import {reactive, ref, watch} from "vue";
|
||||
import JumpMethod from '../../../../../components/JumpMethod/index.vue';
|
||||
import UploadOne from "../../../../../components/upload/UploadOne.vue";
|
||||
import Api from "../../../../../api/index.js";
|
||||
import {Message} from "@arco-design/web-vue";
|
||||
|
||||
const {detail} = defineProps({
|
||||
const {detail, position} = defineProps({
|
||||
detail: {
|
||||
type: Object,
|
||||
default: {},
|
||||
},
|
||||
position: {
|
||||
type: Number,
|
||||
default: 1,
|
||||
}
|
||||
});
|
||||
const emits = defineEmits(['success']);
|
||||
const visible = ref(false);
|
||||
watch(
|
||||
() => visible.value,
|
||||
(val) => {
|
||||
if (val) Object.assign(form, detail);
|
||||
}
|
||||
)
|
||||
const form = reactive({
|
||||
file: null,
|
||||
type: 0,
|
||||
});
|
||||
|
||||
const success = async () => {
|
||||
const {msg} = await Api.admin.addADV(form);
|
||||
Message.success(msg);
|
||||
if (detail.id) {
|
||||
const {msg} = await Api.admin.editADV({
|
||||
...form,
|
||||
position
|
||||
});
|
||||
Message.success(msg);
|
||||
} else {
|
||||
const {msg} = await Api.admin.addADV({
|
||||
...form,
|
||||
position
|
||||
});
|
||||
Message.success(msg);
|
||||
}
|
||||
|
||||
emits('success');
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -95,7 +95,7 @@ const delADV = async (id) => {
|
||||
</template>
|
||||
<template v-slot:action="{record}">
|
||||
<div class="flex gap-[10px]">
|
||||
<EditBanner>
|
||||
<EditBanner :detail="record" @success="fetchData">
|
||||
<a-link :hoverable="false">编辑</a-link>
|
||||
</EditBanner>
|
||||
<a-popconfirm content="确认删除吗?" @ok="delADV(record.id)">
|
||||
|
||||
@@ -4,6 +4,7 @@ import {reactive} from "vue";
|
||||
import useTableQuery from "../../../../../hooks/useTableQuery.js";
|
||||
import Api from "../../../../../api/index.js";
|
||||
import EditBanner from "./EditBanner.vue";
|
||||
import XSwitch from "../../../../../components/XSwitch/index.vue";
|
||||
|
||||
const columns = [
|
||||
{
|
||||
@@ -14,15 +15,16 @@ const columns = [
|
||||
{
|
||||
title: '封面',
|
||||
dataIndex: 'key',
|
||||
slotName: 'file',
|
||||
},
|
||||
{
|
||||
title: '跳转方式',
|
||||
dataIndex: 'key',
|
||||
dataIndex: 'type_text',
|
||||
},
|
||||
{
|
||||
title: '是否启用',
|
||||
dataIndex: 'isA',
|
||||
slotName: 'isA',
|
||||
dataIndex: 'isStatus',
|
||||
slotName: 'isStatus',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
},
|
||||
@@ -40,16 +42,18 @@ const columns = [
|
||||
},
|
||||
];
|
||||
|
||||
const po = reactive({});
|
||||
const po = reactive({
|
||||
position: 2,
|
||||
});
|
||||
const vo = reactive({
|
||||
page: '',
|
||||
rows: [],
|
||||
total: 0,
|
||||
});
|
||||
|
||||
const {loading, pagination, initFetchData} = useTableQuery({
|
||||
const {loading, pagination, fetchData} = useTableQuery({
|
||||
parameter: po,
|
||||
api: Api.system.getData,
|
||||
api: Api.admin.getADVList,
|
||||
callback: (data) => {
|
||||
Object.assign(vo, data);
|
||||
}
|
||||
@@ -57,7 +61,7 @@ const {loading, pagination, initFetchData} = useTableQuery({
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<EditBanner></EditBanner>
|
||||
<EditBanner :position="2" @success="fetchData"></EditBanner>
|
||||
|
||||
<a-table
|
||||
:loading="loading"
|
||||
@@ -66,18 +70,32 @@ const {loading, pagination, initFetchData} = useTableQuery({
|
||||
:data="vo.rows"
|
||||
:columns="columns"
|
||||
class="flex-grow mt-[20px] w-full">
|
||||
<template v-slot:isA>
|
||||
<a-switch></a-switch>
|
||||
<template v-slot:file="{record}">
|
||||
<a-image height="60" :src="record.file"></a-image>
|
||||
</template>
|
||||
<template v-slot:sort>
|
||||
<SequenceAdjustment></SequenceAdjustment>
|
||||
<template v-slot:isStatus="{record}">
|
||||
<x-switch
|
||||
v-model:model-value="record.status"
|
||||
:id="record.id"
|
||||
:api="Api.admin.setADVStatus"
|
||||
@change="fetchData">
|
||||
</x-switch>
|
||||
</template>
|
||||
<template v-slot:action>
|
||||
<template v-slot:sort="{record}">
|
||||
<SequenceAdjustment
|
||||
:id="record.id"
|
||||
@success="fetchData"
|
||||
:api="Api.admin.setADVWeigh">
|
||||
</SequenceAdjustment>
|
||||
</template>
|
||||
<template v-slot:action="{record}">
|
||||
<div class="flex gap-[10px]">
|
||||
<EditBanner>
|
||||
<EditBanner :position="2" :detail="record" @success="fetchData">
|
||||
<a-link :hoverable="false">编辑</a-link>
|
||||
</EditBanner>
|
||||
<a-link :hoverable="false" status="danger">删除</a-link>
|
||||
<a-popconfirm content="确认删除吗?" @ok="delADV(record.id)">
|
||||
<a-link :hoverable="false" status="danger">删除</a-link>
|
||||
</a-popconfirm>
|
||||
</div>
|
||||
</template>
|
||||
</a-table>
|
||||
|
||||
Reference in New Issue
Block a user