chenlu
2024-06-05 af954d6dd06411cd9540520c59dd71dea4eff6e1
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<script setup>
import {defineEmits, onMounted, reactive, ref, watch} from "vue";
import {changeFilterEvent, filterChanged} from "@/hook"
import {useI18n} from "vue-i18n"
import request from "@/utils/request"
import {ElMessage} from "element-plus";
const { t } = useI18n()
const xGrid = ref()
const gridOptions = reactive({
  loading:false,
  border:  "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe:true,//斑马纹
  showOverflow:true,
  id:'sizeCheck',
  toolbarConfig: {
    buttons: [
      {'code': 'review', 'name': '审核',status: 'primary'},
    ]
  },
 
  rowConfig: {isCurrent: true, isHover: true,height: 30},//鼠标移动或选择高亮
  virtualScroll: true, // 开启虚拟滚动功能
  scrollY:{ enabled: true,gt:13 },//开启虚拟滚动
  //scrollX:{ enabled: true,gt:15 },//开启虚拟滚动
 
  columnConfig: {
    useKey: true
  },
  editConfig: {
    trigger: 'dblclick',
    mode: 'cell',
    showStatus: true,
    showIcon:false
  },
  mouseConfig:{selected: true},
  keyboardConfig:{
    isArrow: true,
    isDel: true,
    isEnter: true,
    isTab: true,
    isEdit: true,
    isChecked: true,
    enterToTab:true
  },
 
  customConfig: {
    storage: true
  },
  columns:[
    {field: 'width',  title: '宽',editRender: { name: 'input'}},
    {field: 'height',  title:'高', editRender: { name: 'input'}},
    {field: 'quantity', title: '数量' ,editRender: { name: 'input'}, },
  ],
  editRules: {
    width: [
      { required: true, message: '必填,参数不一致' }
    ],
    height: [
      { required: true, message: '必填,参数不一致' }
    ],
    quantity: [
      { required: true, message: '必填,参数不一致' }
    ]
  }
})
 
const gridEvents = {
  async toolbarButtonClick({code}) {
    const $grid = xGrid.value
    if ($grid) {
      switch (code) {
        case 'review' :{
          const errMap = await $grid.validate(true)
          if (errMap) {
            ElMessage.error(t('basicData.msg.checkoutLose'))
            return
          }
          // const $table = props.OrderDetail
          // $table.getTableData().fullData.forEach((row)=>{
          //   if()row.computeGrossArea
          // })
 
 
          emit('getParent')
          break
        }
      }
    }
  }
}
 
 
const emit = defineEmits(['getParent'])
 
let props = defineProps({
  OrderDetail:null
})
onMounted(()=>{
  const length = props.OrderDetail.getTableData().fullData.length
  const $grid = xGrid.value
  let list = []
  for (let i = 0; i < length; i++) {
    list.push({})
  }
  xGrid.value.reloadData(list)
 
})
 
const editClosedEvent = ({ row, column,rowIndex}) => {
  const $table = props.OrderDetail
  let checkVal = row[column.property]*1
  const oldVal = $table.getTableData().fullData[rowIndex][column.property]*1
  if(checkVal!=oldVal){
    row[column.property]=null
  }
}
 
</script>
 
<template>
  <div style="width: 100%;height: 100%">
    <vxe-grid
        height="100%"
        class="mytable-scrollbar"
        ref="xGrid"
        v-bind="gridOptions"
        v-on="gridEvents"
        @edit-closed="editClosedEvent"
    >
    </vxe-grid>
  </div>
</template>
 
<style scoped>
 
</style>