瀏覽代碼

2024.07.13
- 商品管理页对接查询代金券列表接口;

zweiqin 9 月之前
父節點
當前提交
b74f18a939
共有 2 個文件被更改,包括 27 次插入15 次删除
  1. 4 4
      src/views/commodity/commoditySystem/addComponent.vue
  2. 23 11
      src/views/commodity/commoditySystem/index.vue

+ 4 - 4
src/views/commodity/commoditySystem/addComponent.vue

@@ -99,7 +99,7 @@
           <el-table-column label="商品绑定的代金券">
             <template slot-scope="scope">
               <el-select v-model="scope.row.voucherId" placeholder="请选择商品绑定的代金券">
-                <el-option v-for="item in voucherList" :key="item.id" :label="item.voucherName" :value="item.id">
+                <el-option v-for="item in voucherList" :key="item.id" :label="`${item.voucherName}(${item.id})`" :value="item.id">
                 </el-option>
               </el-select>
             </template>
@@ -240,7 +240,7 @@
                 v-model="scope.row.presenterVoucher" :controls="false" :max="scope.row.price" :min="0"
                 :precision="6"
                 :step="1" style="width: auto;"
-              /> -->
+                /> -->
               <el-input-number
                 v-model="scope.row.presenterVoucher" :controls="false" :min="0"
                 :precision="6"
@@ -263,14 +263,14 @@
                 <el-dropdown size="mini" split-button type="primary" @command="(e) => $emit('syncVoucherId', e)">
                   统一选择
                   <el-dropdown-menu slot="dropdown">
-                    <el-dropdown-item v-for="item in voucherList" :key="item.id" :command="item.id">{{ item.voucherName }}</el-dropdown-item>
+                    <el-dropdown-item v-for="item in voucherList" :key="item.id" :command="item.id">{{ `${item.voucherName}(${item.id})` }}</el-dropdown-item>
                   </el-dropdown-menu>
                 </el-dropdown>
               </div>
             </template>
             <template slot-scope="scope">
               <el-select v-model="scope.row.voucherId" placeholder="请选择商品绑定的代金券">
-                <el-option v-for="item in voucherList" :key="item.id" :label="item.voucherName" :value="item.id">
+                <el-option v-for="item in voucherList" :key="item.id" :label="`${item.voucherName}(${item.id})`" :value="item.id">
                 </el-option>
               </el-select>
             </template>

+ 23 - 11
src/views/commodity/commoditySystem/index.vue

@@ -177,6 +177,7 @@
 import CommAdd from '@/views/commodity/commoditySystem/addCommodity.vue'
 import { getBtnList, getToken, getShopId } from '@/utils/auth'
 import { uploadUrl } from '@/utils/request'
+import { getAllPlatformVoucher } from '@/api/voucherManagement/voucherOperation'
 import {
   getClassifyGetAll,
   getClassifyDelete,
@@ -241,17 +242,28 @@ export default {
       }
     }
   },
-  created() {
-    getVoucher().then((res) => { // 获取可选的代金券,用于创建和修改商品时定义代金券的使用规则
-      this.voucherList = Array.isArray(res.data) ? res.data : typeof res.data === 'number' && res.data ? [ { id: res.data, voucherName: res.data } ] : []
-      this.voucherList.push({
-        voucherName: '不使用代金券',
-        updateTime: '123123123123',
-        ratio: 'xxx',
-        enabled: '666',
-        id: 0,
-        desc: '不支持代金券'
-      })
+  async created() {
+    // getVoucher().then((res) => { // 获取可选的代金券,用于创建和修改商品时定义代金券的使用规则
+    //   this.voucherList = Array.isArray(res.data) ? res.data : typeof res.data === 'number' && res.data ? [ { id: res.data, voucherName: res.data } ] : []
+    //   this.voucherList.push({
+    //     voucherName: '不使用代金券',
+    //     updateTime: '123123123123',
+    //     ratio: 'xxx',
+    //     enabled: '666',
+    //     id: 0,
+    //     desc: '不支持代金券'
+    //   })
+    // })
+    const res = await getAllPlatformVoucher({ page: 1, pageSize: 9999 })
+    this.voucherList = res.data.list.map((item) => ({
+      voucherName: item.voucherName,
+      id: item.platformVoucherId,
+      desc: item.desc
+    }))
+    this.voucherList.push({
+      voucherName: '不使用代金券',
+      id: 0,
+      desc: '不支持代金券'
     })
   },
   mounted() {