|
|
@@ -13,11 +13,27 @@
|
|
|
:ganttTasks="tableData"
|
|
|
:planList="planDataList"
|
|
|
:calendarSourceData="calendarSourceData"
|
|
|
- ></projectGantt>
|
|
|
+ :defaultTab="'factory'"
|
|
|
+ :dateRange="dateRange"
|
|
|
+ @tab-change="handleTabChange"
|
|
|
+ >
|
|
|
+ <template v-slot:toolbar>
|
|
|
+ <el-date-picker
|
|
|
+ v-model="dateRange"
|
|
|
+ type="daterange"
|
|
|
+ size="mini"
|
|
|
+ value-format="yyyy-MM-dd"
|
|
|
+ range-separator="至"
|
|
|
+ start-placeholder="计划开始时间"
|
|
|
+ end-placeholder="计划结束时间"
|
|
|
+ @change="handleDateChange"
|
|
|
+ ></el-date-picker>
|
|
|
+ </template>
|
|
|
+ </projectGantt>
|
|
|
<div class="scheduling-content">
|
|
|
<div class="form-wrapper">
|
|
|
<div class="btnList">
|
|
|
- <el-button
|
|
|
+ <!-- <el-button
|
|
|
type="primary"
|
|
|
size="mini"
|
|
|
:disabled="entryReadonly"
|
|
|
@@ -32,7 +48,7 @@
|
|
|
@click="openPlanPicker(3, '添加临时计划')"
|
|
|
>
|
|
|
添加临时计划
|
|
|
- </el-button>
|
|
|
+ </el-button> -->
|
|
|
</div>
|
|
|
<!-- <div class="btnList">
|
|
|
<el-button type="primary" @click="confirm">保存</el-button>
|
|
|
@@ -73,11 +89,31 @@
|
|
|
:datasource="planDataList"
|
|
|
row-key="id"
|
|
|
:selection.sync="selection"
|
|
|
- @update:selection="handlePlanSelectionChange"
|
|
|
height="400px"
|
|
|
full-height="calc(100vh - 116px)"
|
|
|
:page-size="20"
|
|
|
- ></ele-pro-table>
|
|
|
+ >
|
|
|
+ <template v-slot:action="{ row }">
|
|
|
+ <!-- <el-button type="text" size="small" @click="handlePublish(row)">
|
|
|
+ 发布
|
|
|
+ </el-button> -->
|
|
|
+ <el-link
|
|
|
+ type="primary"
|
|
|
+ :underline="false"
|
|
|
+ @click="handlePublish(row)"
|
|
|
+ >
|
|
|
+ 发布
|
|
|
+ </el-link>
|
|
|
+ </template>
|
|
|
+ <template v-slot:dotLineStatus="{ row }">
|
|
|
+ <el-tag type="success" size="mini" v-if="row.dotLineStatus == 1">
|
|
|
+ 已布点
|
|
|
+ </el-tag>
|
|
|
+ <el-tag type="danger" size="mini" v-if="row.dotLineStatus == 0">
|
|
|
+ 未布点
|
|
|
+ </el-tag>
|
|
|
+ </template>
|
|
|
+ </ele-pro-table>
|
|
|
</div>
|
|
|
<div
|
|
|
v-loading="dotLineLoading"
|
|
|
@@ -149,7 +185,9 @@
|
|
|
import TaskConfigPanel from './newFactoryProductionScheduling/TaskConfigPanel.vue';
|
|
|
import {
|
|
|
getList,
|
|
|
- teamSchedulingGanttChart
|
|
|
+ teamSchedulingGanttChart,
|
|
|
+ factorySchedulingGanttChart,
|
|
|
+ getPlansByIds
|
|
|
} from '@/api/productionPlan/index.js';
|
|
|
import { getTaskListById } from '@/api/materialPlan';
|
|
|
import { teamPage } from '@/api/mainData';
|
|
|
@@ -182,6 +220,18 @@
|
|
|
TaskConfigPanel
|
|
|
},
|
|
|
data() {
|
|
|
+ const now = new Date();
|
|
|
+ const startDate = `${now.getFullYear()}-${String(
|
|
|
+ now.getMonth() + 1
|
|
|
+ ).padStart(2, '0')}-01`;
|
|
|
+ const lastDay = new Date(
|
|
|
+ now.getFullYear(),
|
|
|
+ now.getMonth() + 1,
|
|
|
+ 0
|
|
|
+ ).getDate();
|
|
|
+ const endDate = `${now.getFullYear()}-${String(
|
|
|
+ now.getMonth() + 1
|
|
|
+ ).padStart(2, '0')}-${String(lastDay).padStart(2, '0')}`;
|
|
|
return {
|
|
|
visible: false,
|
|
|
entryReadonly: false,
|
|
|
@@ -194,6 +244,8 @@
|
|
|
planDataList: [],
|
|
|
allPlanDataList: [],
|
|
|
selection: [],
|
|
|
+ activeTab: 'factory',
|
|
|
+ dateRange: [startDate, endDate],
|
|
|
planPickerVisible: false,
|
|
|
planPickerTitle: '添加计划',
|
|
|
planPickerLoading: false,
|
|
|
@@ -442,45 +494,17 @@
|
|
|
|
|
|
// Selected plan detail
|
|
|
handlePlanSelectionChange(rows) {
|
|
|
- const selectedRows = Array.isArray(rows) ? rows : [];
|
|
|
- const currentPlan =
|
|
|
- selectedRows.length > 0
|
|
|
- ? selectedRows[selectedRows.length - 1]
|
|
|
- : null;
|
|
|
- if (selectedRows.length > 1 && currentPlan) {
|
|
|
- this.selection = [currentPlan];
|
|
|
- this.$nextTick(() => {
|
|
|
- const table = this.$refs.planTable;
|
|
|
- table?.clearSelection?.();
|
|
|
- table?.toggleRowSelection?.(currentPlan, true);
|
|
|
- });
|
|
|
- }
|
|
|
- const selectedPlanId =
|
|
|
- currentPlan && currentPlan.id != null ? String(currentPlan.id) : '';
|
|
|
- const currentPlanId = String(this.currentPlan?.id || '');
|
|
|
- if (
|
|
|
- selectedPlanId &&
|
|
|
- selectedPlanId === currentPlanId &&
|
|
|
- (this.dotLineLoading || this.taskList.length > 0)
|
|
|
- ) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!selectedRows.length) {
|
|
|
- this.currentPlan = null;
|
|
|
- this.planRoutingPayload = null;
|
|
|
- this.taskList = [];
|
|
|
- this.dotLineLoading = false;
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!selectedPlanId) {
|
|
|
- this.currentPlan = null;
|
|
|
- this.planRoutingPayload = null;
|
|
|
- this.taskList = [];
|
|
|
- this.dotLineLoading = false;
|
|
|
+ this.selection = Array.isArray(rows) ? rows : [];
|
|
|
+ },
|
|
|
+ handlePublish(row) {
|
|
|
+ if (!row.bomCategoryId) {
|
|
|
+ this.$message.warning('该计划没有配置BOM请先配置BOM');
|
|
|
return;
|
|
|
}
|
|
|
- this.currentPlan = currentPlan;
|
|
|
- this.loadPlanDotLineDetail(currentPlan);
|
|
|
+ this.currentPlan = row;
|
|
|
+ this.selection = [row];
|
|
|
+ this.syncTableSelection('planTable', [row]);
|
|
|
+ this.loadPlanDotLineDetail(row);
|
|
|
},
|
|
|
async loadPlanDotLineDetail(currentPlan) {
|
|
|
this.dotLineLoading = true;
|
|
|
@@ -853,18 +877,47 @@
|
|
|
},
|
|
|
|
|
|
// Scheduling data refresh
|
|
|
+ async handleTabChange(tabKey) {
|
|
|
+ this.activeTab = tabKey;
|
|
|
+ await this.refreshSchedulingView();
|
|
|
+ },
|
|
|
+
|
|
|
+ async handleDateChange(val) {
|
|
|
+ this.dateRange = val;
|
|
|
+ if (this.activeTab === 'factory') {
|
|
|
+ await this.refreshSchedulingView();
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
async refreshSchedulingView() {
|
|
|
- const planIds = (this.planDataList || [])
|
|
|
- .map((item) => item.id)
|
|
|
- .filter((id) => id != null && id !== '');
|
|
|
- if (!planIds.length) {
|
|
|
- this.calendarSourceData = [];
|
|
|
- this.tableData = [];
|
|
|
- return;
|
|
|
+ let data;
|
|
|
+ const params = {};
|
|
|
+ if (this.dateRange && this.dateRange.length === 2) {
|
|
|
+ params.startDate = this.dateRange[0];
|
|
|
+ params.endDate = this.dateRange[1];
|
|
|
+ }
|
|
|
+ if (this.activeTab === 'factory') {
|
|
|
+ data = await factorySchedulingGanttChart(params);
|
|
|
+
|
|
|
+ const extractedPlanIds = new Set();
|
|
|
+ (data || []).forEach((item) => {
|
|
|
+ (item.resourcePeriods || []).forEach((period) => {
|
|
|
+ if (period.planId) extractedPlanIds.add(period.planId);
|
|
|
+ });
|
|
|
+ (item.resourceList || []).forEach((resource) => {
|
|
|
+ if (resource.planId) extractedPlanIds.add(resource.planId);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ if (extractedPlanIds.size > 0) {
|
|
|
+ const plans = await this.loadPlansByIds(
|
|
|
+ Array.from(extractedPlanIds)
|
|
|
+ );
|
|
|
+ this.planDataList = this.buildPlanTableRows(plans);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data = await teamSchedulingGanttChart(params);
|
|
|
}
|
|
|
- const data = await teamSchedulingGanttChart({
|
|
|
- planIds
|
|
|
- });
|
|
|
this.calendarSourceData = data || [];
|
|
|
this.tableData = this.initGanttFlatRows(data || []);
|
|
|
},
|
|
|
@@ -908,6 +961,20 @@
|
|
|
this.dotLineFullscreen = false;
|
|
|
this.calendarSourceData = [];
|
|
|
this.tableData = [];
|
|
|
+ this.activeTab = 'factory';
|
|
|
+ const now = new Date();
|
|
|
+ this.dateRange = [
|
|
|
+ `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(
|
|
|
+ 2,
|
|
|
+ '0'
|
|
|
+ )}-01`,
|
|
|
+ `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(
|
|
|
+ 2,
|
|
|
+ '0'
|
|
|
+ )}-${String(
|
|
|
+ new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate()
|
|
|
+ ).padStart(2, '0')}`
|
|
|
+ ];
|
|
|
await this.refreshSchedulingView();
|
|
|
|
|
|
this.visible = true;
|
|
|
@@ -1194,6 +1261,7 @@
|
|
|
display: flex;
|
|
|
align-items: flex-end;
|
|
|
gap: 12px;
|
|
|
+ margin-top: 12px;
|
|
|
}
|
|
|
|
|
|
.form-wrapper {
|