2 Commits b79cf63124 ... 31ba1e1e19

Autor SHA1 Mensaje Fecha
  yuanchao 31ba1e1e19 Merge remote-tracking branch 'origin/master' hace 1 semana
  yuanchao b12365bb7e 运行记录优化 hace 1 semana

+ 1 - 1
.env

@@ -2,7 +2,7 @@
 VITE_APP_TITLE=DeepOil
 
 # 项目本地运行端口号
-VITE_PORT=80
+VITE_PORT=8080
 
 # open 运行 npm run dev 时自动打开浏览器
 VITE_OPEN=true

+ 4 - 2
src/api/pms/iotopeationfill/index.ts

@@ -19,7 +19,8 @@ export interface IotOpeationFillVO {
   creDate: Date // 填写日期
   name:string
   type:string
-  modelAttr:string
+  modelAttr:string,
+  modelId:number,
   isFill:number,
   fillContent:string
   pointCode:string
@@ -29,7 +30,8 @@ export interface IotOpeationFillVO {
   orderStatus:number
   createTime:Date
   totalRunTime:number
-  userId:number
+  userId:number,
+  isSum:number,
 }
 
 // 运行记录填报 API

+ 4 - 1
src/locales/en.ts

@@ -511,7 +511,10 @@ export default {
     confirm:'Confirm',
     cancel:'Cancel',
     alert:'The following values are from the PLC. Please correct any discrepancies.',
-    fill:'Please fill all of items'
+    fill:'Please fill all of items',
+    enterNumber: "Please fill number",
+    enterContent: "Please fill content",
+    exceedMax: "The input value cannot exceed{max}",
   },
   modelTemplate:{
     name:'TemplateName',

+ 4 - 1
src/locales/zh-CN.ts

@@ -507,7 +507,10 @@ export default {
     confirm:'确定',
     cancel:'取消',
     alert:'以下数值取自PLC,如有不符请修改',
-    fill:'请填写所有项'
+    fill:'请填写所有项',
+    enterNumber: "请输入数字",
+    enterContent: "请输入内容",
+    exceedMax: "输入值不能超过{max}",
   },
   modelTemplate:{
     name:'模板名称',

+ 1 - 0
src/utils/dict.ts

@@ -273,6 +273,7 @@ export enum DICT_TYPE {
   PMS_MAIN_WORK_ORDER_RESULT = 'pms_main_work_order_result', // 保养工单状态
   RQ_IOT_ISCOLLECTION = 'rq_iot_isCollection',//是否数采
   RQ_IOT_MODEL_TEMPLATE_ATTR = 'rq_iot_model_template_attr',
+  RQ_IOT_MODEL_PLUS = "rq_iot_model_plus",
   RQ_IOT_SUM = 'rq_iot_isSum',//是否累计
   PMS_ORDER_PROCESS_MODE = "pms_main_work_order_process_mode",  // 保养方式 0内部保养  1委外保养
   PMS_THING_MODEL_UNIT = 'pms_thing_model_unit', // pms属性模板单位

+ 81 - 1
src/views/pms/iotopeationfill/index1.vue

@@ -72,11 +72,20 @@
                     style="width: 200px"
                     disabled
                   />
+<!--                  <el-input
+                    v-else
+                    v-model="item.fillContent"
+                    clearable
+                    style="width: 200px"
+                  />-->
                   <el-input
                     v-else
                     v-model="item.fillContent"
                     clearable
                     style="width: 200px"
+                    :placeholder="item.type === 'double' ? t('operationFillForm.enterNumber') : t('operationFillForm.enterContent')"
+                    @input="handleInput(item)"
+                    :maxlength="item.type === 'double' ? calculateMaxLength(item) : undefined"
                   />
                 </el-form-item>
             </div>
@@ -103,6 +112,8 @@ import { ElMessage } from 'element-plus'
 import moment from 'moment';
 import { format } from 'date-fns';
 import {cx} from "@fullcalendar/core/internal-common";
+
+
 /** 运行记录填报 列表 */
 defineOptions({ name: 'FillOrderInfo' })
 
@@ -141,7 +152,10 @@ const queryParams = reactive({
   creDate: [],
   createTime: [],
   deviceCategoryId:1,
-  deviceId:undefined
+  deviceId:undefined,
+  threshold:undefined,
+  defaultValue:undefined,
+  isSum:undefined,
 })
 const queryFormRef = ref() // 搜索的表单
 const exportLoading = ref(false) // 导出的加载中
@@ -151,7 +165,69 @@ const formatDescription = async(row, column, cellValue) =>{
   return cellValue.split(',').map(part => `<div>${part}</div>`).join('');
 }
 
+// 计算数字输入的最大长度(根据阈值动态计算)
+const calculateMaxLength = (item: any) => {
+  if (item.type !== 'double' || !item.threshold) return undefined;
+
+  const max = parseFloat(item.threshold);
+  if (isNaN(max)) return undefined;
 
+  // 整数部分长度 + 可能的小数点 + 两位小数
+  return max.toString().length + (max.toString().includes('.') ? 0 : 3);
+};
+
+// 处理输入事件,实时限制输入格式和最大值
+const handleInput = (item: any) => {
+  if (item.type === 'double') {
+    // 保存原始值用于后续比较
+    const originalValue = item.fillContent;
+
+    // 1. 格式验证:只允许数字和小数点
+    item.fillContent = item.fillContent.replace(/[^\d.]/g, '');
+    // 确保只有一个小数点
+    item.fillContent = item.fillContent.replace(/\.{2,}/g, '.');
+    // 确保小数点不在开头
+    item.fillContent = item.fillContent.replace(/^\./g, '');
+    // 限制小数位数为两位
+    item.fillContent = item.fillContent.replace(/(\d+)\.(\d{2}).*/, '$1.$2');
+
+    // 2. 最大值验证
+    if (item.threshold) {
+      const value = parseFloat(item.fillContent);
+      const max = parseFloat(item.threshold);
+
+      if (!isNaN(value) && !isNaN(max) && value > max) {
+        // 输入值超过阈值时,恢复到修改前的值
+        item.fillContent = originalValue.replace(/[^\d.]/g, '')
+          .replace(/\.{2,}/g, '.')
+          .replace(/^\./g, '')
+          .replace(/(\d+)\.(\d{2}).*/, '$1.$2');
+
+        // 如果修正后的值仍然超过阈值,则设置为最大值
+        if (parseFloat(item.fillContent) > max) {
+          item.fillContent = max.toString();
+        }
+
+        // 显示提示信息(使用节流避免频繁提示)
+        throttle(() => {
+          ElMessage.warning(t('operationFillForm.exceedMax', { max }));
+        }, 1000)();
+      }
+    }
+  }
+};
+
+// 简单的节流函数,避免提示信息过于频繁
+const throttle = (fn: Function, delay: number) => {
+  let lastTime = 0;
+  return function(...args: any[]) {
+    const now = Date.now();
+    if (now - lastTime >= delay) {
+      fn.apply(this, args);
+      lastTime = now;
+    }
+  };
+};
 
 const showComponent = () => {
   if(JSON.parse(fillStatus)=== 1){
@@ -226,6 +302,7 @@ const getAttrList = async () => {
   try {
     queryParams.createTime = formatTimestamp(JSON.parse(deptId.split(",")[2].substring(0,10)));
     const data = await IotOpeationFillApi.getAttrs(queryParams)
+
     attrList.value = data[0].nonSumList;
     attrList1.value = data[0].sumList;
     attrList.value.forEach(function (item,index){
@@ -237,12 +314,15 @@ const getAttrList = async () => {
       item.deptId = queryParams.deptId;
       item.deviceId = queryParams.deviceId;
       item.deviceCategoryId = queryParams.deviceCategoryId;
+      item.modelId = item.id;
     })
+    console.log(JSON.stringify(attrList.value))
     attrList1.value.forEach(function (item,index){
       item.deviceCode = queryParams.deviceCode;
       item.deptId = queryParams.deptId;
       item.deviceId = queryParams.deviceId;
       item.deviceCategoryId = queryParams.deviceCategoryId;
+      item.modelId = item.id;
     })
   } finally {
     loading.value = false

+ 34 - 21
src/views/pms/modeltemplate/detail/attrsModel/AttrTemplateModelForm.vue

@@ -38,7 +38,6 @@
                 v-for="dict in getIntDictOptions(DICT_TYPE.RQ_IOT_SUM)"
                 :key="dict.value"
                 :value="dict.value"
-                @click="radioChange(dict.value)"
               >
                 {{ dict.label }}
               </el-radio>
@@ -47,6 +46,38 @@
         </el-col>
 
       </el-row>
+      <el-row>
+        <el-col :span="12">
+          <el-form-item label="累加值" prop="defaultValue" v-if="formData.isSum === 1">
+            <!--            <el-input v-model="formData.defaultValue" placeholder="请选择累加值" />-->
+            <el-select v-model="formData.defaultValue" placeholder="请选择累加值" clearable>
+              <el-option
+                v-for="dict in nonSumList"
+                :key="dict.name"
+                :label="dict.name"
+                :value="dict.id"
+                :track-by="dict.id"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="填写阈值" prop="threshold" v-else>
+            <el-input v-model="formData.threshold" placeholder="请输入阈值" type="number"/>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="是否累加" prop="sumId" v-show="formData.isSum === 1">
+            <el-radio-group v-model="formData.sumId">
+              <el-radio
+                v-for="dict in getIntDictOptions(DICT_TYPE.RQ_IOT_MODEL_PLUS)"
+                :key="dict.value"
+                :value="dict.value"
+              >
+                {{ dict.label }}
+              </el-radio>
+            </el-radio-group>
+          </el-form-item>
+        </el-col>
+      </el-row>
       <el-row>
         <el-col :span="12">
           <el-form-item label="标识符" prop="code" v-show="formData.isSum === 1">
@@ -62,9 +93,6 @@
             </el-radio-group>
           </el-form-item>
         </el-col>
-      </el-row>
-
-      <el-row>
         <el-col :span="12">
           <el-form-item label="物属性" prop="modelAttr">
             <el-select v-model="formData.modelAttr" placeholder="请选择">
@@ -77,26 +105,11 @@
             </el-select>
           </el-form-item>
         </el-col>
-        <el-col :span="12">
-          <el-form-item label="累加值" prop="defaultValue" v-if="formData.isSum === 1">
-<!--            <el-input v-model="formData.defaultValue" placeholder="请选择累加值" />-->
-            <el-select v-model="formData.defaultValue" placeholder="请选择累加值" clearable>
-              <el-option
-                v-for="dict in nonSumList"
-                :key="dict.name"
-                :label="dict.name"
-                :value="dict.id"
-                :track-by="dict.id"
-              />
-            </el-select>
-          </el-form-item>
-          <el-form-item label="填写阈值" prop="threshold" v-else>
-            <el-input v-model="formData.threshold" placeholder="请输入阈值" type="number"/>
-          </el-form-item>
-        </el-col>
       </el-row>
 
 
+
+
       <!-- 属性配置 -->
       <DeviceAttrModelProperty
         v-model="formData.selectOptions"