瀏覽代碼

feat: 日报联调

sunxiao 11 月之前
父節點
當前提交
21415a84b6
共有 5 個文件被更改,包括 86 次插入69 次删除
  1. 1 1
      .env.production
  2. 1 1
      src/router/index.js
  3. 2 1
      src/utils/request.js
  4. 26 23
      src/views/daily/config.js
  5. 56 43
      src/views/daily/index.vue

+ 1 - 1
.env.production

@@ -5,7 +5,7 @@ VITE_APP_TITLE = 人工智能运营体决策助手
 VITE_APP_ENV = 'production'
 
 # 管理系统/生产环境
-VITE_APP_BASE_API = '/prod-api'
+VITE_APP_BASE_API = 'http://10.0.0.28:8080/'
 
 # 是否在打包时开启压缩,支持 gzip 和 brotli
 VITE_BUILD_COMPRESS = gzip

+ 1 - 1
src/router/index.js

@@ -1,4 +1,4 @@
-import { createWebHistory, createRouter } from 'vue-router'
+import { createWebHistory, createWebHashHistory,createRouter } from 'vue-router'
 /* Layout */
 import Layout from '@/layout'
 

+ 2 - 1
src/utils/request.js

@@ -15,7 +15,8 @@ axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
 // 创建axios实例
 const service = axios.create({
   // axios中请求配置有baseURL选项,表示请求URL公共部分
-  baseURL: import.meta.env.VITE_APP_BASE_API,
+  // baseURL: import.meta.env.VITE_APP_BASE_API,
+  url: import.meta.env.VITE_APP_BASE_API,
   // 超时
   timeout: 10000
 })

+ 26 - 23
src/views/daily/config.js

@@ -1,4 +1,3 @@
-
 export const schema = {
   js: {
     title: '进水指标',
@@ -204,17 +203,17 @@ export const schema = {
     default: {
       list: [
         {
-          key: 'jsl',
+          key: 'JSL',
           label: '进水量',
           unit: '(m³/d)'
         },
         {
-          key: 'csl',
+          key: 'CSL',
           label: '出水量',
           unit: '(m³/d)'
         },
         {
-          key: 'sdclcxsl',
+          key: 'SDCLCXSL',
           label: '深度处理冲洗水量',
           unit: '(m³/d)'
         },
@@ -226,12 +225,12 @@ export const schema = {
     default: {
       list: [
         {
-          key: 'qsb',
+          key: 'QSB',
           label: '气水比',
           unit: '(m³/m³)'
         },
         {
-          key: 'fm',
+          key: 'fM',
           label: 'F/M',
           unit: '(kgBOD/kgMLSS·d)'
         },
@@ -269,84 +268,88 @@ export const schema = {
           unit: '(%)'
         },
         {
-          key: 'srt',
+          key: 'SRT',
           label: '污泥龄',
           unit: '(天)'
         },
         {
-          key: 'cnl',
+          key: 'CNL',
           label: '产泥率',
           unit: '(T/万吨)'
         },
         {
-          key: 'chuniliang',
+          key: 'CHUNILIANG',
           label: '出泥量',
           unit: '(m³)'
         },
         {
-          key: 'cnhsl',
+          key: 'CNHSL',
           label: '出泥含水率',
           unit: '(%)'
         },
         {
-          key: 'gwnl',
+          key: 'GWNL',
           label: '干污泥量',
           unit: '(m³)'
         }
       ]
     }
   },
-  
-  cs: {
+  cb: {
     title: '成本指标',
     default: {
       list: [
         {
-          key: 'c',
+          key: 'DF',
           label: '电费',
           unit: '元'
         },
         {
-          key: 'c',
+          key: 'XNJF',
           label: '絮凝剂费',
           unit: '元'
         },
         {
-          key: 'c',
+          key: 'CLF',
+          label: '除磷费',
+          unit: '元'
+        },
+        {
+          key: 'TYF',
           label: '碳源费',
           unit: '元'
         },
         {
-          key: 'c',
+          key: 'XDJF',
           label: '消毒剂费',
           unit: '元'
         },
         {
-          key: 'c',
+          key: 'QTYJF',
           label: '其他药剂费',
           unit: '元'
         },
         {
-          key: 'c',
+          key: 'CNF',
           label: '采暖费',
           unit: '元'
         },
         {
-          key: 'c',
+          key: 'ZLSF',
           label: '自来水费',
           unit: '元'
         },
         {
-          key: 'c',
+          key: 'ZJCB',
           label: '直接成本',
           unit: '元/天'
         },
         {
-          key: 'c',
+          key: 'DWCB',
           label: '单位成本',
           unit: '元/千吨'
         }
       ]
     }
-  },
+  }
 }

+ 56 - 43
src/views/daily/index.vue

@@ -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 {