From d33d80732952b59e150911a3195e4245e184b6a9 Mon Sep 17 00:00:00 2001
From: chengxiangling <291105840@qq.com>
Date: 星期四, 15 五月 2025 17:24:10 +0800
Subject: [PATCH] 提交计划管理页面与联调
---
src/views/basicData/calendar/index.vue | 328 ++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 229 insertions(+), 99 deletions(-)
diff --git a/src/views/basicData/calendar/index.vue b/src/views/basicData/calendar/index.vue
index a0f174e..cf00806 100644
--- a/src/views/basicData/calendar/index.vue
+++ b/src/views/basicData/calendar/index.vue
@@ -26,7 +26,7 @@
<el-select
style="width: 140px"
clearable
- v-model="queryParams.plant"
+ v-model="queryParams.applicableFactory"
placeholder="閫傜敤宸ュ巶"
>
<el-option
@@ -112,7 +112,7 @@
>
<template #status="{ row }">
<vxe-tag v-if="row.type === '1'" status="primary">鍛ㄥ伐浣�</vxe-tag>
- <vxe-tag v-if="row.type === '2'" status="success">鑺傚亣鏃�</vxe-tag>
+ <!-- <vxe-tag v-if="row.type === '2'" status="success">鑺傚亣鏃�</vxe-tag> -->
</template>
<template #mark="{ row }">
<div v-if="row.type === '1'">
@@ -261,7 +261,10 @@
prop="applicableFactory"
class="factory_use_item"
> -->
- <div class="select_factory select_factory_dis">閫傜敤宸ュ巶/杞﹂棿/宸ュ簭</div>
+ <div class="select_factory select_factory_dis">
+ <span class="error_require">*</span>
+ <span>閫傜敤宸ュ巶/杞﹂棿/宸ュ簭</span>
+ </div>
<!-- <el-row :gutter="20" class="select_factory"> -->
<div
class="select_factory_dis"
@@ -390,11 +393,16 @@
<div>閫傜敤宸ュ巶锛� </div>
<div class="flex_item_dis">
<div
+ class="flex_item"
v-for="(item, index) in form.applicableTranslate"
:key="index"
>
- {{ item.factory }} - {{ item.workshop }} -
- {{ item.process }}
+ {{ item }}
+ <div v-if="item[0].factory">{{ item[0].factory }}</div>
+ <div v-if="item[2].workshop">-</div>
+ <div v-if="item[2].workshop">{{ item[2].workshop }}</div>
+ <div v-if="item[1].process">-</div>
+ <div v-if="item[1].process">{{ item[1].process }}</div>
</div>
</div>
</div>
@@ -413,7 +421,7 @@
<div class="grey_bg">
<div
class="flex_holidays_set"
- v-for="(item, index) in formHolidays"
+ v-for="(item, index) in formHolidays.holidays"
:key="index"
>
<div class="dis_error_wrap">
@@ -429,7 +437,9 @@
/>
</div>
</div>
- <div class="error_text">璇疯緭鍏ヨ妭鍋囨棩鎻忚堪</div>
+ <div class="error_text" v-if="item.describe == ''">
+ 璇疯緭鍏ヨ妭鍋囨棩鎻忚堪
+ </div>
</div>
<div class="dis_error_wrap">
<div class="flex_item">
@@ -449,7 +459,9 @@
</el-date-picker>
</div>
</div>
- <div class="error_text">璇疯緭鍏ュ紑濮嬫椂闂�</div>
+ <div class="error_text" v-if="item.startdate == ''">
+ 璇疯緭鍏ュ紑濮嬫椂闂�
+ </div>
</div>
<div class="dis_error_wrap">
<div class="flex_item">
@@ -469,7 +481,9 @@
</el-date-picker>
</div>
</div>
- <div class="error_text">璇疯緭鍏ョ粨鏉熸椂闂�</div>
+ <div class="error_text" v-if="item.enddate == ''">
+ 璇疯緭鍏ョ粨鏉熸椂闂�
+ </div>
</div>
<div class="dis_error_wrap">
<div class="flex_item">
@@ -495,7 +509,11 @@
<el-form-item
label="鑺傚亣鏃ユ弿杩�"
:prop="'holidays.' + index + '.describe'"
- :rules="{ required: true, message: '璇疯緭鍏ヨ妭鍋囨棩鎻忚堪', trigger: 'blur' }"
+ :rules="{
+ required: true,
+ message: '璇疯緭鍏ヨ妭鍋囨棩鎻忚堪',
+ trigger: 'blur',
+ }"
>
<el-input
style="width: 130px"
@@ -506,7 +524,11 @@
<el-form-item
label="寮�濮嬫椂闂�"
:prop="'holidays.' + index + '.startdate'"
- :rules="{ required: true, message: '璇疯緭鍏ュ紑濮嬫椂闂�', trigger: 'blur' }"
+ :rules="{
+ required: true,
+ message: '璇疯緭鍏ュ紑濮嬫椂闂�',
+ trigger: 'blur',
+ }"
>
<el-date-picker
style="width: 130px"
@@ -522,7 +544,11 @@
<el-form-item
label="缁撴潫鏃堕棿"
:prop="'holidays.' + index + '.enddate'"
- :rules="{ required: true, message: '璇疯緭鍏ョ粨鏉熸椂闂�', trigger: 'blur' }"
+ :rules="{
+ required: true,
+ message: '璇疯緭鍏ョ粨鏉熸椂闂�',
+ trigger: 'blur',
+ }"
>
<el-date-picker
style="width: 130px"
@@ -601,6 +627,7 @@
process: "",
},
],
+ applicableTranslate: [{ factory: "" }, { workshop: "" }, { process: "" }],
},
formHolidays: {
holidays: [
@@ -615,7 +642,7 @@
pageNum: 1,
pageSize: 10,
description: null,
- plant: null,
+ applicableFactory: null,
type: null,
effectiveDate: null,
expiringDate: null,
@@ -897,6 +924,10 @@
async function handleAdd() {
open.value = true;
form.value = {
+ type: "1",
+ description: "",
+ expiringDate: "",
+ effectiveDate: "",
applicable: [
{
factory: "",
@@ -904,7 +935,45 @@
process: "",
},
],
+ applicableTranslate: [{ factory: "" }, { workshop: "" }, { process: "" }],
};
+ weekDaysSettingList.value = [
+ {
+ day: "Monday",
+ chineseName: "鏄熸湡涓�",
+ work: "y",
+ },
+ {
+ day: "Tuesday",
+ chineseName: "鏄熸湡浜�",
+ work: "y",
+ },
+ {
+ day: "Wednesday",
+ chineseName: "鏄熸湡涓�",
+ work: "y",
+ },
+ {
+ day: "Thursday",
+ chineseName: "鏄熸湡鍥�",
+ work: "y",
+ },
+ {
+ day: "Friday",
+ chineseName: "鏄熸湡浜�",
+ work: "y",
+ },
+ {
+ day: "Saturday",
+ chineseName: "鏄熸湡鍏�",
+ work: "y",
+ },
+ {
+ day: "Sunday",
+ chineseName: "鏄熸湡鏃�",
+ work: "y",
+ },
+ ];
title.value = "娣诲姞鏃ュ巻绠$悊";
}
/** 閫夋嫨宸ュ巶鍚庝簨浠� 鍔犺浇杞﹂棿 鍜� 宸ュ簭 **/
@@ -919,7 +988,7 @@
}
function changeWorkshop(workShop) {
console.log(workShop.split(";")[0]);
- listByWorkShop({ workShop: "姘旀煖" }).then((res) => {
+ listByWorkShop({ workShop: workShop.split(";")[0] }).then((res) => {
console.log(res, "workShop");
processList.value = res.rows;
});
@@ -936,26 +1005,41 @@
/** 淇敼鎸夐挳鎿嶄綔 */
function handleUpdate(row) {
const _id = row.id || ids.value;
+ open.value = true;
+ title.value = "淇敼鏃ュ巻绠$悊";
getCalendar(_id).then((response) => {
form.value = response.data;
- // form.value.content = JSON.parse(response.data.content.value);
- if (form.value.type === "1") {
- weekDaysSettingList.value = JSON.parse(
- response.data.content.value
- ).weekdays;
- } else if (form.value.type === "2") {
- holidays.value = JSON.parse(response.data.content.value).holidays;
- }
-
- open.value = true;
- title.value = "淇敼鏃ュ巻绠$悊";
+ applicableSettingList.value = JSON.parse(response.data.applicableTranslate);
+ console.log(response.data, "response.data");
+ form.value.content = JSON.parse(response.data.content.value);
+ weekDaysSettingList.value = response.data.content.weekdays;
+ form.value.applicableTranslate= applicableTranslateArr(response.data);
+ console.log(form.value.applicableTranslate,"form.value.applicableTranslate")
});
+
}
+let applicableTranslateArr = (row)=>{
+ return JSON.parse(row.applicableTranslate).map(
+ (item) => {
+ return Object.keys(item).map((n) => {
+ console.log(item);
+ let arrObj = {};
+ if (item[n] && item[n].indexOf(";") > 0) {
+ arrObj[n] = item[n].split(";")[1];
+ } else {
+ arrObj[n] = item[n];
+ }
+ return arrObj;
+ });
+ }
+ );
+}
// 璁剧疆鑺傚亣鏃�
function handleSetHolidays(row) {
+ console.log(applicableTranslateArr, "applicableTranslateArr");
form.value = {
...row,
- applicableTranslate: JSON.parse(row.applicableTranslate),
+ applicableTranslate: applicableTranslateArr(row),
};
if (!row.holidays) {
formHolidays.value = {
@@ -970,7 +1054,7 @@
} else {
formHolidays.value.holidays = JSON.parse(row.holidays.value);
}
- console.log(formHolidays.value.holidays, "formHolidays.value");
+ // console.log(formHolidays.value.holidays, "formHolidays.value");
openSetHolidays.value = true;
}
// 绂佺敤鏃ユ湡
@@ -1029,39 +1113,74 @@
// }
// });
// };
+function checkFieldsEmpty(arr) {
+ let filteredArr = arr.filter((item) => {
+ return Object.values(item).some(
+ (value) => value == null || value == "" || value == undefined
+ );
+ });
+ return filteredArr;
+}
// 鎻愪氦鑺傚亣鏃�
function handleSaveHolidaysForm() {
- console.log(holidaysRef.value, "琛ㄥ崟dom");
+ const hasValidDates = checkFieldsEmpty(formHolidays.value.holidays);
+ console.log(hasValidDates, "hasValidDates");
+ if (hasValidDates.length == 0) {
+ updateCalendar({
+ id: form.value.id,
+ holidays: formHolidays.value.holidays.map((item) => {
+ return {
+ startdate: moment(item.startdate).format("YYYY-MM-DD"),
+ enddate: moment(item.enddate).format("YYYY-MM-DD"),
+ describe: item.describe,
+ };
+ }),
+ }).then((response) => {
+ proxy.$modal.msgSuccess("鏂板鎴愬姛");
+ openSetHolidays.value = false;
+ getList();
+ });
+ }
// holidaysRef.value.validate((valid) => {
- // console.log(valid,"valid")
- // if (valid) {
- // proxy.$modal.msgSuccess('submit!');
- // } else {
- // proxy.$modal.msgSuccess('Form is not valid.');
- // return false;
+ // if (!valid) {
+ // proxy.$modal.msgSuccess("蹇呭~椤逛笉鑳戒负绌�");
// }
- // })
- holidaysRef.value.validate((valid) => {
- if (!valid) {
- proxy.$modal.msgSuccess("蹇呭~椤逛笉鑳戒负绌�");
- }
- if (valid) {
- updateCalendar({
- id: form.value.id,
- holidays: formHolidays.value.holidays.map((item) => {
- return {
- startdate: moment(item.startdate).format("YYYY-MM-DD"),
- enddate: moment(item.enddate).format("YYYY-MM-DD"),
- describe: item.describe,
- };
- }),
- }).then((response) => {
- proxy.$modal.msgSuccess("鏂板鎴愬姛");
- open.value = false;
- getList();
- });
- }
- });
+ // if (valid) {
+ // if (!hasValidDates) {
+ // updateCalendar({
+ // id: form.value.id,
+ // holidays: formHolidays.value.holidays.map((item) => {
+ // return {
+ // startdate: moment(item.startdate).format("YYYY-MM-DD"),
+ // enddate: moment(item.enddate).format("YYYY-MM-DD"),
+ // describe: item.describe,
+ // };
+ // }),
+ // }).then((response) => {
+ // proxy.$modal.msgSuccess("鏂板鎴愬姛");
+ // open.value = false;
+ // getList();
+ // });
+ // }
+ // });
+ //if (valid) {
+ // if (!hasValidDates) {
+ // updateCalendar({
+ // id: form.value.id,
+ // holidays: formHolidays.value.holidays.map((item) => {
+ // return {
+ // startdate: moment(item.startdate).format("YYYY-MM-DD"),
+ // enddate: moment(item.enddate).format("YYYY-MM-DD"),
+ // describe: item.describe,
+ // };
+ // }),
+ // }).then((response) => {
+ // proxy.$modal.msgSuccess("鏂板鎴愬姛");
+ // open.value = false;
+ // getList();
+ // });
+ // }
+ // });
}
/** 鎻愪氦鎸夐挳 */
function submitForm() {
@@ -1075,33 +1194,44 @@
return;
}
if (form.value.id != null) {
- // if (form.value.type === "1") {
- // updateCalendar({
- // ...form.value,
- // content: {
- // weekdays: weekDaysSettingList.value,
- // },
- // applicableWorkshop: form.value.applicableWorkshop,
- // applicableProcess: form.value.applicableProcess,
- // }).then((response) => {
- // proxy.$modal.msgSuccess("淇敼鎴愬姛");
- // open.value = false;
- // getList();
- // });
- // } else if (form.value.type === "2") {
updateCalendar({
- ...form.value,
+ // ...form.value,
+ id: form.value.id,
+ expiringDate: form.value.expiringDate,
+ effectiveDate: form.value.effectiveDate,
+ description: form.value.description,
content: {
- holidays: holidays.value,
+ weekdays: weekDaysSettingList.value,
},
- applicableWorkshop: form.value.applicableWorkshop.map((item) => {
+ // holidays: holidays.value,
+ applicable: applicableSettingList.value.map((item) => {
return {
- factory: item.factory.split(";")[0],
- process: item.process.split(";")[0],
- workshop: item.workshop.split(";")[0],
+ factory: item.factory
+ ? item.factory.indexOf(";") > 0
+ ? item.factory.split(";")[0]
+ : item.factory
+ : "",
+ process: item.process
+ ? item.process.indexOf(";") > 0
+ ? item.process.split(";")[0]
+ : item.process
+ : "",
+ workshop: item.workshop
+ ? item.workshop.indexOf(";") > 0
+ ? item.workshop.split(";")[0]
+ : item.workshop
+ : "",
};
}),
- applicableProcess: form.value.applicableProcess,
+ applicableTranslate: JSON.stringify(
+ applicableSettingList.value.map((item) => {
+ return {
+ factory: item.factory ? item.factory : "",
+ process: item.process ? item.process : "",
+ workshop: item.workshop ? item.workshop : "",
+ };
+ })
+ ),
type: "1",
}).then((response) => {
proxy.$modal.msgSuccess("淇敼鎴愬姛");
@@ -1110,18 +1240,6 @@
});
// }
} else {
- // if (form.value.type === "1") {
- // addCalendar({
- // ...form.value,
- // content: {
- // weekdays: weekDaysSettingList.value,
- // },
- // }).then((response) => {
- // proxy.$modal.msgSuccess("鏂板鎴愬姛");
- // open.value = false;
- // getList();
- // });
- // } else if (form.value.type === "2") {
addCalendar({
...form.value,
content: {
@@ -1130,17 +1248,29 @@
// holidays: holidays.value,
applicable: applicableSettingList.value.map((item) => {
return {
- factory: item.factory.split(";")[0],
- process: item.process.split(";")[0],
- workshop: item.workshop.split(";")[0],
+ factory: item.factory
+ ? item.factory.indexOf(";") > 0
+ ? item.factory.split(";")[0]
+ : item.factory
+ : "",
+ process: item.process
+ ? item.process.indexOf(";") > 0
+ ? item.process.split(";")[0]
+ : item.process
+ : "",
+ workshop: item.workshop
+ ? item.workshop.indexOf(";") > 0
+ ? item.workshop.split(";")[0]
+ : item.workshop
+ : "",
};
}),
applicableTranslate: JSON.stringify(
applicableSettingList.value.map((item) => {
return {
- factory: item.factory.split(";")[1],
- process: item.process.split(";")[1],
- workshop: item.workshop.split(";")[1],
+ factory: item.factory ? item.factory : "",
+ process: item.process ? item.process : "",
+ workshop: item.workshop ? item.workshop : "",
};
})
),
@@ -1305,6 +1435,10 @@
margin-left: 120px;
}
}
+.error_require {
+ color: #f56c6c;
+ margin-right: 5px;
+}
.grey_bg {
background: #f1f1f1;
width: 100%;
@@ -1327,10 +1461,6 @@
font-weight: 600;
margin-left: 20px;
margin-right: 10px;
- .error_require {
- color: #f56c6c;
- margin-right: 5px;
- }
}
.flex_item_dis {
display: flex;
--
Gitblit v1.9.3