Parcourir la source

fix 售价日志接口对接&优化订单详情修改价格后显示为空的问题

ylong il y a 4 mois
Parent
commit
c7af5e99f6

+ 61 - 72
src/views/recycle/components/modify-product-price.vue

@@ -1,18 +1,7 @@
 <!-- 修改销售价格弹窗 -->
 <template>
-    <ele-modal
-        form
-        :width="460"
-        v-model="visible"
-        title="修改销售价格"
-        @open="handleOpen"
-    >
-        <SimpleForm
-            :items="items"
-            labelWidth="100px"
-            ref="formRef"
-            :initKeys="form"
-        />
+    <ele-modal form :width="460" v-model="visible" title="修改销售价格" @open="handleOpen">
+        <SimpleForm :items="items" labelWidth="100px" ref="formRef" :initKeys="form" />
         <template #footer>
             <el-button @click="handleCancel">关闭</el-button>
             <el-button type="primary" @click="handleSubmit">确定</el-button>
@@ -21,73 +10,73 @@
 </template>
 
 <script setup>
-    import { ref, reactive, nextTick } from 'vue';
-    import SimpleForm from '@/components/CommonPage/SimpleForm.vue';
-    import validators from '@/utils/validators';
-    import request from '@/utils/request';
-    import { ElMessage } from 'element-plus';
+import { ref, reactive, nextTick } from 'vue';
+import SimpleForm from '@/components/CommonPage/SimpleForm.vue';
+import validators from '@/utils/validators';
+import request from '@/utils/request';
+import { ElMessage } from 'element-plus';
 
-    /** 弹窗是否打开 */
-    const visible = defineModel({ type: Boolean });
+/** 弹窗是否打开 */
+const visible = defineModel({ type: Boolean });
 
-    /** 关闭弹窗 */
-    const handleCancel = () => {
-        visible.value = false;
-        nextTick(() => {
-            formRef.value?.resetForm();
-        });
-    };
-
-    const form = ref({
-        isbn: '',
-        productPrice: ''
+/** 关闭弹窗 */
+const handleCancel = () => {
+    visible.value = false;
+    nextTick(() => {
+        formRef.value?.resetForm();
     });
+};
 
-    /** 弹窗打开事件 */
-    const handleOpen = (data) => {
-        visible.value = true;
-        nextTick(() => {
-            if (data?.isbn) {
-                form.value.isbn = data.isbn;
-                form.value.productPrice = data.productPrice || 0;
-                formRef.value?.setData(form.value);
-            }
-        });
-    };
+const form = ref({
+    isbn: '',
+    productPrice: ''
+});
 
-    const items = reactive([
-        {
-            label: '销售价格',
-            prop: 'productPrice',
-            type: 'input',
-            required: true,
-            itemProps: {
-                rules: [validators.money]
-            }
+/** 弹窗打开事件 */
+const handleOpen = (data) => {
+    visible.value = true;
+    nextTick(() => {
+        if (data?.isbn) {
+            form.value.isbn = data.isbn;
+            form.value.productPrice = data.productPrice || 0;
+            formRef.value?.setData(form.value);
         }
-    ]);
+    });
+};
 
-    const formRef = ref();
+const items = reactive([
+    {
+        label: '销售价格',
+        prop: 'productPrice',
+        type: 'input',
+        required: true,
+        itemProps: {
+            rules: [validators.money]
+        }
+    }
+]);
 
-    const emit = defineEmits(['refresh']);
-    const handleSubmit = () => {
-        formRef.value?.submitForm().then((data) => {
-            data.isbn = form.value.isbn;
-            request
-                .post('/book/bookInfo/changeProductPrice', data)
-                .then((res) => {
-                    if (res.data.code === 200) {
-                        visible.value = false;
-                        ElMessage.success('修改成功');
-                        emit('refresh');
-                    } else {
-                        ElMessage.error(res.data.msg || '修改失败');
-                    }
-                });
-        });
-    };
+const formRef = ref();
 
-    defineExpose({
-        handleOpen
+const emit = defineEmits(['refresh']);
+const handleSubmit = () => {
+    formRef.value?.submitForm().then((data) => {
+        data.isbn = form.value.isbn;
+        request
+            .post('/book/bookInfo/changeProductPrice', data)
+            .then((res) => {
+                if (res.data.code === 200) {
+                    visible.value = false;
+                    ElMessage.success('修改成功');
+                    emit('refresh', data.productPrice);
+                } else {
+                    ElMessage.error(res.data.msg || '修改失败');
+                }
+            });
     });
+};
+
+defineExpose({
+    handleOpen
+});
 </script>

+ 4 - 4
src/views/recycle/priceAlert/index.vue

@@ -221,11 +221,11 @@
             prop: 'productPrice',
             formatter: (row) => (row.productPrice ? '¥' + row.productPrice : 0)
         },
-        { label: '最大回收量', prop: 'recycleMax', minWidth: 100 },
-        { label: '剩余回收量', prop: 'restRecycleNum', minWidth: 100 },
-        { label: '最近预警时间', prop: 'lastScanTime', minWidth: 120 },
+        { label: '最大回收量', prop: 'recycleMax', minWidth: 100, sortable: true, columnKey: '6' },
+        { label: '剩余回收量', prop: 'restRecycleNum', minWidth: 100, sortable: true, columnKey: '7' },
+        { label: '最近预警时间', prop: 'lastScanTime', minWidth: 120, sortable: true, columnKey: '3' },
         { label: '预警次数', prop: 'alarmNum', minWidth: 90 },
-        { label: '销量', prop: 'salesNum', minWidth: 90 },
+        { label: '销量', prop: 'salesNum', minWidth: 90, sortable: true, columnKey: '8' },
         {
             columnKey: 'view',
             label: '查看',

+ 2 - 1
src/views/recycleOrder/detail/order-book-list.vue

@@ -21,7 +21,7 @@
                     <div
                         class="base-info-left-con flex flex-col items-start ml-3"
                     >
-                        <div
+                        <div style="text-align: left;"
                             ><el-text
                                 type="primary"
                                 style="cursor: pointer"
@@ -627,6 +627,7 @@
     };
 
     const handleRefresh = (type, value) => {
+        console.log(type, value, 'type, value');
         if (!currentRow.value) return;
         const newList = [...dataList.value];
 

+ 60 - 12
src/views/recycleOrder/detail/order-sales-log.vue

@@ -1,7 +1,16 @@
 <!-- 编辑弹窗 -->
 <template>
     <ele-modal form :width="1080" v-model="visible" title="售价日志">
-        <SimpleTable style="width: 100%" :columns="columns" border />
+        <ele-data-table
+            ref="tableRef"
+            style="width: 100%"
+            :columns="columns"
+            :data="dataList"
+            :loading="loading"
+            border
+            rowKey="id"
+            :pagination="false"
+        />
 
         <template #footer>
             <el-button @click="handleCancel">关闭</el-button>
@@ -11,30 +20,69 @@
 
 <script setup>
     import { ref, reactive, nextTick } from 'vue';
-    import { Flag, ChatDotSquare } from '@element-plus/icons-vue';
-    import SimpleTable from '@/components/CommonPage/SimpleTable.vue';
+    import request from '@/utils/request';
+    import { EleMessage } from 'ele-admin-plus/es';
 
     /** 弹窗是否打开 */
     const visible = defineModel({ type: Boolean });
 
+    /** 加载状态 */
+    const loading = ref(false);
+
+    /** 表格数据 */
+    const dataList = ref([]);
+
+    /** 当前ISBN */
+    const currentIsbn = ref('');
+
     /** 关闭弹窗 */
     const handleCancel = () => {
         visible.value = false;
+        dataList.value = [];
+        currentIsbn.value = '';
     };
 
     /** 弹窗打开事件 */
-    const handleOpen = () => {
-        visible.value = true;
-        nextTick(() => console.log('打开'));
+    const handleOpen = (row) => {
+        if (row && row.isbn) {
+            currentIsbn.value = row.isbn;
+            visible.value = true;
+            nextTick(() => {
+                fetchPriceLog();
+            });
+        } else {
+            EleMessage.warning('缺少ISBN信息');
+        }
+    };
+
+    /** 获取售价日志数据 */
+    const fetchPriceLog = async () => {
+        if (!currentIsbn.value) return;
+        
+        loading.value = true;
+        try {
+            const res = await request.post(`/book/bookInfo/getProductPriceLog/${currentIsbn.value}`);
+            if (res.data.code === 200) {
+                dataList.value = res.data.data || [];
+            } else {
+                EleMessage.error(res.data.msg || '获取售价日志失败');
+                dataList.value = [];
+            }
+        } catch (error) {
+            console.error('获取售价日志失败:', error);
+            EleMessage.error('获取售价日志失败');
+            dataList.value = [];
+        } finally {
+            loading.value = false;
+        }
     };
 
-    // 表格数据
+    // 表格列配置
     const columns = reactive([
-        { label: '操作人', prop: 'createBy' },
-        { label: '价格', prop: 'createBy' },
-        { label: '规格', prop: 'discount' },
-        { label: '描述', prop: 'recycleTime' },
-        { label: '修改时间', prop: 'createTime' }
+        { label: 'ISBN', prop: 'bookIsbn', align: 'center',},
+        { label: '操作人', prop: 'userName', align: 'center',},
+        { label: '操作时间', prop: 'changeTime', align: 'center' },
+        { label: '修改价格', prop: 'changePrice', align: 'center' }
     ]);
 
     defineExpose({