Procházet zdrojové kódy

fix 全局tab作为搜索条件使用

Alex před 9 měsíci
rodič
revize
c98657138f

+ 4 - 2
src/components/CommonPage/CommonTable.vue

@@ -30,7 +30,7 @@
   import { EleMessage } from 'ele-admin-plus/es';
   import { useDictData } from '@/utils/use-dict-data';
   import { download, toFormData, checkDownloadRes } from '@/utils/common';
-import { method } from 'lodash-es';
+  import { method } from 'lodash-es';
 
   const slotArray = useSlots();
 
@@ -68,6 +68,8 @@ import { method } from 'lodash-es';
   /** 表格数据源 */
   const datasource = ({ pages, where, orders }) => {
     let initKeys = props.pageConfig.params || {};
+    console.log(initKeys, 'initKeys');
+
     return queryPage({ ...initKeys, ...where, ...orders, ...pages });
   };
 
@@ -136,7 +138,7 @@ import { method } from 'lodash-es';
   }
 
   /** 导出数据 */
-  const exportData = (name,method = 'POST') => {
+  const exportData = (name, method = 'POST') => {
     const loading = EleMessage.loading({
       message: '请求中..',
       plain: true

+ 0 - 16
src/views/finance/withdrawal/components/page-search.vue

@@ -17,13 +17,6 @@
   let { proxy } = getCurrentInstance();
   const emit = defineEmits(['search']);
 
-  const props = defineProps({
-    status: {
-      type: String,
-      default: ''
-    }
-  });
-
   const formItems = reactive([
     { type: 'input', label: '用户名', prop: 'nickName' },
     {
@@ -54,17 +47,8 @@
     startTime: '',
     endTime: '',
     nickName: '',
-    status: ''
   });
 
-  // watch(
-  //   () => props.status,
-  //   (newVal) => {
-  //     initKeys.status = newVal;
-  //     searchRef.value?.setData(initKeys);
-  //   }
-  // );
-
   const searchRef = ref(null);
   /** 搜索 */
   const search = (data) => {

+ 7 - 2
src/views/finance/withdrawal/index.vue

@@ -148,10 +148,12 @@
   function handleStatusChange(value) {
     if (value === '6') {
       pageConfig.pageUrl = '/sys/finance/noWithdrawList';
+      pageConfig.params.status = value;
       pageRef.value?.reload();
     } else {
       pageConfig.pageUrl = '/sys/finance/withdrawList';
-      pageRef.value.reload({ status: value });
+      pageConfig.params.status = value;
+      pageRef.value?.reload();
     }
   }
 
@@ -216,7 +218,10 @@
   const pageConfig = reactive({
     pageUrl: '/sys/finance/withdrawList',
     fileName: '提现管理',
-    cacheKey: 'withdrawalTable'
+    cacheKey: 'withdrawalTable',
+    params: {
+      status: ''
+    }
   });
 
   //刷新表格

+ 3 - 1
src/views/recycle/bookTypes/index.vue

@@ -64,7 +64,9 @@
 
   const bookTag = ref('-1');
   function handleStatusChange(value) {
-    pageRef.value.reload({ bookTag: value });
+    bookTag.value = value;
+    pageConfig.params.bookTag = value;
+    pageRef.value.reload();
   }
 
   /** 表格列配置 */

+ 292 - 196
src/views/recycle/booklist/index.vue

@@ -1,219 +1,316 @@
 <template>
-    <ele-page flex-table>
-        <book-search @search="reload"></book-search>
-
-        <common-table ref="pageRef" :pageConfig="pageConfig" :columns="columns" :tools="false" @sort-change="handleSortChange">
-            <template #toolbar>
-                <el-radio-group @change="handleStatusChange" v-model="searchType">
-                    <el-radio-button label="全部" value="0" />
-                    <el-radio-button label="已加入回收书单(正在回收)" value="1" />
-                    <el-radio-button label="已加入回收书单(暂停回收)" value="2" />
-                    <el-radio-button label="未加入回收书单" value="3" />
-                    <el-radio-button label="黑名单" value="4" />
-                </el-radio-group>
-
-                <span class="ml-8"></span>
-                <el-button type="warning" plain v-permission="'recycle:booklist:batchRemoveBooklist'"
-                    @click="handleOptBooklist('remove')" v-if="['0', '1', '2'].includes(searchType)">
-                    移除回收书单
-                </el-button>
-                <el-button type="success" plain v-permission="'recycle:booklist:batchAddBooklist'"
-                    @click="handleOptBooklist('add')" v-if="['3', '4'].includes(searchType)">
-                    加入回收书单
-                </el-button>
-                <el-button type="warning" plain v-permission="'recycle:booklist:batchRemoveBlacklist'"
-                    @click="handleOptBlacklist('remove')" v-if="searchType === '4'">
-                    移除黑名单
-                </el-button>
-                <el-button type="danger" plain v-permission="'recycle:booklist:batchAddBlacklist'"
-                    @click="handleOptBlacklist('add')" v-if="searchType !== '4'">
-                    加黑名单
-                </el-button>
-
-                <el-button type="warning" plain v-permission="'recycle:booklist:batchPauseRecycle'"
-                    @click="handleOptRecycle('pause')" v-if="searchType === '1'">
-                    暂停回收
-                </el-button>
-                <el-button type="warning" plain v-permission="'recycle:booklist:batchStartRecycle'"
-                    @click="handleOptRecycle('start')" v-if="['0', '2'].includes(searchType)">
-                    开启回收
-                </el-button>
-                <el-button type="primary" plain v-permission="'recycle:booklist:batchAddDiscount'"
-                    @click="handleAddDiscount()" v-if="searchType === '3'">
-                    指定折扣加回收书单
-                </el-button>
-                <el-button type="success" plain v-permission="'recycle:booklist:batchAddSocial'"
-                    @click="handleOptType(1)">
-                    加社科库
-                </el-button>
-                <el-button type="primary" plain v-permission="'recycle:booklist:batchAddTeach'"
-                    @click="handleOptType(2)">
-                    加教材库
-                </el-button>
-            </template>
-
-            <template #cover="{ row }">
-                <el-image style="width: 90px; height: 120px; border-radius: 4px" fit="cover" :src="row.cover" />
-            </template>
-            <template #baseInfo="{ row }">
-                <book-info :row="row" @edit="handleUpdateBook"></book-info>
-            </template>
-            <template #stock="{ row }">
-                <book-stock :row="row"></book-stock>
-            </template>
-
-            <template #action="{ row }">
-                <el-button type="primary" link v-permission="'recycle:booklist:updateBook'"
-                    @click="handleUpdateBook(row)">
-                    [编辑]
-                </el-button>
-                <el-button color="#192bbe" plain link v-permission="'recycle:booklist:setParams'"
-                    @click="handleSetParams(row)">
-                    [设置独立参数]
-                </el-button>
-                <el-button type="success" link v-permission="'recycle:booklist:removeBlacklist'"
-                    @click="handleOptBlacklist('remove', row)" v-if="row.bookStatus == 3">
-                    [移除黑名单]
-                </el-button>
-                <el-button type="warning" link v-permission="'recycle:booklist:addBlacklist'"
-                    @click="handleOptBlacklist('add', row)" v-if="row.bookStatus == 1 || row.bookStatus == 2">
-                    [加入黑名单]
-                </el-button>
-                <el-button type="danger" link v-permission="'recycle:booklist:pauseRecycle'"
-                    @click="handleOptRecycle('pause', row)" v-if="row.recycleStatus == 1">
-                    [暂停回收]
-                </el-button>
-                <el-button type="success" link v-permission="'recycle:booklist:startRecycle'"
-                    @click="handleOptRecycle('start', row)" v-else>
-                    [开启回收]
-                </el-button>
-                <el-button type="success" link v-permission="'recycle:booklist:removeBooklist'"
-                    @click="handleOptBooklist('remove', row)" v-if="row.bookStatus == 2">
-                    [移除回收书单]
-                </el-button>
-                <el-button type="danger" link v-permission="'recycle:booklist:addBooklist'"
-                    @click="handleOptBooklist('add', row)" v-if="row.bookStatus == 1">
-                    [加入回收书单]
-                </el-button>
-            </template>
-        </common-table>
-
-        <books-edit ref="editRef"></books-edit>
-        <set-params ref="paramsRef" @refresh="reload"></set-params>
-        <add-discount ref="discountRef" @refresh="reload"></add-discount>
-        <order-blacklist ref="blacklistRef" @refresh="reload"></order-blacklist>
-    </ele-page>
+  <ele-page flex-table>
+    <book-search @search="reload"></book-search>
+
+    <common-table
+      ref="pageRef"
+      :pageConfig="pageConfig"
+      :columns="columns"
+      :tools="false"
+      @sort-change="handleSortChange"
+    >
+      <template #toolbar>
+        <el-radio-group @change="handleStatusChange" v-model="searchType">
+          <el-radio-button label="全部" value="0" />
+          <el-radio-button label="已加入回收书单(正在回收)" value="1" />
+          <el-radio-button label="已加入回收书单(暂停回收)" value="2" />
+          <el-radio-button label="未加入回收书单" value="3" />
+          <el-radio-button label="黑名单" value="4" />
+        </el-radio-group>
+
+        <span class="ml-8"></span>
+        <el-button
+          type="warning"
+          plain
+          v-permission="'recycle:booklist:batchRemoveBooklist'"
+          @click="handleOptBooklist('remove')"
+          v-if="['0', '1', '2'].includes(searchType)"
+        >
+          移除回收书单
+        </el-button>
+        <el-button
+          type="success"
+          plain
+          v-permission="'recycle:booklist:batchAddBooklist'"
+          @click="handleOptBooklist('add')"
+          v-if="['3', '4'].includes(searchType)"
+        >
+          加入回收书单
+        </el-button>
+        <el-button
+          type="warning"
+          plain
+          v-permission="'recycle:booklist:batchRemoveBlacklist'"
+          @click="handleOptBlacklist('remove')"
+          v-if="searchType === '4'"
+        >
+          移除黑名单
+        </el-button>
+        <el-button
+          type="danger"
+          plain
+          v-permission="'recycle:booklist:batchAddBlacklist'"
+          @click="handleOptBlacklist('add')"
+          v-if="searchType !== '4'"
+        >
+          加黑名单
+        </el-button>
+
+        <el-button
+          type="warning"
+          plain
+          v-permission="'recycle:booklist:batchPauseRecycle'"
+          @click="handleOptRecycle('pause')"
+          v-if="searchType === '1'"
+        >
+          暂停回收
+        </el-button>
+        <el-button
+          type="warning"
+          plain
+          v-permission="'recycle:booklist:batchStartRecycle'"
+          @click="handleOptRecycle('start')"
+          v-if="['0', '2'].includes(searchType)"
+        >
+          开启回收
+        </el-button>
+        <el-button
+          type="primary"
+          plain
+          v-permission="'recycle:booklist:batchAddDiscount'"
+          @click="handleAddDiscount()"
+          v-if="searchType === '3'"
+        >
+          指定折扣加回收书单
+        </el-button>
+        <el-button
+          type="success"
+          plain
+          v-permission="'recycle:booklist:batchAddSocial'"
+          @click="handleOptType(1)"
+        >
+          加社科库
+        </el-button>
+        <el-button
+          type="primary"
+          plain
+          v-permission="'recycle:booklist:batchAddTeach'"
+          @click="handleOptType(2)"
+        >
+          加教材库
+        </el-button>
+      </template>
+
+      <template #cover="{ row }">
+        <el-image
+          style="width: 90px; height: 120px; border-radius: 4px"
+          fit="cover"
+          :src="row.cover"
+        />
+      </template>
+      <template #baseInfo="{ row }">
+        <book-info :row="row" @edit="handleUpdateBook"></book-info>
+      </template>
+      <template #stock="{ row }">
+        <book-stock :row="row"></book-stock>
+      </template>
+
+      <template #action="{ row }">
+        <el-button
+          type="primary"
+          link
+          v-permission="'recycle:booklist:updateBook'"
+          @click="handleUpdateBook(row)"
+        >
+          [编辑]
+        </el-button>
+        <el-button
+          color="#192bbe"
+          plain
+          link
+          v-permission="'recycle:booklist:setParams'"
+          @click="handleSetParams(row)"
+        >
+          [设置独立参数]
+        </el-button>
+        <el-button
+          type="success"
+          link
+          v-permission="'recycle:booklist:removeBlacklist'"
+          @click="handleOptBlacklist('remove', row)"
+          v-if="row.bookStatus == 3"
+        >
+          [移除黑名单]
+        </el-button>
+        <el-button
+          type="warning"
+          link
+          v-permission="'recycle:booklist:addBlacklist'"
+          @click="handleOptBlacklist('add', row)"
+          v-if="row.bookStatus == 1 || row.bookStatus == 2"
+        >
+          [加入黑名单]
+        </el-button>
+        <el-button
+          type="danger"
+          link
+          v-permission="'recycle:booklist:pauseRecycle'"
+          @click="handleOptRecycle('pause', row)"
+          v-if="row.recycleStatus == 1"
+        >
+          [暂停回收]
+        </el-button>
+        <el-button
+          type="success"
+          link
+          v-permission="'recycle:booklist:startRecycle'"
+          @click="handleOptRecycle('start', row)"
+          v-else
+        >
+          [开启回收]
+        </el-button>
+        <el-button
+          type="success"
+          link
+          v-permission="'recycle:booklist:removeBooklist'"
+          @click="handleOptBooklist('remove', row)"
+          v-if="row.bookStatus == 2"
+        >
+          [移除回收书单]
+        </el-button>
+        <el-button
+          type="danger"
+          link
+          v-permission="'recycle:booklist:addBooklist'"
+          @click="handleOptBooklist('add', row)"
+          v-if="row.bookStatus == 1"
+        >
+          [加入回收书单]
+        </el-button>
+      </template>
+    </common-table>
+
+    <books-edit ref="editRef"></books-edit>
+    <set-params ref="paramsRef" @refresh="reload"></set-params>
+    <add-discount ref="discountRef" @refresh="reload"></add-discount>
+    <order-blacklist ref="blacklistRef" @refresh="reload"></order-blacklist>
+  </ele-page>
 </template>
 
 <script setup>
-import { ref, reactive } from 'vue';
-import CommonTable from '@/components/CommonPage/CommonTable.vue';
-import booksEdit from '@/views/data/books/components/books-edit.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 setParams from '@/views/recycle/components/set-params.vue';
-import addDiscount from '@/views/recycle/components/add-discount.vue';
-import orderBlacklist from '@/views/recycleOrder/detail/order-blacklist.vue';
-import { useBookOperation } from '@/utils/use-book-operation';
-
-defineOptions({ name: 'recycleBooklist' });
-
-const searchType = ref('0');
-function handleStatusChange(value) {
-    pageRef.value.reload({ searchType: value });
-}
-
-/** 表格列配置 */
-const columns = ref([
+  import { ref, reactive } from 'vue';
+  import CommonTable from '@/components/CommonPage/CommonTable.vue';
+  import booksEdit from '@/views/data/books/components/books-edit.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 setParams from '@/views/recycle/components/set-params.vue';
+  import addDiscount from '@/views/recycle/components/add-discount.vue';
+  import orderBlacklist from '@/views/recycleOrder/detail/order-blacklist.vue';
+  import { useBookOperation } from '@/utils/use-book-operation';
+
+  defineOptions({ name: 'recycleBooklist' });
+
+  const searchType = ref('0');
+  function handleStatusChange(value) {
+    searchType.value = value;
+    pageConfig.params.searchType = value;
+    reload();
+  }
+
+  /** 表格列配置 */
+  const columns = ref([
     {
-        type: 'selection',
-        columnKey: 'selection',
-        width: 50,
-        align: 'center',
-        fixed: 'left'
+      type: 'selection',
+      columnKey: 'selection',
+      width: 50,
+      align: 'center',
+      fixed: 'left'
     },
     {
-        label: '图片',
-        prop: 'cover',
-        width: 120,
-        slot: 'cover'
+      label: '图片',
+      prop: 'cover',
+      width: 120,
+      slot: 'cover'
     },
     {
-        label: '信息',
-        prop: 'baseInfo',
-        width: 500,
-        slot: 'baseInfo'
+      label: '信息',
+      prop: 'baseInfo',
+      width: 500,
+      slot: 'baseInfo'
     },
     {
-        label: '回收折扣',
-        minWidth: 100,
-        prop: 'recycleDiscount',
-        sortable: true,
-        columnKey: '4'
+      label: '回收折扣',
+      minWidth: 100,
+      prop: 'recycleDiscount',
+      sortable: true,
+      columnKey: '4'
     },
     {
-        label: '回收价格',
-        prop: 'recyclePrice',
-        sortable: true,
-        columnKey: '5',
-        minWidth: 100
+      label: '回收价格',
+      prop: 'recyclePrice',
+      sortable: true,
+      columnKey: '5',
+      minWidth: 100
     },
     {
-        label: '最大回收量',
-        minWidth: 120,
-        prop: 'recycleMax',
-        sortable: true,
-        columnKey: '6'
+      label: '最大回收量',
+      minWidth: 120,
+      prop: 'recycleMax',
+      sortable: true,
+      columnKey: '6'
     },
     {
-        label: '总回收数量',
-        minWidth: 120,
-        prop: 'recycleTotalNum',
-        sortable: true,
-        columnKey: '2'
+      label: '总回收数量',
+      minWidth: 120,
+      prop: 'recycleTotalNum',
+      sortable: true,
+      columnKey: '2'
     },
     {
-        label: '当前剩余回收量',
-        minWidth: 140,
-        prop: 'restRecycleNum',
-        sortable: true,
-        columnKey: '7'
+      label: '当前剩余回收量',
+      minWidth: 140,
+      prop: 'restRecycleNum',
+      sortable: true,
+      columnKey: '7'
     },
     {
-        label: '销量',
-        prop: 'salesNum',
-        sortable: true,
-        columnKey: '8'
+      label: '销量',
+      prop: 'salesNum',
+      sortable: true,
+      columnKey: '8'
     },
     {
-        label: '库存',
-        prop: 'stockTotalNum',
-        sortable: true,
-        columnKey: '9',
-        slot: 'stock',
-        minWidth: 100
+      label: '库存',
+      prop: 'stockTotalNum',
+      sortable: true,
+      columnKey: '9',
+      slot: 'stock',
+      minWidth: 100
     },
     {
-        columnKey: 'action',
-        label: '操作',
-        width: 150,
-        slot: 'action',
-        fixed: 'right'
+      columnKey: 'action',
+      label: '操作',
+      width: 150,
+      slot: 'action',
+      fixed: 'right'
     }
-]);
+  ]);
 
-/** 页面组件实例 */
-const pageRef = ref(null);
+  /** 页面组件实例 */
+  const pageRef = ref(null);
 
-const pageConfig = reactive({
+  const pageConfig = reactive({
     pageUrl: '/book/bookRecycleInfo/pageList',
     fileName: '回收书单管理',
     cacheKey: 'recycleBooklistTable',
-    rowKey: 'isbn'
-});
+    rowKey: 'isbn',
+    params: {
+      searchType: '0'
+    }
+  });
 
-function handleSortChange({ column, order }) {
+  function handleSortChange({ column, order }) {
     // 1 扫描次数 2总回收量 3最后一次扫描时间
     reload({
       orderType: column.columnKey,
@@ -221,23 +318,22 @@ function handleSortChange({ column, order }) {
     });
   }
 
-
-//刷新表格
-function reload(where) {
+  //刷新表格
+  function reload(where) {
     pageRef.value?.reload(where);
-}
+  }
 
-//编辑
-const editRef = ref(null);
-function handleUpdateBook(row) {
+  //编辑
+  const editRef = ref(null);
+  function handleUpdateBook(row) {
     let params = {
-        id: row.bookId
+      id: row.bookId
     };
     editRef.value?.handleOpen(params);
-}
+  }
 
-// 使用图书操作混入
-const {
+  // 使用图书操作混入
+  const {
     blacklistRef,
     discountRef,
     paramsRef,
@@ -247,5 +343,5 @@ const {
     handleOptType,
     handleAddDiscount,
     handleSetParams
-} = useBookOperation(pageRef);
+  } = useBookOperation(pageRef);
 </script>

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

@@ -93,7 +93,6 @@
     maxPrice: void 0,
     minDiscount: void 0,
     maxDiscount: void 0,
-    searchType: 0,
     globalInDiscount: void 0,
     globalNotInDiscount: void 0,
     defaultType: []

+ 7 - 2
src/views/recycle/independentParameter/index.vue

@@ -139,7 +139,9 @@ defineOptions({ name: 'independentParameter' });
 const searchType = ref('0');
 const blacklistRef = ref(null);
 function handleStatusChange(value) {
-    pageRef.value.reload({ searchType: value });
+    searchType.value = value;
+    pageConfig.params.searchType = value;
+    pageRef.value.reload();
 }
 
 /** 表格列配置 */
@@ -213,7 +215,10 @@ const pageConfig = reactive({
     pageUrl: '/book/bookRecycleInfo/sepSet/pageList',
     fileName: '独立参数设置',
     cacheKey: 'independentParameterTable',
-    rowKey: 'isbn'
+    rowKey: 'isbn',
+    params: {
+        searchType: '0'
+    }
 });
 
 //刷新表格

+ 3 - 1
src/views/recycle/scanLog/index.vue

@@ -208,7 +208,9 @@
 
   const searchType = ref('1');
   function handleStatusChange(value) {
-    pageRef.value.reload({ searchType: value });
+    searchType.value = value;
+    pageConfig.params.searchType = value;
+    pageRef.value.reload();
   }
 
   function handleSortChange({ column, order }) {

+ 7 - 2
src/views/recycle/specifiedBooks/index.vue

@@ -133,7 +133,9 @@ defineOptions({ name: 'specifiedBookslist' });
 const searchType = ref('0');
 const blacklistRef = ref(null);
 function handleStatusChange(value) {
-    pageRef.value.reload({ searchType: value });
+    searchType.value = value;
+    pageConfig.params.searchType = value;
+    pageRef.value.reload();
 }
 
 /** 表格列配置 */
@@ -207,7 +209,10 @@ const pageConfig = reactive({
     pageUrl: '/book/bookRecycleInfo/designate/pageList',
     fileName: '指定图书管理',
     cacheKey: 'specifiedBookslistTable',
-    rowKey: 'isbn'
+    rowKey: 'isbn',
+    params: {
+        searchType: '0'
+    }
 });
 
 //刷新表格

+ 9 - 3
src/views/recycleOrder/needReturned/index.vue

@@ -175,7 +175,8 @@
   const tableRef = ref(null);
 
   function handleStatusChange(val) {
-    reload({ tabStatus: val });
+    status.value = val;
+    reload();
   }
 
   /** 表格列配置 */
@@ -235,14 +236,19 @@
 
   /** 表格数据源 */
   const datasource = ({ pages, where, orders }) => {
-    return queryPage({ ...where, ...orders, ...pages });
+    return queryPage({
+      ...where,
+      ...orders,
+      ...pages,
+      tabStatus: status.value
+    });
   };
 
   /** 搜索 */
   const reload = (where) => {
     tableRef.value?.reload?.({
       page: 1,
-      where: { ...where, tabStatus: status.value }
+      where
     });
   };