瀏覽代碼

2022-9-24 11:00

codeMan 2 年之前
父節點
當前提交
2ae31e0c04

+ 51 - 1
src/HDrpManagement/ProductGroupMag/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div>
     <div class="container normal-panel normal-margin">
-      <add></add>
+      <add type="add" @addSuccess="addSuccess" :productData="productList" :brandData="brandList"></add>
     </div>
     <div class="container normal-panel">
       <list></list>
@@ -13,10 +13,60 @@
 import list from './modules/list'
 
 import add from './modules/add'
+import { log } from '@antv/g2plot/lib/utils'
 export default {
   components:{
     list,
     add
+  },
+  data() {
+    return {
+      /* 商品列表数据 */
+      productList:'',
+      /* 品牌列表数据 */
+      brandList:'',
+    }
+  },
+  created() {
+    this.getProductList()
+    this.getBrandList()
+  },
+  methods: {
+    /* 可选择的商品列表 */
+    async getProductList() {
+      let res = await this.$api.requested({
+          "id": "20220923112503",
+          "version":1,
+          "content": {
+            "nocache":true,
+            "sa_itemgroupid":0,
+            "where":{
+                "condition":""
+            }
+          }
+      })
+      this.productList = res.data
+      console.log(this.productList,'商品');
+      
+    },
+    /* 可选择的品牌列表 */
+    async getBrandList() {
+      let res = await this.$api.requested({
+        "id": "20220922085103",
+        "version":1,
+        "content": {
+          "nocache":true,
+          "where":{
+              "condition":""
+          }
+        }
+      })
+      this.brandList = res.data
+      console.log(this.brandList,'品牌');
+    },
+    /* 新增/编辑成功 */
+    addSuccess() {
+    }
   }
 }
 

+ 129 - 3
src/HDrpManagement/ProductGroupMag/modules/add.vue

@@ -1,12 +1,138 @@
 <template>
-  <div>add</div>
+  <div>
+    <el-button type="primary" size="small" @click="dialogTableVisible=true" v-if="type == 'add'">新增产品组</el-button>
+    <el-button type="text" size="small" @click="editBtn" v-else>编辑</el-button>
+    <el-dialog title="新增产品" :visible.sync="dialogTableVisible" width="30%">
+      <el-row :gutter="20">
+        <el-form label-position="right" ref="form" :rules="rules" inline label-width="100px" :model="form" size="small">
+          <el-col :span="24">
+            <el-form-item label="产品组名称" prop="groupname">
+              <el-input v-model="form.groupname" placeholder="请输入商品组名称"></el-input>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="品牌" prop="sa_brandid">
+              <el-select v-model="form.sa_brandid" placeholder="请选择品牌">
+                <el-option
+                  v-for="item in brandData"
+                  :key="item.sa_brandid"
+                  :label="item.brandname"
+                  :value="item.sa_brandid"
+                  size="small">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="商品" prop="itemno">
+              <el-select v-model="form.itemno" placeholder="请选择商品">
+                <el-option
+                  v-for="item in productData"
+                  :key="item.itemno"
+                  :label="item.itemname"
+                  :value="item.itemno"
+                  size="small">
+                </el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span="24">
+            <el-form-item label="自定义标签" prop="tag">
+              <!-- <el-input v-model="form.tag"></el-input> -->
+            </el-form-item>
+          </el-col>
+        </el-form>
+      </el-row>
+      <span slot="footer" class="dialog-footer">
+        <div>
+          <el-button @click="dialogTableVisible = false" size="small">取 消</el-button>
+          <el-button type="primary" @click="submit" size="small">确 定</el-button>
+        </div>
+      </span>
+    </el-dialog>
+  </div>
 </template>
 
 <script>
+import { log } from '@antv/g2plot/lib/utils'
 export default {
-
+  data () {
+    return {
+      dialogTableVisible:false,
+      /* 当前选择的组 */
+      seleteGroup:'',
+      form:{
+        sa_brandid:'',
+        groupname:'',
+        itemno:'',
+        // tag:
+      },
+      rules:{
+        sa_brandid: [
+          { required: true, message: '请选择品牌', trigger: 'blur' },
+        ],
+        groupname: [
+          { required: true, message: '请输入商品组名称', trigger: 'blur' },
+        ],
+        itemno: [
+          { required: true, message: '请选择商品', trigger: 'blur' },
+        ]
+      }
+    }
+  },
+  props:['type','brandData','productData','groupData'],
+  watch: {
+    seleteGroup: {
+      handler(val) {
+        this.form = {
+          sa_brandid:val.sa_brandid,
+          groupname:val.groupname,
+          itemno:val.itemno,
+          // tag:
+        }
+      }
+    }
+  },
+  created() {
+    
+  },
+  methods: {
+    submit() {
+      this.$refs.form.validate(async val => {
+        if(val) {
+          let res = await this.$api.requested({
+            "id": "20220922164303",
+            "version":1,
+            "content": {
+                "sa_itemgroupid":this.type == 'add' ? 0 : this.groupData.sa_itemgroupid,    
+                "sa_brandid":this.form.sa_brandid,
+                "groupname":this.form.groupname,
+                "itemno":this.form.itemno,
+                "tag": []
+            }
+          })
+          console.log(res);
+          this.tool.showMessage(res,() => {
+            this.$emit('addSuccess')
+            this.dialogTableVisible = false
+          })
+        }
+      })
+    },
+    editBtn() {
+      this.dialogTableVisible = true
+      this.seleteGroup = this.groupData
+    }
+  }
 }
 
 </script>
-<style>
+<style scoped>
+/deep/.el-dialog__body {
+  padding-top: 10px !important;
+  padding-bottom: 0 !important;
+}
+/deep/.dialog-footer {
+  margin-top: 10px !important;
+}
 </style>

+ 41 - 0
src/HDrpManagement/ProductGroupMag/modules/delete.vue

@@ -0,0 +1,41 @@
+<template>
+  <div style="display:inline;margin:0 16px">
+    <el-popconfirm title="确定删除当前数据吗?" @confirm="deleteRow()">
+      <el-button slot="reference" size="small" type="text">删 除</el-button>
+    </el-popconfirm>
+  </div>
+</template>
+
+<script>
+export default {
+  props: ['type', 'id','detailId'],
+  methods: {
+    async deleteRow () {
+      let res
+      if (this.type == 'group') {
+        res = await this.$api.requested({
+          "id": "20220922164503",
+          "version": 1,
+          "content": {
+            "sa_itemgroupid": this.id
+          }
+        })
+      } else {
+        res = await this.$api.requested({
+          "id": "20220923105103",
+          "version": 1,
+          "content": {
+            "sa_itemgroupid": this.id,
+            "sa_itemgroupmxid": this.detailId
+          }
+        })
+      }
+      console.log(res);
+      this.tool.showMessage(res, () => {
+        this.$emit('deleteSuccess')
+      })
+    },
+  }
+}
+
+</script>

+ 35 - 0
src/HDrpManagement/ProductGroupMag/modules/down.vue

@@ -0,0 +1,35 @@
+<template>
+  <div>
+    <el-button size="small" type="text" @click="upSubmit">下 架</el-button>
+  </div>
+</template>
+
+<script>
+export default {
+  name: '',
+  data() {
+    return {
+      sa_itemgroupids:[]
+    };
+  },
+  computed:{
+  },
+  watch:{
+  },
+  methods: {
+    async upSubmit() {
+      let res = await this.$api.requested({
+        "id": "20220923143703",
+        "version":1,
+        "content": {
+          "sa_itemgroupids": this.sa_itemgroupids
+        }
+      })
+    }
+  },
+};
+</script>
+
+<style scoped>
+
+</style>

+ 36 - 0
src/HDrpManagement/ProductGroupMag/modules/up.vue

@@ -0,0 +1,36 @@
+<template>
+  <div>
+    <el-button size="small" type="text" @click="upSubmit">上 架</el-button>
+  </div>
+</template>
+
+<script>
+export default {
+  name: '',
+  data() {
+    return {
+      sa_itemgroupids:[]
+    };
+  },
+  computed:{
+  },
+  watch:{
+  },
+  methods: {
+    async upSubmit() {
+      let res = await this.$api.requested({
+        "id": "20220923143603",
+        "version":1,
+        "content": {
+          "sa_itemgroupids": this.sa_itemgroupids
+
+        }
+      })
+    }
+  },
+};
+</script>
+
+<style scoped>
+
+</style>