chenlu
2024-12-12 515025ffd3ace6f7382f9a853d3aba50f191c8d0
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<script setup>
import {nextTick, onMounted, reactive, ref} from "vue";
import {useI18n} from "vue-i18n";
import {Folder, Plus, Setting, Operation,} from "@element-plus/icons-vue";
import OptimizeCompute from "@/views/pp/glassOptimize/page/OptimizeCompute.vue";
import SetAmount from "@/views/pp/glassOptimize/page/SetAmount.vue";
import SetTrimming from "@/views/pp/glassOptimize/page/SetTrimming.vue";
import CheckInventory from "@/views/pp/glassOptimize/page/CheckInventory.vue";
import request from "@/utils/request";
import {ElMessage} from "element-plus";
import { useRoute } from 'vue-router';
 
 
const {t} = useI18n()
 
const xGrid = ref()
const gridOptions = reactive({
  height: '100%',
  loading: false,
  border: "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe: true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true, height: 30, useKey: true},//鼠标移动或选择高亮
  id: 'ProjectDetail',
  scrollX: {enabled: true},
  scrollY: {enabled: true, gt: 0},//开启虚拟滚动
  showOverflow: true,
  columnConfig: {
    resizable: true,
    useKey: true
  },
  filterConfig: {   //筛选配置项
    remote: true
  },
  customConfig: {
    storage: true
  },
  editConfig: {
    trigger: 'click',
    mode: 'row',
    showStatus: true
  },
 
  columns: [
    {field: 'order_number', title: '订序', width: 70},
    {field: 'child_width', width: 100, title: t('order.width'), filters: [{data: ''}], slots: {filter: 'num2_filter'}},
    {field: 'child_height', width: 100, title: t('order.height'),filters: [{data: ''}],slots: {filter: 'num2_filter'}},
    {field: 'quantity', width: 150, title: t('order.quantity'), filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'longGrind1', width: 150, title: '长磨1', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'longGrind2', width: 150, title: '长磨2', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'shortGrind1', width: 150, title: '短磨1', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {field: 'shortGrind2', width: 150, title: '短磨2', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {
      field: 'shape',
      width: 150,
      title: t('order.shape'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
    },
    {field: 'process_cards', width: 150, title: '流程卡号', filters: [{data: ''}], slots: {filter: 'num1_filter'}, sortable: true},
    {
      field: 'product_name',
      width: 150,
      title: t('order.product'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
    },
    {
      field: 'remark',
      width: 150,
      title: t('basicData.remarks'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
    },
    {
      field: 'building_number',
      width: 150,
      title: '楼层号',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
    },
    {
      field: 'perimeter',
      width: 150,
      title: t('order.perimeter'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
    },
    {
      field: 'area',
      width: 150,
      title: t('order.grossArea'),
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
    },
 
    {
      field: 'shelf_number',
      width: 150,
      title: '架号',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
    },
    {
      field: 'technology_number',
      width: 150,
      title: '层',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
    },
    {
      field: 'glass_child',
      width: 150,
      title: '单片名称',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
    },
    {
      field: 'icon',
      width: 150,
      title: '印标类型',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      sortable: true
    },
  ],//表头参数
  data: null,//表格数据
  toolbarConfig: {
    buttons: [],
    slots: {
      buttons: "toolbar"
    },
  },
 
})
 
const handleCommand = async (command) => {
  await emit('changeDialog', command)
}
 
//优化计算
const dialogVisible = ref({});
const openDialog = (index) => {
  dialogVisible.value[index] = true;
};
 
const closeDialog = (index) => {
  dialogVisible.value[index] = false;
};
 
const route = useRoute();
//工程号
const projectNo = ref(route.params.projectNo);
const projectName = ref('');
 
const fetchData = () => {
  request.post(`/glassOptimize/projectInfo/${projectNo.value}`).then((res) => {
    if ((Number(res.code) === 200)) {
      const data = res.data.data;
      data.forEach(item => {
        item.longGrind1 = 0;
        item.longGrind2 = 0;
        item.shortGrind1 = 0;
        item.shortGrind2 = 0;
        item.shelf_number = 0;
      });
      xGrid.value.loadData(res.data.data);
      gridOptions.data = res.data.data;
      projectName.value = res.data.data[0].project_name;
    } else {
      ElMessage.warning(res.msg);
    }
  }).catch((error) => {
    console.error("获取数据出错:", error);
  });
};
onMounted(() => {
  if (projectNo.value) {
    fetchData();
  }
});
 
// 从子组件SetAmount获取磨量值,并更新表格数据
const Amount = (amountData) => {
  nextTick(() => {
    const data = gridOptions.data;
    console.log('接收到的amountData:', amountData);
    console.log('表格原始数据:', data);
    if (data) {
      try {
        const updatedData = [];
        for (let i = 0; i < data.length; i++) {
          const item = data[i];
          const updatedItem = {
            ...item,
            longGrind1: Number(amountData.quicksetTop),
            longGrind2: Number(amountData.quicksetRight),
            shortGrind1: Number(amountData.quicksetBottom),
            shortGrind2: Number(amountData.quicksetLeft)
          };
          updatedData.push(updatedItem);
        }
        gridOptions.data = updatedData;
        xGrid.value.loadData(updatedData);
      } catch (error) {
        console.error('更新表格数据时出错:', error);
        // 这里可以根据实际需求添加一些回滚操作或者提示用户的逻辑,比如显示一个错误提示框等
        ElMessage.error('更新磨量数据时出现错误,请检查输入或联系管理员');
      }
    } else {
      console.warn('表格数据为空,无法更新磨量值');
    }
  });
};
 
//中转站接受SetTrimming的值
const emit = defineEmits([
  'changeDialog',
  'forward-data-to-grandparent'
]);
 
const handleTrimmingData = (data) => {
  emit('forward-data-to-grandparent', data);
};
 
</script>
 
<template>
  <div style="width: 100%;height: 100%">
    <vxe-grid
        @filter-change="filterChanged"
        height="100%"
        class="mytable-scrollbar"
        ref="xGrid"
        v-bind="gridOptions"
        v-on="gridEvents"
    >
 
      <template #num2_filter="{ column, $panel }">
        <div>
          <div v-for="(option, index) in column.filters" :key="index">
            <vxe-select v-model="option.data" :placeholder="$t('processCard.pleaseSelect')"
                        @change="changeFilterEvent($event, option, $panel)">
              <vxe-option value="0" :label="$t('basicData.unchecked')"></vxe-option>
              <vxe-option value="1" :label="$t('basicData.selected')"></vxe-option>
            </vxe-select>
          </div>
        </div>
      </template>
 
      <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 #toolbar>
        <div id="header">
          <div id="title">
            <span>工程编号:</span>
            <el-input disabled  placeholder="" style="width: 150px" v-model="projectNo"></el-input>&nbsp;
            <span>工程名称:</span>
            <el-input disabled placeholder="" style="width: 150px; margin-right: 350px" v-model="projectName"></el-input>
            <el-button id="checkinventory" type="primary" @click="openDialog(1)">查询库存</el-button>
            <el-dialog
                v-model="dialogVisible[1]"
                title="查询库存"
                destroy-on-close
                style="width: 35%;height:35%;">
              <check-inventory />
            </el-dialog>
 
            <el-button id="button" type="primary" @click="openDialog(2)">设置磨量</el-button>
            <el-dialog
                v-model="dialogVisible[2]"
                title="设置磨量"
                destroy-on-close
                style="width: 35%;height:80%;margin-top: 3vh;">
               <set-amount :closeDialog="closeDialog" @set-amount="Amount"/>
            </el-dialog>
 
            <el-button id="button" type="primary" @click="openDialog(3)">设置修边</el-button>
            <el-dialog
                v-model="dialogVisible[3]"
                title="设置修边"
                destroy-on-close
                style="width: 35%;height:80%;margin-top: 3vh;">
              <set-trimming :closeDialog="closeDialog" @send-data-event="handleTrimmingData"/>
            </el-dialog>
 
            <el-button id="button" type="primary">保存</el-button>
 
            <el-button id="button" type="primary" @click="openDialog(4)">优化</el-button>
            <el-dialog
                v-model="dialogVisible[4]"
                title="优化计算"
                destroy-on-close
                style="width: 75%;height:90%;margin-top: 3vh;"
            >
              <optimize-compute/>
            </el-dialog>
 
          </div>
          <!--工程文件菜单-->
          <el-dropdown @command="handleCommand">
            <el-button type="primary" :icon="Folder" style="margin-top: 8px">
              工程文件
            </el-button>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item :command="1" :icon="Plus">创建工程</el-dropdown-item>
                <el-dropdown-item :command="2" :icon="Setting">工程管理</el-dropdown-item>
                <el-dropdown-item :command="3" :icon="Operation">模拟计算</el-dropdown-item>
                <!--              <el-dropdown-item command="4">文件导出</el-dropdown-item>
                              <el-dropdown-item command="5">文件导入</el-dropdown-item>-->
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </template>
    </vxe-grid>
 
  </div>
</template>
 
<style scoped>
 
#header {
  height: 50px;
}
 
#title {
  position: absolute;
  right: 10px;
  margin-top: 8px;
}
 
#button{
  margin-left: 10px;
}
 
</style>