ソースを参照

联锁管理新增

yuhan 9 ヶ月 前
コミット
412c1d61bd

+ 326 - 520
src/views/module_interLock/InterlockSummary/modules/InterlockConditionForm.vue

@@ -1,552 +1,358 @@
 <template>
-  <j-vxe-table
-    ref="vTable"
-    toolbar
-    :height="500"
-    :loading="loading"
-    :dataSource="dataSource"
-    :columns="columns"
-    style="margin-top: 8px;"
-    @valueChange="handleValueChange"
-    class="interlock-condition-tableForm"
-    >
-    <!-- row-number  -->
-    <!-- row-selection -->
-    <!-- drag-sort 移动上下行 -->
-    <!-- keep-source 啥? -->
-    <!-- :scroll-y="{enabled:false}" -->
-
-    <!--  -->
-    <template v-slot:currentValueTag="props">
-      <a-cascader
-        v-model="props.row.currentValueTag"
-        :options="dianweiOptions"
-        :display-render="displayRender"
-        expand-trigger="hover"
-        placeholder="请选择点位"
-        @change="onChange"
-        />
-    </template>
+  <a-spin :spinning="confirmLoading">
+    <j-form-container>
+      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
+        <a-row>
+          <a-col :span="24">
+            <a-form-model-item label="联锁条件位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockConditionData">
+              <a-cascader
+                v-model="model.interlockConditionData"
+                :options="tagDataOptions"
+                :display-render="displayRender"
+                :fieldNames="customFieldNames"
+                expand-trigger="hover"
+                placeholder="请选择点位"/>
+                <!-- @change="dianwerChange" -->
+            </a-form-model-item>
+          </a-col>
+          <!-- 仪表状态开始 -->
+          <a-col :span="24">
+            <a-form-model-item label="仪表状态判定依据" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="instrumentStatusJuge">
+              <a-radio-group name="radioGroup" v-model="model.instrumentStatusJuge" @change="instrumentStatusJugeChange">
+                <a-radio :value="1"> 位号读取 </a-radio>
+                <a-radio :value="2"> 高低限判断 </a-radio>
+                <a-radio :value="3"> 突变超限判断 </a-radio>
+              </a-radio-group>
+            </a-form-model-item>
+          </a-col>
+          <template v-if="model.instrumentStatusJuge === 1">
+            <a-col :span="24">
+              <a-form-model-item label="仪表状态位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="instrumentStatusData">
+                <a-cascader
+                v-model="model.instrumentStatusData"
+                :options="tagDataOptions"
+                :display-render="displayRender"
+                :fieldNames="customFieldNames"
+                expand-trigger="hover"
+                placeholder="请选择仪表状态位号"/>
+              </a-form-model-item>
+            </a-col>
+          </template>
+          <template v-if="model.instrumentStatusJuge === 2">
+            <a-col :span="24">
+              <a-form-model-item label="原始模拟量位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ysmnlData">
+                <a-cascader
+                  v-model="model.ysmnlData"
+                  :options="tagDataOptions"
+                  :display-render="displayRender"
+                  :fieldNames="customFieldNames"
+                  expand-trigger="hover"
+                  placeholder="请选择原始模拟量位号"
+                />
+              </a-form-model-item>
+            </a-col>
+            <a-col :span="24">
+              <a-form-model-item label="高限值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upperLimit">
+                <a-input v-model="model.upperLimit" placeholder="请输入高限"></a-input>
+              </a-form-model-item>
+            </a-col>
+            <a-col :span="24">
+              <a-form-model-item label="低限值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lowerLimit">
+                <a-input v-model="model.lowerLimit" placeholder="请输入低限"></a-input>
+              </a-form-model-item>
+            </a-col>
+          </template>
+          <template v-if="model.instrumentStatusJuge === 3">
+            <a-col :span="24">
+              <a-form-model-item label="原始模拟量位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ysmnlData">
+                <a-cascader
+                  v-model="model.ysmnlData"
+                  :options="tagDataOptions"
+                  :display-render="displayRender"
+                  :fieldNames="customFieldNames"
+                  expand-trigger="hover"
+                  placeholder="请选择原始模拟量位号"
+                />
+              </a-form-model-item>
+            </a-col>
+            <a-col :span="24">
+              <a-form-model-item label="时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="thresholdTime">
+                <a-input v-model="model.thresholdTime" placeholder="请输入时间"></a-input>
+              </a-form-model-item>
+            </a-col>
+            <a-col :span="24">
+              <a-form-model-item label="阈值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="thresholdValue">
+                <a-input v-model="model.thresholdValue" placeholder="请输入阈值"></a-input>
+              </a-form-model-item>
+            </a-col>
+          </template>
+          <a-col :span="24">
+            <a-form-model-item label="描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="description">
+              <a-input v-model="model.description" placeholder="请输入描述"></a-input>
+            </a-form-model-item>
+          </a-col>
+          <!-- 仪表状态结束 -->
 
-    <!-- <template v-slot:toolbarSuffix>
-      <a-button @click="handleTableCheck">表单验证</a-button>
-      <a-tooltip placement="top" title="获取值,忽略表单验证" :autoAdjustOverflow="true">
-        <a-button @click="handleTableGet">获取值</a-button>
-      </a-tooltip>
-      <a-tooltip placement="top" title="模拟加载1000条数据" :autoAdjustOverflow="true">
-        <a-button @click="handleTableSet">设置值</a-button>
-      </a-tooltip>
-    </template> -->
+          <a-col :span="24">
+            <a-form-model-item label="联锁设定值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockSetValue">
+              <a-input v-model="model.interlockSetValue" placeholder="请输入描述"></a-input>
+            </a-form-model-item>
+          </a-col>
+          <a-col :span="24">
+            <a-form-model-item label="当前值位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="currentValueData">
+              <a-cascader
+                v-model="model.currentValueData"
+                :options="tagDataOptions"
+                :display-render="displayRender"
+                :fieldNames="customFieldNames"
+                expand-trigger="hover"
+                placeholder="请选择当前值位号"/>
+            </a-form-model-item>
+          </a-col>
 
-    <!-- 仪表状态 -->
-    <template  v-slot:instrumentStatus="props">
-      <!-- <div @click="dianjiCeshi(props)">点击了{{props.row.ceshi}}</div> -->
-      <a-radio-group name="radioGroup" v-model="props.row.instrumentStatusJuge">
-        <!--  :default-value="props.row.ceshi" -->
-        <a-radio :value="1"> 位号读取 </a-radio>
-        <a-radio :value="2"> 高低限判断 </a-radio>
-        <a-radio :value="3"> 突变超限判断 </a-radio>
-      </a-radio-group>
-      <div v-if="props.row.instrumentStatusJuge === 1">
-        <a-cascader
-          v-model="props.row.currentValueTag"
-          :options="dianweiOptions"
-          :display-render="displayRender"
-          expand-trigger="hover"
-          placeholder="请选择点位"
-          @change="onChange"/>
-      </div>
-      <div v-if="props.row.instrumentStatusJuge === 2">
-        <a-row>
+          <!-- 是否旁路 -->
+          <a-col :span="24">
+            <a-form-model-item label="是否旁路" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ifBypass">
+              <a-radio-group name="radioGroup" v-model="model.ifBypass">
+                <!--  :default-value="model.ifBypass" -->
+                <a-radio :value="1"> 是 </a-radio>
+                <a-radio :value="0"> 否 </a-radio>
+              </a-radio-group>
+            </a-form-model-item>
+          </a-col>
+          <template v-if="model.ifBypass === 1">
+            <a-col :span="24">
+              <a-form-model-item label="旁路位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bypassData">
+                <a-cascader
+                v-model="model.bypassData"
+                :options="tagDataOptions"
+                :display-render="displayRender"
+                :fieldNames="customFieldNames"
+                expand-trigger="hover"
+                placeholder="请选择旁路位号"/>
+              </a-form-model-item>
+            </a-col>
+          </template>
+          <template v-if="model.ifBypass === 0">
+            <a-col :span="24">
+              <a-form-model-item label="旁路状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bypass">
+                <a-input v-model="model.bypass" placeholder="无旁路"></a-input>
+              </a-form-model-item>
+            </a-col>
+          </template>
           <a-col :span="24">
-            原始模拟量位号:<a-cascader
-              v-model="props.row.ysmnlTag"
-              :options="dianweiOptions"
-              :display-render="displayRender"
-              expand-trigger="hover"
-              style="width: 200px"
-              placeholder="请选择原始模拟量位号"
-              @change="onChange"
-            />
+            <a-form-model-item label="输入卡件状态位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inputStatusData">
+              <a-cascader
+                v-model="model.inputStatusData"
+                :options="tagDataOptions"
+                :display-render="displayRender"
+                :fieldNames="customFieldNames"
+                expand-trigger="hover"
+                placeholder="请选择输入卡件状态位号"
+              />
+            </a-form-model-item>
           </a-col>
-          <a-col :span="12">
-            高限值:<a-input v-model="props.row.upperLimit" placeholder="请输入高限" style="width: 100px;"></a-input>
+          <a-col :span="24">
+            <a-form-model-item label="输出卡件状态位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outputStatusData">
+              <a-cascader
+                v-model="model.outputStatusData"
+                :options="tagDataOptions"
+                :display-render="displayRender"
+                :fieldNames="customFieldNames"
+                expand-trigger="hover"
+                placeholder="请选择输出卡件状态位号"
+              />
+            </a-form-model-item>
           </a-col>
-          <a-col :span="12">
-            低限值:<a-input v-model="props.row.lowerLimit" placeholder="请输入低限" style="width: 100px;"></a-input>
+          <a-col :span="24">
+            <a-form-model-item label="MP状态位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mpStatusData">
+              <a-cascader
+                v-model="model.mpStatusData"
+                :options="tagDataOptions"
+                :display-render="displayRender"
+                :fieldNames="customFieldNames"
+                expand-trigger="hover"
+                placeholder="请选择MP状态位号"
+              />
+            </a-form-model-item>
           </a-col>
         </a-row>
-      </div>
-      <div v-if="props.row.instrumentStatusJuge === 3">
-        <a-cascader
-        v-model="props.row.ysmnlTag"
-        :options="dianweiOptions"
-        :display-render="displayRender"
-        expand-trigger="hover"
-        placeholder="请选择原始模拟量位号"
-        @change="onChange"/>
-        <div>
-          时间<a-input v-model="props.row.thresholdTime" placeholder="请输入时间" style="width: 20%;"></a-input>
-        </div>
-        <div>
-          阈值<a-input v-model="props.row.thresholdValue" placeholder="请输入阈值"></a-input>
-        </div>
-      </div>
-    </template>
-    <!-- 是否旁路 -->
-    <template  v-slot:ifBypass="props">
-      <a-radio-group name="radioGroup" v-model="props.row.ifBypass">
-        <!--  :default-value="props.row.ceshi" -->
-        <a-radio :value="0"> 否 </a-radio>
-        <a-radio :value="1"> 是 </a-radio>
-      </a-radio-group>
-      <!-- <div v-if="props.row.ifBypass === 0">
-        无旁路
-      </div> -->
-      <div v-if="props.row.ifBypass === 1">
-        <!-- <a-cascader
-          v-model="props.row.ifBypassTag"
-          :options="dianweiOptions"
-          :display-render="displayRender"
-          expand-trigger="hover"
-          placeholder="请选择点位"
-          @change="onChange"/> -->
-        <a-tree-select
-          v-model="props.row.ifBypassTag"
-          style="width: 100%"
-          :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
-          :tree-data="dianweiOptions"
-          placeholder="请选择"
-          tree-default-expand-all
-        >
-          <!-- <span v-if="key === '0-0-1'" slot="title" slot-scope="{ key, value }" style="color: #08c">
-            Child Node1 {{ value }}
-          </span> -->
-        </a-tree-select>
-      </div>
-    </template>
-    <template v-slot:action="props">
-      <a @click="handleCK(props)">查看</a>
-      <a-divider type="vertical"/>
-      <a-popconfirm title="确定删除吗?" @confirm="handleDL(props)">
-        <a>删除</a>
-      </a-popconfirm>
-    </template>
-
-  </j-vxe-table>
+      </a-form-model>
+    </j-form-container>
+  </a-spin>
 </template>
 
 <script>
-  var dianweiOptions = [
-    {
-      key: '设备1',
-      value: '设备1',
-      title: '设备1',
-      label: '设备1',
-      children: [
-        {
-          key: '模块1',
-          value: '模块1',
-          title: '模块1',
-          label: '模块1',
-          children: [
-            {
-              key: '点位1',
-              value: '点位1',
-              title: '点位1',
-              label: '点位1',
-            },
-          ],
-        },
-      ],
-    },
-    {
-      key: '设备2',
-      value: '设备2',
-      title: '设备2',
-      label: '设备2',
-      children: [
-        {
-          key: '模块2',
-          value: '模块2',
-          title: '模块2',
-          label: '模块2',
-          children: [
-            {
-              key: '点位2',
-              value: '点位2',
-              title: '点位2',
-              label: '点位2',
-            },
-          ],
-        },
-      ],
-    },
-  ]
-  import moment from 'moment'
-  import { pushIfNotExist, randomNumber, randomUUID } from '@/utils/util'
-  import { JVXETypes } from '@/components/jeecg/JVxeTable'
+  import { httpAction, getAction, postAction } from '@/api/manage'
 
   export default {
-    name: 'JVxeDemo1',
-    data() {
+    name: 'InterlockConditionForm',
+    props: {
+      //表单禁用
+      // disabled: {
+      //   type: Boolean,
+      //   default: false,
+      //   required: false
+      // }
+    },
+    data () {
       return {
-        loading: false,
-        dianweiOptions: dianweiOptions,
-        columns: [
-          // {
-          //   title: '联锁条件',
-          //   key: 'normal',
-          //   type: JVXETypes.normal,
-          //   width: '180px',
-          //   // fixed: 'left',
-          //   defaultValue: 'normal-new',
-          // },
-          {
-            title: '联锁条件',
-            key: 'interlockCondition',
-            type: JVXETypes.input,
-            width: '180px',
-            defaultValue: '',
-            placeholder: '请输入${title}',
-            validateRules: [
-              {
-                required: true, // 必填
-                message: '请输入${title}' // 显示的文本
-              },
-              {
-                pattern: /^[a-z|A-Z][a-z|A-Z\d_-]*$/, // 正则
-                message: '${title}必须以字母开头,可包含数字、下划线、横杠'
-              },
-              {
-                unique: true,
-                message: '${title}不能重复'
-              },
-              {
-                handler({cellValue, row, column}, callback, target) {
-                  // cellValue 当前校验的值
-                  // callback(flag, message) 方法必须执行且只能执行一次
-                  //          flag = 是否通过了校验,不填写或者填写 null 代表不进行任何操作
-                  //          message = 提示的类型,默认使用配置的 message
-                  // target 行编辑的实例对象
-                  if (cellValue === 'abc') {
-                    callback(false, '${title}不能是abc')  // false = 未通过校验
-                  } else {
-                    callback(true) // true = 通过验证
-                  }
-                },
-                message: '${title}默认提示'
-              }
-            ]
-          },
-          {
-            title: '仪表状态',
-            key: 'ceshi',
-            type: JVXETypes.slot,
-            // fixed: 'right',
-            minWidth: '400px',
-            align: 'center',
-            slotName: 'instrumentStatus',
-          },
-          {
-            title: '描述',
-            key: 'description',
-            type: JVXETypes.textarea,
-            width: '200px',
-          },
-          {
-            title: '联锁设定值',
-            key: 'interlockSetValue',
-            type: JVXETypes.inputNumber,
-            width: '120px',
-            defaultValue: 32,
-            // 【统计列】sum = 求和、average = 平均值
-            // statistics: ['sum', 'average'],
-          },
-          {
-            title: '当前值',
-            key: 'currentValueTag',
-            type: JVXETypes.slot,
-            // fixed: 'right',
-            minWidth: '180px',
-            align: 'center',
-            slotName: 'currentValueTag',
-          },
-          {
-            title: '是否旁路',
-            key: 'ifBypass',
-            type: JVXETypes.slot,
-            // fixed: 'right',
-            minWidth: '180px',
-            align: 'center',
-            slotName: 'ifBypass',
-          },
-          // {
-          //   title: '下拉框_搜索',
-          //   key: 'select_search',
-          //   type: JVXETypes.selectSearch,
-          //   width: '180px',
-          //   options: [
-          //     {title: 'String', value: 'string'},
-          //     {title: 'Integer', value: 'int'},
-          //     {title: 'Double', value: 'double'},
-          //     {title: 'Boolean', value: 'boolean'}
-          //   ],
-          // },
-          // {
-          //   title: '联锁输出值',
-          //   key: 'interlockOutValueTag',
-          //   type: JVXETypes.select,
-          //   width: '180px',
-          //   // 下拉选项
-          //   options: [
-          //     {title: 'String', value: 'string'},
-          //     {title: 'Integer', value: 'int'},
-          //     {title: 'Double', value: 'double'},
-          //     {title: 'Boolean', value: 'boolean'}
-          //   ],
-          //   allowInput: true,
-          //   placeholder: '请选择'
-          // },
-          {
-            title: '输入卡件状态',
-            key: 'inputStatusTag',
-            type: JVXETypes.select,
-            width: '180px',
-            // 下拉选项
-            options: [
-              {title: 'String', value: 'string'},
-              {title: 'Integer', value: 'int'},
-              {title: 'Double', value: 'double'},
-              {title: 'Boolean', value: 'boolean'}
-            ],
-            allowInput: true,
-            placeholder: '请选择'
-          },
-          {
-            title: '输出卡件状态',
-            key: 'outputStatusTag',
-            type: JVXETypes.select,
-            width: '180px',
-            // 下拉选项
-            options: [
-              {title: 'String', value: 'string'},
-              {title: 'Integer', value: 'int'},
-              {title: 'Double', value: 'double'},
-              {title: 'Boolean', value: 'boolean'}
-            ],
-            allowInput: true,
-            placeholder: '请选择'
-          },
-          {
-            title: 'MP状态',
-            key: 'mpStatusTag',
-            type: JVXETypes.select,
-            width: '180px',
-            // 下拉选项
-            options: [
-              {title: 'String', value: 'string'},
-              {title: 'Integer', value: 'int'},
-              {title: 'Double', value: 'double'},
-              {title: 'Boolean', value: 'boolean'}
-            ],
-            allowInput: true,
-            placeholder: '请选择'
-          },
-          // {
-          //   title: '下拉框_字典',
-          //   key: 'select_dict',
-          //   type: JVXETypes.select,
-          //   width: '180px',
-          //   options: [],
-          //   dictCode: 'sex',
-          //   placeholder: '请选择',
-          // },
-          // {
-          //   title: '下拉框_多选',
-          //   key: 'select_multiple',
-          //   type: JVXETypes.selectMultiple,
-          //   width: '205px',
-          //   options: [
-          //     {title: 'String', value: 'string'},
-          //     {title: 'Integer', value: 'int'},
-          //     {title: 'Double', value: 'double'},
-          //     {title: 'Boolean', value: 'boolean'}
-          //   ],
-          //   defaultValue: ['int', 'boolean'], // 多个默认项
-          //   // defaultValue: 'string,double,int', // 也可使用这种方式
-          //   placeholder: '多选',
-          // },
-          // {
-          //   title: '日期时间',
-          //   key: 'datetime',
-          //   type: JVXETypes.datetime,
-          //   width: '200px',
-          //   defaultValue: '2019-4-30 14:52:22',
-          //   placeholder: '请选择',
-          // },
-          // {
-          //   title: '复选框',
-          //   key: 'checkbox',
-          //   type: JVXETypes.checkbox,
-          //   width: '100px',
-          //   customValue: ['Y', 'N'], // true ,false
-          //   defaultChecked: false,
-          // },
-          // {
-          //   title: '操作',
-          //   key: 'action',
-          //   type: JVXETypes.slot,
-          //   // fixed: 'right',
-          //   minWidth: '100px',
-          //   align: 'center',
-          //   slotName: 'action',
+        model:{
+          instrumentStatusJuge: 1,
+          ifBypass: 1,
+        },
+        labelCol: {
+          xs: { span: 24 },
+          sm: { span: 5 },
+        },
+        wrapperCol: {
+          xs: { span: 24 },
+          sm: { span: 16 },
+        },
+        confirmLoading: false,
+        validatorRules: {
+          interlockConditionData: [{
+            required: true, message: '请选择联锁条件位号!',
+          }],
+          instrumentStatusJuge: [{
+            required: true, message: '请选择仪表状态判定依据!',
+          }],
+          instrumentStatusData: [{
+            required: true, message: '请选择仪表状态位号!',
+          }],
+          description: [{
+            required: true, message: '请输入描述!',
+          }],
+          interlockSetValue: [{
+            required: true, message: '请输入联锁设定值!',
+          }],
+          currentValueData: [{
+            required: true, message: '请选择当前值位号!',
+          }],
+          ifBypass: [{
+            required: true, message: '请选择是否旁路!',
+          }],
+          bypassData: [{
+            required: true, message: '请选择旁路位号!',
+          }],
+          inputStatusData: [{
+            required: true, message: '请选择!',
+          }],
+          interlockConditionData: [{
+            required: true, message: '请选择输入卡件状态位号!',
+          }],
+          outputStatusData: [{
+            required: true, message: '请选择输出卡件状态位号!',
+          }],
+          mpStatusData: [{
+            required: true, message: '请选择MP状态位号!',
+          }],
+          // interlockConditionData:{
+          //   rules: [{
+          //     required: true, message: '请选择!',
+          //   }],
           // },
-        ],
-        dataSource: [],
+        },
+        url: {
+          interLockSelect: '/sys/dict/loadTreeData',
+          add: "/summary/interlockSummary/add",
+          edit: "/summary/interlockSummary/edit",
+          queryById: "/summary/interlockSummary/queryById",
+          getTagInfo: "/iotedgeCollectData/iotedgeCollectData/getTagInfo"
+        },
+        customFieldNames: {
+          label: 'name',
+          value: 'info',
+          children: 'children'
+        },
+        tagDataOptions: [],
       }
-
     },
-
-    created() {
-      this.randomPage(0, 20, true)
+    created () {
+      this.getTagInfo()
+       //备份model原始值
+      this.modelDefault = JSON.parse(JSON.stringify(this.model));
     },
     methods: {
-      onChange(value) {
-        console.log(value);
+      // 获取所有位号
+      getTagInfo(){
+        postAction(this.url.getTagInfo).then(res => {
+          console.log(res)
+          this.tagDataOptions = res.result
+        })
       },
       displayRender({ labels }) {
         return labels[labels.length - 1];
       },
-      handleCK(props) {
-        this.$message.success('请在控制台查看输出')
-        // 参数介绍:
-        // props.value          当前单元格的值
-        // props.row            当前行的数据
-        // props.rowId          当前行ID
-        // props.rowIndex       当前行下标
-        // props.column         当前列的配置
-        // props.columnIndex    当前列下标
-        // props.$table         vxe实例,可以调用vxe内置方法
-        // props.target         JVXE实例,可以调用JVXE内置方法
-        // props.caseId         JVXE实例唯一ID
-        // props.scrolling      是否正在滚动
-        // props.triggerChange  触发change事件,用于更改slot的值
-        console.log('查看: ', {props})
+      // 点位选择改变
+      dianwerChange(e){
+        console.log(e)
       },
-
-      handleDL(props) {
-        // 调用删除方法
-        props.target.removeRows(props.row)
+      // 点位状态依据改变时
+      instrumentStatusJugeChange(e){
+        console.log(e)
       },
-
-      handleValueChange(event) {
-        console.log('handleValueChange.event: ', event)
+      add () {  
+        this.edit(this.modelDefault);
       },
-
-      /** 表单验证 */
-      handleTableCheck() {
-        this.$refs.vTable.validateTable().then(errMap => {
-          if (errMap) {
-            console.log('表单验证未通过:', {errMap})
-            this.$message.error('验证未通过,请在控制台查看详细')
-          } else {
-            this.$message.success('验证通过')
-          }
-        })
+      edit (record) {
+        this.model = Object.assign({}, record);
+        this.visible = true;
       },
+      submitForm () {
+        const that = this;
+        // 触发表单验证
+        this.$refs.form.validate(valid => {
+          if (valid) {
+            // 拆分级联选择器的数据传递后端使用-设备id、模块名称、点位、值
+            var conditionTableData = {}
+            // 联锁条件
+            this.model.interlockConditionDeviceId = this.model.interlockConditionData[0]
+            this.model.interlockConditionModuleName = this.model.interlockConditionData[1]
+            this.model.interlockConditionTag = (this.model.interlockConditionData[2].split('&'))[0]
+            this.model.interlockSetValue = (this.model.interlockConditionData[2].split('&'))[1]
+            // 仪表状态
+            this.model.instrumentStatusDeviceId = this.model.currentValueData[0]
+            this.model.instrumentStatusModuleName = this.model.currentValueData[1]
+            this.model.instrumentStatusTag = (this.model.currentValueData[2].split('&'))[0]
+            this.model.instrumentStatusValue = (this.model.currentValueData[2].split('&'))[1]
+            
+            // 当前值
+            this.model.currentValueDeviceId = this.model.currentValueData[0]
+            this.model.currentValueModuleName = this.model.currentValueData[1]
+            this.model.currentValueTag = (this.model.currentValueData[2].split('&'))[0]
+            this.model.currentValue = (this.model.currentValueData[2].split('&'))[1]
 
-      /** 获取值,忽略表单验证 */
-      handleTableGet() {
-        const values = this.$refs.vTable.getTableData()
-        console.log('获取值:', {values})
-        this.$message.success('获取值成功,请看控制台输出')
-      },
+            // 旁路
+            this.model.bypassDeviceId = this.model.bypassData[0]
+            this.model.bypassModuleName = this.model.bypassData[1]
+            this.model.bypassTag = (this.model.bypassData[2].split('&'))[0]
+            this.model.bypass = (this.model.bypassData[2].split('&'))[1]
+            
+            // 输入卡件状态
+            this.model.inputStatusDeviceId = this.model.inputStatusData[0]
+            this.model.inputStatusModuleName = this.model.inputStatusData[1]
+            this.model.inputStatusTag = (this.model.inputStatusData[2].split('&'))[0]
+            this.model.inputStatus = (this.model.inputStatusData[2].split('&'))[1]
+            
+            // 输出卡件状态 
+            this.model.outputStatusDeviceId = this.model.outputStatusData[0]
+            this.model.outputStatusModuleName = this.model.outputStatusData[1]
+            this.model.outputStatusTag = (this.model.outputStatusData[2].split('&'))[0]
+            this.model.outputStatus = (this.model.outputStatusData[2].split('&'))[1]
 
-      /** 模拟加载1000条数据 */
-      handleTableSet() {
-        this.randomPage(1, 10, true)
-      },
-
-      /* 随机生成数据 */
-      randomPage(current, pageSize, loading = false) {
-        if (loading) {
-          this.loading = true
-        }
-
-        let randomDatetime = () => {
-          let time = randomNumber(1000, 9999999999999)
-          return moment(new Date(time)).format('YYYY-MM-DD HH:mm:ss')
-        }
-
-        let limit = (current - 1) * pageSize
-
-        let options = ['string', 'int', 'double', 'boolean']
-
-        let begin = Date.now()
-        let values = []
-        for (let i = 0; i < pageSize; i++) {
-          values.push({
-            id: randomUUID(),
-            normal: `normal-${(limit + i) + 1}`,
-            input: `text-${(limit + i) + 1}`,
-            textarea: `textarea-${(limit + i) + 1}`,
-            number: randomNumber(0, 233),
-            select: options[randomNumber(0, 3)],
-            select_dict: randomNumber(1, 2).toString(),
-            select_multiple: (() => {
-              let length = randomNumber(1, 4)
-              let arr = []
-              for (let j = 0; j < length; j++) {
-                pushIfNotExist(arr, options[randomNumber(0, 3)])
-              }
-              return arr
-            })(),
-            select_search: options[randomNumber(0, 3)],
-            datetime: randomDatetime(),
-            checkbox: ['Y', 'N'][randomNumber(0, 1)],
-            instrumentStatusJuge: 1,
-            instrumentStatusTag: [],
-            ysmnlTag: [],
-            upperLimit: '',
-            lowerLimit: '',
-            thresholdValue: '',
-            thresholdTime: '',
-            interlockCondition: '',
-            description: '',
-            interlockSetValue: '',
-            currentValueTag: ['zhejiang', 'hangzhou', 'xihu'],
-            ifBypass: '',
-            ifBypassTag: 'xihu',
-            interlockOutValueTag: [],
-            inputStatusTag: [],
-            outputStatusTag: [],
-            mpStatusTag: [],
-          })
-        }
-
-        this.dataSource = values
-        let end = Date.now()
-        let diff = end - begin
+            // MP状态
+            this.model.mpStatusDeviceId = this.model.mpStatusData[0]
+            this.model.mpStatusModuleName = this.model.mpStatusData[1]
+            this.model.mpStatusTag = (this.model.mpStatusData[2].split('&'))[0]
+            this.model.mpStatus = (this.model.mpStatusData[2].split('&'))[1]
 
-        if (loading && diff < pageSize) {
-          setTimeout(() => {
-            this.loading = false
-          }, pageSize - diff)
-        }
-
-      }
+            console.log(this.model)
+            this.$emit('ok', this.model)
+          }
+         
+        })
+      },
     }
   }
-</script>
-
-<style lang="less">
-.interlock-condition-tableForm{
-  .vxe-table.vxe-editable .vxe-body--column, .vxe-table.vxe-editable .vxe-body--column.col--actived{
-    padding: 10px 0 !important;
-  }
-}
-.mt4{
-  margin-top: 4px;
-}
-</style>
+</script>

+ 163 - 120
src/views/module_interLock/InterlockSummary/modules/InterlockSummaryForm.vue

@@ -27,57 +27,29 @@
                 placeholder="请选择系统"
                 @change="handleSystemChange"
                 >
-                <!-- option-filter-prop="children" -->
-                <!-- :filter-option="filterOption" -->
-                <!-- @focus="handleFocus" -->
-                <!-- @blur="handleBlur" -->
                 <a-select-option v-for="(item) in systemData" :key="item.key" :value="item.key">{{ item.title }}</a-select-option>
               </a-select>
             </a-form-model-item>
           </a-col>
           <a-col :span="12">
             <a-form-model-item label="联锁名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockName">
-              <a-auto-complete
-                v-model="model.interlockName"
-                :data-source="interLockData"
-                placeholder="请输入联锁名称"
-                @search="interLockSearch"
-                />
-                <!-- @select="interLockSelect" -->
-                <!-- @change="onChange" -->
-                <!-- style="width: 200px" -->
+                <a-input v-model="model.interlockName" placeholder="请输入联锁名称"></a-input>
             </a-form-model-item>
           </a-col>
-          <!-- <a-col :span="24">
-            <a-form-model-item label="联锁状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockStatus">
-              <a-input v-model="model.interlockStatus" placeholder="请输入联锁状态"  ></a-input>
-            </a-form-model-item>
-          </a-col> -->
-          <!-- <a-col :span="24">
-            <a-form-model-item label="回路健康级别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="loopHealthLevel">
-              <a-input v-model="model.loopHealthLevel" placeholder="请输入回路健康级别"  ></a-input>
-            </a-form-model-item>
-          </a-col> -->
           <a-col :span="12">
             <a-form-model-item label="逻辑关系" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ljgx">
-              <a-input v-model="model.ljgx" placeholder="请选择逻辑关系"></a-input>
+              <a-input v-model="model.ljgx" placeholder="请输入逻辑关系"></a-input>
             </a-form-model-item>
           </a-col>
-          <!-- <a-col :span="24">
-            <a-form-model-item label="联锁输出值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockOutValue">
-              <a-input v-model="model.interlockOutValue" placeholder="请输入联锁输出值"  ></a-input>
-            </a-form-model-item>
-          </a-col> -->
           <a-col :span="12">
-            <a-form-model-item label="联锁输出值点位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockOutValueTag">
-              <!-- <a-input v-model="model.interlockOutValueTag" placeholder="请选择联锁输出值点位"></a-input> -->
+            <a-form-model-item label="联锁输出值位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockOutValueData">
               <a-cascader
-                v-model="model.interlockOutValueTag"
-                :options="dianweiOptions"
+                v-model="model.interlockOutValueData"
+                :options="tagDataOptions"
                 :display-render="displayRender"
                 :fieldNames="customFieldNames"
                 expand-trigger="hover"
-                placeholder="请选择位"
+                placeholder="请选择位"
                 @change="dianwerChange"
                 />
             </a-form-model-item>
@@ -88,94 +60,49 @@
             </a-form-model-item>
           </a-col>
         </a-row>
-        <interlock-condition-form></interlock-condition-form>
+        <div>
+          <a-button @click="handleAddCondition" type="primary" icon="plus">新增联锁条件</a-button>
+        </div>
+        <!-- 联锁条件表格 -->
+        <a-table
+          ref="table"
+          size="middle"
+          :scroll="{x:true}"
+          bordered
+          rowKey="rowIndex"
+          :columns="columns"
+          :dataSource="dataSource"
+          class="j-table-force-nowrap">
+          <!-- :pagination="ipagination" -->
+          <!-- :loading="loading" -->
+          <!-- :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" -->
+          <span slot="action" slot-scope="text, record">
+            <a @click="handleEdit(record)">编辑</a>
+            <a-divider type="vertical" />
+            <a @click="handleDelete(record.id)(record)">复制</a>
+            <a-divider type="vertical" />
+            <a @click="handleDelete(record.id)(record)">删除</a>
+          </span>
+
+        </a-table>
+        <!-- 新增联锁条件 -->
+        <j-modal
+          :title="conditionTitle"
+          :visible="conditionVisible"
+          @ok="handleConditionOk"
+          @cancel="handleConditionCancel"
+          :width="800"
+          cancelText="关闭">
+          <!-- :okButtonProps="{ class:{'jee-hidden': disableSubmit} }" -->
+          <interlock-condition-form ref="conditionForm" @ok="submitCallback"></interlock-condition-form>
+        </j-modal>
       </a-form-model>
     </j-form-container>
   </a-spin>
 </template>
 
 <script>
-  // var dianweiOptions = [
-  //   {
-  //     key: 'zhejiang',
-  //     value: 'zhejiang',
-  //     title: 'Zhejiang',
-  //     label: 'Zhejiang',
-  //     children: [
-  //       {
-  //         key: 'hangzhou',
-  //         value: 'hangzhou',
-  //         title: 'Hangzhou',
-  //         label: 'Hangzhou',
-  //         children: [
-  //           {
-  //             key: 'xihu',
-  //             value: 'xihu',
-  //             title: 'West Lake',
-  //             label: 'West Lake',
-  //           },
-  //         ],
-  //       },
-  //     ],
-  //   },
-  //   {
-  //     key: 'jiangsu',
-  //     value: 'jiangsu',
-  //     title: 'Jiangsu',
-  //     label: 'Jiangsu',
-  //     children: [
-  //       {
-  //         key: 'nanjing',
-  //         value: 'nanjing',
-  //         title: 'Nanjing',
-  //         label: 'Nanjing',
-  //         children: [
-  //           {
-  //             key: 'zhonghuamen',
-  //             value: 'zhonghuamen',
-  //             title: 'Zhong Hua Men',
-  //             label: 'Zhong Hua Men',
-  //           },
-  //         ],
-  //       },
-  //     ],
-  //   },
-  // ]
-  var dianweiOptions = [
-    {
-      info: 'zhejiang1',
-      name: 'Zhejiang1',
-      children: [
-        {
-          info: 'hangzhou',
-          name: 'Hangzhou',
-          children: [
-            {
-              info: 'dianwei&65',
-              name: 'West Lake',
-            },
-          ],
-        },
-      ],
-    },
-    {
-      info: 'jiangsu',
-      name: 'Jiangsu',
-      children: [
-        {
-          info: 'nanjing',
-          name: 'Nanjing',
-          children: [
-            {
-              info: 'dianwei&65',
-              name: 'Zhong Hua Men',
-            },
-          ],
-        },
-      ],
-    },
-  ]
-  import { httpAction, getAction } from '@/api/manage'
+  import { httpAction, getAction, postAction } from '@/api/manage'
   import { validateDuplicateValue } from '@/utils/util'
   import InterlockConditionForm from './InterlockConditionForm.vue'
 
@@ -206,22 +133,108 @@
         },
         confirmLoading: false,
         validatorRules: {
+          interlockName: [{
+            required: true, message: '请输入联锁名称!',
+          }],
+          ljgx: [{
+            required: true, message: '请输入逻辑关系!',
+          }],
+          interlockOutValueData: [{
+            required: true, message: '请选择联锁输出值位号!',
+          }],
         },
         url: {
           interLockSelect: '/sys/dict/loadTreeData',
           add: "/summary/interlockSummary/add",
           edit: "/summary/interlockSummary/edit",
-          queryById: "/summary/interlockSummary/queryById"
+          queryById: "/summary/interlockSummary/queryById",
+          getTagInfo: "/iotedgeCollectData/iotedgeCollectData/getTagInfo",
         },
         customFieldNames: {
           label: 'name',
           value: 'info',
           children: 'children'
         },
-        dianweiOptions: dianweiOptions,
         apparatusData: [],
         systemData: [],
-        interLockData: []
+        interLockData: [],
+        // 设备-模块-位号
+        tagDataOptions: [],
+        // 新增联锁条件
+        conditionTitle: '新增联锁条件',
+        conditionVisible: false,
+        // 联锁条件表格
+        dataSource: [],
+        columns: [
+          {
+            title: '序号',
+            dataIndex: '',
+            key:'rowIndex',
+            width:60,
+            align:"center",
+            customRender:function (t,r,index) {
+              return parseInt(index)+1;
+            }
+          },
+          {
+            title:'联锁条件',
+            align:"center",
+            dataIndex: 'interlockConditionTag'
+          },
+          {
+            title:'仪表状态依据',
+            align:"center",
+            dataIndex: 'instrumentStatusJuge'
+          },
+          {
+            title:'仪表状态内容',
+            align:"center",
+            dataIndex: 'instrumentStatusTag'
+          },
+          {
+            title:'描述',
+            align:"center",
+            dataIndex: 'description'
+          },
+          {
+            title:'联锁设定值',
+            align:"center",
+            dataIndex: 'interlockSetValue'
+          },
+          {
+            title:'当前值位号',
+            align:"center",
+            dataIndex: 'currentValueTag'
+          },
+          {
+            title:'旁路状态',
+            align:"center",
+            dataIndex: 'bypassTag'
+          },
+          {
+            title:'输入卡件状态',
+            align:"center",
+            dataIndex: 'inputStatusTag'
+          },
+          {
+            title:'输出卡件状态',
+            align:"center",
+            dataIndex: 'outputStatusTag'
+          },
+          {
+            title:'MP状态',
+            align:"center",
+            dataIndex: 'mpStatusTag'
+          },
+          {
+            title: '操作',
+            dataIndex: 'action',
+            align:"center",
+            fixed:"right",
+            width:147,
+            scopedSlots: { customRender: 'action' }
+          }
+        ],
       }
     },
     computed: {
@@ -235,11 +248,19 @@
       },
     },
     created () {
+      this.getTagInfo()
       this.getData('0', 'apparatusData')
        //备份model原始值
       this.modelDefault = JSON.parse(JSON.stringify(this.model));
     },
     methods: {
+      // 获取所有位号
+      getTagInfo(){
+        postAction(this.url.getTagInfo).then(res => {
+          console.log(res)
+          this.tagDataOptions = res.result
+        })
+      },
       // 获取装置/系统/联锁数据--默认获取装置数据
       getData(pid, dataName){
         let param = {
@@ -257,6 +278,17 @@
           }
         })
       },
+      handleConditionCancel(){
+        this.conditionVisible = false
+      },
+      handleConditionOk(){
+        this.$refs.conditionForm.submitForm();
+      },
+      submitCallback(model){
+        console.log(model)
+        this.dataSource.push(model)
+        this.conditionVisible = false
+      },
       // 装置选择改变时
       handleApparatusChange(e){
         console.log(e)
@@ -274,10 +306,14 @@
       displayRender({ labels }) {
         return labels[labels.length - 1];
       },
-      // 位选择改变
+      // 位选择改变
       dianwerChange(e){
         console.log(e)
       },
+      // 新增联锁条件
+      handleAddCondition(){
+        this.conditionVisible = true
+      },
       add () {  
         this.edit(this.modelDefault);
       },
@@ -300,6 +336,13 @@
               httpurl+=this.url.edit;
                method = 'put';
             }
+            // 转换数据
+            this.model.interlockDetailAddDTOList = this.dataSource
+            // 联锁输出值位号
+            this.model.deviceld = this.model.interlockOutValueData[0]
+            this.model.moduleName = this.model.interlockOutValueData[1]
+            this.model.interlockOutValueTag = (this.model.interlockOutValueData[2].split('&'))[0]
+            this.model.interlockOutValue = (this.model.interlockOutValueData[2].split('&'))[1]
             httpAction(httpurl,this.model,method).then((res)=>{
               if(res.success){
                 that.$message.success(res.message);

+ 0 - 84
src/views/module_interLock/InterlockSummary/modules/InterlockSummaryModal.Style#Drawer.vue

@@ -1,84 +0,0 @@
-<template>
-  <a-drawer
-    :title="title"
-    :width="width"
-    placement="right"
-    :closable="false"
-    @close="close"
-    destroyOnClose
-    :visible="visible">
-    <interlock-summary-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit" normal></interlock-summary-form>
-    <div class="drawer-footer">
-      <a-button @click="handleCancel" style="margin-bottom: 0;">关闭</a-button>
-      <a-button v-if="!disableSubmit"  @click="handleOk" type="primary" style="margin-bottom: 0;">提交</a-button>
-    </div>
-  </a-drawer>
-</template>
-
-<script>
-
-  import InterlockSummaryForm from './InterlockSummaryForm'
-
-  export default {
-    name: 'InterlockSummaryModal',
-    components: {
-      InterlockSummaryForm
-    },
-    data () {
-      return {
-        title:"操作",
-        width:800,
-        visible: false,
-        disableSubmit: false
-      }
-    },
-    methods: {
-      add () {
-        this.visible=true
-        this.$nextTick(()=>{
-          this.$refs.realForm.add();
-        })
-      },
-      edit (record) {
-        this.visible=true
-        this.$nextTick(()=>{
-          this.$refs.realForm.edit(record);
-        });
-      },
-      close () {
-        this.$emit('close');
-        this.visible = false;
-      },
-      submitCallback(){
-        this.$emit('ok');
-        this.visible = false;
-      },
-      handleOk () {
-        this.$refs.realForm.submitForm();
-      },
-      handleCancel () {
-        this.close()
-      }
-    }
-  }
-</script>
-
-<style lang="less" scoped>
-/** Button按钮间距 */
-  .ant-btn {
-    margin-left: 30px;
-    margin-bottom: 30px;
-    float: right;
-  }
-  .drawer-footer{
-    position: absolute;
-    bottom: -8px;
-    width: 100%;
-    border-top: 1px solid #e8e8e8;
-    padding: 10px 16px;
-    text-align: right;
-    left: 0;
-    background: #fff;
-    border-radius: 0 0 2px 2px;
-  }
-</style>