Эх сурвалжийг харах

fix 回收图书类型的类型默认和增加回收状态搜索

ylong 2 сар өмнө
parent
commit
3fbbdbc53c

+ 151 - 0
src/views/recycle/bookTypes/components/book-search.vue

@@ -0,0 +1,151 @@
+<!-- 搜索表单 -->
+<template>
+    <ele-card :body-style="{ paddingBottom: '8px' }">
+        <ProSearch
+            :items="formItems"
+            ref="searchRef"
+            @search="search"
+            :initKeys="initKeys"
+        />
+    </ele-card>
+</template>
+
+<script setup>
+    import { reactive, ref, defineEmits } from 'vue';
+    import ProSearch from '@/components/CommonPage/ProSearch2.vue';
+
+    const props = defineProps({
+        isBookTag: {
+            type: Boolean,
+            default: false
+        }
+    });
+
+    let { proxy } = getCurrentInstance();
+    const emit = defineEmits(['search']);
+
+    const formItems = reactive([
+        { type: 'input', label: '书名', prop: 'bookName' },
+        { type: 'input', label: 'ISBN', prop: 'isbn' },
+        { type: 'input', label: '作者', prop: 'author' },
+        { type: 'input', label: '出版社', prop: 'publish' },
+        {
+            type: 'daterange',
+            label: '出版时间',
+            prop: 'pubDate',
+            keys: ['pubDateStart', 'pubDateEnd'],
+            props: {
+                format: 'YYYY-MM-DD',
+                valueFormat: 'YYYY-MM-DD',
+                onChange: (val) => {
+                    searchRef.value?.setData({
+                        pubDateStart: val && val.length > 0 ? val[0] : '',
+                        pubDateEnd: val && val.length > 0 ? val[1] : ''
+                    });
+                }
+            }
+        },
+        {
+            type: 'inputNumberRange',
+            label: '定价',
+            prop: 'price',
+            keys: ['minPrice', 'maxPrice'],
+            props: {
+                label: '定价',
+                onChange: (val) => {
+                    searchRef.value?.setData({
+                        minPrice: val.min,
+                        maxPrice: val.max
+                    });
+                }
+            }
+        },
+        {
+            type: 'inputNumberRange',
+            label: '回收折扣',
+            prop: 'discount',
+            keys: ['minDiscount', 'maxDiscount'],
+            props: {
+                minAttrs: { min: 0 },
+                maxAttrs: { max: 10 },
+                label: '回收折扣',
+                onChange: (val) => {
+                    searchRef.value?.setData({
+                        minDiscount: val.min,
+                        maxDiscount: val.max
+                    });
+                }
+            }
+        },
+        {
+            type: 'dictSelect',
+            label: '图书类型',
+            prop: 'bookTag',
+            props: {
+                code: 'book_tag'
+            },
+            vIf: () => {
+                return props.isBookTag;
+            }
+            // 1教材 2社科 3中小学 4其他 5全部
+        },
+        {
+            type: 'select',
+            label: '默认参数',
+            prop: 'defaultType',
+            props: {
+                multiple: true,
+                clearable: true,
+                collapseTags: true
+            },
+            options: [
+                { label: '最大回收数量', value: 1 },
+                { label: '单个订单回收数量', value: 2 },
+                { label: '回收折扣', value: 3 }
+            ]
+        },
+        {
+            type: 'select',
+            label: '回收状态',
+            prop: 'searchType',
+            props: {
+                clearable: true,
+            },
+            options: [
+                { label: '已加入回收书单(正在回收)', value: '1' },
+                { label: '已加入回收书单(暂停回收)', value: '2' },
+                { label: '未加入回收书单', value: '3' },
+                { label: '黑名单', value: '4' },
+                { label: '未加入回收书单(手动暂停)', value: '5' }
+            ]
+        }
+    ]);
+
+    const initKeys = reactive({
+        bookName: '',
+        isbn: '',
+        author: '',
+        publish: '',
+        pubDateStart: '',
+        pubDateEnd: '',
+        minPrice: void 0,
+        maxPrice: void 0,
+        minDiscount: void 0,
+        maxDiscount: void 0,
+        globalInDiscount: void 0,
+        globalNotInDiscount: void 0,
+        defaultType: [],
+        searchType: ''
+    });
+
+    const searchRef = ref(null);
+    /** 搜索 */
+    const search = (data) => {
+        let params = JSON.parse(JSON.stringify(data));
+        delete params.price;
+        delete params.discount;
+        delete params.pubDate;
+        params.defaultType = params.defaultType.join(',');
+        emit('search', params);
+    };
+</script>

+ 187 - 243
src/views/recycle/bookTypes/index.vue

@@ -2,12 +2,7 @@
     <ele-page flex-table>
         <book-search @search="reload" />
 
-        <common-table
-            ref="pageRef"
-            :pageConfig="pageConfig"
-            :columns="columns"
-            :tools="false"
-        >
+        <common-table ref="pageRef" :pageConfig="pageConfig" :columns="columns" :tools="false">
             <template #toolbar>
                 <el-radio-group @change="handleStatusChange" v-model="bookTag">
                     <!-- 1教材 2社科 3中小学 4未分类 5全部 6关键字库 -->
@@ -19,108 +14,52 @@
                     <el-radio-button label="关键字库" value="6" />
                 </el-radio-group>
 
-                <el-button
-                    type="primary"
-                    class="ml-4"
-                    v-permission="'recycle:bookTypes:export'"
-                    @click="handleExportExcel"
-                    >导出Excel</el-button
-                >
+                <el-button type="primary" class="ml-4" v-permission="'recycle:bookTypes:export'"
+                    @click="handleExportExcel">导出Excel</el-button>
             </template>
 
             <template #cover="{ row }">
-                <el-image
-                    style="width: 90px; height: 120px; border-radius: 4px"
-                    fit="cover"
-                    :src="row.cover"
-                    :preview-src-list="[row.cover]"
-                    :initial-index="0"
-                    preview-teleported
-                />
+                <el-image style="width: 90px; height: 120px; border-radius: 4px" fit="cover" :src="row.cover"
+                    :preview-src-list="[row.cover]" :initial-index="0" preview-teleported />
             </template>
             <template #baseInfo="{ row }">
-                <book-info
-                    :row="row"
-                    :showFormat="false"
-                    :showTag="false"
-                    @refresh="reload"
-                />
+                <book-info :row="row" :showFormat="false" :showTag="false" @refresh="reload" />
             </template>
             <template #stock="{ row }">
                 <book-stock :row="row" />
             </template>
 
             <template #action="{ row }">
-                <el-button
-                    type="danger"
-                    link
-                    v-if="bookTag != 4 && bookTag != 6"
-                    v-permission="'recycle:bookTypes:delete'"
-                    @click="handleDelete(row)"
-                >
+                <el-button type="danger" link v-if="bookTag != 4 && bookTag != 6"
+                    v-permission="'recycle:bookTypes:delete'" @click="handleDelete(row)">
                     [移除]
                 </el-button>
-                <el-button
-                    type="warning"
-                    link
-                    v-if="bookTag != 4 && bookTag != 6"
-                    v-permission="'recycle:bookTypes:modifyType'"
-                    @click="handleModifyType(row)"
-                >
+                <el-button type="warning" link v-if="bookTag != 4 && bookTag != 6"
+                    v-permission="'recycle:bookTypes:modifyType'" @click="handleModifyType(row)">
                     [修改类型]
                 </el-button>
-                <el-button
-                    type="primary"
-                    link
-                    v-if="bookTag != 4 && bookTag != 6"
-                    v-permission="'recycle:bookTypes:opeateLog'"
-                    @click="handleOpenLog(row)"
-                >
+                <el-button type="primary" link v-if="bookTag != 4 && bookTag != 6"
+                    v-permission="'recycle:bookTypes:opeateLog'" @click="handleOpenLog(row)">
                     [操作日志]
                 </el-button>
-                <el-button
-                    type="success"
-                    link
-                    v-if="bookTag == 4 || bookTag == 6"
-                    v-permission="'recycle:bookTypes:addTextbook'"
-                    @click="setBookTag(row, '确认加入教材库?', 1)"
-                >
+                <el-button type="success" link v-if="bookTag == 4 || bookTag == 6"
+                    v-permission="'recycle:bookTypes:addTextbook'" @click="setBookTag(row, '确认加入教材库?', 1)">
                     [加教材库]
                 </el-button>
-                <el-button
-                    type="warning"
-                    link
-                    v-if="bookTag == 4 || bookTag == 6"
-                    v-permission="'recycle:bookTypes:addSocial'"
-                    @click="setBookTag(row, '确认加入社科库?', 2)"
-                >
+                <el-button type="warning" link v-if="bookTag == 4 || bookTag == 6"
+                    v-permission="'recycle:bookTypes:addSocial'" @click="setBookTag(row, '确认加入社科库?', 2)">
                     [加社科库]
                 </el-button>
-                <el-button
-                    type="danger"
-                    link
-                    v-if="bookTag == 4 || bookTag == 6"
-                    v-permission="'recycle:bookTypes:addPrimary'"
-                    @click="setBookTag(row, '确认加入中小学库?', 3)"
-                >
+                <el-button type="danger" link v-if="bookTag == 4 || bookTag == 6"
+                    v-permission="'recycle:bookTypes:addPrimary'" @click="setBookTag(row, '确认加入中小学库?', 3)">
                     [加中小学库]
                 </el-button>
-                <el-button
-                    type="success"
-                    link
-                    v-permission="'recycle:bookTypes:removeBlacklist'"
-                    @click="handleOptBlacklist('remove', row)"
-                    v-if="row.bookStatus == 3"
-                >
+                <el-button type="success" link v-permission="'recycle:bookTypes:removeBlacklist'"
+                    @click="handleOptBlacklist('remove', row)" v-if="row.bookStatus == 3">
                     [移除黑名单]
                 </el-button>
-                <el-button
-                    type="danger"
-                    link
-                    v-permission="'recycle:bookTypes:addBlacklist'"
-                    @click="handleOptBlacklist('add', row)"
-                    v-if="row.bookStatus == 1 || row.bookStatus == 2"
-                >
+                <el-button type="danger" link v-permission="'recycle:bookTypes:addBlacklist'"
+                    @click="handleOptBlacklist('add', row)" v-if="row.bookStatus == 1 || row.bookStatus == 2">
                     [加入黑名单]
                 </el-button>
             </template>
@@ -133,166 +72,171 @@
 </template>
 
 <script setup>
-    import { ref, reactive, getCurrentInstance } from 'vue';
-    import CommonTable from '@/components/CommonPage/CommonTable.vue';
-    import bookSearch from '@/views/recycle/components/book-search.vue';
-    import bookInfo from '@/views/recycle/components/book-info.vue';
-    import bookStock from '@/views/recycle/components/book-stock.vue';
-    import ModifyType from './components/modify-type.vue';
-    import OpeateLog from './components/opeate-log.vue';
-    import orderBlacklist from '@/views/recycleOrder/detail/order-blacklist.vue';
-    import { useBookOperation } from '@/utils/use-book-operation';
-    const { proxy } = getCurrentInstance();
-    defineOptions({ name: 'RecycleBooklist' });
-
-    const bookTag = ref('5');
-    function handleStatusChange(value) {
-        bookTag.value = value;
-        pageConfig.params.bookTag = value;
-        pageRef.value.reload();
-    }
-
-    /** 表格列配置 */
-    const columns = ref([
-        {
-            type: 'selection',
-            columnKey: 'selection',
-            width: 50,
-            align: 'center',
-            fixed: 'left'
-        },
-        {
-            label: '图片',
-            prop: 'cover',
-            width: 120,
-            slot: 'cover'
-        },
-        {
-            label: '信息',
-            prop: 'baseInfo',
-            width: 500,
-            slot: 'baseInfo'
-        },
-        {
-            label: '回收折扣',
-            minWidth: 100,
-            prop: 'recycleDiscount',
-            align: 'center'
-        },
-        {
-            label: '回收价格',
-            prop: 'recyclePrice',
-            minWidth: 100,
-            align: 'center'
-        },
-        {
-            label: '最大回收量',
-            minWidth: 120,
-            prop: 'recycleMax',
-            align: 'center'
-        },
-        {
-            label: '总回收数量',
-            minWidth: 120,
-            prop: 'recycleTotalNum',
-            align: 'center'
-        },
-        {
-            label: '当前剩余回收量',
-            minWidth: 140,
-            prop: 'restRecycleNum',
-            align: 'center'
-        },
-        {
-            label: '所属类型',
-            prop: 'bookTagName',
-            width: 120,
-            align: 'center'
-        },
-        {
-            label: '售价',
-            prop: 'salePrice',
-            width: 120,
-            align: 'center',
-            formatter: (row) => '¥ ' + (row.salePrice || 0)
-        },
-        {
-            label: '销量',
-            prop: 'salesNum',
-            align: 'center'
-        },
-        {
-            columnKey: 'action',
-            label: '操作',
-            width: 120,
-            slot: 'action',
-            fixed: 'right'
-        }
-    ]);
-
-    /** 页面组件实例 */
-    const pageRef = ref(null);
-
-    const pageConfig = reactive({
-        pageUrl: '/book/bookInfo/bookTagList',
-        exportUrl: '/book/bookInfo/exportBookTagList',
-        fileName: '图书类型管理',
-        cacheKey: 'bookTypesTable',
-        rowKey: 'isbn',
-        params: {
-            bookTag: bookTag.value
-        }
-    });
-
-    //导出excel
-    function handleExportExcel() {
-        pageRef.value?.exportData('图书类型管理');
-    }
-
-    //刷新表格
-    function reload(where) {
-        pageRef.value?.reload(where);
+import { ref, reactive, getCurrentInstance, onActivated } from 'vue';
+import CommonTable from '@/components/CommonPage/CommonTable.vue';
+import bookSearch from './components/book-search.vue';
+import bookInfo from '@/views/recycle/components/book-info.vue';
+import bookStock from '@/views/recycle/components/book-stock.vue';
+import ModifyType from './components/modify-type.vue';
+import OpeateLog from './components/opeate-log.vue';
+import orderBlacklist from '@/views/recycleOrder/detail/order-blacklist.vue';
+import { useBookOperation } from '@/utils/use-book-operation';
+const { proxy } = getCurrentInstance();
+defineOptions({ name: 'RecycleBooklist' });
+
+const bookTag = ref('4');
+function handleStatusChange(value) {
+    bookTag.value = value;
+    pageConfig.params.bookTag = value;
+    pageRef.value.reload();
+}
+onActivated(() => {
+    bookTag.value = '4';
+    pageConfig.params.bookTag = bookTag.value;
+    pageRef.value.reload();
+})
+
+/** 表格列配置 */
+const columns = ref([
+    {
+        type: 'selection',
+        columnKey: 'selection',
+        width: 50,
+        align: 'center',
+        fixed: 'left'
+    },
+    {
+        label: '图片',
+        prop: 'cover',
+        width: 120,
+        slot: 'cover'
+    },
+    {
+        label: '信息',
+        prop: 'baseInfo',
+        width: 500,
+        slot: 'baseInfo'
+    },
+    {
+        label: '回收折扣',
+        minWidth: 100,
+        prop: 'recycleDiscount',
+        align: 'center'
+    },
+    {
+        label: '回收价格',
+        prop: 'recyclePrice',
+        minWidth: 100,
+        align: 'center'
+    },
+    {
+        label: '最大回收量',
+        minWidth: 120,
+        prop: 'recycleMax',
+        align: 'center'
+    },
+    {
+        label: '总回收数量',
+        minWidth: 120,
+        prop: 'recycleTotalNum',
+        align: 'center'
+    },
+    {
+        label: '当前剩余回收量',
+        minWidth: 140,
+        prop: 'restRecycleNum',
+        align: 'center'
+    },
+    {
+        label: '所属类型',
+        prop: 'bookTagName',
+        width: 120,
+        align: 'center'
+    },
+    {
+        label: '售价',
+        prop: 'salePrice',
+        width: 120,
+        align: 'center',
+        formatter: (row) => '¥ ' + (row.salePrice || 0)
+    },
+    {
+        label: '销量',
+        prop: 'salesNum',
+        align: 'center'
+    },
+    {
+        columnKey: 'action',
+        label: '操作',
+        width: 120,
+        slot: 'action',
+        fixed: 'right'
     }
-    /**
-     * 类型操作(社科库/教材库)
-     * @param {Number} type - 类型:1社科库,2教材库 3 中小学
-     */
-    const modifyTypeRef = ref(null);
-    function handleModifyType(row) {
-        modifyTypeRef.value.open({ isbn: row.isbn, bookTag: row.bookTag });
+]);
+
+/** 页面组件实例 */
+const pageRef = ref(null);
+
+const pageConfig = reactive({
+    pageUrl: '/book/bookInfo/bookTagList',
+    exportUrl: '/book/bookInfo/exportBookTagList',
+    fileName: '图书类型管理',
+    cacheKey: 'bookTypesTable',
+    rowKey: 'isbn',
+    params: {
+        bookTag: bookTag.value
     }
-
-    /**
-     * 操作日志
-     */
-    const logRef = ref(null);
-    function handleOpenLog(row) {
-        logRef.value?.handleOpen(row);
-    }
-
-    //封装一个方法,删除
-    function setBookTag(row, message, operateType) {
-        pageRef.value?.messageBoxConfirm({
-            message: message,
-            fetch: () =>
-                proxy.$http.post('/book/bookInfo/setBookTag', {
-                    isbn: row.isbn,
-                    // 1加入教材库 2加入社科库 3加入中小学库 4移除
-                    operateType: operateType
-                })
-        });
-    }
-
-    /**
-     * 移除
-     */
-    function handleDelete(row) {
-        setBookTag(row, '确认移除?', 4);
-    }
-
-    // 使用图书操作混入
-    const {
-        blacklistRef,
-        handleOptBlacklist
-    } = useBookOperation(pageRef);
+});
+
+//导出excel
+function handleExportExcel() {
+    pageRef.value?.exportData('图书类型管理');
+}
+
+//刷新表格
+function reload(where) {
+    pageRef.value?.reload(where);
+}
+/**
+ * 类型操作(社科库/教材库)
+ * @param {Number} type - 类型:1社科库,2教材库 3 中小学
+ */
+const modifyTypeRef = ref(null);
+function handleModifyType(row) {
+    modifyTypeRef.value.open({ isbn: row.isbn, bookTag: row.bookTag });
+}
+
+/**
+ * 操作日志
+ */
+const logRef = ref(null);
+function handleOpenLog(row) {
+    logRef.value?.handleOpen(row);
+}
+
+//封装一个方法,删除
+function setBookTag(row, message, operateType) {
+    pageRef.value?.messageBoxConfirm({
+        message: message,
+        fetch: () =>
+            proxy.$http.post('/book/bookInfo/setBookTag', {
+                isbn: row.isbn,
+                // 1加入教材库 2加入社科库 3加入中小学库 4移除
+                operateType: operateType
+            })
+    });
+}
+
+/**
+ * 移除
+ */
+function handleDelete(row) {
+    setBookTag(row, '确认移除?', 4);
+}
+
+// 使用图书操作混入
+const {
+    blacklistRef,
+    handleOptBlacklist
+} = useBookOperation(pageRef);
 </script>