潘志宝
2024-12-25 291bf570b2106cb99b0e689af7d6ccaacc9e5c1c
src/views/data/point/DaPointForm.vue
@@ -1,5 +1,5 @@
<template>
  <Dialog v-model="dialogVisible" :title="dialogTitle" width="50%">
  <Dialog v-model="dialogVisible" :title="dialogTitle" width="60%">
    <el-form
      ref="formRef"
      v-loading="formLoading"
@@ -137,14 +137,14 @@
      </el-row>
      <el-row v-if="formData.pointType === 'MEASURE'">
        <el-col :span="12">
          <el-form-item label="值类型" prop="valueType">
          <el-form-item label="测量值类型" prop="measurePoint.valueType">
            <el-select
              v-model="formData.measurePoint.valueType"
              clearable
              placeholder="请选择值类型"
            >
              <el-option
                v-for="dict in getDictOptions(DICT_TYPE.VALUETYPE)"
                v-for="dict in getDictOptions(DICT_TYPE.MEASURE_VALUE_TYPE)"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
@@ -153,8 +153,10 @@
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="平滑尺度" prop="dimension">
            <el-input-number v-model="formData.measurePoint.dimension" style="width: 100%" :controls="false"/>
          <el-form-item label="平滑尺度(min)" prop="measurePoint.dimension">
            <el-input-number v-model="formData.measurePoint.dimension" style="width: 100%"
                             :min="0" :max="100"
                             :controls="false"/>
          </el-form-item>
        </el-col>
      </el-row>
@@ -166,11 +168,11 @@
              :data="expressionList"
              border
              style="width: 100%">
<!--              <el-table-column
              <el-table-column
                type="index"
                align="center"
                width="50"
                label="序号"/>-->
                width="60"
                label="序号"/>
              <el-table-column
                prop=""
                label="左括号"
@@ -194,6 +196,7 @@
              <el-table-column
                prop=""
                label="测点"
                min-width="160"
                align="center">
                <template #default="scope">
                  <el-select
@@ -211,6 +214,7 @@
              <el-table-column
                prop=""
                label="运算值"
                min-width="120"
                align="center">
                <template #default="scope">
                  <el-input
@@ -243,7 +247,7 @@
              <el-table-column
                prop=""
                label="运算符"
                width="120"
                width="100"
                align="center">
                <template #default="scope">
                  <el-select v-model="scope.row.operator" clearable>
@@ -258,19 +262,19 @@
              <el-table-column
                prop=""
                label="操作"
                width="140"
                width="120"
                align="center">
                <template #default="scope">
                  <el-button
                    @click="addExpressionRow(scope.$index, expressionList)"
                    type="text"
                    size="small">
                    size="mini">
                    添加
                  </el-button>
                  <el-button
                    @click="deleteExpressionRow(scope.$index, expressionList)"
                    type="text"
                    size="small">
                    size="mini">
                    删除
                  </el-button>
                </template>
@@ -278,6 +282,38 @@
            </el-table>
          </el-form-item>
        </el-col>
      </el-row>
      <!--累计点-->
      <el-row :gutter="20" v-if="formData.pointType === 'CUMULATE'">
        <el-col :span="24">
          <el-form-item label="瞬时测点" prop="cumulatePoint.momentPoint">
            <el-select
              v-model="formData.cumulatePoint.momentPoint"
              filterable
              placeholder="请选择">
              <el-option
                v-for="(item, index) in pointList2"
                :key="index"
                :label="item.pointName"
                :value="item.pointNo"/>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="累计长度" prop="cumulatePoint.length">
            <el-input-number v-model="formData.cumulatePoint.length" style="width: 100%"
                             :min="1" :max="3000"
                             :controls="false"/>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="除数" prop="cumulatePoint.divisor">
            <el-input-number v-model="formData.cumulatePoint.divisor" style="width: 100%"
                             :min="1" :max="3000"
                             :controls="false"/>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <template #footer>
@@ -290,6 +326,7 @@
import * as DaPoint from '@/api/data/da/point'
import * as TagApi from '@/api/data/channel/tag'
import {DICT_TYPE, getDictOptions, getIntDictOptions} from "@/utils/dict";
import {getPointSimpleList} from "@/api/data/da/point";
defineOptions({name: 'DataDaPointForm'})
@@ -306,7 +343,14 @@
  pointNo: ''
}])
const queryParams = reactive({
  pointType: "MEASURE"
  pointTypes: "MEASURE,CONSTANT",
})
const pointList2 = ref([{
  pointName: '',
  pointNo: ''
}])
const queryParams2 = reactive({
  pointTypes: "MEASURE,CONSTANT,CALCULATE",
})
const operatorList = ref(['+', '-', '*', '/', '&', '|', '!', '>', '<'])
const formData = ref({
@@ -339,12 +383,25 @@
    tagNo: '',
    dimension: '',
    valueType: '',
  },
  cumulatePoint: {
    id: '',
    pointId: '',
    momentPoint: '',
    length: '',
    divisor: ''
  }
})
const formRules = reactive({
  pointName: [{required: true, message: '测点名称不能为空', trigger: 'blur'}],
  pointType: [{required: true, message: '测点类型不能为空', trigger: 'blur'}],
  dataType: [{required: true, message: '数据类型不能为空', trigger: 'blur'}],
  minfreqid: [{required: true, message: '采集频率不能为空', trigger: 'blur'}],
  "measurePoint.valueType": [{required: true, message: '值类型不能为空', trigger: 'blur'}],
  "measurePoint.dimension": [{required: true, message: '平滑尺度不能为空', trigger: 'blur'}],
  "cumulatePoint.momentPoint": [{required: true, message: '累计测点不能为空', trigger: 'blur'}],
  "cumulatePoint.length": [{required: true, message: '累计长度不能为空', trigger: 'blur'}],
  "cumulatePoint.divisor": [{required: true, message: '除数不能为空', trigger: 'blur'}],
})
const formRef = ref() // 表单 Ref
@@ -356,6 +413,7 @@
  resetForm()
  getSourceOption()
  getPointList()
  getPointList2()
  // 修改时,设置数据
  if (id) {
    formLoading.value = true
@@ -438,8 +496,8 @@
    storeType: undefined,
    unit: undefined,
    unittransfactor: 1,
    defaultValue: 10,
    maxValue: 10000000,
    defaultValue: 0,
    maxValue: 100000000,
    minValue: 0,
    minfreqid: undefined,
    remark: undefined,
@@ -458,6 +516,13 @@
      tagNo: '',
      dimension: '1',
      valueType: 'SIMULATE',
    },
    cumulatePoint: {
      id: '',
      pointId: '',
      momentPoint: '',
      length: 60,
      divisor: 60
    }
  }
  formRef.value?.resetFields()
@@ -518,7 +583,11 @@
}
const getPointList = async () => {
  pointList.value = await DaPoint.getPointList(queryParams)
  pointList.value = await DaPoint.getPointSimpleList(queryParams)
}
const getPointList2 = async () => {
  pointList2.value = await DaPoint.getPointSimpleList(queryParams2)
}
const getInfo = async (id) => {