Alex 11 сар өмнө
parent
commit
e6dcdd03dd

+ 0 - 1
src/components/CommonPage/SimpleForm.vue

@@ -67,7 +67,6 @@ function setData(data) {
     // 延迟清空表单验证,防止表单验证不生效
     setTimeout(() => {
         proFormRef.value?.clearValidate?.();
-        
     }, 50);
 }
 

+ 1 - 0
src/views/data/books/components/books-edit.vue

@@ -150,6 +150,7 @@
 
   function handleOpen(data = {}) {
     title.value = data && data.id ? '编辑图书' : '新增图书';
+    console.log(data,'xxxx');
     formData.value = Object.assign(formData.value, data || {});
     editRef.value?.handleOpen(formData.value);
   }

+ 151 - 62
src/views/recycle/booklist/index.vue

@@ -4,7 +4,7 @@
 
         <common-table ref="pageRef" :pageConfig="pageConfig" :columns="columns" :tools="false">
             <template #toolbar>
-                <el-radio-group @change="handleStatusChange" v-model="useStatus">
+                <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" />
@@ -13,40 +13,40 @@
                 </el-radio-group>
 
                 <span class="ml-8"></span>
-                <el-button type="success" plain v-permission="'recycle:booklist:batchRemoveBooklist'"
-                    @click="handleOptBooklist()">
+                <el-button type="warning" plain v-permission="'recycle:booklist:batchRemoveBooklist'"
+                    @click="handleOptBooklist()" v-if="['0', '1', '2'].includes(searchType)">
                     移除回收书单
                 </el-button>
-                <el-button type="danger" plain v-permission="'recycle:booklist:batchAddBooklist'"
-                    @click="handleOptBooklist()">
+                <el-button type="success" plain v-permission="'recycle:booklist:batchAddBooklist'"
+                    @click="handleOptBooklist()" v-if="['3', '4'].includes(searchType)">
                     加入回收书单
                 </el-button>
-                <el-button type="success" plain v-permission="'recycle:booklist:batchRemoveBlacklist'"
-                    @click="handleOptBlacklist()">
-                    批量移除黑名单
+                <el-button type="warning" plain v-permission="'recycle:booklist:batchRemoveBlacklist'"
+                    @click="handleOptBlacklist()" v-if="searchType === '4'">
+                    移除黑名单
                 </el-button>
                 <el-button type="danger" plain v-permission="'recycle:booklist:batchAddBlacklist'"
-                    @click="handleOptBlacklist()">
-                    批量加黑名单
+                    @click="handleOptBlacklist()" v-if="searchType !== '4'">
+                    加黑名单
                 </el-button>
 
                 <el-button type="warning" plain v-permission="'recycle:booklist:batchPauseRecycle'"
-                    @click="handleOptRecycle()">
+                    @click="handleOptRecycle()" v-if="searchType === '1'">
                     暂停回收
                 </el-button>
-                <el-button type="success" plain v-permission="'recycle:booklist:batchStartRecycle'"
-                    @click="handleOptRecycle()">
+                <el-button type="warning" plain v-permission="'recycle:booklist:batchStartRecycle'"
+                    @click="handleOptRecycle()" v-if="['0', '2'].includes(searchType)">
                     开启回收
                 </el-button>
                 <el-button type="primary" plain v-permission="'recycle:booklist:batchAddDiscount'"
-                    @click="handleAddDiscount()">
+                    @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="success" plain v-permission="'recycle:booklist:batchAddTeach'"
+                <el-button type="primary" plain v-permission="'recycle:booklist:batchAddTeach'"
                     @click="handleOptType(2)">
                     加教材库
                 </el-button>
@@ -58,7 +58,7 @@
             <template #baseInfo="{ row }">
                 <div class="flex justify-start items-center">
                     <div style="flex: 2">
-                        <book-info :row="row"></book-info>
+                        <book-info :row="row" @edit="handleUpdateBook"></book-info>
                     </div>
                     <div style="flex: 1.5; margin-left: 15px">
                         <book-other-info :row="row"></book-other-info>
@@ -78,35 +78,35 @@
                     @click="handleSetParams(row)">
                     [设置独立参数]
                 </el-button>
-                <el-button type="warning" link v-permission="'recycle:booklist:addBlacklist'"
-                    @click="handleOptBlacklist(row)">
-                    [加入黑名单]
-                </el-button>
                 <el-button type="success" link v-permission="'recycle:booklist:removeBlacklist'"
-                    @click="handleOptBlacklist(row)">
+                    @click="handleOptBlacklist(row)" v-if="row.bookStatus == 3">
                     [移除黑名单]
                 </el-button>
+                <el-button type="warning" link v-permission="'recycle:booklist:addBlacklist'"
+                    @click="handleOptBlacklist(row)" v-if="row.bookStatus == 1 || row.bookStatus == 2">
+                    [加入黑名单]
+                </el-button>
                 <el-button type="danger" link v-permission="'recycle:booklist:pauseRecycle'"
-                    @click="handleOptRecycle(row)">
+                    @click="handleOptRecycle(row)" v-if="row.recycleStatus == 1">
                     [暂停回收]
                 </el-button>
                 <el-button type="success" link v-permission="'recycle:booklist:startRecycle'"
-                    @click="handleOptRecycle(row)">
+                    @click="handleOptRecycle(row)" v-else>
                     [开启回收]
                 </el-button>
                 <el-button type="success" link v-permission="'recycle:booklist:removeBooklist'"
-                    @click="handleOptBooklist(row)">
+                    @click="handleOptBooklist(row)" v-if="row.bookStatus == 2">
                     [移除回收书单]
                 </el-button>
                 <el-button type="danger" link v-permission="'recycle:booklist:addBooklist'"
-                    @click="handleOptBooklist(row)">
+                    @click="handleOptBooklist(row)" v-if="row.bookStatus == 1">
                     [加入回收书单]
                 </el-button>
             </template>
         </common-table>
 
         <books-edit ref="editRef"></books-edit>
-        <set-params ref="paramsRef"></set-params>
+        <set-params ref="paramsRef" @refresh="reload"></set-params>
     </ele-page>
 </template>
 
@@ -122,11 +122,10 @@ import setParams from '@/views/recycle/components/set-params.vue';
 import { useDictData } from '@/utils/use-dict-data';
 
 defineOptions({ name: 'recycleBooklist' });
-const [useStatusDicts] = useDictData(['use_status']);
 
-const useStatus = ref('0');
+const searchType = ref('0');
 function handleStatusChange(value) {
-    pageRef.value.reload({ useStatus: value });
+    pageRef.value.reload({ searchType: value });
 }
 
 /** 表格列配置 */
@@ -147,46 +146,57 @@ const columns = ref([
     {
         label: '信息',
         prop: 'baseInfo',
-        width: 540,
+        width: 500,
         slot: 'baseInfo'
     },
     {
         label: '回收折扣',
-        prop: 'discount',
+        minWidth: 100,
+        prop: 'recycleDiscount',
+        sortable: true,
+        columnKey: 'recycleDiscount'
+    },
+    {
+        label: '回收价格',
+        prop: 'recyclePrice',
         sortable: true,
-        columnKey: 'discount'
+        columnKey: 'recyclePrice',
+        minWidth: 100
     },
-    { label: '回收价格', prop: 'price', sortable: true, columnKey: 'price' },
     {
         label: '最大回收量',
-        prop: 'maxRecycledAmount',
+        minWidth: 120,
+        prop: 'recycleMax',
         sortable: true,
-        columnKey: 'maxRecycledAmount'
+        columnKey: 'recycleMax'
     },
     {
         label: '总回收数量',
-        prop: 'totalRecycledAmount',
+        minWidth: 120,
+        prop: 'recycleNum',
         sortable: true,
-        columnKey: 'totalRecycledAmount'
+        columnKey: 'recycleNum'
     },
     {
         label: '当前剩余回收量',
-        prop: 'remainingRecycledAmount',
+        minWidth: 140,
+        prop: 'restRecycleNum',
         sortable: true,
-        columnKey: 'remainingRecycledAmount'
+        columnKey: 'restRecycleNum'
     },
     {
         label: '销量',
-        prop: 'salesVolume',
+        prop: 'salesNum',
         sortable: true,
-        columnKey: 'salesVolume'
+        columnKey: 'salesNum'
     },
     {
         label: '库存',
-        prop: 'stock',
+        prop: 'stockNum',
         sortable: true,
-        columnKey: 'stock',
-        slot: 'stock'
+        columnKey: 'stockNum',
+        slot: 'stock',
+        minWidth: 100
     },
     {
         columnKey: 'action',
@@ -201,7 +211,7 @@ const columns = ref([
 const pageRef = ref(null);
 
 const pageConfig = reactive({
-    pageUrl: '/book/bookInfo/list',
+    pageUrl: '/book/bookRecycleInfo/pageList',
     fileName: '回收书单管理',
     cacheKey: 'recycleBooklistTable'
 });
@@ -214,7 +224,10 @@ function reload(where) {
 //编辑
 const editRef = ref(null);
 function handleUpdateBook(row) {
-    editRef.value?.handleOpen(row);
+    let params = {
+        id: row.bookId
+    };
+    editRef.value?.handleOpen(params);
 }
 //设置参数
 const paramsRef = ref(null);
@@ -225,34 +238,110 @@ function handleSetParams(row) {
 //回收书单操作
 function handleOptBooklist(row) {
     let selections = row ? [row] : pageRef.value?.getSelections();
-    let ids = selections.map((item) => item.id).join(',');
-    let url = `/book/bookInfo/removeById/${ids}`;
-    let title = row ? '确认移除回收书单?' : '确认加入回收书单?';
-    pageRef.value?.operatBatch({ title, method: 'post', url, row });
+    if (!selections || selections.length === 0) {
+        ElMessage.warning('请选择要操作的图书');
+        return;
+    }
+
+    const isbnList = selections.map((item) => item.isbn);
+    const isInRecycleList = row ? row.bookStatus === '2' : selections[0].bookStatus === '2';
+
+    const url = isInRecycleList
+        ? '/book/bookRecycleInfo/removeOut'
+        : '/book/bookRecycleInfo/addIn';
+
+    const title = isInRecycleList ? '确认移除回收书单?' : '确认加入回收书单?';
+
+    pageRef.value?.operatBatch({
+        title,
+        method: 'post',
+        url,
+        data: { isbnList },
+        row,
+        success: () => {
+            reload();
+        }
+    });
 }
 //黑名单操作
 function handleOptBlacklist(row) {
     let selections = row ? [row] : pageRef.value?.getSelections();
-    let ids = selections.map((item) => item.id).join(',');
-    let url = `/book/bookInfo/removeBlacklist/${ids}`;
-    let title = row ? '确认移除黑名单?' : '确认加入黑名单?';
-    pageRef.value?.operatBatch({ title, method: 'post', url, row });
+    if (!selections || selections.length === 0) {
+        ElMessage.warning('请选择要操作的图书');
+        return;
+    }
+
+    const isbnList = selections.map((item) => item.isbn);
+    const isBlacklist = row ? row.bookStatus === '3' : selections[0].bookStatus === '3';
+
+    const url = isBlacklist
+        ? '/book/bookRecycleInfo/removeBlackList'
+        : '/book/bookRecycleInfo/addBlackList';
+
+    const title = isBlacklist ? '确认移除黑名单?' : '确认加入黑名单?';
+
+    pageRef.value?.operatBatch({
+        title,
+        method: 'post',
+        url,
+        data: { isbnList },
+        row,
+        success: () => {
+            reload();
+        }
+    });
 }
 //回收操作
 function handleOptRecycle(row) {
     let selections = row ? [row] : pageRef.value?.getSelections();
-    let ids = selections.map((item) => item.id).join(',');
-    let url = `/book/bookInfo/recycle/${ids}`;
-    let title = '确认回收?';
-    pageRef.value?.operatBatch({ title, method: 'post', url, row });
+    if (!selections || selections.length === 0) {
+        ElMessage.warning('请选择要操作的图书');
+        return;
+    }
+
+    const isbnList = selections.map((item) => item.isbn);
+    const isStop = row ? row.recycleStatus === '1' : selections[0].recycleStatus === '1';
+
+    const url = isStop
+        ? '/book/bookRecycleInfo/stopRecycle'
+        : '/book/bookRecycleInfo/openRecycle';
+
+    const title = isStop ? '确认暂停回收?' : '确认开启回收?';
+
+    pageRef.value?.operatBatch({
+        title,
+        method: 'post',
+        url,
+        data: { isbnList },
+        row,
+        success: () => {
+            reload();
+        }
+    });
 }
 //类型操作
 function handleOptType(type) {
     let selections = pageRef.value?.getSelections();
-    let ids = selections.map((item) => item.id).join(',');
-    let url = `/book/bookInfo/changeType/${ids}`;
-    let title = type == 1 ? '确认加社科库?' : '确认加教材库?';
-    pageRef.value?.operatBatch({ title, method: 'post', url, row });
+    if (!selections || selections.length === 0) {
+        ElMessage.warning('请选择要操作的图书');
+        return;
+    }
+
+    const isbnList = selections.map((item) => item.isbn);
+    const url = type == 2
+        ? '/book/bookRecycleInfo/changeBookTag2'
+        : '/book/bookRecycleInfo/changeBookTag1';
+    const title = type == 2 ? '确认加社科库?' : '确认加教材库?';
+
+    pageRef.value?.operatBatch({
+        title,
+        method: 'post',
+        url,
+        data: { isbnList },
+        success: () => {
+            reload();
+        }
+    });
 }
 //指定折扣
 function handleAddDiscount() {

+ 14 - 1
src/views/recycle/components/book-info.vue

@@ -2,7 +2,7 @@
   <div class="recycle-order-number flex flex-col items-start">
     <div class="common-text">
       <el-text>书名:</el-text>
-      <el-text>{{ row.bookName }}</el-text>
+      <el-text type="primary" class="cursor-pointer" @click="handleEdit">{{ row.bookName }}</el-text>
     </div>
     <div class="common-text">
       <el-text>作 者:</el-text>
@@ -29,6 +29,7 @@
 
 <script setup>
   import { dayjs } from 'element-plus';
+  import { computed } from 'vue';
 
   const props = defineProps({
     row: {
@@ -37,9 +38,21 @@
     }
   });
 
+  const emit = defineEmits(['edit']);
+
   const publishDate = computed(() => {
     return props.row.pubDate
       ? dayjs(props.row.pubDate).format('YYYY-MM-DD')
       : '-';
   });
+
+  const handleEdit = () => {
+    emit('edit', props.row);
+  };
 </script>
+
+<style scoped>
+.cursor-pointer {
+  cursor: pointer;
+}
+</style>

+ 20 - 14
src/views/recycle/components/book-search.vue

@@ -23,32 +23,33 @@
     { type: 'input', label: '作者', prop: 'author' },
     { type: 'input', label: '出版社', prop: 'publish' },
     {
-      type: 'date',
+      type: 'daterange',
       label: '出版时间',
-      prop: 'publicationTime',
+      prop: 'pubDate',
+      keys: ['pubDateStart', 'pubDateEnd'],
       props: { format: 'YYYY-MM-DD', valueFormat: 'YYYY-MM-DD' }
     },
     {
       type: 'inputNumberRange',
       label: '定价',
       prop: 'price',
-      keys: ['priceMin', 'priceMax'],
+      keys: ['minPrice', 'maxPrice'],
       props: {
         onChange: (val) => {
-          searchRef.value?.setData({ priceMin: val.min, priceMax: val.max });
+          searchRef.value?.setData({ minPrice: val.min, maxPrice: val.max });
         }
       }
     },
     {
       type: 'inputNumberRange',
       label: '回收折扣',
-      prop: 'recoveryDiscount',
-      keys: ['discountMin', 'discountMax'],
+      prop: 'discount',
+      keys: ['minDiscount', 'maxDiscount'],
       props: {
         minAttrs: { min: 0 },
         maxAttrs: { max: 1 },
         onChange: (val) => {
-          searchRef.value?.setData({ discountMin: val.min, discountMax: val.max });
+          searchRef.value?.setData({ minDiscount: val.min, maxDiscount: val.max });
         }
       }
     },
@@ -58,12 +59,16 @@
     bookName: '',
     isbn: '',
     author: '',
-    publisher: '',
-    publicationTime: '',
-    priceMin: void 0,
-    priceMax: void 0,
-    discountMin: void 0,
-    discountMax: void 0
+    publish: '',
+    pubDateStart: '',
+    pubDateEnd: '',
+    minPrice: void 0,
+    maxPrice: void 0,
+    minDiscount: void 0,
+    maxDiscount: void 0,
+    searchType: 0,
+    globalInDiscount: void 0,
+    globalNotInDiscount: void 0
   });
 
   const searchRef = ref(null);
@@ -71,7 +76,8 @@
   const search = (data) => {
     let params = JSON.parse(JSON.stringify(data));
     delete params.price;
-    delete params.recoveryDiscount
+    delete params.discount;
+    delete params.pubDate;
     emit('search', params);
   };
 </script>

+ 8 - 5
src/views/recycle/components/book-stock.vue

@@ -1,19 +1,18 @@
 <template>
   <div class="recycle-order-number flex flex-col items-start">
     <div class="common-text">
-      <el-text>中等:</el-text>
+      <el-text>中等:{{ row.stockGeneralNum }}</el-text>
       <el-text></el-text>
     </div>
     <div class="common-text">
-      <el-text>良好:</el-text>
-      <el-text></el-text>
+      <el-text>良好:{{ row.stockGoodNum }}</el-text>
     </div>
     <div class="common-text">
-      <el-text>次品:</el-text>
+      <el-text>次品:{{ row.stockBadNum }}</el-text>
       <el-text></el-text>
     </div>
     <div class="common-text">
-      <el-text>合计:</el-text>
+      <el-text>合计:{{ totalStock }}</el-text>
       <el-text></el-text>
     </div>
   </div>
@@ -26,4 +25,8 @@
       default: () => {}
     }
   });
+
+  const totalStock = computed(() => {
+    return props.row.stockGeneralNum + props.row.stockGoodNum + props.row.stockBadNum;
+  });
 </script>

+ 79 - 68
src/views/recycle/components/set-params.vue

@@ -1,97 +1,108 @@
 <!-- 编辑弹窗 -->
 <template>
-  <ele-modal
-    form
-    :width="560"
-    v-model="visible"
-    title="设置独立参数"
-    @open="handleOpen"
-  >
-    <SimpleForm
-      :items="items"
-      labelWidth="140px"
-      ref="formRef"
-      :initKeys="form"
-    ></SimpleForm>
-    <template #footer>
-      <el-button @click="handleCancel">关闭</el-button>
-      <el-button type="primary" @click="handleSumbit">确定</el-button>
-    </template>
-  </ele-modal>
+    <ele-modal form :width="560" v-model="visible" title="设置独立参数" @open="handleOpen">
+        <SimpleForm :items="items" labelWidth="140px" ref="formRef" :initKeys="form"></SimpleForm>
+        <template #footer>
+            <el-button @click="handleCancel">关闭</el-button>
+            <el-button type="primary" @click="handleSumbit">确定</el-button>
+        </template>
+    </ele-modal>
 </template>
 
 <script setup>
-  import { ref, reactive, nextTick } from 'vue';
-  import { Flag, ChatDotSquare } from '@element-plus/icons-vue';
-  import orderTimeline from '@/views/recycleOrder/components/order-timeline.vue';
-  import SimpleForm from '@/components/CommonPage/SimpleForm.vue';
-  import validators from '@/utils/validators';
+import { ref, reactive, nextTick } from 'vue';
+import SimpleForm from '@/components/CommonPage/SimpleForm.vue';
+import validators from '@/utils/validators';
+import request from '@/utils/request';
 
-  /** 弹窗是否打开 */
-  const visible = defineModel({ type: Boolean });
+/** 弹窗是否打开 */
+const visible = defineModel({ type: Boolean });
 
-  /** 关闭弹窗 */
-  const handleCancel = () => {
+/** 关闭弹窗 */
+const handleCancel = () => {
     visible.value = false;
     nextTick(() => {
-      formRef.value?.resetForm();
+        formRef.value?.resetForm();
     });
-  };
+};
 
-  const form = reactive({
-    maxCount: '',
-    discount: '0.01',
-    number: '',
-    status: '1'
-  });
-  /** 弹窗打开事件 */
-  const handleOpen = () => {
+const form = ref({
+    isbn: '',
+    recycleDiscount: '',
+    recycleMax: '',
+    recycleMaxPerOrder: '',
+    settingStatus: '0'
+});
+/** 弹窗打开事件 */
+const handleOpen = (data) => {
     visible.value = true;
     nextTick(() => {
-      formRef.value?.assignFields(form);
+        if (data?.isbn) {
+            form.value.isbn = data.isbn;
+            getParams(data.isbn);
+        }
     });
-  };
+};
+//根据isbn获取参数
+const getParams = (isbn) => {
+    request.get(`/book/bookRecycleInfo/getSepSet/${isbn}`).then((res) => {
+        let data = res.data.data;
+        console.log(data);
+        form.value.recycleDiscount = data.recycleDiscount;
+        form.value.recycleMax = data.recycleMax;
+        form.value.recycleMaxPerOrder = data.recycleMaxPerOrder;
+        form.value.settingStatus = data.settingStatus;
+        formRef.value?.setData(form.value);
+    });
+};
+
 
-  const items = reactive([
+const items = reactive([
     {
-      label: '回收折扣',
-      prop: 'discount',
-      type: 'input',
-      required: true,
-      rules: [validators.decimalRange]
+        label: '回收折扣',
+        prop: 'recycleDiscount',
+        type: 'input',
+        required: true,
+        rules: [validators.decimalRange]
     },
     {
-      label: '最大回收数量',
-      prop: 'maxCount',
-      type: 'input',
-      required: true,
-      rules: [validators.nonNegativeInteger]
+        label: '最大回收数量',
+        prop: 'recycleMax',
+        type: 'input',
+        required: true,
+        rules: [validators.nonNegativeInteger]
     },
     {
-      label: '单个订单回收数量',
-      prop: 'number',
-      type: 'input',
-      required: true,
-      rules: [validators.nonNegativeInteger]
+        label: '单个订单回收数量',
+        prop: 'recycleMaxPerOrder',
+        type: 'input',
+        required: true,
+        rules: [validators.nonNegativeInteger]
     },
     {
-      label: '状态',
-      prop: 'status',
-      type: 'dictRadio',
-      props: { code: 'discount_status' },
-      required: true
+        label: '状态',
+        prop: 'settingStatus',
+        type: 'dictRadio',
+        props: { code: 'discount_status' },
+        required: true
     }
-  ]);
+]);
+
+const formRef = ref();
 
-  const formRef = ref();
-  const handleSumbit = () => {
+const emit = defineEmits(['refresh']);
+const handleSumbit = () => {
     formRef.value?.submitForm().then((data) => {
-      visible.value = false;
-      console.log(data);
+        data.isbn = form.value.isbn;
+        request.post('/book/bookRecycleInfo/setSep', data).then(() => {
+            visible.value = false;
+            ElMessage.success('设置成功');
+            emit('refresh');
+        });
     });
-  };
+};
 
-  defineExpose({
+defineExpose({
     handleOpen
-  });
+});
 </script>