Преглед изворни кода

产品的相关接口调用

zhuliu пре 1 година
родитељ
комит
aac8d62870

+ 10 - 0
src/api/myApi/common.js

@@ -0,0 +1,10 @@
+import request from '@/utils/request'
+
+//获取示例文件
+export function getTemplate(params){
+  return request({
+    url:'/xiaoshi-weixinback/template/getTemplate',
+    method:'post',
+    data:params
+  })
+}

+ 3 - 1
src/api/myApi/index.js

@@ -1,10 +1,12 @@
 import * as product from './product'
 import * as category from './category'
 import * as uploadFile from './file'
+import * as common from './common'
 
 
 export default{
   ...product,
   ...category,
-  ...uploadFile
+  ...uploadFile,
+  ...common
 }

+ 44 - 0
src/api/myApi/product.js

@@ -17,3 +17,47 @@ export function addOrUpdateProduct(params){
   })
 }
 
+//添加或更新爆款产品
+export function addOrUpdateHotProduct(params){
+  return request({
+    url:'/xiaoshi-weixinback/product/addOrUpdateHotProduct',
+    method:'post',
+    data:params
+  })
+}
+
+//查询爆款产品详情
+export function queryHotProductDetail(params){
+  return request({
+    url:'/xiaoshi-weixinback/product/queryHotProductDetail',
+    method:'post',
+    params:params
+  })
+}
+
+//上下架爆款产品
+export function updateProductIfShow(params){
+  return request({
+    url:'/xiaoshi-weixinback/product/updateProductIfShow',
+    method:'post',
+    data:params
+  })
+}
+
+//上下架爆款产品
+export function deleteHotProduct(params){
+  return request({
+    url:'/xiaoshi-weixinback/product/deleteHotProduct',
+    method:'post',
+    data:params
+  })
+}
+
+//导入爆款产品
+export function ImportProductBatch(params){
+  return request({
+    url:'/xiaoshi-weixinback/product/ImportProductBatch',
+    method:'post',
+    data:params
+  })
+}

+ 28 - 24
src/views/pms/product/components/ProductDetail.vue

@@ -14,14 +14,17 @@
   import ProductInfoDetail from './ProductInfoDetail';
 
   const defaultProductParam = {
-    id:null,
+    id:null,// 爆款产品id
+    name:'',//爆款产品名称
     description:'',//描述
-    name:'',//产品描述
-    searchCondition:'',//关键词
-    sellPlatform:'',//售卖平台
+    searchCondition:'',//检索条件
     sourceFrom:'',//来源
-    fileGuids:[],//文件列表
-
+    platformLink:'',//平台链接
+    price:'',//价格
+    bestSellingBrand:'',//品牌
+    fileGuids:[],//图片
+    ifShow:false,//是否上架,
+    productCategoryId:null //产品架构id
   };
   export default {
     name: 'ProductDetail',
@@ -34,32 +37,32 @@
     },
     data() {
       return {
-        active: 0,
         productParam: Object.assign({}, defaultProductParam),
-        showStatus: [true, false, false, false]
+      }
+    },
+    computed:{
+      productId(){
+        return this.$route.query.id
       }
     },
     created(){
       if(this.isEdit){
-        getProduct(this.$route.query.id).then(response=>{
-          this.productParam=response.data;
-        });
+        this.getProductDetails()
+      }else {
+        this.productParam = Object.assign({}, defaultProductParam);
       }
     },
     methods: {
-      hideAll() {
-        for (let i = 0; i < this.showStatus.length; i++) {
-          this.showStatus[i] = false;
-        }
-      },
-      prevStep() {
-        if (this.active > 0 && this.active < this.showStatus.length) {
-          this.active--;
-          this.hideAll();
-          this.showStatus[this.active] = true;
+      //获取产品信息
+      getProductDetails(){
+        var params = {
+          id:this.productId
         }
+        this.$api.queryHotProductDetail(params).then(response=>{
+          this.productParam=response.data.data;
+        });
       },
-
+      //提交信息
       finishCommit(isEdit) {
         this.$confirm('是否要提交该产品', '提示', {
           confirmButtonText: '确定',
@@ -67,7 +70,8 @@
           type: 'warning'
         }).then(() => {
           if(isEdit){
-            updateProduct(this.$route.query.id,this.productParam).then(response=>{
+            this.productParam.id = this.productCateId
+            this.$api.addOrUpdateHotProduct(this.productParam).then(response=>{
               this.$message({
                 type: 'success',
                 message: '提交成功',
@@ -76,7 +80,7 @@
               this.$router.back();
             });
           }else{
-            createProduct(this.productParam).then(response=>{
+            this.$api.addOrUpdateHotProduct(this.productParam).then(response=>{
               this.$message({
                 type: 'success',
                 message: '提交成功',

+ 19 - 7
src/views/pms/product/components/ProductInfoDetail.vue

@@ -5,27 +5,34 @@
         <el-cascader
           style="width:100%"
           :props="categoryProp()"
-          v-model="selectProductCateValue"
+          v-model="value.productCategoryId "
           :options="productCateOptions">
         </el-cascader>
       </el-form-item>
       <el-form-item label="产品名称:" prop="name">
         <el-input v-model="value.name" placeholder="请输入产品名称"></el-input>
       </el-form-item>
+      <el-form-item label="是否上架:" prop="name">
+        <el-switch
+          :active-value="true"
+          :inactive-value="false"
+          v-model="value.ifShow">
+        </el-switch>
+      </el-form-item>
       <el-form-item label="产品图:" >
         <myUpload :file-list="files" @on-change="onChange" @on-remove="onRemove" :autoUpload="true"></myUpload>
       </el-form-item>
       <el-form-item label="关键词:">
-        <el-input v-model="value.name" placeholder="请输入关键词"></el-input>
+        <el-input v-model="value.searchCondition" placeholder="请输入关键词"></el-input>
       </el-form-item>
       <el-form-item label="来源:">
-        <el-input v-model="value.name" placeholder="请输入来源"></el-input>
+        <el-input v-model="value.sourceFrom" placeholder="请输入来源"></el-input>
       </el-form-item>
       <el-form-item label="售卖平台链接:">
-        <el-input v-model="value.name" placeholder="请输入售卖平台链接"></el-input>
+        <el-input v-model="value.platformLink" placeholder="请输入售卖平台链接"></el-input>
       </el-form-item>
       <el-form-item label="销冠品牌:">
-        <el-input v-model="value.name" placeholder="请输入销冠品牌"></el-input>
+        <el-input v-model="value.bestSellingBrand" placeholder="请输入销冠品牌"></el-input>
       </el-form-item>
       <el-form-item label="产品介绍:">
         <el-input
@@ -37,9 +44,9 @@
       <el-form-item label="产品价格:">
         <el-input v-model="value.price" placeholder="请输入产品价格"></el-input>
       </el-form-item>
-      <el-form-item label="排序">
+      <!-- <el-form-item label="排序">
         <el-input v-model="value.sort" placeholder="请输入排序"></el-input>
-      </el-form-item>
+      </el-form-item> -->
       <el-form-item style="text-align: center">
         <el-button type="primary" size="medium" @click="submit('productInfoForm')">确认</el-button>
       </el-form-item>
@@ -179,6 +186,11 @@
       },
 
       submit(formName){
+        var guids = this.$commonJS.checkUploadFile(this.files)
+        if(!guids){
+          return false
+        }
+        this.value.fileGuids = guids
         this.$refs[formName].validate((valid) => {
           if (valid) {
             this.$emit('finishCommit');

+ 67 - 127
src/views/pms/product/index.vue

@@ -21,19 +21,19 @@
       <div style="margin-top: 15px">
         <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
           <el-form-item label="输入搜索:">
-            <el-input style="width: 203px" v-model="listQuery.keyword" placeholder="产品名称"></el-input>
+            <el-input style="width: 203px" v-model="listQuery.name" placeholder="产品名称"></el-input>
           </el-form-item>
           <el-form-item label="产品分类:">
             <el-cascader
               clearable
               :props="categoryProp()"
-              v-model="selectProductCateValue"
+              v-model="listQuery.productCategoryIds "
               :options="productCateOptions">
             </el-cascader>
           </el-form-item>
 
           <el-form-item label="上架状态:">
-            <el-select v-model="listQuery.publishStatus" placeholder="全部" clearable>
+            <el-select v-model="listQuery.ifShow" placeholder="全部" clearable>
               <el-option
                 v-for="item in publishStatusOptions"
                 :key="item.value"
@@ -89,8 +89,8 @@
             <p>上架:
               <el-switch
                 @change="handlePublishStatusChange(scope.$index, scope.row)"
-                :active-value="1"
-                :inactive-value="0"
+                :active-value="true"
+                :inactive-value="false"
                 v-model="scope.row.publishStatus">
               </el-switch>
             </p>
@@ -102,14 +102,14 @@
                 v-model="scope.row.newStatus">
               </el-switch>
             </p> -->
-            <p>推荐:
+            <!-- <p>推荐:
               <el-switch
                 @change="handleRecommendStatusChange(scope.$index, scope.row)"
                 :active-value="1"
                 :inactive-value="0"
                 v-model="scope.row.recommandStatus">
               </el-switch>
-            </p>
+            </p> -->
           </template>
         </el-table-column>
         <el-table-column label="排序" width="100" align="center">
@@ -181,14 +181,13 @@
 <script>
 
   const defaultListQuery = {
-    keyword: null,
+    name: null,
     current: 1,
     size: 10,
-    publishStatus: null,
-    verifyStatus: null,
-    productSn: null,
-    productCategoryId: null,
-    brandId: null
+    ifShow: null,
+    sourceFrom: null,
+    productCategoryIds : null,
+    bestSellingBrand : null
   };
   export default {
     name: "productList",
@@ -205,29 +204,9 @@
             value: "publishOff"
           },
           {
-            label: "设为推荐",
-            value: "recommendOn"
-          },
-          {
-            label: "取消推荐",
-            value: "recommendOff"
-          },
-          // {
-          //   label: "设为新品",
-          //   value: "newOn"
-          // },
-          // {
-          //   label: "取消新品",
-          //   value: "newOff"
-          // },
-          // {
-          //   label: "转移到分类",
-          //   value: "transferCategory"
-          // },
-          // {
-          //   label: "移入回收站",
-          //   value: "recycle"
-          // }
+            label: "删除",
+            value: "delete"
+          }
         ],
         operateType: null,
         listQuery: Object.assign({}, defaultListQuery),
@@ -238,10 +217,10 @@
         multipleSelection: [],
         productCateOptions: [],
         publishStatusOptions: [{
-          value: 1,
+          value: true,
           label: '上架'
         }, {
-          value: 0,
+          value: false,
           label: '下架'
         }],
 
@@ -252,14 +231,14 @@
       // this.getProductCateList();
     },
     watch: {
-      selectProductCateValue: function (newValue) {
-        if (newValue != null && newValue.length == 2) {
-          this.listQuery.productCategoryId = newValue[1];
-        } else {
-          this.listQuery.productCategoryId = null;
-        }
+      // selectProductCateValue: function (newValue) {
+      //   if (newValue != null && newValue.length == 2) {
+      //     this.listQuery.productCategoryId = newValue[1];
+      //   } else {
+      //     this.listQuery.productCategoryId = null;
+      //   }
 
-      }
+      // }
     },
     filters: {
 
@@ -345,34 +324,21 @@
           for(let i=0;i<this.multipleSelection.length;i++){
             ids.push(this.multipleSelection[i].id);
           }
+
           switch (this.operateType) {
-            case this.operates[0].value:
-              this.updatePublishStatus(1,ids);
+            case 'publishOn'://产品上架
+              this.updatePublishStatus(true,ids);
               break;
-            case this.operates[1].value:
-              this.updatePublishStatus(0,ids);
+            case 'publishOff'://产品下架
+              this.updatePublishStatus(false,ids);
               break;
-            case this.operates[2].value:
-              this.updateRecommendStatus(1,ids);
-              break;
-            case this.operates[3].value:
-              this.updateRecommendStatus(0,ids);
-              break;
-            case this.operates[4].value:
-              this.updateNewStatus(1,ids);
-              break;
-            case this.operates[5].value:
-              this.updateNewStatus(0,ids);
-              break;
-            case this.operates[6].value:
-              break;
-            case this.operates[7].value:
-              this.updateDeleteStatus(1,ids);
+            case 'delete'://删除
+              this.updateDeleteStatus(ids);
               break;
+
             default:
               break;
           }
-          this.getList();
         });
       },
       //改变页大小
@@ -390,21 +356,26 @@
       handleSelectionChange(val) {
         this.multipleSelection = val;
       },
-      //修改产品状态
+      //修改产品状态(上架/下架)
       handlePublishStatusChange(index, row) {
         let ids = [];
         ids.push(row.id);
         this.updatePublishStatus(row.publishStatus, ids);
       },
-      handleNewStatusChange(index, row) {
-        let ids = [];
-        ids.push(row.id);
-        this.updateNewStatus(row.newStatus, ids);
-      },
-      handleRecommendStatusChange(index, row) {
-        let ids = [];
-        ids.push(row.id);
-        this.updateRecommendStatus(row.recommandStatus, ids);
+      //修改产品状态
+      updatePublishStatus(publishStatus, ids) {
+        var params = {
+          ids:ids,
+          ifShow:publishStatus
+        }
+        updatePublishStatus(params).then(response => {
+          this.$message({
+            message: '修改成功',
+            type: 'success',
+            duration: 1000
+          });
+          this.getList()
+        });
       },
 
       //重置查询条件
@@ -421,59 +392,14 @@
         }).then(() => {
           let ids = [];
           ids.push(row.id);
-          this.updateDeleteStatus(1,ids);
-        });
-      },
-      //更新产品
-      handleUpdateProduct(index,row){
-        this.$router.push({path:'/pms/updateProduct',query:{id:row.id}});
-      },
-      //查看产品
-      handleShowProduct(index,row){
-        console.log("handleShowProduct",row);
-      },
-      //修改产品状态
-      updatePublishStatus(publishStatus, ids) {
-        let params = new URLSearchParams();
-        params.append('ids', ids);
-        params.append('publishStatus', publishStatus);
-        updatePublishStatus(params).then(response => {
-          this.$message({
-            message: '修改成功',
-            type: 'success',
-            duration: 1000
-          });
-        });
-      },
-      updateNewStatus(newStatus, ids) {
-        let params = new URLSearchParams();
-        params.append('ids', ids);
-        params.append('newStatus', newStatus);
-        updateNewStatus(params).then(response => {
-          this.$message({
-            message: '修改成功',
-            type: 'success',
-            duration: 1000
-          });
-        });
-      },
-      updateRecommendStatus(recommendStatus, ids) {
-        let params = new URLSearchParams();
-        params.append('ids', ids);
-        params.append('recommendStatus', recommendStatus);
-        updateRecommendStatus(params).then(response => {
-          this.$message({
-            message: '修改成功',
-            type: 'success',
-            duration: 1000
-          });
+          this.updateDeleteStatus(ids);
         });
       },
       //删除产品
-      updateDeleteStatus(deleteStatus, ids) {
-        let params = new URLSearchParams();
-        params.append('ids', ids);
-        params.append('deleteStatus', deleteStatus);
+      updateDeleteStatus( ids) {
+        var params = {
+          ids:ids
+        }
         updateDeleteStatus(params).then(response => {
           this.$message({
             message: '删除成功',
@@ -482,7 +408,21 @@
           });
         });
         this.getList();
-      }
+      },
+
+
+      //更新产品
+      handleUpdateProduct(index,row){
+        this.$router.push({path:'/pms/updateProduct',query:{id:row.id}});
+      },
+      //查看产品
+      handleShowProduct(index,row){
+        console.log("handleShowProduct",row);
+      },
+
+
+
+
     }
   }
 </script>

+ 4 - 3
src/views/pms/productCate/components/ProductCateDetail.vue

@@ -1,6 +1,7 @@
 <template>
   <el-card class="form-container" shadow="never">
     <el-form :model="productCate"
+              clearable
              :rules="rules"
              ref="productCateFrom"
              label-width="150px">
@@ -155,9 +156,9 @@
           }
           this.$api.queryCategory(params).then(response => {
             let list = response.data.data;
-            if(parentId == null){
-              list.unshift({id: null, name: '无上级类别'})
-            }
+            // if(parentId == null){
+            //   list.unshift({id: 0, name: '无上级类别'})
+            // }
             // this.productCateOptions = list
             fn(list)
           });

+ 19 - 19
src/views/pms/productCate/index.vue

@@ -24,7 +24,7 @@
         <el-table-column label="级别" width="100" align="center">
           <template slot-scope="scope">{{scope.row.level | levelFilter}}</template>
         </el-table-column>
-        <el-table-column label="是否显示" width="100" align="center">
+        <!-- <el-table-column label="是否显示" width="100" align="center">
           <template slot-scope="scope">
             <el-switch
               @change="handleShowStatusChange(scope.$index, scope.row)"
@@ -33,7 +33,7 @@
               v-model="scope.row.showStatus">
             </el-switch>
           </template>
-        </el-table-column>
+        </el-table-column> -->
         <el-table-column label="排序" width="100" align="center">
           <template slot-scope="scope">{{scope.row.sort }}</template>
         </el-table-column>
@@ -143,20 +143,11 @@
         this.getList();
       },
       //是否显示
-      handleShowStatusChange(index, row) {
-        let data = new URLSearchParams();
-        let ids=[];
-        ids.push(row.id)
-        data.append('ids',ids);
-        data.append('showStatus',row.showStatus);
-        updateShowStatus(data).then(response=>{
-          this.$message({
-            message: '修改成功',
-            type: 'success',
-            duration: 1000
-          });
-        });
-      },
+      // handleShowStatusChange(index, row) {
+      //   let ids=[];
+      //   ids.push(row.id)
+
+      // },
       //查看下级
       handleShowNextLevel(index, row) {
         this.$router.push({path: '/pms/productCate', query: {parentId: row.id}})
@@ -172,15 +163,24 @@
           cancelButtonText: '取消',
           type: 'warning'
         }).then(() => {
-          deleteProductCate(row.id).then(response => {
+          this.del([row.id])
+        });
+      },
+      //删除
+      del(ids){
+        var params = {
+          ids:ids
+        }
+        this.$api.deleteProductCate(params).then(res=>{
+          if(res.code == 200){
             this.$message({
               message: '删除成功',
               type: 'success',
               duration: 1000
             });
             this.getList();
-          });
-        });
+          }
+        })
       }
     },
     filters: {