|
@@ -12,20 +12,29 @@
|
|
:pagination="tablePageOptions"
|
|
:pagination="tablePageOptions"
|
|
:loading="loading"
|
|
:loading="loading"
|
|
:columns="columns"
|
|
:columns="columns"
|
|
- :data-source="list"></a-table>
|
|
|
|
|
|
+ :data-source="list"
|
|
|
|
+ @change="onBookLoaded">
|
|
|
|
+ <template #operator="{record}">
|
|
|
|
+ <confirm-button :label="record.status ? '停止' : '已停止'"
|
|
|
|
+ :disabled="!record.status"
|
|
|
|
+ type="link"
|
|
|
|
+ confirm-content="确定要停止该条内容吗?"
|
|
|
|
+ @click="onStop(record)" />
|
|
|
|
+ </template>
|
|
|
|
+ </a-table>
|
|
<!-- 添加 -->
|
|
<!-- 添加 -->
|
|
<a-modal title="投放书籍添加"
|
|
<a-modal title="投放书籍添加"
|
|
width="400px"
|
|
width="400px"
|
|
|
|
+ destroy-on-close
|
|
v-model:visible="open"
|
|
v-model:visible="open"
|
|
- :confirm-loading="addFormState.inConfirm"
|
|
|
|
- :after-close="onReset"
|
|
|
|
|
|
+ :confirm-loading="inConfirm"
|
|
@ok="onAdd">
|
|
@ok="onAdd">
|
|
<a-form :model="addFormState"
|
|
<a-form :model="addFormState"
|
|
:labelCol="labelCol"
|
|
:labelCol="labelCol"
|
|
:wrapperCol="wrapperCol">
|
|
:wrapperCol="wrapperCol">
|
|
<a-form-item label="公众号名称">
|
|
<a-form-item label="公众号名称">
|
|
<a-select v-model:value="addFormState.official_id">
|
|
<a-select v-model:value="addFormState.official_id">
|
|
- <a-select-option v-for="official in addFormState.officials"
|
|
|
|
|
|
+ <a-select-option v-for="official in officials"
|
|
:key="official.value"
|
|
:key="official.value"
|
|
:value="official.value">
|
|
:value="official.value">
|
|
{{official.label}}
|
|
{{official.label}}
|
|
@@ -51,7 +60,7 @@
|
|
</a-form-item>
|
|
</a-form-item>
|
|
<a-form-item label="流量平台">
|
|
<a-form-item label="流量平台">
|
|
<a-select v-model:value="addFormState.platform">
|
|
<a-select v-model:value="addFormState.platform">
|
|
- <a-select-option v-for="platform in addFormState.platforms"
|
|
|
|
|
|
+ <a-select-option v-for="platform in platforms"
|
|
:key="platform.value"
|
|
:key="platform.value"
|
|
:value="platform.value">
|
|
:value="platform.value">
|
|
{{platform.label}}
|
|
{{platform.label}}
|
|
@@ -74,20 +83,28 @@ import {
|
|
} from "vue";
|
|
} from "vue";
|
|
|
|
|
|
import ToolBar from "@/components/tool-bar/index.vue";
|
|
import ToolBar from "@/components/tool-bar/index.vue";
|
|
|
|
+import ConfirmButton from "@/components/confirm-button/index.vue";
|
|
|
|
|
|
import useApp from "@/hooks/useApp";
|
|
import useApp from "@/hooks/useApp";
|
|
import usePagination from "@/hooks/usePagination";
|
|
import usePagination from "@/hooks/usePagination";
|
|
import useFormLayout from "@/hooks/useFormLayout";
|
|
import useFormLayout from "@/hooks/useFormLayout";
|
|
import useDebounceFn from "@/hooks/useDebounceFn";
|
|
import useDebounceFn from "@/hooks/useDebounceFn";
|
|
import useValidate from "@/hooks/useValidate";
|
|
import useValidate from "@/hooks/useValidate";
|
|
|
|
+import useReset from "@/hooks/useReset";
|
|
|
|
|
|
-import { getDeliveryBookList, getBooksByName, addDeliveryBook } from "@/api";
|
|
|
|
|
|
+import {
|
|
|
|
+ getDeliveryBookList,
|
|
|
|
+ getBooksByName,
|
|
|
|
+ addDeliveryBook,
|
|
|
|
+ onStopDeliveryBook,
|
|
|
|
+} from "@/api";
|
|
import { TableColumnOfPutBooks } from "../_pageOptions/table-put";
|
|
import { TableColumnOfPutBooks } from "../_pageOptions/table-put";
|
|
import { IBookSearchResult, IDeliveryBook } from "@/types/api";
|
|
import { IBookSearchResult, IDeliveryBook } from "@/types/api";
|
|
|
|
|
|
const PutBooks = defineComponent({
|
|
const PutBooks = defineComponent({
|
|
components: {
|
|
components: {
|
|
ToolBar,
|
|
ToolBar,
|
|
|
|
+ ConfirmButton,
|
|
},
|
|
},
|
|
setup() {
|
|
setup() {
|
|
let { loading, meta, tablePageOptions } = usePagination();
|
|
let { loading, meta, tablePageOptions } = usePagination();
|
|
@@ -96,8 +113,11 @@ const PutBooks = defineComponent({
|
|
const { labelCol, wrapperCol } = useFormLayout();
|
|
const { labelCol, wrapperCol } = useFormLayout();
|
|
|
|
|
|
const state = reactive({
|
|
const state = reactive({
|
|
|
|
+ officials: computed(() => store.getters.officials),
|
|
|
|
+ platforms: computed(() => store.getters.platforms),
|
|
searching: false,
|
|
searching: false,
|
|
open: false,
|
|
open: false,
|
|
|
|
+ inConfirm: false,
|
|
list: ref<IDeliveryBook[]>([]),
|
|
list: ref<IDeliveryBook[]>([]),
|
|
columns: TableColumnOfPutBooks,
|
|
columns: TableColumnOfPutBooks,
|
|
official_name: "",
|
|
official_name: "",
|
|
@@ -105,13 +125,10 @@ const PutBooks = defineComponent({
|
|
});
|
|
});
|
|
|
|
|
|
const addFormState = reactive({
|
|
const addFormState = reactive({
|
|
- officials: computed(() => store.getters.officials),
|
|
|
|
- platforms: computed(() => store.getters.platforms),
|
|
|
|
official_id: "",
|
|
official_id: "",
|
|
book: ref<Partial<IBookSearchResult>>({}),
|
|
book: ref<Partial<IBookSearchResult>>({}),
|
|
platform: "",
|
|
platform: "",
|
|
books: ref<IBookSearchResult[]>([]),
|
|
books: ref<IBookSearchResult[]>([]),
|
|
- inConfirm: false,
|
|
|
|
});
|
|
});
|
|
|
|
|
|
const onSearch = (fields: Record<string, string>) => {
|
|
const onSearch = (fields: Record<string, string>) => {
|
|
@@ -121,14 +138,15 @@ const PutBooks = defineComponent({
|
|
onBookLoaded();
|
|
onBookLoaded();
|
|
};
|
|
};
|
|
|
|
|
|
- const onBookLoaded = async (query?: { page: 1 }) => {
|
|
|
|
|
|
+ const onBookLoaded = async (query?: { current: 1 }) => {
|
|
try {
|
|
try {
|
|
|
|
+ console.log(query);
|
|
loading.value = true;
|
|
loading.value = true;
|
|
const { official_name, book_name } = state;
|
|
const { official_name, book_name } = state;
|
|
const { data } = await getDeliveryBookList({
|
|
const { data } = await getDeliveryBookList({
|
|
official_name,
|
|
official_name,
|
|
book_name,
|
|
book_name,
|
|
- page: query?.page ?? 1,
|
|
|
|
|
|
+ page: query?.current ?? 1,
|
|
});
|
|
});
|
|
state.list = data.list;
|
|
state.list = data.list;
|
|
meta.value = data.meta;
|
|
meta.value = data.meta;
|
|
@@ -139,8 +157,9 @@ const PutBooks = defineComponent({
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- // 添加书籍弹窗
|
|
|
|
|
|
+ // 弹窗书籍搜索
|
|
const onBookSearch = useDebounceFn(async (keywords: string) => {
|
|
const onBookSearch = useDebounceFn(async (keywords: string) => {
|
|
|
|
+ addFormState.books.length = 0;
|
|
if (!keywords) return;
|
|
if (!keywords) return;
|
|
const { data } = await getBooksByName(keywords);
|
|
const { data } = await getBooksByName(keywords);
|
|
addFormState.books.push(...data.list);
|
|
addFormState.books.push(...data.list);
|
|
@@ -162,13 +181,14 @@ const PutBooks = defineComponent({
|
|
onBookSearch,
|
|
onBookSearch,
|
|
onSearch,
|
|
onSearch,
|
|
onBookCheck,
|
|
onBookCheck,
|
|
|
|
+ onBookLoaded,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
async onAdd() {
|
|
async onAdd() {
|
|
try {
|
|
try {
|
|
// TODO 没做字段校验 字段校验封装
|
|
// TODO 没做字段校验 字段校验封装
|
|
- this.addFormState.inConfirm = true;
|
|
|
|
|
|
+ this.inConfirm = true;
|
|
const { official_id, platform, book } = this.addFormState;
|
|
const { official_id, platform, book } = this.addFormState;
|
|
// useValidate({ official_id, platform });
|
|
// useValidate({ official_id, platform });
|
|
await addDeliveryBook(
|
|
await addDeliveryBook(
|
|
@@ -180,17 +200,21 @@ const PutBooks = defineComponent({
|
|
);
|
|
);
|
|
this.open = false;
|
|
this.open = false;
|
|
this.$message.success("添加成功");
|
|
this.$message.success("添加成功");
|
|
|
|
+ this.onBookLoaded();
|
|
|
|
+ this.addFormState = useReset(this.addFormState);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
console.log("error while add delivery book");
|
|
console.log("error while add delivery book");
|
|
error.message && this.$message.error(error.message);
|
|
error.message && this.$message.error(error.message);
|
|
} finally {
|
|
} finally {
|
|
- this.addFormState.inConfirm = false;
|
|
|
|
|
|
+ this.inConfirm = false;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- onReset() {
|
|
|
|
- this.addFormState.official_id = "";
|
|
|
|
- this.addFormState.platform = "";
|
|
|
|
- this.addFormState.book = {};
|
|
|
|
|
|
+ onStop(data: IDeliveryBook) {
|
|
|
|
+ const { id } = data;
|
|
|
|
+ onStopDeliveryBook(id).then((_) => {
|
|
|
|
+ this.$message.success("停止成功");
|
|
|
|
+ this.onBookLoaded();
|
|
|
|
+ });
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
});
|