From f6edee889e34cc5de979e05eac4dffe81e29a9f9 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期一, 17 四月 2023 16:55:13 +0800
Subject: [PATCH] 1.多排备份
---
src/views/deviceManager/deviceGroup.vue | 337 ++++--
src/views/deviceManager/deviceType.vue | 2485 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 2,682 insertions(+), 140 deletions(-)
diff --git a/src/views/deviceManager/deviceGroup.vue b/src/views/deviceManager/deviceGroup.vue
index d9d3c9e..425c95f 100644
--- a/src/views/deviceManager/deviceGroup.vue
+++ b/src/views/deviceManager/deviceGroup.vue
@@ -1,3 +1,5 @@
+<!--澶氭帓闈為〉绛惧舰寮�-->
+
<template>
<div>
<div class="body" :style="{height:mainHeight+'px'}">
@@ -1178,7 +1180,9 @@
startdate: handleDatetime(new Date()), // 褰撳墠鏃ユ湡锛堜粖澶╋級
enddate: row.AdvaScheEndDate // 瑕佹眰浜や粯鏃堕棿
})
+ row.AdvaSchePiroQueNumber = row.AdvaSchePiroQue === '姝e父' ? 3 : row.AdvaSchePiroQue === '绱ф��' ? 2 : 1
})
+
const res = await NewOnclickAdvancedSchedulingDevice(DATA)
// 濡傛灉Message鏈夋姤閿欎俊鎭垯缁堟鎵ц鍚庨潰閫昏緫
if (res.rus.Message) {
@@ -1346,6 +1350,9 @@
allCapacity.forEach(it => {
if (item.wo_code === it.wo_code) {
this.pushCapacity(everyEqpCapacity, it.id, it.gtArray)
+ it.gtArray = it.gtArray.filter((currentValue, currentIndex, selfArr) => {
+ return selfArr.findIndex(item => item.start === currentValue.start) === currentIndex
+ })
// it.gtArray.sort((a, b) => new Date(a.end).getTime() - new Date(b.end).getTime())
}
})
@@ -1367,14 +1374,34 @@
}
}
}
+
+ // 灏嗗伐鍗曠殑浼樺厛绾ц繘琛屾帓搴忥紝鍏堜互鏃堕棿鎺掞紝鍐嶄互浼樺厛绾ф帓
+ this.getMultipleSelectionOrder()
+
// this.eqpTopTempData = JSON.parse(JSON.stringify(this.schedulingData))
- console.log(waitingForScheduling, 'waitingForScheduling')
- console.log(allCapacity, 'allCapacity')
- console.log(this.schedulingData, 'schedulingData')
- // console.log(JSON.stringify(this.schedulingData), 'schedulingData')
- console.log(this.schedulingAllData, 'schedulingAllData')
- console.log(everyEqpCapacity, 'everyEqpCapacity')
+ // console.log(waitingForScheduling, 'waitingForScheduling')
+ // console.log(allCapacity, 'allCapacity')
+ // console.log(this.schedulingData, 'schedulingData')
+ // // console.log(JSON.stringify(this.schedulingData), 'schedulingData')
+ // console.log(this.schedulingAllData, 'schedulingAllData')
+ // console.log(everyEqpCapacity, 'everyEqpCapacity')
+ },
+ // 灏嗗伐鍗曠殑浼樺厛绾ц繘琛屾帓搴忥紝鍏堜互鏃堕棿鎺掞紝鍐嶄互浼樺厛绾ф帓
+ getMultipleSelectionOrder() {
+ // 1.鍏堥�氳繃鏃堕棿鍘婚噸鐭ラ亾鏈夊摢鍑犲ぉ鐨勬椂闂� // 2.閬嶅巻杩欏嚑澶╃殑鏃堕棿锛岃繃婊ゅ嚭鐩稿搴旂殑宸ュ崟
+ const newArr = []
+ this.multipleSelection.filter((currentValue, currentIndex, selfArr) => {
+ return selfArr.findIndex(item => item.AdvaScheEndDate === currentValue.AdvaScheEndDate) === currentIndex
+ }).map(i => i.AdvaScheEndDate).forEach(i => {
+ newArr.push(this.multipleSelection.filter(j => j.AdvaScheEndDate === i))
+ })
+ // 鏍规嵁鏃ユ湡鐩稿悓鐨勶紝宸ュ崟浼樺厛绾ц繘琛屾帓搴�
+ newArr.filter(i => {
+ i.sort((a, b) => b.AdvaSchePiroQueNumber - a.AdvaSchePiroQueNumber)
+ })
+ // 鎺掑ソ涔嬪悗 宸ュ崟椤哄簭灏辨槸鏁翠釜鐨勪紭鍏堢骇
+ this.multipleSelection = newArr.flat()// 浜岀淮杞竴缁�
},
// 鏃堕棿/璁惧浼樺厛鎺掔▼
prepareArrange() {
@@ -1387,7 +1414,7 @@
// 璁惧浼樺厛鎴栬�呮椂闂翠紭鍏� 瀵规暟鎹繘琛岀殑鏍煎紡杞崲
if (this.schedulingData !== '' && this.formBottom.types === 'N') { // 璁惧浼樺厛
this.eqpDataTransition()
- this.editLastValue(this.schedulingData)
+ // this.editLastValue(this.schedulingData)
} else if (this.timeTopTempData !== '' && this.formBottom.types === 'Y') { // 鏃堕棿浼樺厛
this.filterAlreadyScheduleTime() // 鎵嬪姩杩囨护鎵�鏈夋椂闂村凡鎺掔▼
this.timeDataTransition()
@@ -1397,144 +1424,180 @@
},
// 璁惧浼樺厛 鏁版嵁鏍煎紡杞崲
eqpDataTransition() {
- let needNumber = this.formBottom.needArrangeNumber // 闇�鎺掓暟閲�
- let flag1 = 0
- console.log(this.schedulingData, 33)
- console.log(this.schedulingData.length, 33)
- for (const i in this.schedulingData) {
- console.log(i, '涓浗绉诲姩')
- let end_arr = [] // 宸叉帓绋嬬殑鏁扮粍
- let need_arr = [] // 寰呮帓绋嬬殑鏁扮粍
+ const needNumber = this.formBottom.needArrangeNumber // 闇�鎺掓暟閲�
- let capacity_arr = [] // 瑕佹帓绋嬬殑鏁扮粍
- this.schedulingData[i].gtArray.sort((a, b) => new Date(a.end).getTime() - new Date(b.end).getTime())
+ // 灏嗕骇鑳界殑鎵�鏈夊�间笌澶氶�夋鐨勯�変腑鐨勮鏃堕棿杩涜鍖归厤鏍¢獙 浠ヤ究鍚庣画璁$畻
+ this.multipleSelection.forEach(item => {
+ this.schedulingAllData.forEach(it => {
+ // 鎵惧埌宸ュ崟鎵�瀵瑰簲鐨勮澶囪繘琛岃绠楁帓绋� 鍐欏嚭璁$畻閫昏緫 杩欓儴鍒嗘瘮杈冧笂澶�
+ if (it.wo_code === item.AdvaScheWorkCode) {
+ it.gtArray.forEach(i => {
+ const t = i.start.split(' ')[0]
+ // 浠h〃褰撳墠宸ュ崟涓嬬殑浜ц兘鏄惁鍙帓
+ i.status = new Date(t).getTime() <= new Date(item.AdvaScheEndDate).getTime()
- end_arr = JSON.parse(JSON.stringify(this.schedulingData[i].gtArray.filter(item => item.type === 'h_schedule'))) // 宸叉帓绋嬫暟缁�
- need_arr = JSON.parse(JSON.stringify(this.schedulingData[i].gtArray.filter(item => item.type === 'capacity'))) // 瀹归噺
- console.log(need_arr, 5)
- console.log(JSON.stringify(need_arr))
+ console.log(i)
- if (end_arr && end_arr.length > 0) {
- capacity_arr = need_arr.map(item => {
- // 鎺掗櫎鎺夊凡缁忔帓绋嬬殑瀛樺湪hshedule锛宻tart锛宔nd閮界浉绛夌殑鎯呭喌
- const schedule = end_arr.filter(it => {
- return new Date(item.start).getTime() <= new Date(it.start).getTime() &&
- new Date(item.end).getTime() >= new Date(it.end).getTime()
+ // 鐩墠璁$畻閫昏緫杩樹笉澶竻妤氭�庝箞鍐� 澶笂澶翠簡
+
+ console.log(it.id, 'it')
+
+ const end_time = ''
+ const mistiming = ''
+ // 宸ュ崟鐩稿悓涔嬪悗 搴旇鏍规嵁鏃堕棿浼樺厛鎴栬�呰澶囦紭鍏� 瀵硅澶囪繘琛屼竴涓�鎺掔▼
+
+ // 浜ц兘鏈夊嚑娈� data鐨勪釜鏁版渶澶氬氨鏈夊嚑涓�
+ const data = {
+ id: it.id,
+ start: '2023-04-17 13:00:00',
+ end: '2023-04-17 16:00:00',
+ type: 'schedule',
+ cl_name: item.AdvaSchePartName,
+ cl_code: item.AdvaSchePartNumber,
+ work_order: item.AdvaScheWorkCode,
+ AdvaScheUom: item.AdvaScheUom,
+ number: 0,
+ real_number: 0
+ }
+
+ // 杩欎釜鍦版柟涓嶅 鍐欎笉鍑烘潵浜�
+ // data.start = it.gtArray[0].start // 鍏堝彧鑰冭檻涓�绉嶆儏鍐�
+ // data.start = it.gtArray[0].start // 鍏堝彧鑰冭檻涓�绉嶆儏鍐�
+ data.number = '230'
+ data.real_number = '230'
+ const index = this.schedulingData.findIndex(i => i.id === it.id)
+ this.schedulingData[index].gtArray.push(data)
+
+ return false
})
-
- if (schedule && schedule.length > 0) {
- item.start = this.MinutesTest(schedule[schedule.length - 1]['end'])
- }
-
- const schedule1 = end_arr.filter(schedule => {
- return new Date(item.start).getTime() === new Date(schedule.start).getTime() &&
- new Date(item.end).getTime() === new Date(schedule.end).getTime()
- })
- if (schedule1 && schedule1.length > 0) {
- item.capacity = false
- }
-
- return item
- }).filter(item => item.capacity !== false)
- } else {
- capacity_arr = need_arr
- }
-
- const id_obj = {
- id: '',
- start_time: ''
- }
- if (end_arr != '') {
- (id_obj.id = end_arr[0].id), (id_obj.start_time = end_arr[0].end)
- }
-
- capacity_arr = this.filterOutTime(capacity_arr) // 杩囨护鎺夊綋鍓嶆椂闂翠箣鍓嶇殑涓嶈兘鎺掔▼
-
- for (const w in capacity_arr) {
- console.log(capacity_arr[w], 'capacity_arr')
- let end_time = ''
- let mistiming = ''
- const data = {
- id: capacity_arr[w].id,
- start: '',
- end: '',
- type: 'schedule',
- cl_name: capacity_arr[w].partname, // 浜у搧鍚嶇О
- cl_code: capacity_arr[w].partcode, // 浜у搧缂栫爜
- work_order: capacity_arr[w].work_order,
- AdvaScheUom: capacity_arr[w].AdvaScheUom,
- number: 0,
- real_number: 0
}
- if (
- id_obj.start_time !== '' &&
- flag1 === 0 &&
- new Date(id_obj.start_time).getTime() >= new Date(capacity_arr[w].start).getTime()
- ) {
- data.start = this.MinutesTest(id_obj.start_time)
- flag1 = 1
- } else {
- data.start = capacity_arr[w].start
- }
- let nowTime = (this.schedulingData[i].AdvaDevicRhythm * needNumber) / capacity_arr[w].mod
- end_time = this.formSeconds(nowTime, data.start, capacity_arr[w].mod) // 鎬诲叡鐨勭粨鏉熸椂闂�
- data.end = end_time
- mistiming = this.compareTime(
- end_time,
- capacity_arr[w].end,
- capacity_arr[w].mod
- ) // 鎬诲叡鐨勭粨鏉熸椂闂�-褰撳墠鐨勭粨鏉熸椂闂� = 鍓╀笅澶氫箙鏃堕棿
- if (mistiming >= 0) {
- data.number =
- ((new Date(data.end) - new Date(data.start)) *
- capacity_arr[w].mod) /
- this.schedulingData[i].AdvaDevicRhythm /
- 1000
- data.real_number =
- ((new Date(data.end) - new Date(data.start)) *
- capacity_arr[w].mod) /
- this.schedulingData[i].AdvaDevicRhythm /
- 1000
- data.number = data.number.toFixed(0)
- data.end_num = true
- if (new Date(data.start) >= new Date(data.end)) {
- } else {
- this.schedulingData[i].gtArray.push(data)
- }
- return false
- } else {
- data.end = capacity_arr[w].end
+ })
+ })
- if (new Date(data.end).getTime() < new Date(data.start)) {
- continue // 鍥犱负寮�濮嬫椂闂存瘮缁撴潫鏃堕棿澶� 闇�瑕佽烦杩囧悗闈㈡楠�
- }
+ // 杩欎釜鏄绠楀嚭鏉ョ殑鏁板�硷紝闇�瑕乸ush鍒皊chedulingData涓�
- // 杩欓噷闄や互涓�鍗冩槸鍥犱负 new Date() 寰楀埌鐨勬槸姣 姣杞寲涓虹鏄崈杩涘埗
- // 涓�娈垫椂闂存鍐呯殑鐢熶骇閲�=涓よ�呮椂闂村樊锛堟绉掞級/1000 / 鐢熶骇鑺傛媿 * 绋煎姩鐜�
- data.number =
- ((new Date(data.end) - new Date(data.start)) *
- capacity_arr[w].mod) /
- this.schedulingData[i].AdvaDevicRhythm /
- 1000
+ // 'id': 'JG002',
+ // 'start': '2023-04-17 10:10:21',
+ // 'end': '2023-04-17 11:30:00',
+ // 'type': 'schedule',
+ // 'cl_name': '涓绘満',
+ // 'cl_code': '201',
+ // 'work_order': 'MO-2023-04-0001_1',
+ // 'AdvaScheUom': '涓�',
+ // 'number': '64',
+ // 'real_number': 63.72
- data.real_number =
- ((new Date(data.end) - new Date(data.start)) *
- capacity_arr[w].mod) /
- this.schedulingData[i].AdvaDevicRhythm /
- 1000
+ // this.schedulingData = [
+ // {
+ // 'id': 'JG002',
+ // 'name': '绮惧伐璁惧2#',
+ // 'AdvaDevicRhythm': '15.0',
+ // 'status': true,
+ // 'colorPair': {
+ // 'dark': 'rgb(83, 186, 241,0.8)',
+ // 'light': 'rgb(83, 186, 241,0.1)',
+ // 'light_capacity': 'rgb(209,239,237,0.8)',
+ // 'h_schedule': 'rgb(100,255,192,0.8)',
+ // 'scheduleing': 'rgb(20,182,231,0.8)'
+ // },
+ // 'gtArray': [
+ // {
+ // 'start': '2023-04-17 08:00:00',
+ // 'end': '2023-04-17 11:30:00',
+ // 'id': 'JG002',
+ // 'mod': 0.2,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-04-17 13:00:00',
+ // 'end': '2023-04-17 18:00:00',
+ // 'id': 'JG002',
+ // 'mod': 0.2,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'id': 'JG002',
+ // 'start': '2023-04-17 10:10:21',
+ // 'end': '2023-04-17 11:30:00',
+ // 'type': 'schedule',
+ // 'cl_name': '涓绘満',
+ // 'cl_code': '201',
+ // 'work_order': 'MO-2023-04-0001_1',
+ // 'AdvaScheUom': '涓�',
+ // 'number': '64',
+ // 'real_number': 63.72
+ // },
+ // {
+ // 'id': 'JG002',
+ // 'start': '2023-04-17 13:00:00',
+ // 'end': '2023-04-17 18:00:00',
+ // 'type': 'schedule',
+ // 'cl_name': '涓绘満',
+ // 'cl_code': '201',
+ // 'work_order': 'MO-2023-04-0001_1',
+ // 'AdvaScheUom': '涓�',
+ // 'number': '240',
+ // 'real_number': 240
+ // }
+ // ]
+ // },
+ // {
+ // 'id': 'SB001',
+ // 'name': '璁惧001',
+ // 'AdvaDevicRhythm': '15.0',
+ // 'status': true,
+ // 'colorPair': {
+ // 'dark': 'rgb(83, 186, 241,0.8)',
+ // 'light': 'rgb(83, 186, 241,0.1)',
+ // 'light_capacity': 'rgb(209,239,237,0.8)',
+ // 'h_schedule': 'rgb(100,255,192,0.8)',
+ // 'scheduleing': 'rgb(20,182,231,0.8)'
+ // },
+ // 'gtArray': [
+ // {
+ // 'start': '2023-04-17 08:00:00',
+ // 'end': '2023-04-17 11:30:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-04-17 13:00:00',
+ // 'end': '2023-04-17 18:00:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'id': 'SB001',
+ // 'start': '2023-04-17 10:10:21',
+ // 'end': '2023-04-17 11:30:00',
+ // 'type': 'schedule',
+ // 'cl_name': '涓绘満',
+ // 'cl_code': '201',
+ // 'work_order': 'MO-2023-04-0001_1',
+ // 'AdvaScheUom': '涓�',
+ // 'number': '96',
+ // 'real_number': 95.58
+ // },
+ // {
+ // 'id': 'SB001',
+ // 'start': '2023-04-17 13:00:00',
+ // 'end': '2023-04-17 18:00:00',
+ // 'type': 'schedule',
+ // 'cl_name': '涓绘満',
+ // 'cl_code': '201',
+ // 'work_order': 'MO-2023-04-0001_1',
+ // 'AdvaScheUom': '涓�',
+ // 'number': '360',
+ // 'real_number': 360
+ // }
+ // ]
+ // }
+ // ]
- data.number = data.number.toFixed(0)
-
- nowTime = (needNumber - data.real_number) * this.schedulingData[i].AdvaDevicRhythm
- needNumber = needNumber - data.real_number
- if (new Date(data.start) >= new Date(data.end)) {
-
- } else {
- this.schedulingData[i].gtArray.push(data)
- }
- }
- }
- }
+ console.log(this.schedulingData, 'schedulingData')
+ console.log(this.schedulingAllData, 'schedulingAllData')
},
// 鑾峰彇鎺掔▼鏃ユ湡鏈�澶у��
getMaxPayDate() {
@@ -1733,7 +1796,7 @@
}
},
// 璁惧浼樺厛 鏁版嵁鏍煎紡杞崲
- eqpDataTransition2() {
+ eqpDataTransition2() { // 杩欓噷鏄師鍏堢殑鍐欐硶
let needNumber = this.formBottom.needArrangeNumber // 闇�鎺掓暟閲�
let flag1 = 0
console.log(this.schedulingData, 33)
diff --git a/src/views/deviceManager/deviceType.vue b/src/views/deviceManager/deviceType.vue
index b4ef92f..7d87187 100644
--- a/src/views/deviceManager/deviceType.vue
+++ b/src/views/deviceManager/deviceType.vue
@@ -1,11 +1,2490 @@
-<template />
+<!--澶氭帓椤电褰㈠紡-->
+
+<template>
+ <div>
+ <div class="body" :style="{height:mainHeight+'px'}">
+
+ <div class="bodyTopFormGroup" style="margin-top: 10px;padding-top: 10px">
+ <el-form
+ ref="form"
+ :model="formTop"
+ label-width="100px"
+ inline
+ style="display: flex;"
+ >
+ <div class="elForm">
+ <el-form-item label="杞﹂棿缂栫爜" style=" display: flex;">
+ <el-input v-model="formTop.workshop" placeholder="璇疯緭鍏�" style="width: 200px" />
+ </el-form-item>
+ <el-form-item label="鐢熶骇宸ュ崟鍙�" style=" display: flex;">
+ <el-input v-model="formTop.wocode" placeholder="璇疯緭鍏�" style="width: 200px" />
+ </el-form-item>
+ <el-form-item label="鐗╂枡缂栫爜" style=" display: flex;">
+ <el-input v-model="formTop.partcode" placeholder="璇疯緭鍏�" style="width: 200px" />
+ </el-form-item>
+ <el-form-item label="鐗╂枡鍚嶇О" style=" display: flex;">
+ <el-input v-model="formTop.partname" placeholder="璇疯緭鍏�" style="width: 200px" />
+ </el-form-item>
+ </div>
+ <div
+ class="bodySearchReset"
+ :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
+ >
+ <el-button v-waves type="primary" icon="el-icon-search" @click="search">鏌ヨ</el-button>
+ <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
+ </div>
+ </el-form>
+ <div
+ class="bodyTopFormExpand"
+ style="height: 5px"
+ />
+ </div>
+
+ <div class="elTableDiv" style="margin-top: 0">
+ <el-table
+ ref="tableDataRef"
+ class="tableFixed"
+ :data="tableData"
+ :height="(tableHeight-400)+'px'"
+ border
+ :row-class-name="tableRowClassName"
+ :style="{width: 100+'%',height:(tableHeight-400)+'px',}"
+ highlight-current-row
+ :header-cell-style="this.$headerCellStyle"
+ :cell-style="this.$cellStyle"
+ @sort-change="sortChangeTop"
+
+ @selection-change="handleSelectionChange"
+ >
+ <!-- @row-click="getCurrentRow"-->
+
+ <!-- @selection-change="handleSelectionChange"-->
+
+ <el-table-column
+ type="selection"
+ width="55"
+ />
+ <el-table-column
+ prop="RowNum"
+ width="50"
+ fixed
+ label="搴忓彿"
+ />
+ <el-table-column
+ prop="AdvaSchePiroQue"
+ show-tooltip-when-overflow
+ label="浼樺厛绾�"
+ width="90"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="AdvaScheWorkShop"
+ label="鐢熶骇杞﹂棿"
+ width="110"
+ show-tooltip-when-overflow
+ sortable="custom"
+ />
+ <el-table-column
+ prop="AdvaScheWorkCode"
+ label="宸ュ崟缂栧彿"
+ min-width="160"
+ show-tooltip-when-overflow
+ sortable="custom"
+ />
+ <el-table-column
+ prop="AdvaSchePartNumber"
+ label="浜у搧缂栫爜"
+ min-width="110"
+ show-tooltip-when-overflow
+ sortable="custom"
+ >
+ <!-- <template slot-scope="{row}">-->
+ <!-- <div v-if="row.AdvaSchePartNumber">{{ row.AdvaSchePartNumber }}</div>-->
+ <!-- <div v-else>/</div>-->
+ <!-- </template>-->
+ </el-table-column>
+ <el-table-column
+ prop="AdvaSchePartName"
+ min-width="160"
+ show-tooltip-when-overflow
+ label="浜у搧鍚嶇О"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="AdvaSchePartSpec"
+ label="浜у搧瑙勬牸"
+ width="110"
+ show-tooltip-when-overflow
+ sortable="custom"
+ >
+ <template slot-scope="{row}">
+ <div v-if="row.AdvaSchePartSpec">{{ row.AdvaSchePartSpec }}</div>
+ <div v-else>/</div>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="AdvaScheQty"
+ label="鏁伴噺"
+ show-tooltip-when-overflow
+ width="110"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="AdvaScheEndDate"
+ label="瑕佹眰浜や粯鏃堕棿"
+ sortable="custom"
+ show-tooltip-when-overflow
+ width="160"
+ />
+ <el-table-column
+ prop="AdvaScheStus"
+ label="鎺掔▼鐘舵��"
+ show-tooltip-when-overflow
+ width="110"
+ sortable="custom"
+ >
+ <template slot-scope="{row}">
+ <div v-if="row.AdvaScheStus==='NOSCHED'">寰呮帓绋�</div>
+ <div v-if="row.AdvaScheStus==='SCHED'">宸叉帓绋�</div>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="AdvaScheBotProcName"
+ label="鎺掔▼宸ュ簭"
+ show-tooltip-when-overflow
+ width="110"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="AdvaSchePCStartDate"
+ label="璁″垝鎺掔▼鏃堕棿"
+ width="200"
+ sortable="custom"
+ show-tooltip-when-overflow
+ >
+ <template slot-scope="{row}">
+ <div v-if="row.AdvaSchePCStartDate">{{ row.AdvaSchePCStartDate }} ~ {{ row.AdvaSchePCEndDate }}</div>
+ <div v-else>/</div>
+ </template>
+ </el-table-column>
+
+ </el-table>
+ </div>
+ <!--鍒嗛〉-->
+ <pagination
+ :total="totalTop"
+ :page.sync="formTop.page"
+ :limit.sync="formTop.rows"
+ align="right"
+ layout="total,prev, pager, next,sizes"
+ popper-class="select_bottom"
+ @pagination="getAdvancedSchedulingSearch"
+ />
+
+ <!-- 鑷姩鎺掔▼閮ㄥ垎鐨勪唬鐮�-->
+ <div class="autoScheduling">
+
+ <div class="bodyTopFormGroup">
+ <el-form
+ ref="form"
+ :model="formBottom"
+ inline
+ label-width="100px"
+ style="display: flex;"
+ >
+ <div class="elForm">
+ <el-form-item label="鎺掔▼鏃ユ湡" style=" display: flex;">
+ <el-date-picker
+ v-model="formBottom.scheDate"
+ :disabled="multipleSelection.length===0"
+ type="daterange"
+ range-separator="~"
+ format="yyyy-MM-dd"
+ value-format="yyyy-MM-dd"
+ start-placeholder="寮�濮嬫棩鏈�"
+ end-placeholder="缁撴潫鏃ユ湡"
+ size="small"
+ :picker-options="pickerOptions1"
+ :clearable="false"
+ @change="dateChange"
+ />
+ </el-form-item>
+ <el-form-item label="鎺掔▼鏂瑰紡" style=" display: flex;">
+ <el-select
+ v-model="formBottom.types"
+ :disabled="multipleSelection.length===0"
+ style="width:120px"
+ @change="typesChange"
+ >
+ <el-option value="N" label="璁惧浼樺厛" />
+ <el-option value="Y" label="鏃堕棿浼樺厛" />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鏃堕棿鍒诲害(鍒嗛挓)" label-width="110" style=" display: flex;">
+ <el-select
+ v-model.number="formBottom.scale"
+ :disabled="multipleSelection.length===0"
+ style="width: 120px;"
+ >
+ <el-option v-for="item in scaleList" :key="item" :value="item" :label="item" />
+ </el-select>
+
+ </el-form-item>
+ <el-form-item label="鎹㈠瀷鏃堕棿(鍒嗛挓)" label-width="110" style=" display: flex;">
+ <el-input
+ id="scale"
+ v-model="formBottom.times"
+ :disabled="multipleSelection.length===0"
+ type="number"
+ style="display:inline-block;width:80px;"
+ @change="no_zero"
+ />
+ </el-form-item>
+ <el-form-item label="棰勬帓杩涘害" style=" display: flex;">
+ <span>
+ <span style="text-decoration:underline;">{{ formBottom.canArrangeNumber }}</span> /
+ <span style="text-decoration:underline">{{ formBottom.needArrangeNumber }}</span>
+ </span>
+ </el-form-item>
+ </div>
+ <div
+ class="bodySearchReset"
+ :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
+ >
+ <el-button
+ v-waves
+ :disabled="multipleSelection.length===0"
+ type="primary"
+ icon="el-icon-document-remove"
+ @click="prepareArrange"
+ >棰勬帓
+ </el-button>
+ <el-button
+ v-waves
+ type="primary"
+ :disabled="multipleSelection.length===0"
+ icon="el-icon-document-checked"
+ @click="prepareSubmit"
+ >鎻愪氦
+ </el-button>
+ </div>
+ </el-form>
+ <div class="colorDescription">
+ <div class="colorDescriptionItem"><i
+ class="el-icon-s-opportunity"
+ style="margin-right: 5px;color: rgba(5, 185, 100, 0.5)"
+ />浜ц兘
+ </div>
+ <div class="colorDescriptionItem"><i
+ class="el-icon-s-opportunity"
+ style="margin-right: 5px;color: rgba(5, 185, 100, 1)"
+ />宸叉帓
+ </div>
+ <div class="colorDescriptionItem"><i
+ class="el-icon-s-opportunity"
+ style="margin-right: 5px;color:rgba(128,0,128,0.7)"
+ />棰勬帓
+ </div>
+ <div>
+ <el-tag
+ v-for="item in multipleSelection"
+ :key="item.AdvaScheId"
+ :effect="item.isPlain"
+ style="margin-right: 10px"
+ @click="isPlainClick(item)"
+ >
+ {{ item.AdvaScheWorkCode }}
+ </el-tag>
+ </div>
+ <!-- <div class="colorDescriptionItem"><i class="el-icon-s-opportunity" style="margin-right: 5px;color: #a7a7a7" />澶辨晥浜ц兘</div>-->
+ </div>
+ <div
+ class="bodyTopFormExpand"
+ style="height: 5px"
+ />
+ </div>
+ <!--
+ 瀛楁鎻忚堪锛�
+ 1.schedulingData:鏁扮粍锛屾槸鎵�鏈変骇鑳界殑姣忎竴琛岀殑姹囨��
+ 2.data:瀵硅薄锛屾槸涓�琛屽唴姣忎竴涓骇鑳界殑姹囨��
+ 3.item:瀵硅薄锛屾槸姣忎竴涓骇鑳芥潯
+ -->
+ <!-- {{ schedulingData }}-->
+ <div class="container" style="margin: 10px;">
+ <v-gantt-chart
+ :start-time="time_data[0]"
+ :end-time="time_data[1]"
+ :cell-width="cellWidth"
+ :cell-height="cellHeight"
+ :title-height="titleHeight"
+ :scale="formBottom.scale"
+ :title-width="titleWidth"
+ show-current-time
+ :hide-header="hideHeader"
+ :data-key="dataKey"
+ :array-keys="arrayKeys"
+
+ :datas="schedulingData"
+ >
+ <!-- 鏆傛椂鐢ㄤ笉鍒�-->
+ <!-- :time-lines="timeLines"-->
+ <!-- @scrollLeft="scrollLeftA"-->
+ <!-- :scroll-to-postion="positionA"-->
+ <template slot="block" slot-scope="{data,item}">
+ <Scheduling
+ :data="data"
+ :cell-height="cellHeight"
+ :item="item"
+ />
+ <!-- 鏆傛椂鐢ㄤ笉鍒�-->
+ <!-- :update-time-lines="updateTimeLines"-->
+ <!-- :current-time="currentTime"-->
+ </template>
+ <template slot="left" slot-scope="{data}">
+ <div class="name">
+ <div class="carId">
+ <el-checkbox
+ v-model="data.status"
+ style="margin-right:5px;"
+ @change="checkboxSingle(data)"
+ />
+ {{ data.id }} {{ data.name }}
+ </div>
+ <div class="speed">
+ <!-- <el-tooltip class="item" effect="dark" content="鏌ョ湅" placement="top">-->
+ <!-- <el-button v-waves type="text" size="mini" @click="look(data)">-->
+ <!-- <i class="el-icon-document size i-color" />-->
+ <!-- </el-button>-->
+ <!-- </el-tooltip>-->
+ </div>
+ </div>
+ </template>
+ <template slot="title">
+ <span class="tc">宸ヤ綅鍒楄〃</span>
+ <el-checkbox
+ v-model="ganttCheckboxAll"
+ class="box_style"
+ :disabled="multipleSelection.length===0"
+ @change="checkboxAll()"
+ />
+ <input
+ v-model.number="cellWidth"
+ type="range"
+ min="20"
+ max="100"
+ class="box_styles"
+ :disabled="multipleSelection.length===0"
+ >
+ </template>
+ </v-gantt-chart>
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+</template>
<script>
+import Pagination from '@/components/Pagination'
+import Scheduling from '@/components/Scheduling'
+import dayjs from 'dayjs'
+import {
+ AdvancedSchedulingSearch, NewOnclickAdvancedSchedulingDevice,
+ OnclickAdvancedSchedulingDevice,
+ SubmitAlreadyScheduling
+} from '@/api/produceManager'
+import { handleDatetime, handleDatetime2 } from '@/utils/global'
+import waves from '@/directive/waves'
+import template from '@/views/template'
+
export default {
- name: 'Sblx'
+ name: 'Zzjg',
+ components: {
+ Pagination, Scheduling
+ },
+ directives: { waves },
+ data() {
+ return {
+ mouseHoverType: 'mouseout',
+ isExpandForm: false,
+ mainHeight: 0,
+ tableHeight: 0,
+
+ formTop: {
+ workshop: '', // 杞﹂棿缂栫爜
+ wocode: '', // 鐢熶骇宸ュ崟鍙�
+ partcode: '', // 鐗╂枡缂栫爜
+ partname: '', // 鐗╂枡鍚嶇О
+ prop: 'AdvaScheWorkCode', // 鎺掑簭瀛楁
+ order: 'desc', // 鎺掑簭瀛楁
+ page: 1, // 绗嚑椤�
+ rows: 20 // 姣忛〉澶氬皯鏉�
+ },
+ totalTop: 10, // 鎬诲叡澶氬皯鏉�
+ tableData: [],
+ multipleSelection: [],
+ /*
+ 鎺掔▼閮ㄥ垎鐨勫睘鎬�
+ * */
+ show: false,
+ pickerOptions1: {
+ disabledDate(time) {
+ return time.getTime() <= Date.now() - 24 * 60 * 60 * 1000
+ }
+ },
+
+ ganttCheckboxAll: true, // 鐢樼壒鍥惧乏渚у閫夋鏄惁閫変腑鎴栬�呭彇娑�
+ ganttLeftArrId: [], // 鐢樼壒鍥惧乏渚х殑鏁扮粍id
+ cl_name: '', // 浜у搧鍚嶇О
+ cl_code: '', // 浜у搧缂栫爜
+ work_order: '', // 宸ュ崟缂栧彿
+ AdvaScheUom: '', // 浜у搧鍗曚綅
+ time_data: [[handleDatetime(new Date()) + ' 00:00:00'], [handleDatetime(new Date()) + ' 00:00:00']], // 鐢樼壒鍥惧垵濮嬫覆鏌撶殑鏃堕棿鑼冨洿
+ forms: { // 鐐瑰嚮琛岃幏鍙栦俊鎭� 璇锋眰鎺ュ彛 鐨勬暟鎹璞�
+ wocode: '', // 宸ュ崟缂栧彿
+ wkshpcode: '', // 杞﹂棿缂栫爜
+ partcode: '', // 鐗╂枡缂栫爜
+ botproccode: '', // 鐡堕宸ュ簭缂栫爜(棣栭亾宸ュ簭)
+ startdate: '', // 寮�濮嬫棩鏈�
+ enddate: ''// 缁撴潫鏃ユ湡
+ },
+
+ formsTempArr: [], // 琛ㄥ崟鏁扮粍褰㈠紡瀛樺偍
+
+ formBottom: { // 搴曢儴琛ㄥ崟鐨� 鏁版嵁瀵硅薄
+ scheDate: [handleDatetime(new Date()), handleDatetime(new Date())], // 鎺掔▼鏃ユ湡
+ types: 'N', // 鎺掔▼鏂瑰紡
+ scale: 60, // 鏃堕棿鍒诲害
+ times: 0, // 鎹㈠瀷鏃堕棿
+ canArrangeNumber: 0, // 鍙帓鏁伴噺
+ needArrangeNumber: 0// 闇�鎺掓暟閲�
+ },
+ schedulingAllData: [], // 鎺掔▼鐨勬墍鏈夋暟鎹�
+ schedulingData: [], // 鎺掔▼鐨勬渶缁堟暟鎹�
+ timeTopTempData: [], // 鏃堕棿浼樺厛鐨勪复鏃舵暟鎹�
+ eqpTopTempData: [], // 璁惧浼樺厛鐨勪复鏃舵暟鎹�
+
+ formUpdate: {
+ WorkCode: '',
+ BotProceCode: '',
+ json: []
+ },
+ // currentTime: dayjs(),
+ cellWidth: 50,
+ cellHeight: 30,
+ titleHeight: 40,
+ titleWidth: 250,
+ dataKey: 'id', // 鐩稿綋浜庢槸璁惧code鍋氬敮涓�瀛楃
+ scaleList: `30,60,240,360`.split(',').map(n => parseInt(n)), // 鏃堕棿鍒诲害锛堝垎閽燂級
+ hideHeader: false,
+ arrayKeys: ['gtArray', 'error']
+
+ }
+ },
+
+ created() {
+ const loading = this.$loading({
+ lock: true,
+ text: '姝e湪鍔犺浇鏁版嵁锛岃绋嶇瓑...',
+ spinner: 'el-icon-loading',
+ customClass: 'osloading',
+ background: 'rgba(0, 0, 0, 0.7)'
+ })
+ setTimeout(() => {
+ if (this.getAdvancedSchedulingSearch()) {
+ loading.close()
+ }
+ }, 3000)
+
+ // this.getAdvancedSchedulingSearch()
+ },
+ mounted() {
+ window.addEventListener('resize', this.getHeight)
+ this.getHeight()
+ },
+ methods: {
+ async getAdvancedSchedulingSearch() {
+ const res = await AdvancedSchedulingSearch(this.formTop)
+ this.tableData = res.data
+ this.totalTop = res.count
+
+ this.tableData.forEach(row => {
+ row.AdvaSchePiroQueNumber = row.AdvaSchePiroQue === '姝e父' ? 3 : row.AdvaSchePiroQue === '绱ф��' ? 2 : 1
+ })
+
+ const newArr = []
+ this.tableData.filter((currentValue, currentIndex, selfArr) => {
+ return selfArr.findIndex(item => item.AdvaScheEndDate === currentValue.AdvaScheEndDate) === currentIndex
+ }).map(i => i.AdvaScheEndDate).forEach(i => {
+ newArr.push(this.tableData.filter(j => j.AdvaScheEndDate === i))
+ })
+ // 鏍规嵁鏃ユ湡鐩稿悓鐨勶紝宸ュ崟浼樺厛绾ц繘琛屾帓搴�
+ newArr.filter(i => {
+ i.sort((a, b) => b.AdvaSchePiroQueNumber - a.AdvaSchePiroQueNumber)
+ })
+ // 鎺掑ソ涔嬪悗 宸ュ崟椤哄簭灏辨槸鏁翠釜鐨勪紭鍏堢骇
+ this.tableData = newArr.flat()// 浜岀淮杞竴缁�
+ this.tableData.reverse()
+ return true
+ },
+ // 鎺掑簭鏀瑰彉鏃�
+ sortChangeTop({ column, prop, order }) {
+ if (order === 'descending') {
+ order = 'desc'
+ } else if (order === 'ascending') {
+ order = 'asc'
+ } else {
+ order = 'desc'
+ }
+ this.formTop.order = order
+ this.formTop.prop = prop
+ this.getAdvancedSchedulingSearch()
+ },
+ // 鏌ヨ
+ search() {
+ this.getAdvancedSchedulingSearch()
+ },
+ // 閲嶇疆
+ reset() {
+ this.formTop.workshop = ''
+ this.formTop.wocode = ''
+ this.formTop.partcode = ''
+ this.formTop.partname = ''
+ this.getAdvancedSchedulingSearch()
+
+ this.schedulingData = [] // 鎺掔▼鏁版嵁缃┖
+ },
+ // 鑾峰彇椤甸潰楂樺害
+ getHeight() {
+ this.$nextTick(() => {
+ this.mainHeight = window.innerHeight - 85
+ this.tableHeight = this.mainHeight - 255
+ this.$refs.tableDataRef.doLayout()
+ })
+ },
+ tableRowClassName({ row, rowIndex }) {
+ return 'custom-row'
+ },
+ /*
+ 鎺掔▼閮ㄥ垎鐨勬柟娉�
+ */
+ // 纭繚鎹㈠瀷鏃堕棿涓洪潪璐熸暟
+ no_zero() {
+ if (this.formBottom.times < 0) {
+ this.formBottom.times = 0
+ }
+ },
+ // 鎺掔▼鏂瑰紡鏀瑰彉
+ typesChange() {
+ this.getOnclickAdvancedSchedulingDevice()
+ },
+ // 鎺掔▼鏃ユ湡鍊兼敼鍙樻椂
+ dateChange() {
+ this.time_data[0] = this.formBottom.scheDate[0] + ' 00:00'
+ this.time_data[1] = this.formBottom.scheDate[1] + ' 23:59'
+ this.forms.startdate = this.formBottom.scheDate[0]
+ this.forms.enddate = this.formBottom.scheDate[1]
+ this.getOnclickAdvancedSchedulingDevice()
+ },
+ // 宸ヤ綅鍒楄〃澶嶉�夋鎿嶄綔 (鍏ㄩ�夈�佸叏涓嶉��)
+ checkboxAll() {
+ if (this.ganttCheckboxAll) { // 澶嶉�夋浠庡彇娑堝埌閫変腑
+ console.log('003')
+ this.ganttLeftArrId = []
+
+ // 杩欓噷瑕佽繘琛宖orEach寰幆閬嶅巻
+ // 鍏堢敤涓�涓复鏃舵暟缁勫璞″瓨鍌ㄩ渶璇锋眰鎺ュ彛鐨刦orms淇℃伅
+ let tempArr = []
+ this.schedulingData.forEach(val => {
+ val.status = true
+ tempArr.push({
+ wocode: val.wocode, // 宸ュ崟缂栧彿
+ wkshpcode: val.wkshpcode, // 杞﹂棿缂栫爜
+ partcode: val.partcode, // 浜у搧缂栫爜
+ botproccode: val.botproccode, // 宸ヨ壓璺嚎缂栫爜
+ startdate: val.startdate, // 褰撳墠鏃ユ湡锛堜粖澶╋級
+ enddate: val.enddate // 瑕佹眰浜や粯鏃堕棿
+ })
+ })
+
+ // 鏁扮粍瀵硅薄鍘婚噸
+ tempArr = tempArr.filter((currentValue, currentIndex, selfArr) => {
+ return selfArr.findIndex(item => item.wocode === currentValue.wocode) === currentIndex
+ })
+
+ tempArr.forEach(i => {
+ setTimeout(() => {
+ console.log('鍥藉搴�', i)
+ this.forms = i
+ this.getOnclickAdvancedSchedulingDevice()
+ // this.$forceUpdate()
+ })
+ })
+ } else { // 澶嶉�夋浠庨�変腑鍒板彇娑�
+ console.log('004')
+ for (const i in this.schedulingData) {
+ this.schedulingData[i].status = false
+ this.schedulingData[i].gtArray = []
+ }
+ for (const i in this.timeTopTempData) {
+ this.timeTopTempData[i].gtArray = []
+ }
+ }
+ // this.prepareArrange()
+ },
+ // 鐢樼壒鍥惧乏渚heckbox鍊奸�変腑鎴栬�呭彇娑堟椂
+ // checkboxSingle(val) {
+ // console.log(val, 'xaxaxa')
+ // console.log(val.status)
+ // },
+ checkboxSingle(val) {
+ console.log(val, 'xaxaxa')
+ if (!val.status) { // 澶嶉�夋鐘舵�佷粠閫変腑鍒板彇娑�
+ console.log('001')
+ for (const i in this.timeTopTempData) {
+ const new_arr = []
+ for (const j in this.timeTopTempData[i].gtArray) {
+ if (this.timeTopTempData[i].gtArray[j].id === val.id) {
+ } else {
+ new_arr.push(this.timeTopTempData[i].gtArray[j])
+ }
+ }
+ this.timeTopTempData[i].gtArray = new_arr
+ }
+ } else { // 澶嶉�夋鐘舵�佷粠鍙栨秷鍒伴�変腑
+ console.log('002')
+ this.ganttLeftArrId = []
+ for (const i in this.schedulingData) {
+ if (!this.schedulingData[i].status) {
+ this.ganttLeftArrId.push(this.schedulingData[i].id)
+ }
+ }
+
+ this.forms = {
+ wocode: val.wocode, // 宸ュ崟缂栧彿
+ wkshpcode: val.wkshpcode, // 杞﹂棿缂栫爜
+ partcode: val.partcode, // 浜у搧缂栫爜
+ botproccode: val.botproccode, // 宸ヨ壓璺嚎缂栫爜
+ startdate: val.startdate, // 褰撳墠鏃ユ湡锛堜粖澶╋級
+ enddate: val.enddate // 瑕佹眰浜や粯鏃堕棿
+ }
+ this.getOnclickAdvancedSchedulingDevice()
+ }
+
+ if (!val.status) { // 澶嶉�夋鐘舵�佷粠閫変腑鍒板彇娑�
+ console.log('005')
+ for (const i in this.schedulingData) {
+ if (!this.schedulingData[i].status) {
+ this.schedulingData[i].gtArray = []
+ }
+ }
+ } else { // 澶嶉�夋鐘舵�佷粠鍙栨秷鍒伴�変腑
+ console.log('006')
+ this.ganttLeftArrId = []
+ for (const i in this.schedulingData) {
+ if (!this.schedulingData[i].status) {
+ this.ganttLeftArrId.push(this.schedulingData[i].id)
+ }
+ }
+ this.getOnclickAdvancedSchedulingDevice()
+ }
+ for (const i in this.schedulingData) {
+ const arr = []
+ for (const j in this.schedulingData[i].gtArray) {
+ if (this.schedulingData[i].gtArray[j].type !== 'schedule') {
+ arr.push(this.schedulingData[i].gtArray[j])
+ }
+ }
+ this.schedulingData[i].gtArray = arr
+ }
+ this.formBottom.canArrangeNumber = 0
+
+ // this.prepareArrange()
+ },
+ // 鐐瑰嚮甯﹀嚭鏁版嵁
+ async getOnclickAdvancedSchedulingDevice2() {
+ console.log(this.forms, 302)
+
+ this.formsTempArr.push(this.forms)
+ this.formsTempArr = this.formsTempArr.filter((currentValue, currentIndex, selfArr) => {
+ return selfArr.findIndex(item => item.wocode === currentValue.wocode) === currentIndex
+ })
+ console.log(JSON.stringify(this.formsTempArr))
+
+ const res = await OnclickAdvancedSchedulingDevice(this.forms)
+ if (res.rus.Message) {
+ return this.$message.error(res.rus.Message)
+ }
+
+ const data = res.rows // 鎷垮埌寰呮帓鏁版嵁 瀵规暟鎹繘琛屾敼閫�
+ const cont = res.Cont // 鎷垮埌宸叉帓鏁版嵁 瀵规暟鎹繘琛屾敼閫�
+
+ this.formBottom.canArrangeNumber = 0
+
+ // 鎵惧埌index鍊�
+ // const index = this.formsTempArr.findIndex(i => i.wocode === this.forms.wocode)
+
+ // 灏嗕簲涓椂闂存杩涜璧嬪�� 鎷垮埌鍚庣鐨勬帴鍙f牸寮忥紝鏀规垚鍓嶇鎵�闇�鐨勬牸寮�
+ data.forEach(item => {
+ item.children.forEach(it => {
+ if (it.OneStartDate !== '') {
+ it.OneStartDate = it.OneStartDate.split('~')
+ it.OneStartDate[0] = item.YearDate + ' ' + it.OneStartDate[0] + ':00'
+ it.OneStartDate[1] = item.YearDate + ' ' + it.OneStartDate[1] + ':00'
+ }
+
+ if (it.TwoStartDate !== '') {
+ it.TwoStartDate = it.TwoStartDate.split('~')
+ it.TwoStartDate[0] = item.YearDate + ' ' + it.TwoStartDate[0] + ':00'
+ it.TwoStartDate[1] = item.YearDate + ' ' + it.TwoStartDate[1] + ':00'
+ }
+ if (it.ThreeStartDate !== '') {
+ it.ThreeStartDate = it.ThreeStartDate.split('~')
+ it.ThreeStartDate[0] = item.YearDate + ' ' + it.ThreeStartDate[0] + ':00'
+ it.ThreeStartDate[1] = item.YearDate + ' ' + it.ThreeStartDate[1] + ':00'
+ }
+ if (it.FourStartDate !== '') {
+ it.FourStartDate = it.FourStartDate.split('~')
+ it.FourStartDate[0] = item.YearDate + ' ' + it.FourStartDate[0] + ':00'
+ it.FourStartDate[1] = item.YearDate + ' ' + it.FourStartDate[1] + ':00'
+ }
+ if (it.FiveStartDate !== '') {
+ it.FiveStartDate = it.FiveStartDate.split('~')
+ it.FiveStartDate[0] = item.YearDate + ' ' + it.FiveStartDate[0] + ':00'
+ it.FiveStartDate[1] = item.YearDate + ' ' + it.FiveStartDate[1] + ':00'
+ }
+ })
+ })
+
+ // 鏋勫缓 鎸夎澶囦紭鍏堟帓绋嬬殑 鏁版嵁鏍煎紡 schedulingData
+ const list = [] // 涓存椂list 鏆傚瓨 浠h〃鐨勬槸鎵�鏈夌殑浜ц兘
+ console.log(this.forms.wocode, ' this.forms.wocode')
+ console.log(data, 'xxx1')
+
+ data[0].children.forEach(item => {
+ const obj = {
+ // 鏂板浜斾釜鍙傛暟
+ // wocode: this.formsTempArr[index].wocode, // 宸ュ崟缂栧彿
+ // wkshpcode: this.formsTempArr[index].wkshpcode, // 杞﹂棿缂栫爜
+ // partcode: this.formsTempArr[index].partcode, // 浜у搧缂栫爜
+ // botproccode: this.formsTempArr[index].botproccode, // 宸ヨ壓璺嚎缂栫爜
+ // startdate: this.formsTempArr[index].startdate, // 褰撳墠鏃ユ湡锛堜粖澶╋級
+ // enddate: this.formsTempArr[index].enddate, // 瑕佹眰浜や粯鏃堕棿
+
+ wocode: this.forms.wocode, // 宸ュ崟缂栧彿
+ wkshpcode: this.forms.wkshpcode, // 杞﹂棿缂栫爜
+ partcode: this.forms.partcode, // 浜у搧缂栫爜
+ botproccode: this.forms.botproccode, // 宸ヨ壓璺嚎缂栫爜
+ startdate: this.forms.startdate, // 褰撳墠鏃ユ湡锛堜粖澶╋級
+ enddate: this.forms.enddate, // 瑕佹眰浜や粯鏃堕棿
+
+ id: '', // 璁惧鐨刢ode
+ name: '', // 璁惧鍚嶇О
+ AdvaDevicRhythm: '', // 鑺傛媿澶氬皯绉掔敓浜т竴涓紙鐢熶骇鑺傛媿锛�
+ status: true, // 鐢樼壒鍥惧乏渚у閫夋鏄惁鏄�変腑鐘舵�� 褰撲负true鏃舵覆鏌� 涓篺alse鏃� 涓嶆覆鏌撲骇鑳�
+ colorPair: { // 棰滆壊闆� 涓嶅悓鐘舵�佷笅鐨勭敇鐗瑰浘鐨勯鑹� (鐩墠鐨勭悊瑙�)
+ dark: 'rgb(83, 186, 241,0.8)',
+ light: 'rgb(83, 186, 241,0.1)',
+ light_capacity: 'rgb(209,239,237,0.8)',
+ h_schedule: 'rgb(100,255,192,0.8)',
+ scheduleing: 'rgb(20,182,231,0.8)'
+ },
+ gtArray: [] // 鐢樼壒鍥剧殑姣忎竴涓瓙椤�
+ }
+ // 灏嗘帴鍙h繑鍥炵殑璁惧缂栫爜锛岃澶囧悕绉帮紝鐢熶骇鑺傛媿璧嬪�肩粰obj
+ obj.id = item.AdvaDevicNumber
+ obj.name = item.AdvaDevicName
+ obj.AdvaDevicRhythm = item.AdvaDevicRhythm
+ list.push(obj)
+ })
+
+ // 缁勫悎鏂扮殑缁撴瀯 娴呯豢鑹茶儗鏅潯
+ const newList = []
+ for (const i in data) {
+ for (const j in data[i].children) {
+ if (data[i].children[j].OneStartDate !== '') {
+ const data1 = {
+ id: '',
+ start: '',
+ end: '',
+ mod: ''
+ }
+ data1.id = data[i].children[j].AdvaDevicNumber
+ data1.start = data[i].children[j].OneStartDate[0]
+ data1.end = data[i].children[j].OneStartDate[1]
+ // AdvaDevicCropMob 绋煎姩鐜� AdvaDevicRhythm 鐢熶骇鑺傛媿
+ data1.mod = (data[i].children[j].AdvaDevicCropMob * 1) / 100 // 绋煎姩鐜�
+ newList.push(data1)
+ }
+ if (data[i].children[j].TwoStartDate !== '') {
+ const data2 = {
+ id: '',
+ start: '',
+ end: '',
+ mod: ''
+ }
+ data2.id = data[i].children[j].AdvaDevicNumber
+ data2.start = data[i].children[j].TwoStartDate[0]
+ data2.end = data[i].children[j].TwoStartDate[1]
+ data2.mod = (data[i].children[j].AdvaDevicCropMob * 1) / 100
+ newList.push(data2)
+ }
+ if (data[i].children[j].ThreeStartDate !== '') {
+ const data3 = {
+ id: '',
+ start: '',
+ end: '',
+ mod: ''
+ }
+ data3.id = data[i].children[j].AdvaDevicNumber
+ data3.start = data[i].children[j].ThreeStartDate[0]
+ data3.end = data[i].children[j].ThreeStartDate[1]
+ data3.mod = (data[i].children[j].AdvaDevicCropMob * 1) / 100
+ newList.push(data3)
+ }
+ if (data[i].children[j].FourStartDate !== '') {
+ const data4 = {
+ id: '',
+ start: '',
+ end: '',
+ mod: ''
+ }
+ data4.id = data[i].children[j].AdvaDevicNumber
+ data4.start = data[i].children[j].FourStartDate[0]
+ data4.end = data[i].children[j].FourStartDate[1]
+ data4.mod = (data[i].children[j].AdvaDevicCropMob * 1) / 100
+ newList.push(data4)
+ }
+ if (data[i].children[j].FiveStartDate !== '') {
+ const data5 = {
+ id: '',
+ start: '',
+ end: '',
+ mod: ''
+ }
+ data5.id = data[i].children[j].AdvaDevicNumber
+ data5.start = data[i].children[j].FiveStartDate[0]
+ data5.end = data[i].children[j].FiveStartDate[1]
+ data5.mod = (data[i].children[j].AdvaDevicCropMob * 1) / 100
+ newList.push(data5)
+ }
+ }
+ }
+
+ // 鎻掑叆浜ц兘鏃堕棿娈� 浜ц兘鏁版嵁閮藉湪gtArray閲岄潰
+ for (const i in list) {
+ this.pushItem(newList, list[i].id, list[i].gtArray)
+ }
+
+ // this.schedulingData = list
+
+ // 涓婇潰娉ㄩ噴浠g爜鍙�傚悎list鏁扮粍闀垮害涓轰竴鐨勬椂鍊欙紝鏄笉瀵圭殑锛屼笅闈㈤�昏緫杩涜浼樺寲
+ // 鍒ゆ柇褰撳墠鐐瑰嚮琛岀殑鏁版嵁璇锋眰鎺ュ彛鏁版嵁 鏄惁宸茬粡鍦ㄦ帓绋嬫暟缁勫唴
+ list.forEach((item, index) => {
+ const flag = this.schedulingData.map(i => i.id).includes(list[index].id)
+ if (!flag) { // 褰撹澶嘽ode涓嶅湪鎺掔▼鏁扮粍鍐呮椂 鐩存帴push鎺掔▼鏁扮粍鍗冲彲
+ this.schedulingData.push(list[index])
+ } else { // 褰撳凡缁忓湪鎺掔▼鏁扮粍鍐呮椂 搴旇鍒ゆ柇鏃堕棿鍙栧苟闆�
+ const ind = this.schedulingData.findIndex(i => i.id === list[index].id)
+ const tempGtArray = [...new Set(this.schedulingData[ind].gtArray.concat(list[index].gtArray))]
+ // 鏁扮粍涓璞$浉鍚岀殑鍘婚噸
+ this.schedulingData[ind].gtArray = tempGtArray.filter((currentValue, currentIndex, selfArr) => {
+ return selfArr.findIndex(item => item.start === currentValue.start) === currentIndex
+ })
+ }
+ })
+
+ if (cont !== '') { // 瀵瑰凡鎺掔殑浜ц兘杩涜鏁扮粍閲嶇粍
+ for (const i in cont) {
+ for (const j in this.schedulingData) {
+ if (this.schedulingData[j].id === cont[i].eqp_code) { // 褰撹澶嘽ode鐩哥瓑鏃�
+ const data = {
+ id: cont[i].eqp_code,
+ number: cont[i].alloc_qty,
+ cl_name: cont[i].part_name,
+ cl_code: cont[i].part_code,
+ AdvaScheUom: cont[i].uom_name, // 鍗曚綅
+ work_order: cont[i].wo_code,
+ start: cont[i].time_start,
+ end: cont[i].time_end,
+ // type: cont[i].status === 'S' ? 'h_schedule' : 'bm_schedule'
+ type: 'h_schedule'
+ }
+ this.schedulingData[j].gtArray.unshift(data)
+ }
+ }
+ }
+ }
+
+ // console.log(this.ganttLeftArrId)
+ if (this.ganttLeftArrId !== '') {
+ // console.log('ykxkd')
+ for (const j in this.schedulingData) {
+ // console.log(this.ganttLeftArrId.indexOf(this.schedulingData[j].id) >= 0) //false
+ if (this.ganttLeftArrId.indexOf(this.schedulingData[j].id) >= 0) {
+ this.schedulingData[j].gtArray = []
+ this.schedulingData[j].status = false
+ }
+ }
+ }
+
+ // 璁惧浼樺厛鐨勬暟鎹牸寮�
+ // this.eqpTopTempData = []
+ // console.log(this.schedulingData, 30)
+ // console.log(data, 30)
+ // for (const i in data[0].children) {
+ // console.log(i, '鐗规柉鎷�')
+ // const obj = {
+ // id: '',
+ // name: '',
+ // status: true,
+ // AdvaDevicRhythm: '',
+ // // mod:'',
+ // colorPair: {
+ // dark: 'rgb(83, 186, 241,0.8)',
+ // light: 'rgb(83, 186, 241,0.1)',
+ // light_capacity: 'rgb(209,239,237,0.8)',
+ // h_schedule: 'rgb(100,255,192,0.8)',
+ // scheduleing: 'rgb(20,182,231,0.8)'
+ // },
+ // gtArray: []
+ // }
+ // obj.id = data[0].children[i].AdvaDevicNumber
+ // obj.name = data[0].children[i].AdvaDevicName
+ // obj.AdvaDevicRhythm = data[0].children[i].AdvaDevicRhythm
+ // // obj.mod =data[0].children[i].AdvaDevicCropMob *1
+ //
+ // this.eqpTopTempData.push(obj)
+ // }
+
+ // 涓婇潰鐨勬敞閲婁唬鐮佸彲浠ユ崲鎴愪笅闈㈣繖琛屼唬鐮�
+ this.eqpTopTempData = JSON.parse(JSON.stringify(this.schedulingData))
+
+ // 鏇存敼鏍煎紡
+ // this.timeTopTempData = []
+
+ console.log(data, 31)
+
+ // 鏋勫缓鎸夋椂闂翠紭鍏堢殑鎺掔▼鏁版嵁鏍煎紡 timeTopTempData
+ for (const i in data) {
+ const time = {
+ date: data[i].YearDate, // 鏃ユ湡
+ AdvaDevicRhythm: '', // 鐢熶骇鑺傛媿
+ gtArray: []
+ }
+ if (data[i].children !== '') {
+ time.AdvaDevicRhythm = data[i].children[0].AdvaDevicRhythm
+ }
+ for (const j in data[i].children) {
+ if (data[i].children[j].OneStartDate !== '') {
+ const icu1 = {
+ name: data[i].children[j].AdvaDevicName,
+ id: data[i].children[j].AdvaDevicNumber,
+ type: 'capacity',
+ rhythm: data[i].children[j].AdvaDevicRhythm, // 鐢熶骇鑺傛媿
+ start: data[i].children[j].OneStartDate[0],
+ end: data[i].children[j].OneStartDate[1],
+ mod: (data[i].children[j].AdvaDevicCropMob * 1) / 100
+ }
+ time.gtArray.push(icu1)
+ }
+ if (data[i].children[j].TwoStartDate !== '') {
+ const icu2 = {
+ name: data[i].children[j].AdvaDevicName,
+ id: data[i].children[j].AdvaDevicNumber,
+ type: 'capacity',
+ rhythm: data[i].children[j].AdvaDevicRhythm,
+ start: data[i].children[j].TwoStartDate[0],
+ end: data[i].children[j].TwoStartDate[1],
+ mod: (data[i].children[j].AdvaDevicCropMob * 1) / 100
+ }
+ time.gtArray.push(icu2)
+ }
+ if (data[i].children[j].ThreeStartDate !== '') {
+ const icu3 = {
+ name: data[i].children[j].AdvaDevicName,
+ id: data[i].children[j].AdvaDevicNumber,
+ type: 'capacity',
+ rhythm: data[i].children[j].AdvaDevicRhythm,
+ start: data[i].children[j].ThreeStartDate[0],
+ end: data[i].children[j].ThreeStartDate[1],
+ mod: (data[i].children[j].AdvaDevicCropMob * 1) / 100
+ }
+ time.gtArray.push(icu3)
+ }
+ if (data[i].children[j].FourStartDate !== '') {
+ const icu4 = {
+ name: data[i].children[j].AdvaDevicName,
+ id: data[i].children[j].AdvaDevicNumber,
+ type: 'capacity',
+ rhythm: data[i].children[j].AdvaDevicRhythm,
+ start: data[i].children[j].FourStartDate[0],
+ end: data[i].children[j].FourStartDate[1],
+ mod: (data[i].children[j].AdvaDevicCropMob * 1) / 100
+ }
+ time.gtArray.push(icu4)
+ }
+ if (data[i].children[j].FiveStartDate !== '') {
+ const icu5 = {
+ name: data[i].children[j].AdvaDevicName, // 璁惧鍚嶇О
+ id: data[i].children[j].AdvaDevicNumber, // 璁惧code
+ type: 'capacity', // 浜ц兘
+ rhythm: data[i].children[j].AdvaDevicRhythm, // 鐢熶骇鑺傛媿
+ start: data[i].children[j].FiveStartDate[0], // 寮�濮嬫椂闂�
+ end: data[i].children[j].FiveStartDate[1], // 缁撴潫鏃堕棿
+ mod: (data[i].children[j].AdvaDevicCropMob * 1) / 100 // 绋煎姩鐜�
+ }
+ time.gtArray.push(icu5)
+ }
+ }
+ this.timeTopTempData.push(time)
+ // console.log(this.timeTopTempData)
+ }
+
+ if (cont !== '') {
+ for (const i in cont) {
+ for (const j in this.timeTopTempData) {
+ const data = {
+ id: cont[i].eqp_code,
+ date: cont[i].time_start.split(' ')[0],
+ number: cont[i].alloc_qty,
+ cl_name: cont[i].part_name,
+ cl_code: cont[i].part_code,
+ AdvaScheUom: cont[i].uom_name, // 鍗曚綅
+ work_order: cont[i].wo_code,
+ start: cont[i].time_start,
+ end: cont[i].time_end,
+ type: 'h_schedule'
+ }
+ if (this.timeTopTempData[j].date === data.date) {
+ this.timeTopTempData[j].gtArray.unshift(data)
+ }
+ }
+ }
+ }
+
+ console.log(JSON.parse(JSON.stringify(this.eqpTopTempData)), 7)
+ console.log(this.timeTopTempData, 8)
+
+ this.$forceUpdate()
+ },
+ // 鎹㈠瀷鏃堕棿
+ MinutesTest(time) {
+ const t = new Date(time)
+ t.setMinutes(t.getMinutes() + this.formBottom.times * 1)
+ const now =
+ t.getFullYear() +
+ '-' +
+ (t.getMonth() + 1).toString().padStart(2, '0') +
+ '-' +
+ t.getDate().toString().padStart(2, '0') +
+ ' ' +
+ t.getHours().toString().padStart(2, '0') +
+ ':' +
+ t.getMinutes().toString().padStart(2, '0') +
+ ':' +
+ t.getSeconds().toString().padStart(2, '0')
+ return now
+ },
+ // 鎻掑叆浜ц兘鏃堕棿娈�
+ pushItem(newList, id, arr) {
+ for (const i in newList) {
+ if (newList[i].id === id) {
+ const data = {
+ start: newList[i].start,
+ end: newList[i].end,
+ id: newList[i].id,
+ mod: newList[i].mod,
+ type: 'capacity'
+ }
+ arr.push(data)
+ }
+ }
+ },
+
+ isPlainClick(val) {
+ console.log(val)
+ this.tableData.forEach(i => {
+ if (val.AdvaScheWorkCode === i.AdvaScheWorkCode) {
+ i.isPlain = 'dark'
+ } else {
+ i.isPlain = 'plain'
+ }
+ })
+ this.getOnclickAdvancedSchedulingDevice('getApi')
+ this.$forceUpdate()
+ },
+
+ // checkbox 鐐瑰嚮鏀瑰彉浜嬩欢
+ handleSelectionChange(val) {
+ console.log(val, '009')
+ this.multipleSelection = val
+ this.getOnclickAdvancedSchedulingDevice()
+ },
+ // 鍕鹃�夎〃鏍煎閫夋甯﹀嚭鏁版嵁 鑾峰彇NEW楂樼骇鎺掔▼鐐瑰嚮宸ュ崟浠诲姟甯﹀嚭鐡堕宸ュ簭璁惧銆佸凡鎺掔▼浠诲姟鏁版嵁
+ async getOnclickAdvancedSchedulingDevice(val) {
+ // 鎷垮埌澶嶉�夋鍕鹃�夌殑鏁版嵁璇锋眰鎺ュ彛
+ let DATA = []
+ if (val === 'getApi') { // 浠h〃鏄粠鍒囨崲椤电杩囨潵鐨�
+ console.log(this.tableData, 333)
+ const row = this.tableData.find(i => i.isPlain === 'dark')
+ console.log(row, 334)
+ DATA = [
+ {
+ isPlain: row.isPlain, // 浠h〃鏄惁鏄�変腑鐘舵��
+ wocode: row.AdvaScheWorkCode, // 宸ュ崟缂栧彿
+ wkshpcode: row.AdvaScheWorkShopid, // 杞﹂棿缂栫爜
+ partcode: row.AdvaSchePartNumber, // 浜у搧缂栫爜
+ botproccode: row.AdvaScheBotProcid, // 宸ヨ壓璺嚎缂栫爜
+ startdate: handleDatetime(new Date()), // 褰撳墠鏃ユ湡锛堜粖澶╋級
+ enddate: row.AdvaScheEndDate // 瑕佹眰浜や粯鏃堕棿
+ }
+ ]
+ console.log(DATA)
+ } else {
+ this.multipleSelection.forEach((row, index) => {
+ row.isPlain = index !== 0 ? 'plain' : 'dark'
+ row.AdvaSchePiroQueNumber = row.AdvaSchePiroQue === '姝e父' ? 3 : row.AdvaSchePiroQue === '绱ф��' ? 2 : 1
+ DATA.push({
+ isPlain: row.isPlain, // 浠h〃鏄惁鏄�変腑鐘舵��
+ wocode: row.AdvaScheWorkCode, // 宸ュ崟缂栧彿
+ wkshpcode: row.AdvaScheWorkShopid, // 杞﹂棿缂栫爜
+ partcode: row.AdvaSchePartNumber, // 浜у搧缂栫爜
+ botproccode: row.AdvaScheBotProcid, // 宸ヨ壓璺嚎缂栫爜
+ startdate: handleDatetime(new Date()), // 褰撳墠鏃ユ湡锛堜粖澶╋級
+ enddate: row.AdvaScheEndDate // 瑕佹眰浜や粯鏃堕棿
+ })
+ })
+ }
+
+ const res = await NewOnclickAdvancedSchedulingDevice(DATA.filter(i => i.isPlain === 'dark'))
+ // 濡傛灉Message鏈夋姤閿欎俊鎭垯缁堟鎵ц鍚庨潰閫昏緫
+ if (res.rus.Message) {
+ return this.$message.error(res.rus.Message)
+ }
+
+ // 鑾峰彇棰勬帓杩涘害鍊煎拰鏈�澶х殑瑕佹眰浜や粯鏃ユ湡
+ this.getMaxPayDate()
+
+ let waitingForScheduling = res.rows // 鎷垮埌寰呮帓鏁版嵁锛屽鏁版嵁杩涜鏀归��
+ const alreadyForScheduling = res.Cont // 鎷垮埌宸叉帓鏁版嵁 瀵规暟鎹繘琛屾敼閫�
+
+ this.formBottom.canArrangeNumber = 0 // 棰勬帓杩涘害鐨勫彲鎺掓暟閲忕疆闆�
+
+ // 灏嗕簲涓椂闂存杩涜璧嬪�� 鎷垮埌鍚庣鐨勬帴鍙f牸寮忥紝鏀规垚鍓嶇鎵�闇�鐨勬牸寮�
+ waitingForScheduling.forEach(item => {
+ item.children.forEach(it => {
+ if (it.OneStartDate !== '') {
+ it.OneStartDate = it.OneStartDate.split('~')
+ it.OneStartDate[0] = item.YearDate + ' ' + it.OneStartDate[0] + ':00'
+ it.OneStartDate[1] = item.YearDate + ' ' + it.OneStartDate[1] + ':00'
+ }
+
+ if (it.TwoStartDate !== '') {
+ it.TwoStartDate = it.TwoStartDate.split('~')
+ it.TwoStartDate[0] = item.YearDate + ' ' + it.TwoStartDate[0] + ':00'
+ it.TwoStartDate[1] = item.YearDate + ' ' + it.TwoStartDate[1] + ':00'
+ }
+ if (it.ThreeStartDate !== '') {
+ it.ThreeStartDate = it.ThreeStartDate.split('~')
+ it.ThreeStartDate[0] = item.YearDate + ' ' + it.ThreeStartDate[0] + ':00'
+ it.ThreeStartDate[1] = item.YearDate + ' ' + it.ThreeStartDate[1] + ':00'
+ }
+ if (it.FourStartDate !== '') {
+ it.FourStartDate = it.FourStartDate.split('~')
+ it.FourStartDate[0] = item.YearDate + ' ' + it.FourStartDate[0] + ':00'
+ it.FourStartDate[1] = item.YearDate + ' ' + it.FourStartDate[1] + ':00'
+ }
+ if (it.FiveStartDate !== '') {
+ it.FiveStartDate = it.FiveStartDate.split('~')
+ it.FiveStartDate[0] = item.YearDate + ' ' + it.FiveStartDate[0] + ':00'
+ it.FiveStartDate[1] = item.YearDate + ' ' + it.FiveStartDate[1] + ':00'
+ }
+ })
+ })
+
+ // 鏍煎紡杞崲锛屾牴鎹畐o_code鍐嶅涓�灞俢hildren
+ waitingForScheduling = this.listToTree(waitingForScheduling)
+
+ // 鏋勫缓 鎸夎澶囦紭鍏堟帓绋嬬殑 鏁版嵁鏍煎紡 schedulingData
+ const allCapacity = [] // 浠h〃鐨勬槸鎵�鏈夌殑浜ц兘
+ waitingForScheduling.forEach(item => {
+ item.children[0].children.forEach(it => {
+ const obj = {
+ wo_code: item.wo_code, // 宸ュ崟鍙�
+ id: it.AdvaDevicNumber, // 璁惧鐨刢ode
+ name: it.AdvaDevicName, // 璁惧鍚嶇О
+ AdvaDevicRhythm: it.AdvaDevicRhythm, // 鑺傛媿澶氬皯绉掔敓浜т竴涓紙鐢熶骇鑺傛媿锛�
+ status: true, // 鐢樼壒鍥惧乏渚у閫夋鏄惁鏄�変腑鐘舵�� 褰撲负true鏃舵覆鏌� 涓篺alse鏃� 涓嶆覆鏌撲骇鑳�
+ colorPair: { // 棰滆壊闆� 涓嶅悓鐘舵�佷笅鐨勭敇鐗瑰浘鐨勯鑹� (鐩墠鐨勭悊瑙�)
+ dark: 'rgb(83, 186, 241,0.8)',
+ light: 'rgb(83, 186, 241,0.1)',
+ light_capacity: 'rgb(209,239,237,0.8)',
+ h_schedule: 'rgb(100,255,192,0.8)',
+ scheduleing: 'rgb(20,182,231,0.8)'
+ },
+ gtArray: [] // 鐢樼壒鍥剧殑姣忎竴涓瓙椤�
+ }
+ allCapacity.push(obj)
+ })
+ })
+
+ // 姣忎竴涓澶囩殑浜ц兘
+ const everyEqpCapacity = []
+ waitingForScheduling.forEach(item => {
+ item.children.forEach(it => {
+ const maxDate = this.multipleSelection.find(i => i.AdvaScheWorkCode === it.wo_code).AdvaScheEndDate // 褰撳墠宸ュ崟鐨勬渶澶ф帓绋嬫棩鏈�
+ it.children.forEach(i => {
+ if (i.OneStartDate !== '') {
+ const obj = {
+ maxDate,
+ work_order: item.wo_code,
+ id: '',
+ start: '',
+ end: '',
+ mod: ''
+ }
+ obj.id = i.AdvaDevicNumber
+ obj.start = i.OneStartDate[0]
+ obj.end = i.OneStartDate[1]
+ // AdvaDevicCropMob 绋煎姩鐜� AdvaDevicRhythm 鐢熶骇鑺傛媿
+ obj.mod = (i.AdvaDevicCropMob * 1) / 100 // 绋煎姩鐜�
+ everyEqpCapacity.push(obj)
+ }
+ if (i.TwoStartDate !== '') {
+ const obj = {
+ maxDate,
+ work_order: item.wo_code,
+ id: '',
+ start: '',
+ end: '',
+ mod: ''
+ }
+ obj.id = i.AdvaDevicNumber
+ obj.start = i.TwoStartDate[0]
+ obj.end = i.TwoStartDate[1]
+ // AdvaDevicCropMob 绋煎姩鐜� AdvaDevicRhythm 鐢熶骇鑺傛媿
+ obj.mod = (i.AdvaDevicCropMob * 1) / 100 // 绋煎姩鐜�
+ everyEqpCapacity.push(obj)
+ }
+ if (i.ThreeStartDate !== '') {
+ const obj = {
+ maxDate,
+ work_order: item.wo_code,
+ id: '',
+ start: '',
+ end: '',
+ mod: ''
+ }
+ obj.id = i.AdvaDevicNumber
+ obj.start = i.ThreeStartDate[0]
+ obj.end = i.ThreeStartDate[1]
+ // AdvaDevicCropMob 绋煎姩鐜� AdvaDevicRhythm 鐢熶骇鑺傛媿
+ obj.mod = (i.AdvaDevicCropMob * 1) / 100 // 绋煎姩鐜�
+ everyEqpCapacity.push(obj)
+ }
+ if (i.FourStartDate !== '') {
+ const obj = {
+ maxDate,
+ work_order: item.wo_code,
+ id: '',
+ start: '',
+ end: '',
+ mod: ''
+ }
+ obj.id = i.AdvaDevicNumber
+ obj.start = i.FourStartDate[0]
+ obj.end = i.FourStartDate[1]
+ // AdvaDevicCropMob 绋煎姩鐜� AdvaDevicRhythm 鐢熶骇鑺傛媿
+ obj.mod = (i.AdvaDevicCropMob * 1) / 100 // 绋煎姩鐜�
+ everyEqpCapacity.push(obj)
+ }
+ if (i.FiveStartDate !== '') {
+ const obj = {
+ maxDate,
+ work_order: item.wo_code,
+ id: '',
+ start: '',
+ end: '',
+ mod: ''
+ }
+ obj.id = i.AdvaDevicNumber
+ obj.start = i.FiveStartDate[0]
+ obj.end = i.FiveStartDate[1]
+ // AdvaDevicCropMob 绋煎姩鐜� AdvaDevicRhythm 鐢熶骇鑺傛媿
+ obj.mod = (i.AdvaDevicCropMob * 1) / 100 // 绋煎姩鐜�
+ everyEqpCapacity.push(obj)
+ }
+ })
+ })
+ })
+
+ // 鎻掑叆浜ц兘鏃堕棿娈� 浜ц兘鏁版嵁閮藉湪gtArray閲岄潰
+ waitingForScheduling.forEach(item => {
+ allCapacity.forEach(it => {
+ if (item.wo_code === it.wo_code) {
+ this.pushCapacity(everyEqpCapacity, it.id, it.gtArray)
+ it.gtArray = it.gtArray.filter((currentValue, currentIndex, selfArr) => {
+ return selfArr.findIndex(item => item.start === currentValue.start) === currentIndex
+ })
+ // it.gtArray.sort((a, b) => new Date(a.end).getTime() - new Date(b.end).getTime())
+ }
+ })
+ })
+ // console.log(allCapacity, 'allCapacity')
+ this.schedulingAllData = JSON.parse(JSON.stringify(allCapacity))
+
+ // 鍘婚噸璁惧id(code)
+ this.schedulingData = allCapacity.filter((currentValue, currentIndex, selfArr) => {
+ return selfArr.findIndex(item => item.id === currentValue.id) === currentIndex
+ })
+
+ // 鎺掔▼澶嶉�夋鐨勯�変腑涓庡彇娑�
+ if (this.ganttLeftArrId !== '') {
+ for (const j in this.schedulingData) {
+ if (this.ganttLeftArrId.indexOf(this.schedulingData[j].id) >= 0) {
+ this.schedulingData[j].gtArray = []
+ this.schedulingData[j].status = false
+ }
+ }
+ }
+
+ // 灏嗗伐鍗曠殑浼樺厛绾ц繘琛屾帓搴忥紝鍏堜互鏃堕棿鎺掞紝鍐嶄互浼樺厛绾ф帓
+ // this.getMultipleSelectionOrder()
+
+ // this.eqpTopTempData = JSON.parse(JSON.stringify(this.schedulingData))
+
+ // console.log(waitingForScheduling, 'waitingForScheduling')
+ // console.log(allCapacity, 'allCapacity')
+ // console.log(this.schedulingData, 'schedulingData')
+ // // console.log(JSON.stringify(this.schedulingData), 'schedulingData')
+ // console.log(this.schedulingAllData, 'schedulingAllData')
+ // console.log(everyEqpCapacity, 'everyEqpCapacity')
+ },
+ // 灏嗗伐鍗曠殑浼樺厛绾ц繘琛屾帓搴忥紝鍏堜互鏃堕棿鎺掞紝鍐嶄互浼樺厛绾ф帓
+ getMultipleSelectionOrder() {
+ // 1.鍏堥�氳繃鏃堕棿鍘婚噸鐭ラ亾鏈夊摢鍑犲ぉ鐨勬椂闂� // 2.閬嶅巻杩欏嚑澶╃殑鏃堕棿锛岃繃婊ゅ嚭鐩稿搴旂殑宸ュ崟
+ const newArr = []
+ this.multipleSelection.filter((currentValue, currentIndex, selfArr) => {
+ return selfArr.findIndex(item => item.AdvaScheEndDate === currentValue.AdvaScheEndDate) === currentIndex
+ }).map(i => i.AdvaScheEndDate).forEach(i => {
+ newArr.push(this.multipleSelection.filter(j => j.AdvaScheEndDate === i))
+ })
+ // 鏍规嵁鏃ユ湡鐩稿悓鐨勶紝宸ュ崟浼樺厛绾ц繘琛屾帓搴�
+ newArr.filter(i => {
+ i.sort((a, b) => b.AdvaSchePiroQueNumber - a.AdvaSchePiroQueNumber)
+ })
+ // 鎺掑ソ涔嬪悗 宸ュ崟椤哄簭灏辨槸鏁翠釜鐨勪紭鍏堢骇
+ this.multipleSelection = newArr.flat()// 浜岀淮杞竴缁�
+ },
+
+ // 璁惧浼樺厛 鏁版嵁鏍煎紡杞崲
+ eqpDataTransition2() {
+ const needNumber = this.formBottom.needArrangeNumber // 闇�鎺掓暟閲�
+
+ // 灏嗕骇鑳界殑鎵�鏈夊�间笌澶氶�夋鐨勯�変腑鐨勮鏃堕棿杩涜鍖归厤鏍¢獙 浠ヤ究鍚庣画璁$畻
+ this.multipleSelection.forEach(item => {
+ this.schedulingAllData.forEach(it => {
+ // 鎵惧埌宸ュ崟鎵�瀵瑰簲鐨勮澶囪繘琛岃绠楁帓绋� 鍐欏嚭璁$畻閫昏緫 杩欓儴鍒嗘瘮杈冧笂澶�
+ if (it.wo_code === item.AdvaScheWorkCode) {
+ it.gtArray.forEach(i => {
+ const t = i.start.split(' ')[0]
+ // 浠h〃褰撳墠宸ュ崟涓嬬殑浜ц兘鏄惁鍙帓
+ i.status = new Date(t).getTime() <= new Date(item.AdvaScheEndDate).getTime()
+ })
+ // 鐩墠璁$畻閫昏緫杩樹笉澶竻妤氭�庝箞鍐� 澶笂澶翠簡
+
+ console.log(it.id, 'it')
+
+ const end_time = ''
+ const mistiming = ''
+ const data = {
+ id: it.id,
+ start: '2023-04-17 14:00:00',
+ end: '2023-04-17 16:00:00',
+ type: 'schedule',
+ cl_name: item.AdvaSchePartName,
+ cl_code: item.AdvaSchePartNumber,
+ work_order: item.AdvaScheWorkCode,
+ AdvaScheUom: item.AdvaScheUom,
+ number: 0,
+ real_number: 0
+ }
+ // 宸ュ崟鐩稿悓涔嬪悗 搴旇鏍规嵁鏃堕棿浼樺厛鎴栬�呰澶囦紭鍏� 瀵硅澶囪繘琛屼竴涓�鎺掔▼
+
+ // 杩欎釜鍦版柟涓嶅 鍐欎笉鍑烘潵浜�
+ // data.start = it.gtArray[0].start // 鍏堝彧鑰冭檻涓�绉嶆儏鍐�
+ // data.start = it.gtArray[0].start // 鍏堝彧鑰冭檻涓�绉嶆儏鍐�
+ data.number = '230'
+ data.real_number = '230'
+ const index = this.schedulingData.findIndex(i => i.id === it.id)
+ this.schedulingData[index].gtArray.push(data)
+ console.log(JSON.stringify(it))
+ }
+ })
+ })
+
+ // 杩欎釜鏄绠楀嚭鏉ョ殑鏁板�硷紝闇�瑕乸ush鍒皊chedulingData涓�
+
+ // 'id': 'JG002',
+ // 'start': '2023-04-17 10:10:21',
+ // 'end': '2023-04-17 11:30:00',
+ // 'type': 'schedule',
+ // 'cl_name': '涓绘満',
+ // 'cl_code': '201',
+ // 'work_order': 'MO-2023-04-0001_1',
+ // 'AdvaScheUom': '涓�',
+ // 'number': '64',
+ // 'real_number': 63.72
+
+ // this.schedulingData = [
+ // {
+ // 'id': 'JG002',
+ // 'name': '绮惧伐璁惧2#',
+ // 'AdvaDevicRhythm': '15.0',
+ // 'status': true,
+ // 'colorPair': {
+ // 'dark': 'rgb(83, 186, 241,0.8)',
+ // 'light': 'rgb(83, 186, 241,0.1)',
+ // 'light_capacity': 'rgb(209,239,237,0.8)',
+ // 'h_schedule': 'rgb(100,255,192,0.8)',
+ // 'scheduleing': 'rgb(20,182,231,0.8)'
+ // },
+ // 'gtArray': [
+ // {
+ // 'start': '2023-04-17 08:00:00',
+ // 'end': '2023-04-17 11:30:00',
+ // 'id': 'JG002',
+ // 'mod': 0.2,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-04-17 13:00:00',
+ // 'end': '2023-04-17 18:00:00',
+ // 'id': 'JG002',
+ // 'mod': 0.2,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'id': 'JG002',
+ // 'start': '2023-04-17 10:10:21',
+ // 'end': '2023-04-17 11:30:00',
+ // 'type': 'schedule',
+ // 'cl_name': '涓绘満',
+ // 'cl_code': '201',
+ // 'work_order': 'MO-2023-04-0001_1',
+ // 'AdvaScheUom': '涓�',
+ // 'number': '64',
+ // 'real_number': 63.72
+ // },
+ // {
+ // 'id': 'JG002',
+ // 'start': '2023-04-17 13:00:00',
+ // 'end': '2023-04-17 18:00:00',
+ // 'type': 'schedule',
+ // 'cl_name': '涓绘満',
+ // 'cl_code': '201',
+ // 'work_order': 'MO-2023-04-0001_1',
+ // 'AdvaScheUom': '涓�',
+ // 'number': '240',
+ // 'real_number': 240
+ // }
+ // ]
+ // },
+ // {
+ // 'id': 'SB001',
+ // 'name': '璁惧001',
+ // 'AdvaDevicRhythm': '15.0',
+ // 'status': true,
+ // 'colorPair': {
+ // 'dark': 'rgb(83, 186, 241,0.8)',
+ // 'light': 'rgb(83, 186, 241,0.1)',
+ // 'light_capacity': 'rgb(209,239,237,0.8)',
+ // 'h_schedule': 'rgb(100,255,192,0.8)',
+ // 'scheduleing': 'rgb(20,182,231,0.8)'
+ // },
+ // 'gtArray': [
+ // {
+ // 'start': '2023-04-17 08:00:00',
+ // 'end': '2023-04-17 11:30:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-04-17 13:00:00',
+ // 'end': '2023-04-17 18:00:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'id': 'SB001',
+ // 'start': '2023-04-17 10:10:21',
+ // 'end': '2023-04-17 11:30:00',
+ // 'type': 'schedule',
+ // 'cl_name': '涓绘満',
+ // 'cl_code': '201',
+ // 'work_order': 'MO-2023-04-0001_1',
+ // 'AdvaScheUom': '涓�',
+ // 'number': '96',
+ // 'real_number': 95.58
+ // },
+ // {
+ // 'id': 'SB001',
+ // 'start': '2023-04-17 13:00:00',
+ // 'end': '2023-04-17 18:00:00',
+ // 'type': 'schedule',
+ // 'cl_name': '涓绘満',
+ // 'cl_code': '201',
+ // 'work_order': 'MO-2023-04-0001_1',
+ // 'AdvaScheUom': '涓�',
+ // 'number': '360',
+ // 'real_number': 360
+ // }
+ // ]
+ // }
+ // ]
+
+ console.log(this.schedulingData, 'schedulingData')
+ console.log(this.schedulingAllData, 'schedulingAllData')
+ },
+ // 鑾峰彇鎺掔▼鏃ユ湡鏈�澶у��
+ getMaxPayDate() {
+ this.formBottom.needArrangeNumber = 0
+ let maxPayDate = handleDatetime(new Date())
+ if (this.multipleSelection.length > 0) {
+ this.multipleSelection.forEach(i => {
+ this.formBottom.needArrangeNumber += i.AdvaScheQty * 1 - i.AdvaScheYPQty * 1
+ if (new Date(i.AdvaScheEndDate).getTime() > new Date(maxPayDate).getTime()) {
+ maxPayDate = i.AdvaScheEndDate
+ }
+ })
+ }
+
+ this.formBottom.scheDate = [] // 鎺掔▼鏃ユ湡缃┖
+ this.formBottom.scheDate.push(handleDatetime(new Date())) // 褰撳墠鏃ユ湡锛堜粖澶╋級
+ this.formBottom.scheDate.push(maxPayDate) // 瑕佹眰浜や粯鏃堕棿
+
+ if (this.formBottom.scheDate !== '') {
+ this.time_data[0] = this.formBottom.scheDate[0] + ' 00:00' // 鎺掔▼寮�濮嬫椂闂�
+ this.time_data[1] = this.formBottom.scheDate[1] + ' 23:59' // 鎺掔▼缁撴潫鏃堕棿
+ }
+ },
+ // 鎻掑叆浜ц兘鏃堕棿娈�
+ pushCapacity(newList, id, arr) {
+ for (const i in newList) {
+ if (newList[i].id === id) {
+ // console.log(JSON.stringify(newList[i]))
+ const t = this.multipleSelection.find(j => j.AdvaScheWorkCode === newList[i].work_order)
+ const data = {
+ work_order: t.AdvaScheWorkCode,
+ AdvaScheUom: t.AdvaScheUom,
+ partname: t.AdvaSchePartName,
+ partcode: t.AdvaSchePartNumber,
+ start: newList[i].start,
+ end: newList[i].end,
+ id: newList[i].id,
+ mod: newList[i].mod,
+ type: 'capacity'
+ }
+ arr.push(data)
+ }
+ }
+ },
+ // 閫掑綊鏋勫缓鏍戝舰骞惰繑鍥�
+ listToTree(list) {
+ const pid = [...new Set(list.map(i => i.wo_code))]
+ const newArr = []
+ pid.forEach(i => {
+ const arr = []
+ list.forEach(j => {
+ if (i === j.wo_code) {
+ arr.push(j)
+ }
+ })
+ newArr.push({ children: arr, wo_code: i })
+ })
+ return newArr
+ },
+
+ // 鎻愪氦鎺掔▼
+ async prepareSubmit() {
+ if (this.formBottom.canArrangeNumber !== this.formBottom.needArrangeNumber) {
+ this.$message.error('鏁伴噺鏈帓瀹岋紝璇疯缃骇鑳芥椂闂达紒')
+ } else {
+ const list = [] // 鎻愪氦鏁扮粍
+ for (const i in this.schedulingData) {
+ const arr = []
+ for (const j in this.schedulingData[i].gtArray) {
+ if (this.schedulingData[i].gtArray[j].type === 'schedule') {
+ arr.push(this.schedulingData[i].gtArray[j])
+ }
+ }
+ if (arr !== '') {
+ for (const i in arr) {
+ const data = {
+ AlreDevicNumber: '',
+ AlreStartDate: '',
+ AlreEndDate: '',
+ AlreQty: ''
+ }
+ data.AlreDevicNumber = arr[i].id
+ data.AlreStartDate = arr[i].start
+ data.AlreEndDate = arr[i].end
+ data.AlreQty = arr[i].number
+ list.push(data)
+ }
+ }
+ }
+ // 鎺掔▼鐩稿悓璁惧鑾峰彇寮�濮嬫椂闂� 缁撴潫鏃堕棿 鏁伴噺鐨勬�诲拰
+ // 杩囨护
+ let update = []
+ for (const i in list) {
+ if (list[i].AlreStartDate !== '') {
+ update.push(list[i])
+ }
+ }
+
+ update = JSON.stringify(update)
+ this.formUpdate.json = update
+ if (list === '') {
+ this.$message.error('璇峰厛棰勬帓')
+ return false
+ }
+
+ const formData = new FormData()
+ formData.append('wocode', this.formUpdate.WorkCode)
+ formData.append('botprocecode', this.formUpdate.BotProceCode)
+ formData.append('json', this.formUpdate.json)
+
+ const res = await SubmitAlreadyScheduling(formData)
+
+ if (res.code === '200') {
+ this.$message.success(res.Message)
+ }
+
+ this.formBottom.needArrangeNumber = 0
+ this.formBottom.canArrangeNumber = 0
+ await this.getOnclickAdvancedSchedulingDevice()
+ await this.getAdvancedSchedulingSearch()
+ }
+ },
+
+ prepareArrange() {
+ const timestamp = new Date().toLocaleDateString()
+
+ if (new Date(this.formBottom.scheDate[1]) < new Date(timestamp)) {
+ this.$message.error('鎺掔▼鏃ユ湡涓嶅彲浠ュ皬浜庡綋鍓嶆椂闂�!')
+ return false
+ }
+ this.filterAlreadyScheduleEqp()// 鎵嬪姩杩囨护鎵�鏈夎澶囧凡鎺掔▼
+
+ // 璁惧浼樺厛鎴栬�呮椂闂翠紭鍏� 瀵规暟鎹繘琛岀殑鏍煎紡杞崲
+ if (this.schedulingData !== '' && this.formBottom.types === 'N') { // 璁惧浼樺厛
+ this.eqpDataTransition()
+ this.editLastValue(this.schedulingData)
+ } else if (this.timeTopTempData !== '' && this.formBottom.types === 'Y') { // 鏃堕棿浼樺厛
+ this.filterAlreadyScheduleTime() // 鎵嬪姩杩囨护鎵�鏈夋椂闂村凡鎺掔▼
+ this.timeDataTransition()
+ this.dataTransition()
+ this.editLastValue(this.schedulingData)
+ }
+ },
+ // 鎵嬪姩杩囨护鎵�鏈夋椂闂村凡鎺掔▼
+ filterAlreadyScheduleTime() {
+ this.timeTopTempData.forEach(item => {
+ if (item.gtArray && item.gtArray.length > 0) {
+ item.gtArray = item.gtArray.filter(it => it.type !== 'schedule')
+ }
+ })
+ },
+ // 鎵嬪姩杩囨护鎵�鏈夎澶囧凡鎺掔▼
+ filterAlreadyScheduleEqp() {
+ this.schedulingData.forEach(item => {
+ if (item.gtArray && item.gtArray.length > 0) {
+ item.gtArray = item.gtArray.filter(it => it.type !== 'schedule')
+ }
+ })
+ },
+ // 缁欐帓绋嬫渶鍚庝竴涓慨鏀规暟閲�
+ editLastValue(arr) {
+ this.formBottom.canArrangeNumber = 0 // 鐪熷疄宸叉帓鏁伴噺
+ let num = 0 // 鍙栨暣宸叉帓鏁伴噺
+ const arr_num = [] // 宸叉帓鏁版嵁
+ let need_num = 0
+ for (const i in arr) {
+ for (const j in arr[i].gtArray) {
+ if (arr[i].gtArray[j].type === 'schedule') {
+ arr_num.unshift(arr[i].gtArray[j])
+ }
+ }
+ }
+
+ for (const n in arr_num) {
+ this.formBottom.canArrangeNumber += arr_num[n].real_number
+ num += arr_num[n].number * 1
+ }
+
+ this.formBottom.canArrangeNumber = Math.ceil(this.formBottom.canArrangeNumber)
+ const y10 = this.formBottom.needArrangeNumber - this.formBottom.canArrangeNumber
+ if (y10 <= 10) {
+ this.formBottom.canArrangeNumber = this.formBottom.needArrangeNumber
+ need_num = this.formBottom.needArrangeNumber - num
+ } else {
+ }
+ for (const i in this.schedulingData) {
+ for (const j in this.schedulingData[i].gtArray) {
+ if (
+ this.schedulingData[i].gtArray[j].type === 'schedule' &&
+ this.schedulingData[i].gtArray[j].end_num
+ ) {
+ this.schedulingData[i].gtArray[j].number =
+ this.schedulingData[i].gtArray[j].number * 1 + need_num
+ }
+ }
+ }
+ },
+ // 璁惧浼樺厛 鏁版嵁鏍煎紡杞崲
+ eqpDataTransition() { // 杩欓噷鏄師鍏堢殑鍐欐硶
+ let needNumber = this.formBottom.needArrangeNumber // 闇�鎺掓暟閲�
+ let flag1 = 0
+ console.log(this.schedulingData, 33)
+ console.log(this.schedulingData.length, 33)
+ for (const i in this.schedulingData) {
+ console.log(i, '涓浗绉诲姩')
+ let end_arr = [] // 宸叉帓绋嬬殑鏁扮粍
+ let need_arr = [] // 寰呮帓绋嬬殑鏁扮粍
+
+ let capacity_arr = [] // 瑕佹帓绋嬬殑鏁扮粍
+ this.schedulingData[i].gtArray.sort((a, b) => new Date(a.end).getTime() - new Date(b.end).getTime())
+
+ end_arr = JSON.parse(JSON.stringify(this.schedulingData[i].gtArray.filter(item => item.type === 'h_schedule'))) // 宸叉帓绋嬫暟缁�
+ need_arr = JSON.parse(JSON.stringify(this.schedulingData[i].gtArray.filter(item => item.type === 'capacity'))) // 瀹归噺
+ // console.log(need_arr, 5)
+ // console.log(JSON.stringify(need_arr))
+
+ // need_arr = [
+ // {
+ // 'start': '2023-03-25 08:00:00',
+ // 'end': '2023-03-25 11:30:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-25 13:00:00',
+ // 'end': '2023-03-25 18:00:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-26 06:00:00',
+ // 'end': '2023-03-26 11:00:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-26 14:00:00',
+ // 'end': '2023-03-26 20:00:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-26 21:30:00',
+ // 'end': '2023-03-26 23:00:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-27 05:30:00',
+ // 'end': '2023-03-27 17:30:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-28 08:00:00',
+ // 'end': '2023-03-28 11:30:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-28 13:00:00',
+ // 'end': '2023-03-28 18:00:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-29 08:00:00',
+ // 'end': '2023-03-29 11:30:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-29 13:00:00',
+ // 'end': '2023-03-29 18:00:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-30 08:00:00',
+ // 'end': '2023-03-30 11:30:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-30 13:00:00',
+ // 'end': '2023-03-30 18:00:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-31 08:00:00',
+ // 'end': '2023-03-31 11:30:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // },
+ // {
+ // 'start': '2023-03-31 13:00:00',
+ // 'end': '2023-03-31 18:00:00',
+ // 'id': 'SB001',
+ // 'mod': 0.3,
+ // 'type': 'capacity'
+ // }
+ // ]
+ if (end_arr && end_arr.length > 0) {
+ capacity_arr = need_arr.map(item => {
+ // 鎺掗櫎鎺夊凡缁忔帓绋嬬殑瀛樺湪hshedule锛宻tart锛宔nd閮界浉绛夌殑鎯呭喌
+ const schedule = end_arr.filter(it => {
+ return new Date(item.start).getTime() <= new Date(it.start).getTime() &&
+ new Date(item.end).getTime() >= new Date(it.end).getTime()
+ })
+
+ if (schedule && schedule.length > 0) {
+ item.start = this.MinutesTest(schedule[schedule.length - 1]['end'])
+ }
+
+ const schedule1 = end_arr.filter(schedule => {
+ return new Date(item.start).getTime() === new Date(schedule.start).getTime() &&
+ new Date(item.end).getTime() === new Date(schedule.end).getTime()
+ })
+ if (schedule1 && schedule1.length > 0) {
+ item.capacity = false
+ }
+
+ return item
+ }).filter(item => item.capacity !== false)
+ } else {
+ capacity_arr = need_arr
+ }
+
+ const id_obj = {
+ id: '',
+ start_time: ''
+ }
+ if (end_arr != '') {
+ (id_obj.id = end_arr[0].id), (id_obj.start_time = end_arr[0].end)
+ }
+
+ capacity_arr = this.filterOutTime(capacity_arr) // 杩囨护鎺夊綋鍓嶆椂闂翠箣鍓嶇殑涓嶈兘鎺掔▼
+
+ for (const w in capacity_arr) {
+ let end_time = ''
+ let mistiming = ''
+ const data = {
+ id: capacity_arr[w].id,
+ start: '',
+ end: '',
+ type: 'schedule',
+ cl_name: this.cl_name,
+ cl_code: this.cl_code,
+ work_order: this.work_order,
+ AdvaScheUom: this.AdvaScheUom,
+ number: 0,
+ real_number: 0
+ }
+ if (
+ id_obj.start_time !== '' &&
+ flag1 === 0 &&
+ new Date(id_obj.start_time).getTime() >= new Date(capacity_arr[w].start).getTime()
+ ) {
+ data.start = this.MinutesTest(id_obj.start_time)
+ flag1 = 1
+ } else {
+ data.start = capacity_arr[w].start
+ }
+ let nowTime = (this.schedulingData[i].AdvaDevicRhythm * needNumber) / capacity_arr[w].mod
+ end_time = this.formSeconds(nowTime, data.start, capacity_arr[w].mod) // 鎬诲叡鐨勭粨鏉熸椂闂�
+ data.end = end_time
+ mistiming = this.compareTime(
+ end_time,
+ capacity_arr[w].end,
+ capacity_arr[w].mod
+ ) // 鎬诲叡鐨勭粨鏉熸椂闂�-褰撳墠鐨勭粨鏉熸椂闂� = 鍓╀笅澶氫箙鏃堕棿
+ if (mistiming >= 0) {
+ data.number =
+ ((new Date(data.end) - new Date(data.start)) *
+ capacity_arr[w].mod) /
+ this.schedulingData[i].AdvaDevicRhythm /
+ 1000
+ data.real_number =
+ ((new Date(data.end) - new Date(data.start)) *
+ capacity_arr[w].mod) /
+ this.schedulingData[i].AdvaDevicRhythm /
+ 1000
+ data.number = data.number.toFixed(0)
+ data.end_num = true
+ if (new Date(data.start) >= new Date(data.end)) {
+ } else {
+ this.schedulingData[i].gtArray.push(data)
+ }
+ return false
+ } else {
+ data.end = capacity_arr[w].end
+
+ if (new Date(data.end).getTime() < new Date(data.start)) {
+ continue // 鍥犱负寮�濮嬫椂闂存瘮缁撴潫鏃堕棿澶� 闇�瑕佽烦杩囧悗闈㈡楠�
+ }
+
+ // 杩欓噷闄や互涓�鍗冩槸鍥犱负 new Date() 寰楀埌鐨勬槸姣 姣杞寲涓虹鏄崈杩涘埗
+ // 涓�娈垫椂闂存鍐呯殑鐢熶骇閲�=涓よ�呮椂闂村樊锛堟绉掞級/1000 / 鐢熶骇鑺傛媿 * 绋煎姩鐜�
+ data.number =
+ ((new Date(data.end) - new Date(data.start)) *
+ capacity_arr[w].mod) /
+ this.schedulingData[i].AdvaDevicRhythm /
+ 1000
+
+ data.real_number =
+ ((new Date(data.end) - new Date(data.start)) *
+ capacity_arr[w].mod) /
+ this.schedulingData[i].AdvaDevicRhythm /
+ 1000
+
+ data.number = data.number.toFixed(0)
+
+ nowTime = (needNumber - data.real_number) * this.schedulingData[i].AdvaDevicRhythm
+ needNumber = needNumber - data.real_number
+ if (new Date(data.start) >= new Date(data.end)) {
+
+ } else {
+ this.schedulingData[i].gtArray.push(data)
+ }
+ }
+ }
+ }
+ },
+ // 鏃堕棿浼樺厛 鏁版嵁鏍煎紡杞崲
+ timeDataTransition() {
+ // 鎺掗櫎鏈嬀閫夐」
+ for (const i in this.timeTopTempData) {
+ const newArr = []
+ for (const j in this.timeTopTempData[i].gtArray) {
+ if (this.ganttLeftArrId.indexOf(this.timeTopTempData[i].gtArray[j].id) < 0) {
+ newArr.push(this.timeTopTempData[i].gtArray[j])
+ }
+ }
+ this.timeTopTempData[i].gtArray = newArr
+ }
+ let needNumber = this.formBottom.needArrangeNumber // 闇�鎺掓暟閲�
+
+ // 閲岄潰閫昏緫瑕佹悶娓呮 寰堥噸瑕�
+ for (const i in this.timeTopTempData) {
+ let end_arr = []
+ let need_arr = [] // 鎺掔▼鐨勬暟缁�
+
+ let capacity_arr = [] // 瑕佹帓绋嬬殑鏁扮粍
+
+ this.timeTopTempData[i].gtArray.sort((a, b) => new Date(a.end).getTime() - new Date(b.end).getTime())
+
+ end_arr = JSON.parse(JSON.stringify(this.timeTopTempData[i].gtArray.filter(item => item.type === 'h_schedule'))) // 宸叉帓绋嬫暟鎹�
+ need_arr = JSON.parse(JSON.stringify(this.timeTopTempData[i].gtArray.filter(item => item.type === 'capacity'))) // 瀹归噺
+
+ capacity_arr = JSON.parse(JSON.stringify(need_arr)) // 瀹归噺
+
+ // 鑾峰彇鍙帓绋嬬殑鏃堕棿 浠ヤ究鎺ョ潃寰�鍚庢帓绋� 閬嶅巻缁撴潫瑕佸緱鍒扮殑鏄� 褰撳墠鏃ユ湡鍙帓瀹归噺
+ end_arr.forEach((item, index) => { // 宸叉帓绋嬬殑鏁扮粍
+ capacity_arr.forEach((it, ind) => { // 瀹归噺锛堟棩浜ц兘锛�
+ if (item.id === it.id &&
+ new Date(item.start).getTime() >= new Date(it.start).getTime() &&
+ new Date(item.end).getTime() === new Date(it.end).getTime() // new Date(item.end).getTime() <= new Date(it.end).getTime()
+ ) {
+ capacity_arr.splice(ind, 1)
+ }
+ })
+ })
+
+ // continue:琛ㄧず璺冲嚭鏈寰幆锛屼篃灏辨槸涓嶆墽琛屾湰娆″惊鐜痗ontinue涔嬪悗鐨勬搷浣�
+ // break:琛ㄧず璺冲嚭褰撳墠鐨勫惊鐜紝閽堝鏁翠釜寰幆浣撶粓姝㈠悗缁殑閬嶅巻锛�
+ if (!capacity_arr || capacity_arr.length === 0) {
+ continue
+ }
+
+ const schedule_arr = end_arr.filter(item => {
+ const remain = need_arr.some(it => {
+ return (new Date(item.start).getTime() >= new Date(it.start).getTime() &&
+ new Date(item.end).getTime() < new Date(it.end).getTime())
+ })
+
+ return remain
+ })
+
+ // 涓嬮潰閫昏緫寰堥噸瑕�
+ if (schedule_arr && schedule_arr.length > 0) {
+ const scheduleCan = schedule_arr.map(item => {
+ const temp = need_arr.filter(it => {
+ if (it.id === item.id) {
+ return (new Date(item.start).getTime() >= new Date(it.start).getTime() &&
+ new Date(item.end).getTime() < new Date(it.end).getTime())
+ // ||
+ // (new Date(item.start).getTime() > new Date(it.start).getTime() &&
+ // new Date(item.end).getTime() < new Date(it.end).getTime())
+ }
+ })[0]
+
+ temp.start = this.MinutesTest(item.end)
+
+ return temp
+ })
+
+ const newSchedule = JSON.parse(JSON.stringify(scheduleCan))
+
+ capacity_arr.forEach(item => {
+ newSchedule.forEach(it => {
+ if (item.id === it.id && new Date(item.start).getTime() < new Date(it.start).getTime()) {
+ item.start = it.start
+ }
+ })
+ })
+ }
+
+ const id_obj = {}
+ if (end_arr != '') {
+ (id_obj.id = end_arr[0].id), (id_obj.start_time = end_arr[0].end)
+ }
+
+ capacity_arr = this.filterOutTime(capacity_arr) // 杩囨护鎺夊綋鍓嶆椂闂翠箣鍓嶇殑涓嶈兘鎺掔▼
+
+ for (const w in capacity_arr) {
+ const data = {
+ id: capacity_arr[w].id,
+ start: '',
+ end: '',
+ type: 'schedule',
+ cl_name: this.cl_name,
+ cl_code: this.cl_code,
+ work_order: this.work_order,
+ AdvaScheUom: this.AdvaScheUom, // 鍗曚綅
+ number: 0,
+ real_number: 0
+ }
+
+ if (
+ id_obj &&
+ new Date(id_obj.start_time).getTime() >=
+ new Date(capacity_arr[w].start).getTime()
+ ) {
+ if (data.id === id_obj.id) {
+ data.start = this.MinutesTest(id_obj.start_time)
+ } else {
+ data.start = capacity_arr[w].start
+ }
+ } else {
+ data.start = capacity_arr[w].start
+ }
+
+ let nowTime = (capacity_arr[w].rhythm * needNumber) / capacity_arr[w].mod
+
+ const end_time = this.formSeconds(nowTime, data.start)
+
+ data.end = end_time
+ const mistiming = this.compareTime(end_time, capacity_arr[w].end)
+ if (mistiming >= 0) {
+ data.number = ((new Date(data.end) - new Date(data.start)) * capacity_arr[w].mod) / capacity_arr[w].rhythm / 1000
+ data.real_number = ((new Date(data.end) - new Date(data.start)) * capacity_arr[w].mod) / capacity_arr[w].rhythm / 1000
+ data.number = data.number.toFixed(0)
+ data.end_num = true
+
+ if (new Date(data.start) >= new Date(data.end)) {
+
+ } else {
+ this.timeTopTempData[i].gtArray.push(data)
+ }
+
+ return false
+ } else {
+ data.end = capacity_arr[w].end
+ data.number = ((new Date(data.end) - new Date(data.start)) * capacity_arr[w].mod) / capacity_arr[w].rhythm / 1000
+ data.real_number = ((new Date(data.end) - new Date(data.start)) * capacity_arr[w].mod) / capacity_arr[w].rhythm / 1000
+ data.number = data.number.toFixed(0)
+ nowTime = (needNumber - data.real_number) * capacity_arr[w].rhythm
+ needNumber = needNumber - data.real_number
+
+ if (new Date(data.start) >= new Date(data.end)) {
+ } else {
+ this.timeTopTempData[i].gtArray.push(data)
+ }
+ }
+ }
+ }
+ },
+ // 杩囨护鎺夊綋鍓嶆椂闂翠箣鍓嶇殑涓嶈兘鎺掔▼
+ filterOutTime(capacity_arr) {
+ // 杩欓噷瑕佸皢瀹归噺鍜屽綋鍓嶆椂闂村仛瀵规瘮 鍋氭椂闂村鐞� 濡傛灉鍦ㄥ綋鍓嶆椂闂翠箣鍓嶇殑涓嶈兘鎺掔▼
+ capacity_arr.forEach((item, index) => {
+ // 褰撳墠鏃堕棿 澶т簬绛変簬寮�濮嬫椂闂� 涓斿皬浜庣瓑浜庣粨鏉熸椂闂�
+ if (new Date(item.start).getTime() <= new Date(handleDatetime2(new Date())).getTime() && new Date(item.end).getTime() >= new Date(handleDatetime2(new Date())).getTime()) {
+ item.start = handleDatetime2(new Date())
+ }
+ // 褰撳墠鏃堕棿姣斿紑濮嬫椂闂村ぇ 姣旂粨鏉熸椂闂翠篃澶�
+ if (new Date(item.start).getTime() < new Date(handleDatetime2(new Date())).getTime() && new Date(item.end).getTime() < new Date(handleDatetime2(new Date())).getTime()) {
+ item.capacity = false
+ }
+ })
+
+ return capacity_arr.filter(item => item.capacity !== false)
+ },
+
+ // 鏃堕棿浼樺厛 缁欒澶囪浆鎹㈡牸寮�
+ dataTransition() {
+ this.schedulingData = []
+ const data = this.timeTopTempData
+
+ const all = []
+ // const list = this.eqpTopTempData
+ const list = this.eqpTopTempData
+
+ console.log(this.eqpTopTempData, 212)
+ for (const i in data) {
+ for (const j in data[i].gtArray) {
+ all.push(data[i].gtArray[j])
+ }
+ }
+
+ for (const i in list) {
+ list[i].gtArray = []
+ this.pushTimes(all, list[i].id, list[i].gtArray)// 鎻掑叆浜ц兘鏃堕棿娈�
+ }
+
+ for (const n in list) {
+ if (list[n].gtArray.length === 0) {
+ list[n].status = false
+ }
+ }
+
+ this.schedulingData = list
+ },
+ // 鎻掑叆浜ц兘鏃堕棿娈�
+ pushTimes(newList, id, arr) {
+ for (const i in newList) {
+ if (newList[i].id === id) {
+ arr.push(newList[i])
+ }
+ }
+ },
+ // 鎺掔▼鏂规硶
+ formSeconds(s1, start, mod) {
+ const nowData = new Date(start)
+ // 绠楀嚭褰撳墠鎺掔▼鐨勭粨鏉熸椂闂�
+ return this.transitionTime(
+ new Date(nowData.setSeconds(nowData.getSeconds() + s1))
+ )
+ },
+ // 杞寲鏍囧噯鏃堕棿
+ transitionTime(time) {
+ const d = new Date(time)
+ return (
+ d.getFullYear() +
+ '-' +
+ (d.getMonth() + 1).toString().padStart(2, '0') +
+ '-' +
+ d.getDate().toString().padStart(2, '0') +
+ ' ' +
+ d.getHours().toString().padStart(2, '0') +
+ ':' +
+ d.getMinutes().toString().padStart(2, '0') +
+ ':' +
+ d.getSeconds().toString().padStart(2, '0')
+ )
+ },
+ // 鏃堕棿姣旇緝
+ compareTime(d1, d2, mod) {
+ // d1 鎺掗櫎缁撴潫鏃堕棿 d2 褰撳墠浜ц兘缁撴潫鏃堕棿
+ const time1 = new Date(d1)
+ const time2 = new Date(d2)
+ return parseInt(time2 - time1) / 1000
+ }
+ }
}
</script>
-
+<!--鎺掔▼閮ㄥ垎鐨勬牱寮�-->
<style scoped>
+body {
+ font-size: 12px;
+ margin: 0;
+ padding: 0;
+ width: 100%;
+ height: 100%;
+}
+
+.box_style {
+ position: relative;
+ top: 40px;
+ left: -91px;
+}
+
+.box_styles {
+ position: relative;
+ top: 40px;
+ left: 0;
+}
+
+/*鑷姩鎺掔▼閮ㄥ垎*/
+.autoScheduling {
+ display: flex;
+ flex-direction: column;
+ /*padding: 0 10px;*/
+ /* height: calc(100vh - 100px); */
+ /*background-color: #f8f8fa;*/
+ background-color: #fff;
+ margin-top: 20px;
+ height: 490px;
+}
+
+.colorDescription {
+ display: flex;
+ padding: 5px 30px 0;
+ align-items: center;
+}
+
+.colorDescriptionItem {
+ display: flex;
+ margin-right: 20px;
+}
+
+label {
+ margin-left: 10px;
+}
+
+input {
+ width: 40px;
+ height: 20px;
+ vertical-align: middle;
+}
+
+input[type="range"] {
+ width: 100px;
+}
+
+.container {
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+}
+
+.tc {
+ text-align: center;
+}
+
+.name {
+ display: flex;
+ box-sizing: border-box;
+ overflow: hidden;
+ height: 100%;
+ width: 100%;
+ padding: 0 5px 0 0;
+ border-radius: 8px 0 0 8px;
+ align-items: center;
+}
+
+.carId {
+ flex: 1;
+}
+
+.tc {
+ color: #909399;
+ font-size: 14px;
+}
+</style>
+
+<!--鍏叡椤甸潰鏍峰紡-->
+<style lang="scss" scoped>
+$main_color: #42b983;
+.elTableDiv {
+ ::v-deep .el-radio__label {
+ display: none;
+ }
+}
+
+::v-deep .el-button--text {
+ font-size: 14px;
+ cursor: pointer;
+}
+
+.el-icon-share, .el-icon-delete, .el-icon-edit-outline {
+ color: $main_color;
+ cursor: pointer;
+}
+
+.el-icon-edit-outline {
+ margin-right: 15px;
+}
+
+::v-deep .el-button--primary, .el-button--default, .el-button--info {
+ height: 34px;
+ display: flex;
+ align-items: center;
+ padding: 0 15px;
+}
+
+::v-deep .el-button--primary {
+ //background-color: $main_color !important;
+}
+
+::v-deep .el-button--default {
+ background-color: #f8f8fa;
+ border: none;
+}
+
+::v-deep .el-input__inner {
+ height: 34px;
+ line-height: 34px;
+ //color: #a7a7a7;
+}
+
+::v-deep .el-dialog__body {
+ padding: 20px 100px !important;
+}
+
+::v-deep .dialogVisibleRoles .el-dialog__body {
+ padding: 20px 20px !important;
+}
+
+::v-deep .importPickerClass .el-dialog__body {
+ padding: 20px 20px !important;
+}
+
+::v-deep .el-dialog__footer {
+ display: flex;
+ justify-content: flex-end;
+}
+
+::v-deep .el-table .caret-wrapper {
+ transform: scale(0.8);
+}
+
+::v-deep .cell {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+::v-deep .el-table::before {
+ height: 0;
+}
+
+::v-deep .el-table__body-wrapper {
+ background-color: #f8f8fa;
+}
+
+::v-deep .el-table__body .el-table__row.hover-row td {
+ background-color: #eaecef;
+}
+
+::v-deep .el-form--inline .el-form-item__label {
+ color: #a7a7a7;
+}
+
+.body ::v-deep .el-divider {
+ border: 1px solid #eee;
+ width: 99%;
+ margin: 10px auto;
+}
+
+.body ::v-deep .el-form-item {
+ margin-bottom: 0;
+}
+
+.userDialogVisible ::v-deep .el-form-item {
+ margin-bottom: 0;
+}
+
+::v-deep .el-select__caret {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.tableFixed {
+ ::v-deep .el-table__fixed-right {
+ height: 100% !important;
+ }
+
+ ::v-deep .el-table__fixed {
+ height: 100% !important;
+ }
+
+}
+
+::v-deep .gantt-header-title {
+ background-color: #fff;
+ //border-left: 1px solid #eee !important;
+ //border-bottom: 1px solid #eee !important;
+}
</style>
+<style>
+
+.el-table .custom-row {
+ background: #f8f8fa;
+}
+
+</style>
+
+<!--<style>-->
+<!--input[type=range]:focus {-->
+<!-- display: none;-->
+<!--}-->
+
+<!--input[type=range] {-->
+<!-- -webkit-appearance: none;-->
+<!-- width: 500px;-->
+<!-- border-radius: 10px;-->
+<!-- /*杩欎釜灞炴�ц缃娇濉厖杩涘害鏉℃椂鐨勫浘褰负鍦嗚*/-->
+<!--}-->
+
+<!--input[type=range]::-webkit-slider-runnable-track {-->
+<!-- height: 20px;-->
+<!-- border-radius: 10px;-->
+<!-- /*灏嗚建閬撹涓哄渾瑙掔殑*/-->
+<!-- /* box-shadow: 0 1px 1px #def3f8, inset 0 .125em .125em #0d1112; */-->
+<!-- border: solid 1px red;-->
+<!--}-->
+
+<!--input[type=range]::-webkit-slider-thumb {-->
+<!-- -webkit-appearance: none;-->
+<!-- height: 30px;-->
+<!-- width: 120px;-->
+<!-- margin-top: -5px;-->
+<!-- /*浣挎粦鍧楄秴鍑鸿建閬撻儴鍒嗙殑鍋忕Щ閲忕浉绛�*/-->
+<!-- background: #ffffff;-->
+<!-- /* border-radius: 50%; */-->
+<!-- /*澶栬璁剧疆涓哄渾褰�*/-->
+<!-- border: solid 0.125em rgba(205, 224, 230, 0.5);-->
+<!-- /*璁剧疆杈规*/-->
+<!-- /* box-shadow: 0 .125em .125em #3b4547; */-->
+<!-- /*娣诲姞搴曢儴闃村奖*/-->
+<!--}-->
+<!--</style>-->
--
Gitblit v1.9.3