Browse Source

优惠券添加门店承担比例只能为整数、优惠券适用范围新增指定范围选项、商品列表增加导出

DELL 3 years ago
parent
commit
5516bb55bf

+ 9 - 0
src/api/business/goods.js

@@ -50,3 +50,12 @@ export function setTableData(data) {
   })
 }
 
+// 导出商品信息
+export function salesiteGoodsExport( data) {
+  return request({
+    url: '/api/v1/mp/admin/goods/export',
+    method: 'post',
+    data: data,
+  })
+}
+

+ 41 - 32
src/views/business/coupon/add.vue

@@ -63,41 +63,46 @@
               <el-radio :label="0">所有盲票</el-radio>
               <el-radio :label="3">线上盲票</el-radio>
               <el-radio :label="4">线下盲票</el-radio>
-<!--              <el-radio :label="1">指定盲票</el-radio>-->
+              <el-radio :label="1">指定盲票</el-radio>
             </el-radio-group>
           </el-form-item>
         </el-form>
-        <div v-if="addData.useArea === 1" style="padding: 0 20px">
-          <el-table :data="addData.ticketBoxList" height="300px">
-            <el-table-column label="盲票图片" prop="picUrl" align="center" width="80">
-              <template slot-scope="{row}">
-                <a target="_black" v-if="row.picUrl && row.picUrl.split(',').length > 0" :href="`${IMG_URL + row.picUrl}`"><img :src="`${IMG_URL + row.picUrl.split(',')[0]}`" style="max-height: 37px;max-width: 54px"></a>
-                <span v-else>-</span>
-              </template>
-            </el-table-column>
-            <el-table-column label="盲票名称" prop="title" />
-            <el-table-column label="盲票面值" prop="facePrice" />
-            <el-table-column label="盲票类型" prop="type">
-              <template slot-scope="{row}">
-                {{ JSON.parse(row.type).desc }}
-              </template>
-            </el-table-column>
-            <el-table-column label="盲票状态" prop="status">
-              <template slot-scope="{row}">
-                <el-tag :type="JSON.parse(row.status).value === 'on' ? 'success' : 'info'">{{ JSON.parse(row.status).desc }}</el-tag>
-              </template>
-            </el-table-column>
-            <el-table-column v-if="!readonly" prop="date" label="操作">
-              <template slot-scope="{ $index }">
-                <el-button type="text" class="del" @click="addData.ticketBoxList.splice($index, 1)">删除</el-button>
-              </template>
-            </el-table-column>
-          </el-table>
-          <br>
-          <el-button v-if="!readonly" type="primary" size="small" plain @click="$refs.select.show()">选择盲票</el-button> <span style="margin-left: 10px">已选盲票({{ addData.ticketBoxList.length }})</span>
-        </div>
       </el-col>
     </el-row>
+    <el-row :gutter="18">
+     <el-col :span="18" :offset="2">
+       <div v-if="addData.useArea === 1" style="padding: 0 20px">
+         <el-table :data="addData.ticketBoxList" height="300px">
+           <el-table-column label="盲票图片" prop="picUrl" align="center">
+             <template slot-scope="{row}">
+               <a target="_black" v-if="row.picUrl && row.picUrl.split(',').length > 0" :href="`${IMG_URL + row.picUrl}`"><img :src="`${IMG_URL + row.picUrl.split(',')[0]}`" style="max-height: 37px;max-width: 54px"></a>
+               <span v-else>-</span>
+             </template>
+           </el-table-column>
+           <el-table-column label="盲票名称" prop="title" />
+           <el-table-column label="盲票面值" prop="facePrice" />
+           <el-table-column label="盲票类型" prop="type">
+             <template slot-scope="{row}">
+               {{ JSON.parse(row.type).desc }}
+             </template>
+           </el-table-column>
+           <el-table-column label="盲票状态" prop="status">
+             <template slot-scope="{row}">
+               <el-tag :type="JSON.parse(row.status).value === 'on' ? 'success' : 'info'">{{ JSON.parse(row.status).desc }}</el-tag>
+             </template>
+           </el-table-column>
+           <el-table-column v-if="!readonly" prop="date" label="操作">
+             <template slot-scope="{ $index }">
+               <el-button type="text" class="del" @click="addData.ticketBoxList.splice($index, 1)">删除</el-button>
+             </template>
+           </el-table-column>
+         </el-table>
+         <br>
+         <el-button v-if="!readonly" type="primary" size="small" plain @click="selectShow = true">选择盲票</el-button> <span style="margin-left: 10px">已选盲票({{ addData.ticketBoxList.length }})</span>
+       </div>
+     </el-col>
+    </el-row>
+
     <el-row v-if="!readonly">
       <el-col :span="23" style="text-align: center">
         <el-button type="info" @click="$router.go(-1)">取消</el-button>
@@ -106,7 +111,7 @@
     </el-row>
 
     <!-- 弹出层 -->
-    <SelectTicket ref="select" v-model="addData.ticketBoxList" />
+    <SelectTicket :select-show="selectShow" :value="addData.ticketBoxList" @close="selectShow = false" @selectTicket="selectTicket"   v-if="selectShow"/>
   </div>
 </template>
 <script>
@@ -136,6 +141,7 @@ export default {
         minOrderAmt:0,
       },
       addIng: false,
+      selectShow: false,
       rules: {
         title: [{ required: true, message: '请输入券名称', trigger: 'blur' }],
         type: [{ required: true, message: '请输入券类型', trigger: 'blur' }],
@@ -149,7 +155,7 @@ export default {
         ],
         channelSharedRate: [
           { required: true, message: '请输入门店默认承担比例', trigger: 'blur' },
-          { pattern: /^100$|^(\d|[1-9]\d)(\.\d+)*$/, message: "请输入正确的百分比数字", trigger: ["blur", "change"] }
+          { pattern: /^([1-9]\d*)$/, message: "请输入正确的百分比数字", trigger: ["blur", "change"] }
         ],
         minOrderAmt: [
           { required: true, message: '请输入最低消费金额', trigger: 'blur' },
@@ -179,6 +185,9 @@ export default {
     }
   },
   methods: {
+    selectTicket(select) {
+      this.addData.ticketBoxList = this.addData.ticketBoxList.concat(select)
+    },
     update() {
       if (this.addData.type == 1) {
         if(this.addData.useArea !== 0 && this.addData.useArea !== 1 && this.addData.useArea !== 3 && this.addData.useArea !== 4) {

+ 22 - 12
src/views/business/coupon/components/selectTicket.vue

@@ -1,5 +1,5 @@
 <template>
-  <el-dialog title="选择盲票" :visible.sync="selectShow" width="800px" :close-on-click-modal="false" :destroy-on-close="true">
+  <el-dialog title="选择盲票" :visible.sync="selectShow" min-width="800px" :before-close="close">
     <el-form :model="queryParams" ref="queryForm" label-width="80px" size="small">
       <el-row :gutter="10">
         <el-col :span="7">
@@ -16,6 +16,8 @@
           <el-form-item label="盲票类型">
             <el-select v-model="queryParams.type" placeholder="请选择盲票类型" clearable>
               <el-option label="全部" value="" />
+              <el-option label="线上票" value="online" />
+              <el-option label="线下票" value="offline" />
             </el-select>
           </el-form-item>
         </el-col>
@@ -38,7 +40,7 @@
     </el-form>
     <el-table v-loading="loading" :data="tableData" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" />
-      <el-table-column label="盲票ID" prop="boxId" width="80" />
+      <el-table-column label="盲票ID" prop="boxId" min-width="90" />
       <el-table-column label="盲票图片" prop="picUrl" align="center" width="80">
         <template slot-scope="{row}">
           <a target="_black" v-if="row.picUrl && row.picUrl.split(',').length > 0" :href="`${IMG_URL + row.picUrl}`"><img :src="`${IMG_URL + row.picUrl.split(',')[0]}`" style="max-height: 37px;max-width: 54px"></a>
@@ -60,7 +62,7 @@
     </el-table>
     <pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList()" />
     <span slot="footer">
-      <el-button type="info" plain @click="selectShow = false">取消</el-button>
+      <el-button type="info" plain @click="close">取消</el-button>
       <el-button type="primary" @click="update">确定</el-button>
     </span>
   </el-dialog>
@@ -74,23 +76,28 @@ export default {
     value: {
       type: Array,
       default: []
-    }
+    },
+    selectShow: {
+      type: Boolean,
+      default: false,
+    },
   },
   data() {
     return {
       IMG_URL: publicFileGetUrl,
       loading: false,
-      selectShow: false,
       tableData: [],
       queryParams: {},
       total: 0,
       selection: []
     }
   },
+  created() {
+    this.getTicketList();
+  },
   methods: {
-    show() {
+    getTicketList() {
       this.getList(true)
-      this.selectShow = true
       this.selection = this.value
       // this.$refs.table.toggleRowSelection(this.selection)
     },
@@ -100,13 +107,13 @@ export default {
       }
       this.loading = true
       if (reset) {
-        this.queryParams = { pageNum: 1, pageSize: 20 }
+        this.queryParams = { pageNum: 1, pageSize: 10 }
       }
       getTicketList('pageNum='+this.queryParams.pageNum + '&pageSize='+this.queryParams.pageSize+'&', this.queryParams).then(res => {
         this.loading = false
         if (res.code === 0) {
           this.tableData = res.rows
-          
+
           this.total = res.total
         }
       }).catch(() => {
@@ -117,9 +124,12 @@ export default {
       this.selection = val
     },
     update() {
-      this.$emit('input', this.selection)
-      this.selectShow = false
-    }
+      this.$emit('selectTicket', this.selection);
+      this.close()
+    },
+    close() {
+      this.$emit("close");
+    },
   }
 }
 </script>

+ 37 - 2
src/views/business/goods/index.vue

@@ -75,14 +75,25 @@
       </el-form-item>
     </el-form>
     <el-row :gutter="10" class="mb8">
-      <el-col :span="10">
+      <el-col :span="1.5">
         <el-button v-hasPermi="['business:goods:add']" type="primary" icon="el-icon-plus" size="mini" @click="$router.push({ name: 'GoodsAdd' })">添加商品</el-button>
         <!-- <el-button v-hasPermi="['business:goods:on']" type="primary" plain size="mini">上架</el-button> -->
         <!-- <el-button v-hasPermi="['business:goods:off']" type="primary" plain size="mini">下架</el-button> -->
         <!-- <el-button v-hasPermi="['business:goods:remove']" type="danger" plain size="mini">删除</el-button> -->
+      </el-col>
+        <el-col :span="1.5">
+          <el-button
+            type="infor"
+            plain
+            icon="el-icon-download"
+            size="mini"
+            @click="handleOrderExport"
+            v-hasPermi="['business:goods:export']"
+          >导出商品</el-button>
       </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
+
     <el-table v-loading="loading" :data="tableData"  @sort-change="sortChannelId">
       <el-table-column label="商品ID" prop="goodsId" width="60" />
       <el-table-column label="商品图片" prop="picUrl" align="center">
@@ -142,7 +153,7 @@
 </template>
 <script>
 import { publicFileGetUrl } from "@/api/common"
-import { getGoodsList, delGoods, setGoodsStatus, setTableData} from '@/api/business/goods'
+import { getGoodsList, delGoods, setGoodsStatus, setTableData, salesiteGoodsExport} from '@/api/business/goods'
 import { goodsCategoryListTree } from '@/api/business/category'
 import { goodsTagItems } from '@/api/business/tag'
 import { accMul } from '@/utils/util'
@@ -270,6 +281,30 @@ export default {
       })
     },
 
+    // 导出商品
+    handleOrderExport() {
+      this.$confirm("是否确认导出商品?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          this.vloading = this.$loading({
+            lock: true,
+            text: "正在导出商品.....",
+            background: "rgba(0, 0, 0, 0.7)",
+          });
+          return salesiteGoodsExport(this.queryParams);
+        })
+        .then((response) => {
+          this.vloading.close();
+          this.download(response.msg);
+        })
+        .catch(() => {
+          this.vloading.close();
+        });
+    },
+
     del(item) {
       this.$confirm(`确认删除商品 “${item.title}” 吗?`, '删除商品', {
         confirmButtonText: '确定',