胶料快检曲线图展示优化
This commit is contained in:
@@ -85,20 +85,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-section__body detail-section__body--chart">
|
<div class="detail-section__body detail-section__body--chart">
|
||||||
<a-row :gutter="16">
|
<div class="chart-stack">
|
||||||
<a-col :span="12">
|
|
||||||
<div class="chart-card">
|
<div class="chart-card">
|
||||||
<div class="chart-card__title">温度曲线(上模 / 下模)</div>
|
<div class="chart-card__title">温度曲线(上模 / 下模)</div>
|
||||||
<div ref="tempChartRef" class="chart-box"></div>
|
<div ref="tempChartRef" class="chart-box"></div>
|
||||||
</div>
|
</div>
|
||||||
</a-col>
|
<div class="chart-card chart-card--spaced">
|
||||||
<a-col :span="12">
|
|
||||||
<div class="chart-card">
|
|
||||||
<div class="chart-card__title">S'(dNm) 曲线</div>
|
<div class="chart-card__title">S'(dNm) 曲线</div>
|
||||||
<div ref="torqueChartRef" class="chart-box"></div>
|
<div ref="torqueChartRef" class="chart-box"></div>
|
||||||
</div>
|
</div>
|
||||||
</a-col>
|
</div>
|
||||||
</a-row>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -172,8 +168,16 @@
|
|||||||
|
|
||||||
const tempChartRef = ref<HTMLDivElement | null>(null);
|
const tempChartRef = ref<HTMLDivElement | null>(null);
|
||||||
const torqueChartRef = ref<HTMLDivElement | null>(null);
|
const torqueChartRef = ref<HTMLDivElement | null>(null);
|
||||||
const { setOptions: setTempChartOptions, resize: resizeTempChart } = useECharts(tempChartRef as Ref<HTMLDivElement>);
|
const {
|
||||||
const { setOptions: setTorqueChartOptions, resize: resizeTorqueChart } = useECharts(torqueChartRef as Ref<HTMLDivElement>);
|
setOptions: setTempChartOptions,
|
||||||
|
resize: resizeTempChart,
|
||||||
|
getInstance: getTempChartInstance,
|
||||||
|
} = useECharts(tempChartRef as Ref<HTMLDivElement>);
|
||||||
|
const {
|
||||||
|
setOptions: setTorqueChartOptions,
|
||||||
|
resize: resizeTorqueChart,
|
||||||
|
getInstance: getTorqueChartInstance,
|
||||||
|
} = useECharts(torqueChartRef as Ref<HTMLDivElement>);
|
||||||
|
|
||||||
const ledgerPickTarget = ref<'prod' | 'inspect'>('prod');
|
const ledgerPickTarget = ref<'prod' | 'inspect'>('prod');
|
||||||
|
|
||||||
@@ -281,53 +285,69 @@
|
|||||||
}
|
}
|
||||||
tableReady.value = true;
|
tableReady.value = true;
|
||||||
if (useNewDetail.value) {
|
if (useNewDetail.value) {
|
||||||
|
await nextTick();
|
||||||
await scheduleRenderCharts(chartPointDataSource.value);
|
await scheduleRenderCharts(chartPointDataSource.value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function isChartContainerReady() {
|
||||||
|
const temp = tempChartRef.value;
|
||||||
|
const torque = torqueChartRef.value;
|
||||||
|
return !!(
|
||||||
|
temp &&
|
||||||
|
torque &&
|
||||||
|
temp.offsetWidth > 0 &&
|
||||||
|
temp.offsetHeight > 0 &&
|
||||||
|
torque.offsetWidth > 0 &&
|
||||||
|
torque.offsetHeight > 0
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function waitForChartContainers(maxTry = 24) {
|
||||||
|
for (let i = 0; i < maxTry; i++) {
|
||||||
|
await nextTick();
|
||||||
|
if (isChartContainerReady()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
await new Promise<void>((resolve) => window.setTimeout(resolve, 80));
|
||||||
|
}
|
||||||
|
return isChartContainerReady();
|
||||||
|
}
|
||||||
|
|
||||||
async function scheduleRenderCharts(points: Recordable[]) {
|
async function scheduleRenderCharts(points: Recordable[]) {
|
||||||
await nextTick();
|
if (!useNewDetail.value) {
|
||||||
await nextTick();
|
return;
|
||||||
await new Promise<void>((resolve) => {
|
}
|
||||||
window.setTimeout(() => {
|
await waitForChartContainers();
|
||||||
renderCharts(points);
|
renderCharts(points);
|
||||||
|
await nextTick();
|
||||||
resizeTempChart();
|
resizeTempChart();
|
||||||
resizeTorqueChart();
|
resizeTorqueChart();
|
||||||
resolve();
|
getTempChartInstance()?.resize();
|
||||||
}, 280);
|
getTorqueChartInstance()?.resize();
|
||||||
});
|
window.setTimeout(() => {
|
||||||
|
resizeTempChart();
|
||||||
|
resizeTorqueChart();
|
||||||
|
getTempChartInstance()?.resize();
|
||||||
|
getTorqueChartInstance()?.resize();
|
||||||
|
}, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onModalVisibleChange(visible: boolean) {
|
function onModalVisibleChange(visible: boolean) {
|
||||||
if (visible && useNewDetail.value) {
|
if (visible && useNewDetail.value) {
|
||||||
|
window.setTimeout(() => {
|
||||||
scheduleRenderCharts(chartPointDataSource.value);
|
scheduleRenderCharts(chartPointDataSource.value);
|
||||||
|
}, 320);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(useNewDetail, async (visible) => {
|
watch(
|
||||||
if (visible) {
|
() => chartPointDataSource.value.length,
|
||||||
|
async (len) => {
|
||||||
|
if (useNewDetail.value && len > 0) {
|
||||||
await scheduleRenderCharts(chartPointDataSource.value);
|
await scheduleRenderCharts(chartPointDataSource.value);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => [useNewDetail.value, tempChartRef.value, torqueChartRef.value] as const,
|
|
||||||
([visible, tempEl, torqueEl]) => {
|
|
||||||
if (visible && tempEl && torqueEl) {
|
|
||||||
scheduleRenderCharts(chartPointDataSource.value);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{ flush: 'post' },
|
|
||||||
);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
chartPointDataSource,
|
|
||||||
async (points) => {
|
|
||||||
if (useNewDetail.value && points?.length) {
|
|
||||||
await scheduleRenderCharts(points);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ deep: true },
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const title = computed(() => (unref(isDetail) ? '快检记录详情' : '编辑胶料快检记录'));
|
const title = computed(() => (unref(isDetail) ? '快检记录详情' : '编辑胶料快检记录'));
|
||||||
@@ -524,7 +544,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.detail-section__body--chart {
|
.detail-section__body--chart {
|
||||||
padding: 12px 12px 4px;
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-stack {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chart-card {
|
.chart-card {
|
||||||
@@ -534,6 +560,10 @@
|
|||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chart-card--spaced {
|
||||||
|
margin-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
.chart-card__title {
|
.chart-card__title {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
@@ -545,7 +575,7 @@
|
|||||||
|
|
||||||
.chart-box {
|
.chart-box {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 220px;
|
height: 260px;
|
||||||
min-height: 220px;
|
min-height: 260px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user