zory 3 tygodni temu
rodzic
commit
2ae1817fd1
2 zmienionych plików z 76 dodań i 3 usunięć
  1. 47 0
      src/api/model/goods.js
  2. 29 3
      src/views/merchant/goods/add.vue

+ 47 - 0
src/api/model/goods.js

@@ -0,0 +1,47 @@
+import config from "@/config";
+import http from "@/utils/request";
+
+export default {
+    list: {
+        url: `${config.API_URL}/store/list`,
+        name: "-",
+        get: async function (data = {}) {
+            return await http.get(this.url, data);
+        },
+    },
+    save: {
+        url: `${config.API_URL}/store/save`,
+        name: "-",
+        post: async function (data = {}) {
+            return await http.post(this.url, data);
+        },
+    },
+    edit: {
+        url: `${config.API_URL}/store/edit`,
+        name: "-",
+        post: async function (data = {}) {
+            return await http.post(this.url, data);
+        },
+    },
+    batch: {
+        url: `${config.API_URL}/store/batch`,
+        name: "-",
+        post: async function (data = {}) {
+            return await http.post(this.url, data);
+        },
+    },
+    sync: {
+        url: `${config.API_URL}/store/sync`,
+        name: "-",
+        get: async function (data = {}) {
+            return await http.get(this.url, data);
+        },
+    },
+    del: {
+        url: `${config.API_URL}/store/del`,
+        name: "-",
+        post: async function (data = {}) {
+            return await http.post(this.url, data);
+        },
+    },
+}

+ 29 - 3
src/views/merchant/goods/add.vue

@@ -2,7 +2,12 @@
     <el-container>
         <el-main>
             <el-form ref="dialogForm" :model="formData" :rules="rules" label-width="100px" label-position="top">
-                <el-card shadow="never" header="基础信息"></el-card>
+                <el-card shadow="never" header="基础信息">
+                    <el-form-item label="商品品类" prop="category">
+                        <el-cascader v-model="formData.category" :options="categoryData" :props="deptsProps" clearable style="width: 100%;" />
+                        <div class="el-form-item-msg"></div>
+                    </el-form-item>
+                </el-card>
             </el-form>
         </el-main>
         <el-footer style="text-align: center;">
@@ -18,12 +23,33 @@ export default {
         return {
             isSaveing:false,
             formData:{},
-            rules:{}
+            rules:{},
+            deptsProps:{
+                value: "category_id",
+                label: "name"
+            },
+            categoryData:[]
         }
     },
+    created(){
+        this.getData()
+    },
     methods: {
+        async getData(){
+            var resp = await this.$API.category.list.get();
+            if (resp.code == 0) {
+                return this.$message.error(resp.msg)
+            }
+            this.categoryData = resp.data;
+        },
         reback(){
-            this.$router.go(-1)
+            this.$confirm(`确定要退出添加商品吗?`, '提示', {
+                type: 'warning'
+            }).then(() => {
+                this.$router.go(-1)
+            }).catch(() => {
+
+            })
         },
         submit(){