InterlockSummaryForm.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  5. <div class="interlock-summary-item">
  6. <div class="interlock-summary-item-title">联锁基本信息</div>
  7. <a-row>
  8. <!-- <a-col :span="12">
  9. <a-form-model-item label="装置" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockApparatusId">
  10. <a-select
  11. v-model="model.interlockApparatusId"
  12. show-search
  13. placeholder="请选择装置"
  14. @change="handleApparatusChange"
  15. >
  16. <a-select-option v-for="(item) in apparatusData" :key="item.key" :value="item.key">{{ item.title }}</a-select-option>
  17. </a-select>
  18. </a-form-model-item>
  19. </a-col> -->
  20. <!-- <a-col :span="12">
  21. <a-form-model-item label="系统" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockSystemId">
  22. <a-select
  23. v-model="model.interlockSystemId"
  24. show-search
  25. placeholder="请选择系统"
  26. @change="handleSystemChange"
  27. >
  28. <a-select-option v-for="(item) in systemData" :key="item.key" :value="item.key">{{ item.title }}</a-select-option>
  29. </a-select>
  30. </a-form-model-item>
  31. </a-col> -->
  32. <a-col :span="12">
  33. <a-form-model-item label="联锁名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockName">
  34. <a-input v-model="model.interlockName" placeholder="请输入联锁名称"></a-input>
  35. </a-form-model-item>
  36. </a-col>
  37. <a-col :span="12">
  38. <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
  39. <a-input v-model="model.remark" placeholder="请输入备注"></a-input>
  40. </a-form-model-item>
  41. </a-col>
  42. </a-row>
  43. </div>
  44. <!-- 联锁条件信息 -->
  45. <div class="interlock-summary-item" style="padding-bottom: 12px;">
  46. <div class="interlock-summary-item-title u-flex-jab">
  47. <div>联锁条件信息</div>
  48. <a-button @click="handleAddCondition" type="primary" icon="plus">新增联锁条件</a-button>
  49. </div>
  50. <a-row>
  51. <a-col :span="12">
  52. <a-form-model-item label="逻辑关系" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ljgx">
  53. <!-- <a-input v-model="model.ljgx" placeholder="请输入逻辑关系"></a-input> -->
  54. <j-dict-select-tag v-model="model.ljgx" placeholder="请选择操作类型" dictCode="ljgx"/>
  55. </a-form-model-item>
  56. </a-col>
  57. </a-row>
  58. <!-- 联锁条件表格 -->
  59. <a-table
  60. ref="table"
  61. size="middle"
  62. :scroll="{x:true}"
  63. bordered
  64. :pagination="false"
  65. :rowKey="(record,index)=>{return index}"
  66. :columns="columns"
  67. :dataSource="conditionDataSource"
  68. class="j-table-force-nowrap"
  69. style="margin: 0 12px;">
  70. <!-- 仪表状态依据 -->
  71. <span slot="instrumentStatusJuge" slot-scope="text, record">
  72. <template v-if="record.instrumentStatusJuge === '0'">
  73. <span>位号读取</span>
  74. </template>
  75. <template v-if="record.instrumentStatusJuge === '1'">
  76. <span>高低限判断</span>
  77. </template>
  78. <template v-if="record.instrumentStatusJuge === '2'">
  79. <span>突变超限判断</span>
  80. </template>
  81. </span>
  82. <!-- 仪表状态内容 -->
  83. <span slot="instrumentStatusContent" slot-scope="text, record">
  84. <template v-if="record.instrumentStatusJuge === '0'">
  85. <span>位号:{{ record.instrumentStatusTag }}</span>
  86. </template>
  87. <template v-if="record.instrumentStatusJuge === '1'">
  88. <span>位号:{{ record.ysmnlTag }}</span><br/>
  89. <span>
  90. <span>高限值:{{ record.upperLimit }}</span>
  91. <span>低限值:{{ record.lowerLimit }}</span>
  92. </span>
  93. </template>
  94. <template v-if="record.instrumentStatusJuge === '2'">
  95. <span>位号:{{ record.ysmnlTag }}</span>
  96. <span>
  97. <span>时间:{{ record.thresholdTime }}</span>
  98. <span>阈值:{{ record.thresholdValue }}</span>
  99. </span>
  100. </template>
  101. </span>
  102. <!-- 是否旁路 -->
  103. <span slot="ifBypass" slot-scope="text, record">
  104. <span v-if="record.ifBypass === '1'">{{ record.bypassTag }}</span>
  105. <span v-if="record.ifBypass === '0'">{{ record.bypass }}</span>
  106. </span>
  107. <!-- 操作 -->
  108. <span slot="action" slot-scope="text, record, index">
  109. <a @click="handleEditCondition(record, index)">编辑</a>
  110. <a-divider type="vertical" />
  111. <a @click="handleCopyCondition(record, index)">复制</a>
  112. <a-divider type="vertical" />
  113. <a-popconfirm title="确定删除吗?" @confirm="() => handleDeleteCondition(record, index)">
  114. <a>删除</a>
  115. </a-popconfirm>
  116. </span>
  117. </a-table>
  118. </div>
  119. <!-- 联锁输出 -->
  120. <div class="interlock-summary-item">
  121. <div class="interlock-summary-item-title">联锁输出</div>
  122. <a-row>
  123. <a-col :span="12">
  124. <a-form-model-item label="联锁输出值位号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="interlockOutValueData">
  125. <a-cascader
  126. v-model="model.interlockOutValueData"
  127. :options="tagDataOptions"
  128. :display-render="displayRender"
  129. :fieldNames="customFieldNames"
  130. expand-trigger="hover"
  131. placeholder="请选择位号"
  132. @change="dianwerChange"
  133. />
  134. </a-form-model-item>
  135. </a-col>
  136. </a-row>
  137. </div>
  138. <!-- 新增联锁条件 -->
  139. <j-modal
  140. :title="conditionTitle"
  141. :visible="conditionVisible"
  142. @ok="handleConditionOk"
  143. @cancel="handleConditionCancel"
  144. :width="800"
  145. cancelText="关闭">
  146. <!-- :okButtonProps="{ class:{'jee-hidden': disableSubmit} }" -->
  147. <interlock-condition-form ref="conditionForm" @ok="submitCallback"></interlock-condition-form>
  148. </j-modal>
  149. </a-form-model>
  150. </j-form-container>
  151. </a-spin>
  152. </template>
  153. <script>
  154. import { httpAction, getAction, postAction } from '@/api/manage'
  155. import { validateDuplicateValue } from '@/utils/util'
  156. import InterlockConditionForm from './InterlockConditionForm.vue'
  157. // import { mixinDevice } from '@/utils/mixin'
  158. // import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  159. export default {
  160. name: 'InterlockSummaryForm',
  161. // mixins:[JeecgListMixin, mixinDevice],
  162. components: {
  163. InterlockConditionForm
  164. },
  165. props: {
  166. //表单禁用
  167. disabled: {
  168. type: Boolean,
  169. default: false,
  170. required: false
  171. },
  172. addInterlock: {
  173. type: Object,
  174. default: function(){
  175. return {} // 使用工厂函数返回默认值
  176. }
  177. },
  178. },
  179. data () {
  180. return {
  181. model:{
  182. },
  183. labelCol: {
  184. xs: { span: 24 },
  185. sm: { span: 5 },
  186. },
  187. wrapperCol: {
  188. xs: { span: 24 },
  189. sm: { span: 16 },
  190. },
  191. confirmLoading: false,
  192. validatorRules: {
  193. interlockName: [{
  194. required: true, message: '请输入联锁名称!',
  195. }],
  196. ljgx: [{
  197. required: true, message: '请输入逻辑关系!',
  198. }],
  199. interlockOutValueData: [{
  200. required: true, message: '请选择联锁输出值位号!',
  201. }],
  202. },
  203. url: {
  204. interLockSelect: '/sys/dict/loadTreeData',
  205. add: "/summary/interlockSummary/addLS",
  206. edit: "/summary/interlockSummary/editLS",
  207. queryById: "/summary/interlockSummary/queryById",
  208. getLsAllData: "/summary/interlockSummary/xxxxLS",
  209. getTagInfo: "/iotedgeCollectData/iotedgeCollectData/getTagInfo",
  210. },
  211. customFieldNames: {
  212. label: 'name',
  213. value: 'info',
  214. children: 'children'
  215. },
  216. apparatusData: [],
  217. systemData: [],
  218. interLockData: [],
  219. // 设备-模块-位号
  220. tagDataOptions: [],
  221. // 新增联锁条件
  222. conditionTitle: '新增联锁条件',
  223. conditionVisible: false,
  224. // 联锁条件表格
  225. conditionDataSource: [],
  226. columns: [
  227. {
  228. title: '序号',
  229. dataIndex: '',
  230. key:'rowIndex',
  231. width:60,
  232. align:"center",
  233. customRender:function (t,r,index) {
  234. return parseInt(index)+1;
  235. }
  236. },
  237. {
  238. title:'联锁条件',
  239. align:"center",
  240. dataIndex: 'interlockConditionTag'
  241. },
  242. {
  243. title:'仪表状态依据',
  244. align:"center",
  245. // dataIndex: 'instrumentStatusJuge',
  246. scopedSlots: { customRender: 'instrumentStatusJuge' }
  247. },
  248. {
  249. title:'仪表状态内容',
  250. align:"center",
  251. // dataIndex: 'instrumentStatusTag',
  252. scopedSlots: { customRender: 'instrumentStatusContent' }
  253. },
  254. {
  255. title:'描述',
  256. align:"center",
  257. dataIndex: 'description'
  258. },
  259. {
  260. title:'联锁设定值位号',
  261. align:"center",
  262. dataIndex: 'interlockSetValue'
  263. },
  264. {
  265. title:'当前值位号',
  266. align:"center",
  267. dataIndex: 'currentValueTag'
  268. },
  269. {
  270. title:'旁路状态位号',
  271. align:"center",
  272. scopedSlots: { customRender: 'ifBypass' }
  273. },
  274. {
  275. title:'输入卡件状态位号',
  276. align:"center",
  277. dataIndex: 'inputStatusTag'
  278. },
  279. {
  280. title:'输出卡件状态位号',
  281. align:"center",
  282. dataIndex: 'outputStatusTag'
  283. },
  284. {
  285. title:'MP状态位号',
  286. align:"center",
  287. dataIndex: 'mpStatusTag'
  288. },
  289. {
  290. title: '操作',
  291. dataIndex: 'action',
  292. align:"center",
  293. fixed:"right",
  294. width:147,
  295. scopedSlots: { customRender: 'action' }
  296. }
  297. ],
  298. tableClickRowIndex: -1,
  299. }
  300. },
  301. computed: {
  302. formDisabled(){
  303. return this.disabled
  304. },
  305. },
  306. // watch: {
  307. // 'model.interlockName'(val) {
  308. // console.log('value', val);
  309. // },
  310. // },
  311. created () {
  312. console.log('弹窗', this.addInterlock)
  313. this.getTagInfo()
  314. this.getData('0', 'apparatusData')
  315. //备份model原始值
  316. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  317. },
  318. methods: {
  319. // 获取所有位号
  320. getTagInfo(){
  321. postAction(this.url.getTagInfo).then(res => {
  322. console.log(res)
  323. this.tagDataOptions = res.result
  324. })
  325. },
  326. // 获取装置/系统/联锁数据--默认获取装置数据
  327. getData(pid, dataName){
  328. let param = {
  329. pid: pid,
  330. tableName: 'interlock_base',
  331. text: 'interlock_name',
  332. code: 'id',
  333. pidField: 'pid',
  334. hasChildField: 'has_child',
  335. condition: ''
  336. }
  337. getAction(this.url.interLockSelect,param).then(res=>{
  338. if(res.success){
  339. this[dataName] = res.result
  340. }
  341. })
  342. },
  343. // 联锁条件弹窗-取消
  344. handleConditionCancel(){
  345. this.conditionVisible = false
  346. },
  347. // 联锁条件弹窗-确认
  348. handleConditionOk(){
  349. this.$refs.conditionForm.submitForm();
  350. },
  351. // 联锁条件弹窗-确认回调
  352. submitCallback(model){
  353. if(this.tableClickRowIndex >= 0){
  354. // 编辑回调
  355. this.conditionDataSource[this.tableClickRowIndex] = model
  356. } else {
  357. // 新增回调
  358. this.conditionDataSource.push(model)
  359. }
  360. this.conditionVisible = false
  361. },
  362. // 装置选择改变时
  363. handleApparatusChange(e){
  364. console.log(e)
  365. this.getData(e, 'systemData')
  366. },
  367. // 系统选择改变时
  368. handleSystemChange(e){
  369. console.log(e)
  370. this.getData(e, 'interLockData')
  371. },
  372. interLockSearch(searchText){
  373. console.log(searchText)
  374. // this.interLockData = !searchText ? [] : [searchText, searchText.repeat(2), searchText.repeat(3)]
  375. },
  376. displayRender({ labels }) {
  377. return labels[labels.length - 1];
  378. },
  379. // 位号选择改变
  380. dianwerChange(e){
  381. console.log(e)
  382. },
  383. // 新增联锁条件
  384. handleAddCondition(){
  385. this.tableClickRowIndex = -1
  386. this.conditionVisible = true
  387. },
  388. // 编辑联锁条件
  389. handleEditCondition(record, index){
  390. console.log(index)
  391. this.tableClickRowIndex = index
  392. this.conditionVisible = true
  393. this.$nextTick(()=>{
  394. this.$refs.conditionForm.edit(record);
  395. })
  396. },
  397. // 复制联锁条件
  398. handleCopyCondition(record){
  399. this.tableClickRowIndex = -1
  400. this.conditionVisible = true
  401. this.$nextTick(()=>{
  402. this.$refs.conditionForm.edit(record);
  403. })
  404. },
  405. // 删除联锁条件
  406. handleDeleteCondition(record, index){
  407. this.conditionDataSource.splice(index, 1)
  408. },
  409. // 新增联锁-弹窗
  410. add () {
  411. // this.edit(this.modelDefault);
  412. this.visible = true;
  413. },
  414. // 编辑联锁-弹窗
  415. edit (record) {
  416. // this.model = Object.assign({}, record);
  417. // 编辑时获取当前联锁所有详细信息
  418. getAction(this.url.getLsAllData, {id: record.summaryid}).then(res => {
  419. console.log(res)
  420. var resultArr = res.result
  421. this.model = resultArr
  422. this.conditionDataSource = resultArr.interlockDetailEditQueryVOList
  423. this.model.interlockOutValueData = [resultArr.deviceId, resultArr.moduleName, resultArr.interlockOutValueTag+'&'+resultArr.interlockOutValue]
  424. })
  425. this.visible = true;
  426. },
  427. submitForm () {
  428. const that = this;
  429. // 触发表单验证
  430. this.$refs.form.validate(valid => {
  431. if (valid) {
  432. if(this.conditionDataSource.length===0){
  433. this.$message.error('联锁条件未设置')
  434. return false
  435. }
  436. that.confirmLoading = true;
  437. let httpurl = '';
  438. let method = '';
  439. if(!this.model.id){
  440. httpurl+=this.url.add;
  441. method = 'post';
  442. }else{
  443. httpurl+=this.url.edit;
  444. method = 'put';
  445. }
  446. // 装置系统id赋值
  447. if(this.addInterlock && this.addInterlock.interlockType === '1'){
  448. // 当前是新增-用树选择的装置系统进行赋值
  449. this.model.interlockApparatusId = this.addInterlock.pid
  450. this.model.interlockSystemId = this.addInterlock.id
  451. }
  452. // 转换数据
  453. this.model.interlockDetailAddDTOList = this.conditionDataSource
  454. // 联锁输出值位号
  455. this.model.deviceId = this.model.interlockOutValueData[0]
  456. this.model.moduleName = this.model.interlockOutValueData[1]
  457. this.model.interlockOutValueTag = (this.model.interlockOutValueData[2].split('&'))[0]
  458. this.model.interlockOutValue = (this.model.interlockOutValueData[2].split('&'))[1]
  459. httpAction(httpurl,this.model,method).then((res)=>{
  460. if(res.success){
  461. that.$message.success(res.message);
  462. that.$emit('ok');
  463. }else{
  464. that.$message.warning(res.message);
  465. }
  466. }).finally(() => {
  467. that.confirmLoading = false;
  468. })
  469. }
  470. })
  471. },
  472. }
  473. }
  474. </script>
  475. <style lang="less">
  476. .interlock-summary-item{
  477. // box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);
  478. margin-bottom: 12px;
  479. // border-radius: 4px;
  480. }
  481. .interlock-summary-item-title{
  482. background-color: #F5F7FA;
  483. line-height: 40px;
  484. font-size: 15px;
  485. padding: 0 20px;
  486. margin-bottom: 10px;
  487. border-bottom: 1px solid #f3f3f3;
  488. }
  489. .u-flex-jab{
  490. display: flex;
  491. justify-content: space-between;
  492. align-items: center;
  493. }
  494. </style>