Explorar el Código

运行记录填报

yuanchao hace 3 meses
padre
commit
2561dcd450
Se han modificado 2 ficheros con 39 adiciones y 33 borrados
  1. 1 1
      src/views/pms/iotopeationfill/index.vue
  2. 38 32
      src/views/pms/iotopeationfill/index1.vue

+ 1 - 1
src/views/pms/iotopeationfill/index.vue

@@ -119,7 +119,7 @@
             <el-button
               link
               type="primary"
-              @click="openWrite(scope.row.deptId+','+scope.row.userId+','+scope.row.createTime)"
+              @click="openWrite(scope.row.deptId+','+scope.row.userId+','+scope.row.createTime+','+scope.row.id)"
               v-hasPermi="['rq:iot-opeation-fill:update']"
             >
               填写

+ 38 - 32
src/views/pms/iotopeationfill/index1.vue

@@ -30,21 +30,21 @@
               </el-form>
             </div>
             <div v-for="(item,index) in attrList" :key="index">
-                <el-form-item :label='item.name' prop="deviceId" v-if="item.name==='当日运转时间'" >
+                <el-form-item :label='item.name' prop="deviceId"  >
                   <el-input
+                    v-if="item.isCollection===1"
                     v-model="item.fillContent" @input="attrList[index].fillContent = $event.target.fillContent"
                     clearable
                     style="width: 200px"
                     disabled
                   />
+                  <el-input
+                    v-else
+                    v-model="item.fillContent" @input="attrList[index].fillContent = $event.target.fillContent"
+                    clearable
+                    style="width: 200px"
+                  />
                 </el-form-item>
-              <el-form-item :label='item.name' prop="deviceId" v-else>
-                <el-input
-                  v-model="item.fillContent" @input="attrList[index].fillContent = $event.target.fillContent"
-                  clearable
-                  style="width: 200px"
-                />
-              </el-form-item>
             </div>
             <el-form-item>
               <el-button type="info" @click="deleteFillInfo">取消</el-button>
@@ -52,9 +52,6 @@
             </el-form-item>
           </el-form>
         </div>
-
-
-
       </el-tab-pane>
     </el-tabs>
   </ContentWrap>
@@ -68,8 +65,9 @@ import { IotOpeationFillApi, IotOpeationFillVO } from '@/api/pms/iotopeationfill
 import IotOpeationFillForm from './IotOpeationFillForm.vue'
 import Vue from "@vitejs/plugin-vue";
 import {useUserStore} from "@/store/modules/user";
-
-
+import { ElMessage } from 'element-plus'
+import moment from 'moment';
+import { format } from 'date-fns';
 /** 运行记录填报 列表 */
 defineOptions({ name: 'IotOpeationFill' })
 
@@ -119,28 +117,33 @@ const getList = async () => {
   try {
     queryParams.deptId = deptId.split(",")[0];
     queryParams.userId = deptId.split(",")[1];
-    queryParams.createTime = formatTimestamp(JSON.parse(deptId.split(",")[2]));
+    queryParams.createTime = formatTimestamp(JSON.parse(deptId.split(",")[2].substring(0,10)));
     const data = await IotOpeationFillApi.getIotOpeationFillPage(queryParams)
-    list.value = data;
-    list.value.forEach(function (item, index) {
-      arry1.value[index] = item;
-    });
-    queryParams.deviceCategoryId = arry1.value[0].deviceCategoryId
-    queryParams.deptId = arry1.value[0].deptId;
-    queryParams.deviceCode = arry1.value[0].deviceCode;
-    queryParams.deviceName = arry1.value[0].deviceName;
-    queryParams.deviceId = arry1.value[0].deviceId;
-    getAttrList();
+    if(data.length===0){
+      ElMessage({
+        message: '改用户负责设备状态为非施工或待命,请调整',
+        type: 'warning',
+      })
+    }else{
+      list.value = data;
+      list.value.forEach(function (item, index) {
+        arry1.value[index] = item;
+      });
+      queryParams.deviceCategoryId = arry1.value[0].deviceCategoryId
+      queryParams.deptId = arry1.value[0].deptId;
+      queryParams.deviceCode = arry1.value[0].deviceCode;
+      queryParams.deviceName = arry1.value[0].deviceName;
+      queryParams.deviceId = arry1.value[0].deviceId;
+      getAttrList();
+    }
   } finally {
     loading.value = false
   }
 }
 function formatTimestamp(timestamp) {
-  const date = new Date(timestamp);
-  const year = date.getFullYear();
-  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份是从0开始的
-  const day = String(date.getDate()).padStart(2, '0');
-  return `${year}-${month}-${day}`;
+  const date = new Date(timestamp*1000);
+  return moment.unix(timestamp).format('YYYY-MM-DD');
+
 }
 
 /** 搜索按钮操作 */
@@ -178,14 +181,16 @@ const getAttrList = async () => {
   loading.value = true
   try {
     totalRunTime1 = 0;
+    queryParams.createTime = formatTimestamp(JSON.parse(deptId.split(",")[2].substring(0,10)));
     const data = await IotOpeationFillApi.getAttrs(queryParams)
     attrList.value = data;
     //totalRunTime1 = Number(attrList.value[0].totalRunTime).toFixed(2)
     attrList.value.forEach(function (item,index){
+
       if(item.name==='累计运行时间'){
         item.name = '当日运转时间'
-        totalRunTime1 = Number(item.totalRunTime).toFixed(2)
       }
+      totalRunTime1 = Number(item.totalRunTime).toFixed(2)
       item.fillContent = Number(item.fillContent).toFixed(2)
       item.deviceCode = queryParams.deviceCode;
       item.deptId = queryParams.deptId;
@@ -200,13 +205,14 @@ const getAttrList = async () => {
 /** 获取填写信息保存到后台*/
 const getFillInfo = async () => {
   try {
+    alert(deptId)
     attrList.value.forEach(function (item,index){
       item.pointName = item.name;
-      item.createTime = formatTimestamp(JSON.parse(deptId.split(",")[2]));
+      item.createTime = formatTimestamp(JSON.parse(deptId.split(",")[2].substring(0,10)));
       item.userId = deptId.split(",")[1];
+      item.id = deptId.split(",")[3];
     })
     const data = attrList.value as unknown as IotOpeationFillVO
-
     await IotOpeationFillApi.insertLog(data)
     message.success(t('common.createSuccess'))
     // 发送操作成功的事件