fujunling
2023-05-26 087511862a295eda0cf808a92f2ed2df348d54ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<template>
<basic-container style="height: 750px">
  <avue-crud ref="crud" :data="data" :option="option" style="height: 750px" @sort-change="sortChange"></avue-crud>
</basic-container>
</template>
 
<script>
import { MasterTable,TableData } from "@/api/GetItem";
export default {
  name: "Crud.vue",
  data(){
    return{
      data:[
        {
          zhiliangbz:"111",
        },
        {
          xinghaoguige:"1121",
        },
      ],
      option:{
        //默认高度,
        align:'center',
        menuAlign:'center',
        column:[]
      },
      List:[],
      columnType: {
        text: "input",
        combox: "select",
        truefalse: "switch",
        number: "number",
        datetime: "datetime",
      },
    }
  },
  created() {
   this.CrudHeaderRend();
   this.CrudRend()
  },
  activated() {
    this.doLayout()
  },
  methods:{
    doLayout() {
      this.$nextTick(() => {
        this.$refs.crud.doLayout();
      });
    },
    CrudHeaderRend(){
      MasterTable({codeClassifyOid:"D9CF223F-317D-71EB-BD11-433A94CAD9F3",functionId: 5,_: 1685067339479}).then(res=>{
        this.List=res.data.tableDefineVO.cols[0];
        this.List.forEach(item=>{
          console.log(item)
          let columnItem={
            label:item.title,
            prop:item.field,
            type:this.columnType[item.type],
            sortable:item.sort,
            width:item.minWidth
          };
          this.option.column.push(columnItem);
 
        })
      })
    },
    CrudRend(){
      TableData({templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
        codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
        page: 1,
        limit: 9,
        _: 1685089123575
      }).then(res=>{
        console.log(res)
        this.data=res.data.data
      })
    },
    // 排序
    sortChange(val){
      console.log(val)
 
      // TableData(  {
      //   templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
      //   codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
      //   order:"desc",
      //   sort:val.prop
      // }).then(res=>{
      //   console.log(res.data.data)
      //   this.data=res.data.data
      // })
    },
  }
}
</script>
 
<style scoped>
 
</style>