|
@@ -6,49 +6,63 @@ const { proxy } = getCurrentInstance();
|
|
|
|
|
|
const isVisible = ref(false);
|
|
|
const testDate = ref(null);
|
|
|
-
|
|
|
const formData = ref({});
|
|
|
+const holidays = ref([]);
|
|
|
+const formRefDom = ref(null);
|
|
|
|
|
|
-const holidays = ref([])
|
|
|
-
|
|
|
-const isHoliday = ({ dayjs }) => {
|
|
|
- return holidays.value.find(({ testDate }) => dayjs.format('YYYY/MM/DD') === testDate)?.exists;
|
|
|
-};
|
|
|
+const isHoliday = ({ dayjs }) => holidays.value.find(({ testDate }) => dayjs.format('YYYY/MM/DD') === testDate)?.exists;
|
|
|
|
|
|
const isExistData = computed(() => Object.keys(unref(formData)).length);
|
|
|
|
|
|
+const rules = computed(() => {
|
|
|
+ let arr = [];
|
|
|
+ let rule = {};
|
|
|
+ Object.keys(schema).map(key => {
|
|
|
+ const parentItem = schema[key];
|
|
|
+ Object.keys(parentItem).map(k => {
|
|
|
+ if (parentItem[k]?.list) {
|
|
|
+ arr = [...arr, ...parentItem[k].list]
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
|
|
|
+ arr.forEach(item => {
|
|
|
+ rule[item.key] = [{ required: true, message: item.label + '必须填写', trigger: 'blur' }];
|
|
|
+ });
|
|
|
+
|
|
|
+ return rule;
|
|
|
+})
|
|
|
+
|
|
|
+// 查询近30日的填写记录
|
|
|
const queryRecent = async () => {
|
|
|
-
|
|
|
const { data } = await getRecentMsg();
|
|
|
-
|
|
|
holidays.value = data;
|
|
|
}
|
|
|
|
|
|
// btn - 提交数据
|
|
|
-const onSubmit = () => {
|
|
|
+const onSubmit = async () => {
|
|
|
|
|
|
- if (!isExistData.value) {
|
|
|
- return proxy.$modal.msgError("请填写日报内容,在进行提交");
|
|
|
- }
|
|
|
+ formRefDom.value.validate((valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ proxy.$modal.confirm('是否确认提交?').then(async () => {
|
|
|
|
|
|
- proxy.$modal.confirm('是否确认提交?').then(async () => {
|
|
|
+ const dateTime = holidays.value.find(({ testDate: day }) => day === unref(testDate));
|
|
|
|
|
|
- const dateTime = holidays.value.find(({ testDate: day }) => day === unref(testDate));
|
|
|
+ await postDaily({
|
|
|
+ id: dateTime?.id,
|
|
|
+ testDate: unref(testDate),
|
|
|
+ ...unref(formData)
|
|
|
+ });
|
|
|
|
|
|
- await postDaily({
|
|
|
- id: dateTime?.id,
|
|
|
- testDate: unref(testDate),
|
|
|
- ...unref(formData)
|
|
|
- });
|
|
|
+ queryRecent();
|
|
|
|
|
|
- queryRecent();
|
|
|
-
|
|
|
- proxy.$modal.msgSuccess("提交成功");
|
|
|
+ proxy.$modal.msgSuccess("提交成功");
|
|
|
|
|
|
- isVisible.value = !isVisible.value;
|
|
|
+ isVisible.value = false;
|
|
|
|
|
|
- testDate.value = null;
|
|
|
+ testDate.value = null;
|
|
|
+ }).catch(() => { });
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -58,7 +72,7 @@ const handleNextStep = async () => {
|
|
|
return proxy.$modal.msgError("请先选择需要填写日报日期");
|
|
|
}
|
|
|
|
|
|
- const { data = {} } = await getDetailByDay({ testDate: unref(testDate) })
|
|
|
+ const { data = {} } = await getDetailByDay({ testDate: unref(testDate) });
|
|
|
|
|
|
formData.value = data;
|
|
|
|
|
@@ -69,10 +83,12 @@ const handleNextStep = async () => {
|
|
|
const onBackStep = async () => {
|
|
|
if (isExistData.value) {
|
|
|
return proxy.$modal.confirm('测到当前日报已填写,是否返回上一步?').then(function () {
|
|
|
- isVisible.value = false
|
|
|
- }).catch(() => {});
|
|
|
+ isVisible.value = false;
|
|
|
+ formRefDom.value.resetFields();
|
|
|
+ }).catch(() => { });
|
|
|
}
|
|
|
|
|
|
+ formRefDom.value.resetFields();
|
|
|
isVisible.value = false;
|
|
|
}
|
|
|
|
|
@@ -83,8 +99,8 @@ onMounted(async () => {
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <div class="app-container">
|
|
|
- <el-card shadow="never" header="选择日报填写日期" class="pre-form" v-show="!isVisible">
|
|
|
+ <div class="app-container daily-container">
|
|
|
+ <el-card shadow="never" header="选择日报填写日期" class="pre-form" v-show="!isVisible">
|
|
|
<el-form :inline="true">
|
|
|
<div class="pre-form_inner">
|
|
|
<el-form-item label="水厂名称">
|
|
@@ -98,9 +114,10 @@ onMounted(async () => {
|
|
|
<template #default="cell">
|
|
|
<div class="cell" :class="{ current: cell.isCurrent }">
|
|
|
<span class="text">{{ cell.text }}</span>
|
|
|
- <el-tooltip :content="isHoliday(cell) ? '已填写' : '未填写'" placement="top" v-if="isHoliday(cell) !== undefined">
|
|
|
- <span :class="isHoliday(cell) ? 'blue' : 'holiday'" />
|
|
|
- </el-tooltip>
|
|
|
+ <el-tooltip :content="isHoliday(cell) ? '已填写' : '未填写'" placement="top"
|
|
|
+ v-if="isHoliday(cell) !== undefined">
|
|
|
+ <span :class="isHoliday(cell) ? 'blue' : 'holiday'" />
|
|
|
+ </el-tooltip>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-date-picker>
|
|
@@ -113,21 +130,21 @@ onMounted(async () => {
|
|
|
</el-card>
|
|
|
|
|
|
<div v-show="isVisible">
|
|
|
- <el-card class="card" shadow="never" :header="obj.title" :key="key" v-for="obj, key in schema">
|
|
|
- <el-form label-position="top" label-suffix=":">
|
|
|
+ <el-form label-position="top" label-suffix=":" ref="formRefDom" :model="formData" :rules="rules">
|
|
|
+ <el-card class="card" shadow="never" :header="obj.title" :key="key" v-for="obj, key in schema">
|
|
|
<div v-for="val, k in obj" :key="key + k">
|
|
|
<el-divider content-position="left" v-show="val.title">{{ val.title }}</el-divider>
|
|
|
<el-row :gutter="100">
|
|
|
<el-col :span="8" v-for="item in val.list" :key="item.key">
|
|
|
- <el-form-item :label-width="150" :label="item.label">
|
|
|
- <el-input-number v-model="formData[item.key]" :controls="false" />
|
|
|
+ <el-form-item :label-width="150" :label="item.label" :prop="item.key">
|
|
|
+ <el-input-number v-model.trim="formData[item.key]" :controls="false" />
|
|
|
<span style="padding-left: 10px; color: #999; font-size: 12px;">{{ item.unit }}</span>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
- </el-form>
|
|
|
- </el-card>
|
|
|
+ </el-card>
|
|
|
+ </el-form>
|
|
|
<div class="btn-group">
|
|
|
<el-button @click="onBackStep">上一步</el-button>
|
|
|
<el-button type="primary" @click="onSubmit">提交</el-button>
|
|
@@ -138,17 +155,14 @@ onMounted(async () => {
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
.daily-container {
|
|
|
- // height: calc(100vh - 84px);
|
|
|
padding: 20px;
|
|
|
- // background: #fafbfa;
|
|
|
|
|
|
- .card:not(:last-child) {
|
|
|
+ .card {
|
|
|
margin-bottom: 20px;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.pre-form {
|
|
|
- margin-bottom: 20px;
|
|
|
|
|
|
&_inner,
|
|
|
.next-btn {
|
|
@@ -162,7 +176,6 @@ onMounted(async () => {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
- padding-top: 20px;
|
|
|
}
|
|
|
|
|
|
.cell {
|