瀏覽代碼

商品管理详情

qymljy 2 年之前
父節點
當前提交
3cae260fe6

+ 46 - 0
src/HDrpManagement/ProductGroupMag/components/classTree.vue

@@ -0,0 +1,46 @@
+<template>
+  <div>
+    <ul style="padding-left:40px;">
+      <li class="class-item" v-for="item in data" :key="item.index">
+        <el-checkbox v-model="item.checked" @change="onChange">{{item.label}}</el-checkbox>
+        <tree :data="item.children"></tree>
+      </li>
+    </ul>
+  </div>
+</template>
+
+<script>
+export default {
+  name: "Tree",
+  props:['data'],
+  data () {
+    return {
+      checked:false,
+      checks:[]
+    }
+  },
+  methods:{
+    onChange () {
+      var that = this
+      function convertToElementTree(node) {
+        if (node.checked === true) {
+          that.$store.dispatch('checkClass',node.value)
+        } else {
+          that.$store.dispatch('uncheckClass',node.value)
+        }
+      }
+      that.data.forEach((element) => {
+        convertToElementTree(element)
+      });
+    },
+  }
+}
+</script>
+
+<style scoped>
+.class-item{
+  /* height: 40px; */
+  font-size: 1.5rem;
+  
+}
+</style>

+ 4 - 1
src/HDrpManagement/ProductGroupMag/modules/details.vue

@@ -15,6 +15,7 @@
       <div slot="customOperation">
 <!--        <Edit class="inline-16" :data="mainData" @onSuccess="queryMainData" :disabled="mainData.isonsale"/>-->
         <shelves class="inline-16" @upSuccess="queryMainData" :data="mainData"></shelves>
+<!--        <saleClass :data="mainData" class="inline-16"></saleClass>-->
 <!--        <el-popover placement="bottom" style="20px">
           <Up type="one" @upSuccess="queryMainData" ":id="[mainData.sa_itemgroupid] v-if="mainData.isonsale == 0 && tool.checkAuth($route.name,'up_sales')"></Up>
           <Down type="one" @downSuccess="queryMainData" :id="[mainData.sa_itemgroupid]" v-if="mainData.isonsale == 1 && tool.checkAuth($route.name,'down_sales')"></Down>
@@ -34,6 +35,7 @@ import Up from './up'
 import Down from './down'
 import shelves from '../components/shelves'
 import Edit from './edit'
+import saleClass from './saleClass'
 export default {
   name: "detail",
   data() {
@@ -48,7 +50,8 @@ export default {
     Up,
     Down,
     shelves,
-    Edit
+    Edit,
+    saleClass
   },
   methods:{
     async queryMainData(id) {

+ 175 - 0
src/HDrpManagement/ProductGroupMag/modules/saleClass.vue

@@ -0,0 +1,175 @@
+<template>
+  <div>
+    <!-- <el-button size="small" type="primary" @click="dialogTableVisible = true">设置营销分类</el-button> -->
+<!--    <el-dropdown-item @click.native="onShow()">设置营销分类</el-dropdown-item>-->
+    <el-button size="mini" @click="onShow()">设置营销分类</el-button>
+    <el-dialog title="设置营销分类" append-to-body   :visible.sync="dialogTableVisible">
+      <ul class="flex-align-center">
+        <li class="brand-item" :class="activeid === item.value?'act':''" v-for="item in classList" :key="item.index" @click="brandClick(item)">{{item.label}}</li>
+      </ul>
+      <div>
+        <tree :data="activeBrandData"></tree>
+      </div>
+      <div class="dialog-footer">
+        <el-button size="small" @click="dialogTableVisible = false" class="normal-btn-width">取 消</el-button>
+        <el-button size="small" type="warning" class="normal-btn-width btn-warning" @click="onSubmit">确 定</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import tree from '../components/classTree.vue'
+import {mapGetters} from 'vuex'
+export default {
+  props:['data'],
+  data () {
+    return {
+      dialogTableVisible:false,
+      classList:[],
+      activeBrandData:[],
+      haveBindClass:[],
+      activeid:0
+    }
+  },
+  components:{
+    tree
+  },
+  computed:{
+    ...mapGetters({
+      checks:'checks'
+    })
+  },
+  methods:{
+    onShow () {
+      this.saleClass(()=>{
+        this.dialogTableVisible = true
+        this.bindSaleClass()
+        console.log("营销分类")
+        console.log(this.data)
+      })
+    },
+    async saleClass (fn) {
+      const res = await this.$api.requested({
+          "id": "20220922110403",
+          "version":1,
+          "content": {
+            "sa_brandid":0
+          }
+      })
+      let arr = res.data.map(e=>{
+        return {
+          itemclassname:e.brandname,
+          itemclassid:e.sa_brandid,
+          subdep:e.ttemclass
+        }
+      })
+      this.classList = this.createMenu(arr)
+      this.activeid = this.classList[0].value
+      this.activeBrandData = this.classList[0].children
+      fn()
+    },
+    createMenu (array) {
+      let arr = []
+      function convertToElementTree(node) {
+        // 新节点
+        var elNode = {
+          label:node['itemclassname'],
+          value:node['itemclassid'],
+          itemclassnum:node['itemclassnum'],
+          checked:false
+        }
+        if (node.subdep && node.subdep.length > 0) {
+          // 如果存在子节点
+          elNode.children = []
+          for (var index = 0; index < node.subdep.length; index++) {
+          // 遍历子节点, 把每个子节点看做一颗独立的树, 传入递归构造子树, 并把结果放回到新node的children中
+            elNode.children.push(convertToElementTree(node.subdep[index]));
+          }
+        }
+        return elNode;
+      }
+      array.forEach((element) => {
+        arr.push(convertToElementTree(element))
+      });
+      return arr
+    },
+    //点击品牌
+    brandClick (item) {
+      this.activeid = item.value
+      this.activeBrandData = item.children
+    },
+
+    // 提交授权数据
+    async onSubmit () {
+      const res = await this.$api.requested({
+        "id": 20220927090102,
+        "content": {
+            "itemclassids":this.checks,
+            "itemid": this.data.itemid,
+            "itemno":this.data.itemno
+        }
+      })
+      this.tool.showMessage(res,()=>{
+        this.dialogTableVisible = false
+      })
+    },
+
+    // 查询已绑定分类
+    async bindSaleClass () {
+      var that = this
+      const res = await this.$api.requested({
+        "id": 20220927090202,
+        "content": {
+            "itemid": this.data.itemid,
+            "itemno":this.data.itemno
+        }
+      })
+
+      this.haveBindClass = res.data
+      // 设置已绑定的id,用于check显示
+      res.data.filter(e=>{
+        this.$store.dispatch('checkClass',e.itemclassid)
+      })
+      // 递归,遍历数组设置勾选状态
+      function convertToElementTree(node) {
+        that.haveBindClass.forEach(e=>{
+          if (e.itemclassid === node.value) {
+            node.checked = true
+          }
+        })
+        if (node.children && node.children.length > 0) {
+          for (var index = 0; index < node.children.length; index++) {
+            convertToElementTree(node.children[index])
+          }
+        }
+      }
+
+      this.classList.forEach((element) => {
+        convertToElementTree(element)
+      });
+    }
+  },
+  mounted () {
+    // this.saleClass()
+
+  }
+}
+
+</script>
+<style>
+</style>
+<style scoped>
+.brand-item{
+  padding-left:40px ;
+  margin-right:20px;
+  margin-bottom: 15px;
+  text-align: center;
+  font-size: 16px;
+  font-weight: 600;
+  cursor: pointer;
+}
+.act{
+  color: red;
+}
+</style>

+ 1 - 1
src/HDrpManagement/ProductMag/detail/index.vue

@@ -17,7 +17,7 @@
       <div slot="tags">
       </div>
       <div slot="customOperation" >
-        <saleClass class="inline-16"></saleClass>
+        <saleClass :data="mainData" class="inline-16"></saleClass>
       </div>
       <div slot="slot0" >
         <detail_data :basic="mainData"></detail_data>

+ 0 - 1
src/HDrpManagement/ProductMag/detail/modules/detailedData.vue

@@ -34,7 +34,6 @@ export default {
   props:["basic"],
   data(){
     return {
-      basic:[],
     }
   },
   mounted() {

+ 6 - 5
src/HManagement/marketing2/agent/details/modules/saleclass/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div>
-    <add-sale-class class="normal-margin" @addSuccess="getClassList" v-if="tool.checkAuth($route.name,'add_saleClass') && !detail"/>
-    <tableLayout v-if="saleClassList" :layout="tablecols" :data="saleClassList" :custom="false" height="calc(100vh - 405px)" fixedName="operation">
+    <add-sale-class class="normal-margin" :data="data" @addSuccess="getClassList" v-if="tool.checkAuth($route.name,'add_saleClass') "/>
+    <tableLayout  :layout="tablecols" :data="saleClassList" :custom="false" height="calc(100vh - 405px)" fixedName="operation">
       <template v-slot:opreation="scope">
         <Del v-if="tool.checkAuth($route.name,'delete')" :id="scope.data.sys_enterprise_saleclassid" @onSuccess="getClassList"/>
       </template>
@@ -24,8 +24,6 @@ export default {
   components:{addSaleClass,Del},
   computed:{
   },
-  watch:{
-  },
   created() {
     this.tablecols = this.tool.tabelCol(this.$route.name)['saleClassTable'].tablecols
     // if(this.detail) this.tablecols.pop()
@@ -38,7 +36,7 @@ export default {
         "content": {
             "pageNumber": 1,
             "pageSize": 1000,
-            "sys_enterpriseid": this.param.sys_enterpriseid,
+            "sys_enterpriseid": this.data.sys_enterpriseid,
             "where": {
                 "condition": ""
             }
@@ -47,6 +45,9 @@ export default {
       this.saleClassList = res.data
     }
   },
+  mounted() {
+    this.getClassList()
+  },
   watch:{
     data (val) {
       this.param = val

+ 8 - 2
src/HManagement/marketing2/agent/details/modules/saleclass/modules/addSaleClass.vue

@@ -27,8 +27,11 @@ export default {
   },
   created() {
     this.department()
+    console.log("data")
+    console.log(this.data)
+
   },
-  inject: ['sys_enterpriseid'],
+ /* inject: ['sys_enterpriseid'],*/
   methods: {
     async department () {
       const res = await this.$api.requested({
@@ -93,11 +96,14 @@ export default {
       return arr
     },
     async submit() {
+      console.log(this.selectArr.length)
+      console.log(this.sys_enterpriseid)
+      console.log(this.data)
       if(this.selectArr.length == 0) return
       let res = await this.$api.requested({
           "id": 20220924134302,
           "content": {
-              "sys_enterpriseid": this.sys_enterpriseid(), //企业id
+              "sys_enterpriseid": this.data.sys_enterpriseid, //企业id
               "itemclassid":this.result
           },
       })