|
@@ -2,7 +2,7 @@
|
|
|
<div class="page-wrap page-wrap-put-books">
|
|
|
<tool-bar :text="['official_name', 'book_name']"
|
|
|
:label="['公众号名称', '书名']"
|
|
|
- v-model:loading="inSearching"
|
|
|
+ v-model:loading="searching"
|
|
|
@confirm="onSearch" />
|
|
|
<div class="operator-bar">
|
|
|
<a-button type="primary"
|
|
@@ -64,7 +64,14 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts">
|
|
|
-import { defineComponent, reactive, ref, computed, toRefs } from "vue";
|
|
|
+import {
|
|
|
+ defineComponent,
|
|
|
+ reactive,
|
|
|
+ ref,
|
|
|
+ computed,
|
|
|
+ toRefs,
|
|
|
+ onMounted,
|
|
|
+} from "vue";
|
|
|
|
|
|
import ToolBar from "@/components/tool-bar/index.vue";
|
|
|
|
|
@@ -89,10 +96,12 @@ const PutBooks = defineComponent({
|
|
|
const { labelCol, wrapperCol } = useFormLayout();
|
|
|
|
|
|
const state = reactive({
|
|
|
- inSearching: false,
|
|
|
+ searching: false,
|
|
|
open: false,
|
|
|
list: ref<IDeliveryBook[]>([]),
|
|
|
columns: TableColumnOfPutBooks,
|
|
|
+ official_name: "",
|
|
|
+ book_name: "",
|
|
|
});
|
|
|
|
|
|
const addFormState = reactive({
|
|
@@ -105,20 +114,28 @@ const PutBooks = defineComponent({
|
|
|
inConfirm: false,
|
|
|
});
|
|
|
|
|
|
- const onSearch = async (fields: Record<string, string>) => {
|
|
|
+ const onSearch = (fields: Record<string, string>) => {
|
|
|
+ const { official_name, book_name } = fields;
|
|
|
+ state.official_name = official_name;
|
|
|
+ state.book_name = book_name;
|
|
|
+ onBookLoaded();
|
|
|
+ };
|
|
|
+
|
|
|
+ const onBookLoaded = async (query?: { page: 1 }) => {
|
|
|
try {
|
|
|
- const { official_name, book_name } = fields;
|
|
|
+ loading.value = true;
|
|
|
+ const { official_name, book_name } = state;
|
|
|
const { data } = await getDeliveryBookList({
|
|
|
official_name,
|
|
|
book_name,
|
|
|
- page: 1,
|
|
|
+ page: query?.page ?? 1,
|
|
|
});
|
|
|
state.list = data.list;
|
|
|
- meta = data.meta;
|
|
|
- } catch (e) {
|
|
|
- console.log(e);
|
|
|
+ meta.value = data.meta;
|
|
|
+ } catch (error) {
|
|
|
+ console.log("on get books list error");
|
|
|
} finally {
|
|
|
- state.inSearching = false;
|
|
|
+ state.searching = false;
|
|
|
}
|
|
|
};
|
|
|
|
|
@@ -133,6 +150,8 @@ const PutBooks = defineComponent({
|
|
|
addFormState.book = options.key;
|
|
|
};
|
|
|
|
|
|
+ onMounted(onBookLoaded);
|
|
|
+
|
|
|
return {
|
|
|
...toRefs(state),
|
|
|
addFormState,
|