|
@@ -12,7 +12,16 @@
|
|
|
:pagination="tablePageOptions"
|
|
|
:loading="loading"
|
|
|
: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="投放书籍添加"
|
|
|
width="400px"
|
|
@@ -74,6 +83,7 @@ import {
|
|
|
} from "vue";
|
|
|
|
|
|
import ToolBar from "@/components/tool-bar/index.vue";
|
|
|
+import ConfirmButton from "@/components/confirm-button/index.vue";
|
|
|
|
|
|
import useApp from "@/hooks/useApp";
|
|
|
import usePagination from "@/hooks/usePagination";
|
|
@@ -81,13 +91,19 @@ import useFormLayout from "@/hooks/useFormLayout";
|
|
|
import useDebounceFn from "@/hooks/useDebounceFn";
|
|
|
import useValidate from "@/hooks/useValidate";
|
|
|
|
|
|
-import { getDeliveryBookList, getBooksByName, addDeliveryBook } from "@/api";
|
|
|
+import {
|
|
|
+ getDeliveryBookList,
|
|
|
+ getBooksByName,
|
|
|
+ addDeliveryBook,
|
|
|
+ onStopDeliveryBook,
|
|
|
+} from "@/api";
|
|
|
import { TableColumnOfPutBooks } from "../_pageOptions/table-put";
|
|
|
import { IBookSearchResult, IDeliveryBook } from "@/types/api";
|
|
|
|
|
|
const PutBooks = defineComponent({
|
|
|
components: {
|
|
|
ToolBar,
|
|
|
+ ConfirmButton,
|
|
|
},
|
|
|
setup() {
|
|
|
let { loading, meta, tablePageOptions } = usePagination();
|
|
@@ -121,14 +137,15 @@ const PutBooks = defineComponent({
|
|
|
onBookLoaded();
|
|
|
};
|
|
|
|
|
|
- const onBookLoaded = async (query?: { page: 1 }) => {
|
|
|
+ const onBookLoaded = async (query?: { current: 1 }) => {
|
|
|
try {
|
|
|
+ console.log(query);
|
|
|
loading.value = true;
|
|
|
const { official_name, book_name } = state;
|
|
|
const { data } = await getDeliveryBookList({
|
|
|
official_name,
|
|
|
book_name,
|
|
|
- page: query?.page ?? 1,
|
|
|
+ page: query?.current ?? 1,
|
|
|
});
|
|
|
state.list = data.list;
|
|
|
meta.value = data.meta;
|
|
@@ -162,6 +179,7 @@ const PutBooks = defineComponent({
|
|
|
onBookSearch,
|
|
|
onSearch,
|
|
|
onBookCheck,
|
|
|
+ onBookLoaded,
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
@@ -180,6 +198,7 @@ const PutBooks = defineComponent({
|
|
|
);
|
|
|
this.open = false;
|
|
|
this.$message.success("添加成功");
|
|
|
+ this.onBookLoaded();
|
|
|
} catch (error) {
|
|
|
console.log("error while add delivery book");
|
|
|
error.message && this.$message.error(error.message);
|
|
@@ -187,10 +206,18 @@ const PutBooks = defineComponent({
|
|
|
this.addFormState.inConfirm = false;
|
|
|
}
|
|
|
},
|
|
|
+ onStop(data: IDeliveryBook) {
|
|
|
+ const { id } = data;
|
|
|
+ onStopDeliveryBook(id).then((_) => {
|
|
|
+ this.$message.success("停止成功");
|
|
|
+ this.onBookLoaded();
|
|
|
+ });
|
|
|
+ },
|
|
|
onReset() {
|
|
|
this.addFormState.official_id = "";
|
|
|
this.addFormState.platform = "";
|
|
|
this.addFormState.book = {};
|
|
|
+ this.addFormState.books = [];
|
|
|
},
|
|
|
},
|
|
|
});
|