wuyouming666
2025-04-07 ba6b8c6be389e1c76f15f85e43f2d55ff5d34caf
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<script setup>
import {computed, onMounted, reactive, ref, watch} from "vue";
import {changeFilterEvent, filterChanged} from "@/hook"
import footSum from "@/hook/footSum"
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,
  showFooter: true,//显示脚
  rowConfig: {isCurrent: true, isHover: true,height: 30},//鼠标移动或选择高亮
  virtualScroll: true, // 开启虚拟滚动功能
  id: 'Order_Process',
  printConfig: {},
  importConfig: {},
  exportConfig: {},
  scrollY:{ enabled: true,gt:13 },//开启虚拟滚动
  //scrollX:{ enabled: true,gt:15 },//开启虚拟滚动
  filterConfig: {   //筛选配置项
    // remote: true
  },
  columnConfig: {
    resizable: true,
    useKey: true
  },
 
  customConfig: {
    storage: true
  },
 
 
  columns:[
 
  ],
  mergeCells:[],
  toolbarConfig: {
    zoom: true,
    custom: true
  },
  cellClassName ({ row, column,columnIndex})  {
    if (columnIndex>10 && row.quantity*1 === row.reportWorkQuantity[column.title]*1){
        return 'row-green'
    }
    return null
  },
  footerMethod ({ columns, data }) {//页脚函数
    return[
      columns.map((column, columnIndex) => {
        if (columnIndex === 0) {
          return t('basicData.total')
        }
        if (list.value.includes(column.field)) {
          return footSum(data, column.field)
        }
        return ''
      })
    ]
  }
})
const list = ref([])
 
let props = defineProps({
  orderId:null
})
const columns = [
  {field: 'order_number',fixed:"left", width: 90,title: t('order.OrderNum'),showOverflow:"ellipsis"},
  // {type:'expand',fixed:"left",slots: { content:'content' },width: 50},
  {field: 'product_name', width: 150, title: t('order.product'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
  {field: 'glass_child',width: 130, title: t('reportingWorks.glassChild') ,filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
  {field: 'order_type', width: 120,title: t('order.orderType'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
  {field: 'process_id',width: 110, title: t('processCard.processId'),filters:[{ data: '' }],slots: { filter: 'num1_filter' }},
  {field: 'technology_number', width: 90,title:  t('processCard.technologyNumber'),showOverflow:"ellipsis"},
  {field: 'quantity', width: 90,title: t('order.quantity')},
  {field: 'gross_area', width: 90,title: t('order.area')},
  {field: 'shippedQuantity',width: 120, title: t('delivery.deliveryQuantity')},
  {field: 'inventory',width: 120, title: t('productStock.inventoryQuantity')},
  {field: 'inventoryArea',width: 120, title: t('report.inventoryArea')},
  {field: 'broken_num',width: 90, title: t('reportingWorks.quantityBroken')},
]
let column = [0,1,3,6,7,8,9]
 
 
onMounted(()=>{
  getWorkOrder()
})
 
watch(()=>props.orderId,(newValue)=>{
  getWorkOrder()
})
 
 
 
const getWorkOrder = () => {
  request.post(`/report/processCardProgress/${props.orderId}`,column).then(async (res) => {
    if (res.code == 200) {
 
      gridOptions.columns = JSON.parse(JSON.stringify(columns))
      gridOptions.columns.forEach(item =>{
        item.filterMethod = filterChanged
      })
      list.value = ['quantity']
      res.data.title.forEach((item,index) =>{
        list.value.push('reportWorkQuantity.'+item.process)
        let column = {slots: { default: 'quantitySum'},
          width: 90,
          title: item.process,
          field:'reportWorkQuantity.'+item.process}
        gridOptions.columns.push(column)
      })
      res.data.data.forEach(item => {
        item.reportWorkQuantity=JSON.parse(item.reportWorkQuantity)
        item.reportWorkQuantityCount=JSON.parse(item.reportWorkQuantityCount)
      })
      //gridOptions.mergeCells= res.data.mergeCells
      await xGrid.value.loadData(res.data.data)
    } else {
      ElMessage.warning(res.msg)
    }
  })
}
 
const quantitySum = ( row,column )=>{
  const reportWorkQuantity = row.reportWorkQuantity[column.title] || 0
  const reportWorkQuantityCount = row.reportWorkQuantityCount[column.title] || 0
  if(reportWorkQuantity===reportWorkQuantityCount){
    return reportWorkQuantity
  }
 
  return (reportWorkQuantity
      +'('
      +reportWorkQuantityCount
      +')' )
  //return
}
</script>
 
<template>
  <div style="width: 100%;height: 100%">
    <vxe-grid
        height="100%"
        size="mini"
        class="mytable-scrollbar"
        ref="xGrid"
        v-bind="gridOptions"
    >
      <template #num1_filter="{ column, $panel }">
        <div>
          <div v-for="(option, index) in column.filters" :key="index">
            <input
                type="type"
                v-model="option.data"
                @keyup.enter.native="$panel.confirmFilter()"
                @input="changeFilterEvent($event, option, $panel)"/>
          </div>
        </div>
      </template>
 
      <template #quantitySum="{ row,column }">
        <span>{{ quantitySum(row,column) }} </span>
      </template>
 
    </vxe-grid>
  </div>
</template>
 
<style scoped>
::v-deep(.vxe-grid .vxe-body--column.row-green) {
  background-color: #D5EAFF;
}
 
</style>