Browse Source

添加复制商品按钮,添加供货价字段

pangqijun 1 year ago
parent
commit
af657f3a96
2 changed files with 35 additions and 16 deletions
  1. 11 0
      src/api/mall/storegoodsinfo.js
  2. 24 16
      src/views/store/storegoods/index.vue

+ 11 - 0
src/api/mall/storegoodsinfo.js

@@ -60,6 +60,17 @@ export const audit = (param) => {
   })
 }
 
+
+export const copy = (id) => {
+  return request({
+    url: '/api/mall/goodsinfo/copy',
+    method: 'post',
+    params: {
+      id
+    }
+  })
+}
+
 export const modifyCategory = (ids, categoryIds) => {
   return request({
     url: '/api/mall/goodsinfo/modifyCategory',

+ 24 - 16
src/views/store/storegoods/index.vue

@@ -46,6 +46,11 @@
             @click="modifyGoodsState(scope.row.id, 1)"
         >上架
         </el-button>
+        <el-button
+            type="text"
+            size="small"
+            @click="copyGoods(scope.row.id)"
+        >复制</el-button>
       </template>
 
     </avue-crud>
@@ -81,7 +86,7 @@
 
 
 <script>
-  import {getList, getDetail, add, update, remove, modifyState, audit} from "@/api/mall/storegoodsinfo";
+  import {getList, getDetail, add, update, remove, modifyState, audit, copy} from "@/api/mall/storegoodsinfo";
   import {mapGetters} from "vuex";
   import {getByParentId} from "../../../api/mall/categoryinfo";
 
@@ -113,7 +118,7 @@
             {
               label: "商品编号",
               search: true,
-              prop: "id",
+              prop: "goodsNo",
               overHidden: true,
               addDisplay: false,
               editDisplay: false,
@@ -121,7 +126,7 @@
               width: 160
             },
             {
-              label: "商品封面",
+              label: "缩略图",
               width: 80,
               prop: "goodsCover",
               addDisplay: false,
@@ -144,7 +149,6 @@
             {
               label: "规格",
               prop: "goodsSpec",
-              editDisplay: false,
               rules: [{
                 required: true,
                 message: "请输入规格",
@@ -213,11 +217,6 @@
               prop: "brandId",
               hide: true,
               search: true,
-              rules: [{
-                required: true,
-                message: "请选择品牌",
-                trigger: "blur"
-              }],
               type: "select",
               remote: true,
               dicUrl: "/api/mall/brandsinfo/getByName?brandName={{key}}",
@@ -240,8 +239,8 @@
             //   },{ validator: validatePass, trigger: 'blur' }],
             // },
             {
-              label: "价",
-              prop: "discountPrice",
+              label: "供货价",
+              prop: "costPrice",
               precision: 2,
               type: "number",
               formatter:(val,value)=>{
@@ -249,7 +248,7 @@
               },
               rules: [{
                 required: true,
-                message: "请输入价",
+                message: "请输入供货价",
                 trigger: "blur"
               }],
             },
@@ -350,14 +349,14 @@
               editDisabled: false,
             },
             {
-              label: '商品封面',
+              label: '商品缩略图',
               prop: 'uploadCover',
               type: 'upload',
               listType: 'picture-img',
               loadText: '上传中,请稍等',
               accept: 'image/png, image/jpeg',
-              fileSize: 1024,
-              tip: '只能上传jpg/png文件,且不超过1M',
+              fileSize: 500,
+              tip: '只能上传jpg/png文件,且不超过500kb',
               span: 24,
               hide: true,
               propsHttp: {
@@ -367,7 +366,7 @@
               action: "/api/blade-resource/oss/endpoint/put-file-attach"
             },
             {
-              label: '商品轮播图',
+              label: '商品图',
               prop: 'slideshowList',
               type: 'upload',
               dataType: 'array',
@@ -740,6 +739,15 @@
           loading();
           console.log(error);
         });
+      },
+      copyGoods(goodsId) {
+        copy(goodsId).then(res => {
+          this.$message({
+            type: "success",
+            message: "复制成功"
+          });
+          this.onLoad(this.page);
+        })
       }
     }
   };