浏览代码

优化事件管理

yangyuxuan 1 月之前
父节点
当前提交
23abbea491

+ 32 - 14
src/views/dataFilling/fillingAdd.vue

@@ -15,7 +15,7 @@
         <el-button type="primary" @click="handleNewTemplate">重新加载</el-button>
       </el-col>
       <el-col :span="1.5">
-        <el-button type="primary" @click="handleSaveTemporarily(1)">暂存</el-button>
+        <el-button type="primary" @click="handleSaveTemporarily(formRef, 1)">暂存</el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button type="primary" @click="handleSave(formRef,2)"> 发布 </el-button>
@@ -176,21 +176,39 @@ const rules = {
   ],
   user_ids: [{ required: true, message: '请选择填报人', trigger: 'blur' }],
 }
-const handleSaveTemporarily = async (statuCode) => {
-  if (hotData.value && hotData.value[0] && hotData.value[0].length > 0) {
-    const data2 = [];
-    hotData.value[0].forEach((item) => {
-      if (!!item) {
-        data2.push(item);
+const handleSaveTemporarily = async (formEl,statuCode) => {
+  if (!formEl) return;
+  await formEl.validate((valid, fields) => {
+    if (valid) {
+      if (hotData.value && hotData.value[0] && hotData.value[0].length > 0) {
+        const data2 = [];
+        hotData.value[0].forEach((item) => {
+          if (!!item) {
+            data2.push(item);
+          }
+        })
+        form.value.field_names = data2;
       }
-    })
-    form.value.field_names = data2;
-  }
 
-  form.value.issued_status = statuCode;
-  fillingAdd(form.value).then(() => {
-    proxy.$modal.msgSuccess('暂存成功');
-    emits('close');
+      form.value.issued_status = statuCode;
+      fillingAdd(form.value).then(() => {
+        proxy.$modal.msgSuccess('暂存成功');
+        emits('close');
+      });
+    } else {
+      nextTick(() => {
+        let isError = document.getElementsByClassName('is-error');
+        isError[0].scrollIntoView({
+          // 滚动到指定节点
+          // 值有start,center,end,nearest,当前显示在视图区域中间
+          block: 'center',
+          // 值有auto、instant,smooth,缓动动画(当前是慢速的)
+          behavior: 'smooth'
+        });
+      });
+      proxy.$modal.msgError('表单校验失败');
+      return false;
+    }
   });
 };
 

+ 0 - 11
src/views/dataFilling/fillingIssued.vue

@@ -1,14 +1,3 @@
-<!--<script setup lang="ts">-->
-
-<!--</script>-->
-
-<!--<template>-->
-
-<!--</template>-->
-
-<!--<style scoped lang="scss">-->
-
-<!--</style>-->
 <template>
   <div class="app-container p-2">
     <el-row :gutter="20" class="mb8" style="margin-top: 5px">

+ 84 - 43
src/views/dataFilling/tableDetails.vue

@@ -15,13 +15,13 @@
 <!--          <el-button v-if="is_filling_ended === 0" type="primary" @click="handleReport()">智能识别</el-button>-->
 <!--        </el-col>-->
         <el-col :span="1.5">
-          <el-button v-if="is_filling_ended === 0" type="primary" @click="handleSaveTemporarily(1)">暂存</el-button>
-        </el-col>
-        <el-col :span="1.5">
-          <el-button v-if="reportInfo.issued_status === 2" type="primary" @click="handleData()">数据</el-button>
+          <el-button v-if="is_filling_ended === 0" type="primary" @click="handleSaveTemporarily(formRef,1)">暂存</el-button>
         </el-col>
+<!--        <el-col :span="1.5">-->
+<!--          <el-button v-if="reportInfo.issued_status === 2" type="primary" @click="handleData()">数据</el-button>-->
+<!--        </el-col>-->
         <el-col :span="1.5">
-          <el-button v-if="is_filling_ended === 0" type="primary" @click="handleSave(2)">发布</el-button>
+          <el-button v-if="is_filling_ended === 0" type="primary" @click="handleSave(formRef, 2)">发布</el-button>
         </el-col>
         <el-col :span="1.5">
           <el-button type="danger" @click="handleReturn()">返回</el-button>
@@ -98,9 +98,11 @@ import informantSelect from './informantSelect.vue';
 import { deepClone } from '@/utils';
 import { ElButton, ElCol, ElDatePicker, ElFormItem, ElInput, ElRow } from 'element-plus';
 import { validatePhone } from '@/utils/validate';
+import { ref } from 'vue';
 
 const { proxy } = getCurrentInstance();
 const isShowSelect = ref(false);
+const formRef = ref('');
 let treeData = ref([]);
 const emits = defineEmits(['close']);
 const reportInfo = ref({
@@ -327,51 +329,90 @@ const handleReload = () => {
   alert('表格已清空');
 };
 
-const handleSaveTemporarily = async (statuCode) => {
-  if (hotData.value && hotData.value[0] && hotData.value[0].length > 0) {
-    const data2 = [];
-    hotData.value[0].forEach((item) => {
-      if (!!item) {
-        data2.push(item);
+const handleSaveTemporarily = async (formEl,statuCode) => {
+  if (!formEl) return;
+  await formEl.validate((valid, fields) => {
+    if (valid) {
+      if (hotData.value && hotData.value[0] && hotData.value[0].length > 0) {
+        const data2 = [];
+        hotData.value[0].forEach((item) => {
+          if (!!item) {
+            data2.push(item);
+          }
+        })
+        reportInfo.value.field_names = tableData.value;
       }
-    })
-    reportInfo.value.field_names = tableData.value;
-  }
 
-  reportInfo.value.issued_status = statuCode;
-  const tempHead = reportInfo.value.field_names.flatMap(obj =>
-    Object.values(obj).filter(value => typeof value === "string")
-  );
-  let data = {
-    table_name: reportInfo.value.table_name,
-    status: reportInfo.value.issued_status,
-    period_type: reportInfo.value.period_type,
-    end_time: reportInfo.value.end_time,
-    new_fields: tempHead
-  }
-  fillingChange(reportId.value, data).then(() => {
-    proxy.$modal.msgSuccess('暂存成功');
-    emits('close');
+      reportInfo.value.issued_status = statuCode;
+      const tempHead = reportInfo.value.field_names.flatMap(obj =>
+        Object.values(obj).filter(value => typeof value === "string")
+      );
+      let data = {
+        creator_name: reportInfo.value.creator_name,
+        creator_phone: reportInfo.value.creator_phone,
+        table_name: reportInfo.value.table_name,
+        status: reportInfo.value.issued_status,
+        period_type: reportInfo.value.period_type,
+        end_time: reportInfo.value.end_time,
+        new_fields: tempHead,
+        user_ids: reportInfo.value.user_ids
+      }
+      fillingChange(reportId.value, data).then(() => {
+        proxy.$modal.msgSuccess('暂存成功');
+        emits('close');
+      });
+    } else {
+      nextTick(() => {
+        let isError = document.getElementsByClassName('is-error');
+        isError[0].scrollIntoView({
+          // 滚动到指定节点
+          // 值有start,center,end,nearest,当前显示在视图区域中间
+          block: 'center',
+          // 值有auto、instant,smooth,缓动动画(当前是慢速的)
+          behavior: 'smooth'
+        });
+      });
+      proxy.$modal.msgError('表单校验失败');
+      return false;
+    }
   });
 };
 
 const handleReport = () => console.log('上报');
 
-const handleSave = async (statuCode) => {
-  reportInfo.value.issued_status = statuCode;
-  const tempHead = reportInfo.value.field_names.flatMap(obj =>
-    Object.values(obj).filter(value => typeof value === "string")
-  );
-  let data = {
-    table_name: reportInfo.value.table_name,
-    status: reportInfo.value.issued_status,
-    period_type: reportInfo.value.period_type,
-    end_time: reportInfo.value.end_time,
-    new_fields: tempHead
-  }
-  fillingChange(reportId.value, data).then(() => {
-    proxy.$modal.msgSuccess('发布成功');
-    emits('close');
+const handleSave = async (formEl, statuCode) => {
+  if (!formEl) return;
+  await formEl.validate((valid, fields) => {
+    if (valid) {
+      reportInfo.value.issued_status = statuCode;
+      const tempHead = reportInfo.value.field_names.flatMap(obj =>
+        Object.values(obj).filter(value => typeof value === "string")
+      );
+      let data = {
+        table_name: reportInfo.value.table_name,
+        status: reportInfo.value.issued_status,
+        period_type: reportInfo.value.period_type,
+        end_time: reportInfo.value.end_time,
+        new_fields: tempHead
+      }
+      fillingChange(reportId.value, data).then(() => {
+        proxy.$modal.msgSuccess('发布成功');
+        emits('close');
+      });
+    } else {
+      nextTick(() => {
+        let isError = document.getElementsByClassName('is-error');
+        isError[0].scrollIntoView({
+          // 滚动到指定节点
+          // 值有start,center,end,nearest,当前显示在视图区域中间
+          block: 'center',
+          // 值有auto、instant,smooth,缓动动画(当前是慢速的)
+          behavior: 'smooth'
+        });
+      });
+      proxy.$modal.msgError('表单校验失败');
+      return false;
+    }
   });
 };
 

+ 6 - 2
src/views/duty/eventing/CloseEventDialog.vue

@@ -50,7 +50,7 @@
         </el-col>
         <el-col :span="24">
           <el-form-item label="总结报告:" prop="fileNames">
-            <FileUpload v-model="form.fileNames" buttonText="上传报告" :file-type="['pdf']" />
+            <FileUpload v-model="form.fileNames" buttonText="上传报告" :file-type="['pdf','doc','docx','xlsx','xls']" />
           </el-form-item>
         </el-col>
       </el-row>
@@ -67,6 +67,7 @@
 <script lang="ts" setup>
 import { closeEvent } from '@/api/duty/eventing';
 import { ref, computed } from 'vue';
+import BigNumber from 'bignumber.js';
 
 interface Form {
   eventId: string;
@@ -133,7 +134,10 @@ const eventList = ref([
 
 // 计算合计的方法
 const calculateTotal = (prop: string) => {
-  return eventList.value.reduce((sum, item) => sum + (item[prop] || 0), 0);
+  return eventList.value.reduce((sum, item) => {
+    const currentValue = new BigNumber(item[prop] || 0);
+    return sum.plus(currentValue);
+  }, new BigNumber(0)).toNumber();
 };
 
 const props = withDefaults(defineProps<Props>(), {

+ 76 - 2
src/views/duty/eventing/eventDetails.vue

@@ -85,7 +85,22 @@
         <el-table-column label="失踪人数(人)" align="center" prop="data3" />
         <el-table-column label="死亡人数(人)" align="center" prop="data4" />
         <el-table-column label="紧急转移(人)" align="center" prop="data5" />
-        <el-table-column label="直接经济损失(万元)" align="center" prop="data6" />
+        <el-table-column label="直接经济损失(万元)" align="center">
+          <template #default="{ row }">
+            {{ new BigNumber(row.data6 || 0).toFormat() }}
+          </template>
+        </el-table-column>
+
+        <template #append>
+          <tr class="summary-row">
+            <td>合计</td>
+            <td>{{ new BigNumber(calculateTotal('data2')).toFormat() }}</td>
+            <td>{{ new BigNumber(calculateTotal('data3')).toFormat() }}</td>
+            <td>{{ new BigNumber(calculateTotal('data4')).toFormat() }}</td>
+            <td>{{ new BigNumber(calculateTotal('data5')).toFormat() }}</td>
+            <td>{{ new BigNumber(calculateTotal('data6')).toFormat() }}</td>
+          </tr>
+        </template>
       </el-table>
     </div>
     <div class="common-info-box">
@@ -175,6 +190,7 @@ import EditCasualtiesDialog from './EditCasualtiesDialog.vue';
 import { download2 } from '@/utils/request';
 import PdfViewer from '@/views/knowledge/HiddenStandards/PdfViewer.vue';
 import { ref } from 'vue';
+import BigNumber from 'bignumber.js';
 
 const props = defineProps({
   eventId: String
@@ -201,7 +217,47 @@ const eventList = ref([
     data4: 0,
     data5: 0,
     data6: 0
-  }
+  },
+  {
+    data1: "茂南区",
+    data2: 0,
+    data3: 0,
+    data4: 0,
+    data5: 0,
+    data6: 100
+  },
+  {
+    data1: "电白区",
+    data2: 1,
+    data3: 0,
+    data4: 0,
+    data5: 0,
+    data6: 0
+  },
+  {
+    data1: "化州市",
+    data2: 0,
+    data3: 2,
+    data4: 0,
+    data5: 0,
+    data6: 0
+  },
+  {
+    data1: "高州市",
+    data2: 0,
+    data3: 0,
+    data4: 3,
+    data5: 0,
+    data6: 0
+  },
+  {
+    data1: "信宜市",
+    data2: 0,
+    data3: 0,
+    data4: 0,
+    data5: 4,
+    data6: 5
+  },
 ])
 
 const handleEventLevelOpen = () => {
@@ -211,6 +267,14 @@ const handleEventLevelClose = () => {
   eventLevelState.show = false;
 };
 
+// 计算合计的方法
+const calculateTotal = (prop: string) => {
+  return eventList.value.reduce((sum, item) => {
+    const currentValue = new BigNumber(item[prop] || 0)
+    return sum.plus(currentValue)
+  }, new BigNumber(0)).toFormat()
+}
+
 // 下载总结报告
 let summaryFiles = ref([]);
 let planFiles = ref([]);
@@ -465,4 +529,14 @@ onMounted(() => {
     border-radius: 5px;
   }
 }
+.summary-row {
+  font-weight: bold;
+
+  td {
+    text-align: center;
+    padding: 18px 10px;
+    width: 220px;
+    word-break: break-all;
+  }
+}
 </style>