瀏覽代碼

fix 激活码接口对接优化

ylong 4 月之前
父節點
當前提交
41fd5b9ab6

+ 84 - 77
src/views/code/list/components/activation-out-stock-modal.vue

@@ -6,27 +6,27 @@
                 <span class="label">ISBN:</span>
                 <span class="value">{{ outStockData.isbn || '-' }}</span>
             </div>
-            
+
             <div class="info-row">
                 <span class="label">书名:</span>
                 <span class="value">{{ outStockData.bookName || '-' }}</span>
             </div>
-            
+
             <div class="info-row">
                 <span class="label">数量:</span>
                 <span class="value">{{ outStockData.num || '-' }}</span>
             </div>
-            
+
             <div class="info-row">
                 <span class="label">链接:</span>
-                <span class="value link-text">{{ outStockData.urlLink || '-' }}</span>
+                <span class="value link-text" @click="handleRedirect(outStockData.urlLink)">{{ outStockData.urlLink || '-' }}</span>
             </div>
-            
+
             <div class="info-row">
                 <span class="label">提取码:</span>
                 <span class="value">{{ outStockData.extCode || '-' }}</span>
             </div>
-            
+
             <div class="info-row">
                 <span class="label">备注:</span>
                 <span class="value">{{ outStockData.remark || '-' }}</span>
@@ -43,14 +43,38 @@
 </template>
 
 <script setup>
-    import { ref, reactive } from 'vue';
-    import { EleMessage } from 'ele-admin-plus/es';
-
-    /** 弹窗是否打开 */
-    const visible = defineModel({ type: Boolean });
-
-    /** 出库数据 */
-    const outStockData = reactive({
+import { ref, reactive } from 'vue';
+import { EleMessage } from 'ele-admin-plus/es';
+
+/** 弹窗是否打开 */
+const visible = defineModel({ type: Boolean });
+
+/** 出库数据 */
+const outStockData = reactive({
+    isbn: '',
+    bookName: '',
+    num: '',
+    urlLink: '',
+    extCode: '',
+    remark: ''
+});
+
+/** 处理链接点击事件 */
+const handleRedirect = (url) => {
+    if (url) {
+        window.open(url, '_blank');
+    }
+};
+
+/** 关闭弹窗 */
+const handleCancel = () => {
+    visible.value = false;
+};
+
+/** 弹窗关闭事件 */
+const handleClosed = () => {
+    // 重置数据
+    Object.assign(outStockData, {
         isbn: '',
         bookName: '',
         num: '',
@@ -58,78 +82,61 @@
         extCode: '',
         remark: ''
     });
+};
 
-    /** 关闭弹窗 */
-    const handleCancel = () => {
-        visible.value = false;
-    };
-
-    /** 弹窗关闭事件 */
-    const handleClosed = () => {
-        // 重置数据
-        Object.assign(outStockData, {
-            isbn: '',
-            bookName: '',
-            num: '',
-            urlLink: '',
-            extCode: '',
-            remark: ''
-        });
-    };
-
-    /** 复制全部信息 */
-    const handleCopyAll = async () => {
-        try {
-            // 格式化复制内容
-            const copyText = `ISBN: ${outStockData.isbn || '-'}
+/** 复制全部信息 */
+const handleCopyAll = async () => {
+    try {
+        // 格式化复制内容
+        const copyText = `ISBN: ${outStockData.isbn || '-'}
 书名: ${outStockData.bookName || '-'}
 数量: ${outStockData.num || '-'}
 链接: ${outStockData.urlLink || '-'}
 提取码: ${outStockData.extCode || '-'}
 备注: ${outStockData.remark || '-'}`;
 
-            // 使用 Clipboard API 复制到剪贴板
-            if (navigator.clipboard && window.isSecureContext) {
-                await navigator.clipboard.writeText(copyText);
-            } else {
-                // 降级方案:使用 document.execCommand
-                const textArea = document.createElement('textarea');
-                textArea.value = copyText;
-                textArea.style.position = 'fixed';
-                textArea.style.left = '-999999px';
-                textArea.style.top = '-999999px';
-                document.body.appendChild(textArea);
-                textArea.focus();
-                textArea.select();
-                document.execCommand('copy');
-                textArea.remove();
-            }
-            
-            EleMessage.success('复制成功');
-        } catch (error) {
-            console.error('复制失败:', error);
-            EleMessage.error('复制失败,请手动复制');
+        // 使用 Clipboard API 复制到剪贴板
+        if (navigator.clipboard && window.isSecureContext) {
+            await navigator.clipboard.writeText(copyText);
+        } else {
+            // 降级方案:使用 document.execCommand
+            const textArea = document.createElement('textarea');
+            textArea.value = copyText;
+            textArea.style.position = 'fixed';
+            textArea.style.left = '-999999px';
+            textArea.style.top = '-999999px';
+            document.body.appendChild(textArea);
+            textArea.focus();
+            textArea.select();
+            document.execCommand('copy');
+            textArea.remove();
         }
-    };
-
-    /** 弹窗打开事件 */
-    const handleOpen = (data) => {
-        if (data) {
-            Object.assign(outStockData, {
-                isbn: data.isbn || '',
-                bookName: data.bookName || '',
-                num: data.num || '',
-                urlLink: data.urlLink || '',
-                extCode: data.extCode || '',
-                remark: data.remark || ''
-            });
-            visible.value = true;
-        }
-    };
 
-    defineExpose({
-        handleOpen
-    });
+        EleMessage.success('复制成功');
+    } catch (error) {
+        console.error('复制失败:', error);
+        EleMessage.error('复制失败,请手动复制');
+    }
+};
+
+/** 弹窗打开事件 */
+const handleOpen = (data) => {
+    if (data) {
+        Object.assign(outStockData, {
+            isbn: data.isbn || '',
+            bookName: data.bookName || '',
+            num: data.num || '',
+            urlLink: data.urlLink || '',
+            extCode: data.extCode || '',
+            remark: data.remark || ''
+        });
+        visible.value = true;
+    }
+};
+
+defineExpose({
+    handleOpen
+});
 </script>
 
 <style scoped>

+ 16 - 20
src/views/code/list/components/out-stock-modal.vue

@@ -97,20 +97,18 @@ const handleClosed = () => {
 
 /** 生成链接 */
 const handleGenerateLink = async () => {
-    try {
-        // 表单验证
-        await formRef.value?.validate();
-
-        loading.value = true;
-
-        // 调用出库接口
-        const response = await request.post('/activation/bookActivationInfo/outStock', {
-            isbn: formData.isbn,
-            num: formData.num,
-            price: formData.price,
-            remark: formData.remark
-        });
-
+    // 表单验证
+    await formRef.value?.validate();
+
+    loading.value = true;
+
+    // 调用出库接口
+    request.post('/activation/bookActivationInfo/outStock', {
+        isbn: formData.isbn,
+        num: formData.num,
+        price: formData.price,
+        remark: formData.remark
+    }).then((response) => {
         if (response.data.code === 200) {
             outStockResult.value = response.data.data;
             EleMessage.success('出库成功');
@@ -124,14 +122,12 @@ const handleGenerateLink = async () => {
                 ...response.data.data
             });
         } else {
-            EleMessage.error(response.msg || '出库失败');
+            EleMessage.error(response.data.msg || '出库失败');
         }
-    } catch (error) {
-        console.error('出库失败:', error);
-        EleMessage.error('出库失败,请重试');
-    } finally {
+    }).finally(() => {
         loading.value = false;
-    }
+    })
+
 };
 
 /** 弹窗打开事件 */

+ 32 - 13
src/views/code/list/index.vue

@@ -5,7 +5,7 @@
         <common-table ref="pageRef" :pageConfig="pageConfig" :columns="columns">
             <template #bookInfo="{ row }">
                 <div class="book-info">
-                    <div class="book-title">{{ row.bookName }}</div>
+                    <div class="book-title" @click="handleClick(row)">{{ row.bookName }}</div>
                     <div class="book-details">
                         <div class="book-detail-item">作者:{{ row.author || '-' }}</div>
                         <div class="book-detail-item">ISBN:{{ row.isbn || '-' }}</div>
@@ -19,15 +19,18 @@
 
             <template #cover="{ row }">
                 <div class="book-cover">
-                    <img :src="row.cover" alt="封面" style="width: 40px; height: 50px; object-fit: cover;" />
+                    <img :src="row.cover" alt="封面" style="width: 60px; height: 80px; object-fit: cover;" />
                 </div>
             </template>
 
             <template #retailPrice="{ row }">
                 <div class="price-cell">
                     <span>{{ row.retailPrice ? `¥${row.retailPrice}` : '-' }}</span>
-                    <el-button type="primary" link size="small" @click="handleEditPrice(row, 'retail')" style="margin-left: 8px;">
-                        <el-icon style="font-size: 18px;"><Edit /></el-icon>
+                    <el-button type="primary" link size="small" @click="handleEditPrice(row, 'retail')"
+                        style="margin-left: 8px;">
+                        <el-icon style="font-size: 18px;">
+                            <Edit />
+                        </el-icon>
                     </el-button>
                 </div>
             </template>
@@ -35,8 +38,11 @@
             <template #wholesalePrice="{ row }">
                 <div class="price-cell">
                     <span>{{ row.wholesalePrice ? `¥${row.wholesalePrice}` : '-' }}</span>
-                    <el-button type="primary" link size="small" @click="handleEditPrice(row, 'wholesale')" style="margin-left: 8px;">
-                        <el-icon style="font-size: 18px;"><Edit /></el-icon>
+                    <el-button type="primary" link size="small" @click="handleEditPrice(row, 'wholesale')"
+                        style="margin-left: 8px;">
+                        <el-icon style="font-size: 18px;">
+                            <Edit />
+                        </el-icon>
                     </el-button>
                 </div>
             </template>
@@ -46,7 +52,7 @@
                     <el-button type="warning" v-permission="'code:activation:out'" link @click="handleViewDetails(row)">
                         出库
                     </el-button>
-                    <el-button type="danger" v-permission="'code:activation:in'" link @click="handleInDetails(row)">
+                    <el-button type="danger" v-permission="'code:activation:inDetails'" link @click="handleInDetails(row)">
                         入库明细
                     </el-button>
                     <el-button type="success" v-permission="'code:activation:outDetails'" link
@@ -59,18 +65,22 @@
 
         <!-- 出库明细弹窗 -->
         <out-detail-modal ref="outDetailModalRef" v-model="outDetailVisible" />
-        
+
         <!-- 入库明细弹窗 -->
         <in-detail-modal ref="inDetailModalRef" v-model="inDetailVisible" />
-        
+
         <!-- 出库操作弹窗 -->
-        <out-stock-modal ref="outStockModalRef" v-model="outStockVisible" @openActivationModal="handleOpenActivationModal" />
-        
+        <out-stock-modal ref="outStockModalRef" v-model="outStockVisible"
+            @openActivationModal="handleOpenActivationModal" />
+
         <!-- 激活码出库单弹窗 -->
         <activation-out-stock-modal ref="activationOutStockModalRef" v-model="activationOutStockVisible" />
-        
+
         <!-- 价格编辑弹窗 -->
         <price-edit-modal ref="priceEditModalRef" v-model="priceEditVisible" @success="handlePriceEditSuccess" />
+
+        <!-- 商品编辑弹窗 -->
+        <booksEdit ref="bookEditRef" />
     </ele-page>
 </template>
 
@@ -86,6 +96,7 @@ import InDetailModal from './components/in-detail-modal.vue';
 import OutStockModal from './components/out-stock-modal.vue';
 import ActivationOutStockModal from './components/activation-out-stock-modal.vue';
 import PriceEditModal from './components/price-edit-modal.vue';
+import booksEdit from '@/views/data/books/components/books-edit.vue';
 
 defineOptions({ name: 'CodeList' });
 
@@ -103,6 +114,13 @@ const outStockModalRef = ref(null);
 const activationOutStockModalRef = ref(null);
 const priceEditModalRef = ref(null);
 
+//编辑图书
+const bookEditRef = ref(null);
+function handleClick(row) {
+    return
+    bookEditRef.value?.handleOpen(row);
+}
+
 /** 表格列配置 */
 const columns = reactive([
     {
@@ -266,10 +284,11 @@ function handleInDetails(row) {
     margin-bottom: 8px;
     font-size: 14px;
     line-height: 1.4;
+    cursor: pointer;
 }
 
 .book-details {
-    font-size: 12px;
+    font-size: 14px;
     color: #666;
     line-height: 1.5;
 }

+ 2 - 2
src/views/code/record/index.vue

@@ -45,10 +45,10 @@
 
             <template #action="{ row }">
                 <div>
-                    <el-button type="primary" link @click="handleViewDetails(row)">
+                    <el-button type="primary" v-permission="'code:activation:detail'" link @click="handleViewDetails(row)">
                         [查看详情]
                     </el-button>
-                    <el-button type="danger" link @click="handleInvalid(row)" v-if="row.type == 1">
+                    <el-button type="danger" v-permission="'code:activation:invalid'" link @click="handleInvalid(row)" v-if="row.type == 1">
                         [作废]
                     </el-button>
                 </div>