wangfei
2024-11-13 18e4df43f79f51539474b2918544a9d2d4c5c4e0
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<script lang="ts" setup>
import {onBeforeUnmount, onMounted, onUnmounted, reactive, ref} from "vue";
import {useRouter} from "vue-router"
import {ElMessage} from 'element-plus'
import {useI18n} from 'vue-i18n'
import {host, WebSocketHost} from '@/utils/constants'
import request from "@/utils/request"
import {closeWebSocket, initializeWebSocket} from '@/utils/WebSocketService';
 
const router = useRouter()
const {t} = useI18n()
const selectValuesa = reactive([]);
const selectedProjectNo = ref('');
const stationCell = ref('2');
const filmRemove = ref('');
const dialogFormVisible = ref(false)
const blind = ref(false)
const blinda = ref(false)
const dialoglea = ref(false)
const tableDatax = ref([])
const upstatus = ref(t('basicData.machineaa'));
const cuttingMachineStatusColor = ref('#911005'); // 用于动态设置i标签的背景色 
const tableDataa = ref<any[]>([]);
const tableDatab = ref<any[]>([]);
const tableData = ref([])
// const tableData = reactive([]);
const titleSelectJson = ref({
  engineerId: [],
})
const handlezhiban = () => {
  dialoglea.value = true;
  fetchFlowCardId();
};
const selectproject = () => {
  dialogFormVisible.value = true;
  selectgong();
};
const markingMachineStatus = ref('#911005');
const cuttingMachineStatus = ref('#911005');
const confirmMarkingMachine = () => {
  markingMachineStatus.value = 'green';
};
const confirmCuttingMachine = () => {
  cuttingMachineStatus.value = 'green';
};
onMounted(() => {
  socket = initializeWebSocket(socketUrl, handleMessage);
});
onUnmounted(() => {
  if (socket) {
    closeWebSocket(socket);
  }
});
const fetchTableData = async () => {
  try {
    const response = await request.get("/loadGlass/up-patten-usage/prioritylist");
    if (response.code === 200) {
      tableData.splice(0, tableData.length, ...response.data);
      ElMessage.error(response.message);
    }
  } catch (error) {
    // 处理请求失败的情况
    // ElMessage.error('获取表格数据失败,请重试');
  }
};
let socket = null;
const socketUrl = `ws://${WebSocketHost}:${host}/api/loadGlass/api/talk/uploadGlass`;
const handleMessage = (data: any) => {
  tableDataa.value = data.list[0].slice(0, 2);
  tableDatab.value = data.list[0].slice(2, 4);
};
onBeforeUnmount(() => {
  closeWebSocket();
});
const requestData = {
  state: 100
};
const selectgong = async (queryString: string) => {
  try {
    const response = await request.post('/loadGlass/optimizeProject/listByState', {
      ...requestData,
      query: queryString
    });
    if (response.code == 200) {
      titleSelectJson.value.engineerId = response.data;
    } else {
      ElMessage.error(response.message);
    }
  } catch (error) {
    console.error(error);
  }
};
//选择工程预览确认
const handlesure = async () => {
  try {
    const response = await request.post('/loadGlass/up-patten-usage/selectUpPattenUsage', {
      stationCell: 2,
      // engineerId: 'P24101602',
      engineerId: selectedProjectNo.value,
      filmRemove: filmRemove.value,
    })
    window.localStorage.setItem('engineeringId', selectedProjectNo.value)
    window.localStorage.setItem('filmRemove', filmRemove.value)
    if (response.code == 200) {
      ElMessage.success(response.message);
      tableData.value = response.data;
      dialogFormVisible.value = false;
      selectedProjectNo.value = '';
      filmRemove.value = '';
      markingMachineStatus.value = '#911005';
      cuttingMachineStatus.value = '#911005';
    } else {
      ElMessage.error(response.message);
    }
  } catch (error) {
    console.error(error);
  }
}
// 开始上片
const handleon = async () => {
  let filmRemove = window.localStorage.getItem('filmRemove')
  let engineeringId = window.localStorage.getItem('engineeringId')
  if (markingMachineStatus.value === 'green' && cuttingMachineStatus.value === 'green') {
    try {
      const response = await request.post('/loadGlass/engineering/engineering/changeTask', {
        stationCell: 2,
        filmRemove: filmRemove,
        // engineerId: 'P24101602',
        engineerId: engineeringId,
        state: 1,
      })
      if (response.code == 200) {
        ElMessage.success(response.message);
        blind.value = false;
      } else {
        ElMessage.error(response.message);
      }
    } catch (error) {
      console.error(error);
    }
  } else if (markingMachineStatus.value === '#911005' || cuttingMachineStatus.value === '#911005') {
    // 提示用户打标机未就绪
    ElMessage.warning(t('basicData.pausea'));
  }
}
// 暂停
const handleup = async () => {
  try {
    let engineeringId = window.localStorage.getItem('engineeringId')
    console.log(engineeringId);
    if (engineeringId !== '') {
      const response = await request.post('/loadGlass/engineering/engineering/pauseTask', {
        stationCell: 2,
        // engineerId: 'P24101602',
        engineeringId: engineeringId,
        state: 0,
      })
      if (response.code == 200) {
        ElMessage.success(response.message);
        blinda.value = false;
      } else {
        ElMessage.error(response.message);
      }
    } else {
      ElMessage({
        type: 'info',
        message: t('basicData.infonull'),
      })
    }
  } catch (error) {
    console.error(error);
  }
}
 
// 查询数据
const selectReportData = async () => {
  let stateList = []
  if (selectValuesa[0] != null && selectValuesa[0] != 'undefined') {
    if (selectValuesa[0] != "") {
      stateList = [selectValuesa[0]];
    }
  }
  const response = await request.post("/loadGlass/up-patten-usage/setUpPattenRequest", {
    taskState: stateList,
    taskType: 2
  })
  if (response.code === 200) {
    tableData.value = response.data;
    ElMessage.success(response.message);
  } else {
    ElMessage.error(response.message);
  }
};
 
// 值班信息
const fetchFlowCardId = async () => {
  try {
    const response = await request.post('/loadGlass/work_assignment/selectWorkAssignment', {
      line: 2001,
      workingProcedure: '冷加工'
    })
    if (response.code == 200) {
      ElMessage.success(response.message);
      tableDatax.value = response.data;
    } else {
      ElMessage.error(response.message);
    }
  } catch (error) {
    console.error(error);
  }
}
onMounted(fetchTableData);
// 开始上片
const handleBind = (row) => {
  blind.value = true;
};
// 暂停
const handleBinda = (row) => {
  blinda.value = true;
};
const toggleEnableState = async (row: any) => {
  // 检查 id 是否为空  
  if (!row.id) {  
    ElMessage.error(t('basicData.updatanull'));  
    return; // 如果 id 为空,则不执行后续操作  
  }  
  const newState = row.state === 100 ? 0 : 100;
  try {
    const response = await request.post('/loadGlass/up-patten-usage/updateGlassState', {id: row.id, state: newState});
    if (response.code === 200) {
      ElMessage.success(response.message);
      row.state = newState;
    } else {
      ElMessage.error(response.message);
    }
  } catch (error) {
    ElMessage.error(t('basicData.glassnull'));
  }
};
</script>
<template>
  <div style="height: 500px;">
    <div>
      <div id="dotClass">
        <div>{{ $t('basicData.laserprinting') }}</div>
        <i :style="{ marginTop: '2px', backgroundColor: markingMachineStatus, width: '18px', height: '18px', borderRadius: '50%', display: 'block' }"></i>
        <el-button @click="confirmMarkingMachine" style="margin-left: 30px;margin-top: -3px;">{{
            $t('basicData.yes')
          }}
        </el-button>
        <div style="margin-left: 70px;">{{ $t('basicData.cuttingmachine') }}</div>
        <i :style="{ marginTop: '2px', backgroundColor: cuttingMachineStatus, width: '18px', height: '18px', borderRadius: '50%', display: 'block' }"></i>
        <el-button @click="confirmCuttingMachine" style="margin-left: 30px;margin-top: -3px;">{{
            $t('basicData.yes')
          }}
        </el-button>
        <div style="margin-left: 70px;">{{ upstatus }}</div>
        <i :style="{ marginTop: '2px', backgroundColor: cuttingMachineStatusColor, width: '18px', height: '18px', borderRadius: '50%', display: 'block' }"></i>
        <el-button @click="confirmCutting" style="margin-left: 30px;margin-top: -3px;">{{
            $t('basicData.change')
          }}
        </el-button>
  </div>
    <el-button style="margin-top: 5px;margin-left: 15px;"  type="primary" @click="selectproject">{{ $t('Mounting.previewproject') }}</el-button>
    <el-button style="margin-top: 5px;margin-left: 20px;" type="success" @click="handleBind">{{ $t('basicData.startloading') }}</el-button>
    <el-button style="margin-top: 5px;margin-left: 20px;"  id="searchButton" type="warning" @click="handleBinda">{{ $t('basicData.stop') }}</el-button>
    <el-button style="margin-top: 5px;margin-left: 20px;" id="searchButton" type="info" @click="handlezhiban">{{ $t('searchOrder.dutyinformation') }}</el-button>
    <el-select disabled v-model="selectValuesa[1]" clearable :placeholder="$t('Mounting.twoloadingline')"
               style="margin-top: 5px;margin-left: 20px;">
      <el-option :label="$t('Mounting.all')" value="0"></el-option>
      <el-option :label="$t('Mounting.oneloadingline')" value="1"></el-option>
      <el-option :label="$t('Mounting.twoloadingline')" value="2"></el-option>
    </el-select>
    <el-select v-model="selectValuesa[0]" clearable :placeholder="$t('film.taskstatus')" style="margin-top: 5px;margin-left: 20px;" >
      <el-option :label="$t('Mounting.waiting')" value="1"></el-option>
      <el-option :label="$t('film.execution')" value="2"></el-option>
      <el-option :label="$t('film.finish')" value="3"></el-option>
    </el-select>
    <el-button type="primary" style="margin-left: 10px;" @click="selectReportData()">{{ $t('Mounting.setparameters') }}</el-button>
    <el-card style="flex: 1;margin-left: 10px;margin-top: 15px;" v-loading="loading">
      <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
    <el-table
    height="350"
     ref="table" 
     :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}"
      :data="tableData"
    >
      <el-table-column prop="layoutSequence" :label="$t('Mounting.project')" width="100" align="center"/>
      <el-table-column prop="engineeringId" :label="$t('Mounting.width')" width="200" align="center"/>
      <el-table-column prop="width" :label="$t('Mounting.height')" align="center"/>
      <el-table-column prop="height" :label="$t('Mounting.thickness')" align="center"/>
      <el-table-column prop="filmsId" :label="$t('Mounting.loadinglinea')" align="center"/>
      <el-table-column :label="$t('Mounting.projectnumber')" align="center">  
      <template #default="{ row }">  
        <!-- 这里总是显示 1 -->  
        <span>{{ 1 }}</span>  
      </template>  
    </el-table-column>  
      <el-table-column
          align="center"
            :label="$t('Mounting.state')"
            min-width="80"
            prop="state"
          >
          <template #default="scope">  
          <el-tag  
            :type="scope.row.state === 100 ? 'success' : 'warning'"  
            @click="toggleEnableState(scope.row)"  
          >  
            {{ scope.row.state === 100 ? $t('Mounting.pass') : $t('Mounting.waiting') }}
          </el-tag>  
        </template> 
          </el-table-column>
      <el-table-column prop="filmsId" :label="$t('Mounting.createtime')" align="center"/>
    </el-table>
      </div>
    </el-card>
    <div style="display: flex;">
      <div style="width: 49%;float: left;margin-left: 300px;">
        <div style="display: flex;">
          <img src="../../assets/shangpianji.png" alt=""
               style="max-width: 25%;max-height: 25%;margin-left: 10%;margin-top: 5%;">
          <el-table :data="tableDataa" border style="width: 75%;margin-top: 10%;margin-left: 8%;"
                    :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}"
          >
            <el-table-column prop="workstationId" align="center" :label="$t('basicData.station')" min-width="60"/>
            <el-table-column prop="patternWidth" align="center" :label="$t('basicData.width')" min-width="80"/>
            <el-table-column prop="patternHeight" align="center" :label="$t('basicData.height')" min-width="80"/>
            <el-table-column prop="filmsId" align="center" :label="$t('basicData.coatingtypes')" min-width="80"/>
            <el-table-column prop="number" align="center" :label="$t('basicData.quantity')" min-width="80"/>
          </el-table>
        </div>
      </div>
      <!-- <div style="width: 48%;float: right;">
        <div style="display: flex;">
          <img src="../../assets/shangpianji.png" alt="" style="max-width: 25%;max-height: 25%;margin-left: 10%;margin-top: 5%;">
          <el-table :data="tableDatab" border style="width: 75%;margin-top: 10%;margin-left: 2%;"
       :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}"
          >
            <el-table-column prop="workstationId" align="center" :label="$t('basicData.station')" min-width="60" />
            <el-table-column prop="patternWidth" align="center" :label="$t('basicData.width')" min-width="80" />
            <el-table-column prop="patternHeight" align="center" :label="$t('basicData.height')" min-width="80" />
            <el-table-column prop="filmsId" align="center" :label="$t('basicData.coatingtypes')" min-width="80" />
            <el-table-column prop="number" align="center" :label="$t('basicData.quantity')" min-width="80" />
          </el-table>
      </div>
  </div> -->
</div>
  <el-dialog v-model="blind" top="30vh" width="25%" :title="$t('basicData.startfilm')">
    <template #footer>
      <div id="dialog-footer">
        <el-button type="primary" @click="handleon">
          {{ $t('basicData.confirm') }}
        </el-button>
        <el-button @click="blind = false">{{ $t('basicData.cancel') }}</el-button>
      </div>
    </template>
  </el-dialog>
 
    <el-dialog v-model="dialoglea" top="15vh" width="70%" :title="$t('searchOrder.dutyinformation')">
      <el-table ref="table" style="margin-top: 20px;height: 300px;"
                :data="tableDatax" :header-cell-style="{background:'#F2F3F5 ',color:'#1D2129'}">
        <el-table-column prop="line" fixed align="center" :label="$t('searchOrder.line')"/>
        <el-table-column prop="workProcesses" fixed align="center" :label="$t('searchOrder.process')"/>
        <el-table-column prop="teamsGroupsName" align="center" :label="$t('searchOrder.team')">
          <!-- <template #default="{ row }">
            <el-input v-model="row.teamsGroupsName" autocomplete="off" min-width="150"/>
          </template>   -->
        </el-table-column>
        <el-table-column prop="deviceName" align="center" :label="$t('searchOrder.basic')">
          <!-- <template #default="{ row }">
        <el-input v-model="row.deviceName" autocomplete="off" min-width="150"/>
      </template> -->
        </el-table-column>
        </el-table>
        <template #footer>
      <div id="dialog-footer">
        <el-button @click="dialoglea = false">{{ $t('large.close') }}</el-button>
      </div>
    </template>
</el-dialog>
  <el-dialog v-model="blinda" top="24vh" width="30%" :title="$t('basicData.whetherpause')">
    <div style="margin-left: 50px;margin-bottom: 10px;">
    <el-form-item :label="$t('Mounting.loadingline')" :required="true">
      <el-select disabled v-model="stationCell" clearable :placeholder="$t('Mounting.inloadingline')"
                 style="margin-left: 20px;">
        <el-option :label="$t('Mounting.all')" value="0"></el-option>
        <el-option :label="$t('Mounting.oneloadingline')" value="1"></el-option>
        <el-option :label="$t('Mounting.twoloadingline')" value="2"></el-option>
      </el-select>
    </el-form-item>
    </div>
    <template #footer>
      <div id="dialog-footer">
        <el-button type="primary" @click="handleup">
          {{ $t('basicData.confirm') }}
        </el-button>
        <el-button @click="blinda = false">{{ $t('basicData.cancel') }}</el-button>
      </div>
    </template>
  </el-dialog>
  </div>
  <el-dialog v-model="dialogFormVisible" top="24vh" width="70%">
    <div class="flex-container" style="margin-left: 50px;margin-bottom: 10px;">
      <el-form-item :label="$t('Mounting.loadingline')" :required="true">
        <el-select disabled v-model="stationCell" clearable :placeholder="$t('Mounting.inloadingline')">
          <el-option :label="$t('Mounting.oneloadingline')" value="1"></el-option>
          <el-option :label="$t('Mounting.twoloadingline')" value="2"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('Mounting.projecta')" :required="true">
        <el-select
            v-model="selectedProjectNo"
            filterable
            clearable
            :placeholder="$t('basicData.plselectproject')"
            style="width: 220px"
            @input="handleInputChange"
        >
          <el-option
              v-for="item in titleSelectJson['engineerId']"
              :key="item.id"
              :label="item.projectNo"
              :value="item.projectNo"
          />
        </el-select>
      </el-form-item>
      <el-form-item :label="$t('Mounting.removalmethoda')" :required="true">
        <el-select v-model="filmRemove" clearable :placeholder="$t('Mounting.removalmethod')">
          <el-option :label="$t('Mounting.noremoval')" value="0"></el-option>
          <el-option :label="$t('Mounting.coarselyground')" value="1"></el-option>
          <el-option :label="$t('Mounting.finegrinding')" value="2"></el-option>
        </el-select>
      </el-form-item>
    </div>
    <template #footer>
      <div id="dialog-footer">
        <el-button type="primary" @click="handlesure">
          {{ $t('basicData.confirm') }}
        </el-button>
        <el-button @click="dialogFormVisible = false">{{ $t('basicData.cancel') }}</el-button>
      </div>
    </template>
  </el-dialog>
  </div>
</template>
 
<style scoped>
 .flex-container {  
  display: flex;  
  align-items: center; /* 垂直居中 */  
}  
.flex-container .el-form-item {  
  flex: 1; /* 使每个表单项占据相等的空间 */  
  margin-right: 0; /* 移除默认的右侧边距 */  
}  
.flex-container .el-form-item:last-child {  
  margin-left: 20px; /* 为第二个表单项添加左侧边距 */  
}
 
 
 
#dt { display:block; float:left;line-height: 20px;margin-left: 100px;}
#dta { display:block; float:left;line-height: 20px;margin-left: 80%;}
#dialog-footer{
  text-align: center;
  margin-top: -15px;
}
#dotClass {
  display: flex;
  margin-left: 20px; 
  size: 50px;
  margin-top: 20px;
  margin-bottom: 10px;
}
</style>