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

+ 36 - 0
src/utils/common.js

@@ -48,4 +48,40 @@ export default {
     return str
   },
 
+  //获取字段列表
+  getField(array,fun,props){
+    var type = {
+      'Integer':'3',
+      'DateTime':'2',
+      'String':'1'
+    }
+
+    //获取规范数据
+    var keys = []
+    var arr = []
+    if(props){
+      keys = Object.keys(props)
+    }
+    //获取所需要的数据
+    var newArray = array.filter(item=>{
+      return  fun(item)
+    })
+    if(keys.length>0){
+      newArray.forEach(item=>{
+        var obj = {}
+        keys.forEach(key=>{
+          if(key == 'type'){
+            obj[key] = type[item[props[key]]] || item[props[key]]
+          }else{
+            obj[key] = item[props[key]]
+          }
+          
+        })
+        arr.push(obj)
+      })
+      return arr;
+    }
+    return newArray
+  }
+
 }

+ 10 - 13
src/views/event/components/index.vue

@@ -184,21 +184,18 @@ export default {
           })
           // 分组字段
           let conditionDTOList= JSON.parse(JSON.stringify(res.data[0].conditionDTOList))
-          this.groupingOption = conditionDTOList.filter(item => {
-            return item.ifGroup == true
+          // this.groupingOption = conditionDTOList.filter(item => {
+          //   return item.ifGroup == true
+          // })
+          this.groupingOption = this.$commonJS.getField(conditionDTOList,(u)=> u.ifGroup == true,{
+            name: 'name',
+            value: 'value',
           })
           // 搜索字段
-          this.searchFiled = res.data[0].conditionDTOList.filter(item => {
-            item.label = item.name
-            if (['createTime','eventDate'].includes(item.value)) {
-              item.type=2
-            }else if (['scenarioId'].includes(item.value)) {
-              item.type = 3
-              item.options=this.scene
-            } else {
-              item.type=1
-            }
-            return item.ifSearch == true
+          this.searchFiled = this.$commonJS.getField(conditionDTOList,(u)=> u.ifSearch == true ,{
+            label: 'name',
+            value: 'value',
+            type:'type',
           })
         }
       })

+ 2 - 10
src/views/event/components/view/mergeTable.vue

@@ -4,7 +4,7 @@
       <el-table-column type="expand">
         <template slot-scope="props">
           <div style="padding: 10px;height: 340px;">
-            <Table  :column="column"  @option="handleOption" :row="{row:props.row,groupBy:groupBy,searchOption:searchOption,}" :addEditData="addEditData" :deleData="deleData" @getData="getData"/>
+            <Table  :column="column" :tableData="props.row.data"  @option="handleOption" :row="{row:props.row,groupBy:groupBy,searchOption:searchOption,}" v-bind="$attrs" v-on="$listeners"/>
           </div>
         </template>
       </el-table-column>
@@ -25,10 +25,6 @@ import Table from "./table";
 
 export default {
   props: {
-    // 分组时删除事件数组
-    deleData:Array,
-    // 分组时新增或编辑事件数组
-    addEditData:Array,
     // 检索条件
     searchOption: {
       type: Object,
@@ -116,10 +112,6 @@ export default {
     
   },
   methods: {
-    // 分组时若删除当前分组最后一条数据时重新请求分组接口
-    getData(val) {
-      this.$emit('getData',val)
-    },
     // 排序
     sortChange({ column, prop, order }) {
       let str='1'
@@ -131,7 +123,7 @@ export default {
     },
     //打开展开行获取数据并保存起来
     expandChange(row, expandedRows) {
-
+      row.data = []
     }
   }
 }

+ 5 - 1
src/views/event/components/view/table.vue

@@ -195,7 +195,10 @@ export default {
     // 排序
     sortChange({ column, prop, order }) {
       this.handleSort({ column, prop, order })
-      this.$emit('on-sort', { column, prop, order })
+      if(!this.row){
+        this.$emit('on-sort', { column, prop, order })
+      }
+      
     },
     // 排序方法
     handleSort({ column, prop, order }) {
@@ -221,6 +224,7 @@ export default {
       this.params.current = 0
       this.disabled = false
       this.tableData.splice(0)
+      this.getList()
     },
     // 数据处理
     getColumnData(row, key) {

+ 3 - 0
src/views/product/components/dialog/addEditCategory.vue

@@ -90,6 +90,9 @@ export default {
     // 打开弹窗
     open(row) {
       this.form = JSON.parse(JSON.stringify(row))
+      if(!this.form.showType && this.form.showType!=0){
+        this.form.showType=0
+      }
       if (row.id) {
         this.title = '编辑产品类别'
       } else {

+ 3 - 11
src/views/product/components/index.vue

@@ -108,23 +108,15 @@ export default {
       // 产品类别总数
       total: 0,
       // 产品类别数据
-      tableData:[
-        {
-          id: '12987122',
-          name: '好滋好味鸡蛋仔',
-          category: '江浙小吃、小吃零食',
-          desc: '荷兰优质淡奶,奶香浓而不腻',
-          address: '上海市普陀区真北路',
-          shop: '王小虎夫妻店',
-          shopId: '10333'
-        }
-      ],
+      tableData:[],
     }
   },
   mounted() {
     //获取产品类别数据
     this.getList()
     //获取检索字段以及分组字段
+    this.getColumn() 
+    //获取检索字段以及分组字段
     this.getFieldList()
     
   },