From e3e17a37d85f50bace525ed019ee0cd8d39143eb Mon Sep 17 00:00:00 2001
From: CD配唱片 <CD配唱片>
Date: 星期四, 08 五月 2025 18:19:23 +0800
Subject: [PATCH] 钣金工单计划管理
---
src/views/mainPlan/apsPartRoutStat/index.vue | 197 +++++++++++++++++++++++++++++-------------------
1 files changed, 119 insertions(+), 78 deletions(-)
diff --git a/src/views/mainPlan/apsPartRoutStat/index.vue b/src/views/mainPlan/apsPartRoutStat/index.vue
index e3432df..2395889 100644
--- a/src/views/mainPlan/apsPartRoutStat/index.vue
+++ b/src/views/mainPlan/apsPartRoutStat/index.vue
@@ -8,16 +8,19 @@
icon="Download"
@click="handleExport"
v-hasPermi="['apsPartRouteStat:export']"
- >瀵煎嚭</el-button>
+ >{{ $t(`common.common.export`) }}</el-button
+ >
</el-col>
<el-col :span="1.5">
<el-button
- type="info"
+ type="success"
plain
icon="Refresh"
@click="handleRefresh"
+ :disabled="loading"
v-hasPermi="['apsPartRouteStat:edit']"
- >鏇存柊</el-button>
+ >{{ $t(`common.common.update`) }}</el-button
+ >
</el-col>
<right-toolbar @queryTable="getList" :search="false"></right-toolbar>
</el-row>
@@ -26,142 +29,176 @@
</template>
<script setup name="apsPartRouteStat">
-import { query,updateStat } from "@/api/mainPlan/partRouteStat.js";
+import { query, updateStat } from "@/api/mainPlan/partRouteStat.js";
import { ref } from "vue";
-import * as XLSX from 'xlsx';
+import * as XLSX from "xlsx";
const { proxy } = getCurrentInstance();
-
-const loading = ref(true);
+import { useI18n } from "vue-i18n"; //瑕佸湪js涓娇鐢ㄥ浗闄呭寲
+const { t, locale } = useI18n();
+const loading = ref(false);
const gridRef = ref();
-const height = ref(document.documentElement.clientHeight - 130 + "px;")
+const height = ref(document.documentElement.clientHeight - 130 + "px;");
const headers = ref([]);
const exportData = ref([]);
const gridOptions = reactive({
border: true,
+ stripe: true,
loading: false,
showOverflow: true,
showHeaderOverflow: true,
showFooterOverflow: true,
+ virtualXConfig: {
+ enabled: true,
+ gt: 0,
+ },
height: height,
columnConfig: {
- resizable: true
+ resizable: true,
},
scrollX: {
enabled: true,
gt: 0,
- threshold: 50
+ threshold: 50,
},
scrollY: {
enabled: true,
gt: 0,
- threshold: 50
- }
+ threshold: 50,
+ },
});
-let tableColumn = []
-let tableData = []
+let tableColumn = [];
+let tableData = [];
let merges = [];
-
+watch(
+ locale,
+ (newLocale) => {
+ getList();
+ },
+ { immediate: true, deep: true }
+);
/** 鏌ヨ闆朵欢缁熻琛ㄥ垪琛� */
function getList() {
- let rowKey = 0
- let colKey = 0
- headers.value = []
- exportData.value = []
- tableColumn = []
- tableData = []
+ let rowKey = 0;
+ let colKey = 0;
+ headers.value = [];
+ exportData.value = [];
+ tableColumn = [];
+ tableData = [];
loading.value = true;
- query().then(response => {
- const colList = []
- let headersOne = []
- let headersTwo = []
- if(response.code == '200'){
+ query().then((response) => {
+ const colList = [];
+ let headersOne = [];
+ let headersTwo = [];
+ if (response.code == "200") {
if (!response.planTitle) {
loading.value = false;
return;
}
- headersOne.push('鏃ユ湡');
- headersTwo.push('璧勬簮缁�');
+ headersOne.push(t("plan.table.dateYearMonth"));
+ headersTwo.push(t("plan.table.resourceName"));
colList.push({
- field: 'dateCol',
- title: '鏃ユ湡',
- fixed: 'left',
- children: [
- { field: `resourceName`, title: '璧勬簮缁�', width: 250, type: 'html'},
- ],
- width: 160
- })
- response.planTitle.forEach(item => {
+ field: "dateCol",
+ title: t("plan.table.dateYearMonth"),
+ fixed: "left",
+ children: [
+ {
+ field: `resourceName`,
+ title: t("plan.table.resourceName"),
+ width: 250,
+ type: "html",
+ },
+ ],
+ width: 160,
+ });
+ response.planTitle.forEach((item) => {
headersOne.push(item);
- headersOne.push('');
- headersOne.push('');
- headersTwo.push('璁捐宸ユ椂');
- headersTwo.push('闇�姹傚伐鏃�');
- headersTwo.push('浜ц兘璐熻嵎');
- colKey++
+ headersOne.push("");
+ headersOne.push("");
+ headersTwo.push(t("plan.table.designWorkingHours"));
+ headersTwo.push(t("plan.table.requiredWorkingHours"));
+ headersTwo.push(t("plan.table.capacityLoad"));
+ colKey++;
colList.push({
field: `dateColTime${colKey}`,
title: item,
children: [
- { field: `designTimes${colKey}`, title: '璁捐宸ユ椂', width: 80},
- { field: `requireTimes${colKey}`, title: '闇�姹傚伐鏃�', width: 80},
- { field: `capacityLoad${colKey}`, title: '浜ц兘璐熻嵎', width: 80, type: 'html'},
+ {
+ field: `designTimes${colKey}`,
+ title: t("plan.table.designWorkingHours"),
+ width: 80,
+ },
+ {
+ field: `requireTimes${colKey}`,
+ title: t("plan.table.requiredWorkingHours"),
+ width: 80,
+ },
+ {
+ field: `capacityLoad${colKey}`,
+ title: t("plan.table.capacityLoad"),
+ width: 80,
+ type: "html",
+ },
],
- width: 160
- })
+ width: 160,
+ });
});
headers.value.push(headersOne);
headers.value.push(headersTwo);
- const columnList = [...tableColumn, ...colList]
- const dataList = []
+ const columnList = [...tableColumn, ...colList];
+ const dataList = [];
let startCol = 1;
//鑾峰彇map
- response.planTable.forEach(mapItem => {
- rowKey++
+ response.planTable.forEach((mapItem) => {
+ rowKey++;
let lastCol = startCol + 2;
- merges.push({ s: { r: 0, c: startCol }, e: { r: 0, c: lastCol} });
+ merges.push({ s: { r: 0, c: startCol }, e: { r: 0, c: lastCol } });
startCol = lastCol + 1;
let data = [];
const item = {
- id: `${rowKey}`
- }
+ id: `${rowKey}`,
+ };
for (const [key, listValue] of Object.entries(mapItem)) {
data.push(key);
-
+
let tableKey = 0;
let flag = false;
- listValue.forEach(listItem => {
-
- tableKey++
+ listValue.forEach((listItem) => {
+ tableKey++;
item[`designTimes${tableKey}`] = listItem.designTimes;
item[`requireTimes${tableKey}`] = listItem.requireTimes;
- item[`capacityLoad${tableKey}`] = listItem.capacityLoad > 100 ? `<font color="red">${listItem.capacityLoad}%</font>` :listItem.capacityLoad+'%';
+ item[`capacityLoad${tableKey}`] =
+ listItem.capacityLoad > 100
+ ? `<font color="red">${listItem.capacityLoad}%</font>`
+ : listItem.capacityLoad + "%";
data.push(listItem.designTimes);
data.push(listItem.requireTimes);
- data.push(listItem.capacityLoad+'%');
+ data.push(listItem.capacityLoad + "%");
if (listItem.capacityLoad > 100) {
flag = true;
}
});
- item[`resourceName`] = flag ? `<div class='el-badge'><sup class="el-badge__content is-fixed is-dot"></sup>${key}</div>` : key;
+ item[`resourceName`] = flag
+ ? `<div class='el-badge'><sup class="el-badge__content is-fixed is-dot"></sup>${key}</div>`
+ : key;
}
exportData.value.push(data);
dataList.push(item);
});
-
- const $grid = gridRef.value
+
+ const $grid = gridRef.value;
if ($grid) {
- tableColumn = columnList
- tableData = [...tableData, ...dataList]
- $grid.loadColumn(tableColumn)
- $grid.loadData(tableData)
- gridOptions.loading = false
+ tableColumn = columnList;
+ tableData = [...tableData, ...dataList];
+ $grid.loadColumn(tableColumn);
+ $grid.loadData(tableData);
+ gridOptions.loading = false;
}
loading.value = false;
@@ -171,7 +208,6 @@
/** 瀵煎嚭鎸夐挳鎿嶄綔 */
function handleExport() {
-
// 鍚堝苟琛ㄥご鍜屾暟鎹�
const finalData = [...headers.value, ...exportData.value];
@@ -184,25 +220,30 @@
{ s: { r: 0, c: 0 }, e: { r: 0, c: 0 } }
]; */
- ws['!merges'] = merges;
-
+ ws["!merges"] = merges;
+
// 鍒涘缓 workbook
const wb = XLSX.utils.book_new();
// 灏� worksheet 娣诲姞鍒� workbook 涓�
- XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
+ XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
// 瀵煎嚭鏂囦欢
XLSX.writeFile(wb, `apsPartRouteStat_${new Date().getTime()}.xlsx`);
-
}
/** 鍒锋柊鎸夐挳鎿嶄綔 */
-function handleRefresh(){
- updateStat().then(response => {
- if(response.code == '200'){
+function handleRefresh() {
+ loading.value = true;
+ updateStat().then((response) => {
+ if (response.code == "200") {
+ ElMessage({
+ message: t("plan.message.update"),
+ type: "success",
+ });
getList();
+ loading.value = false;
}
});
}
-getList();
+// getList();
</script>
--
Gitblit v1.9.3