DetailModalCC.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <BasicModal @register="register" title="设备控制" width="700px" v-bind="$attrs" @ok="onSubmit" @cancel="onSubmit">
  3. <div>
  4. <div class="password-box">
  5. <div class="vent-flex-row">
  6. <ExclamationCircleFilled style="color: #ffb700; font-size: 30px" />
  7. <div class="warning-text">请先输入密码再进行操作!</div>
  8. </div>
  9. <div class="vent-flex-row input-box">
  10. <div class="label">操作密码:</div>
  11. <a-input size="small" type="password" v-model:value="passWord" />
  12. </div>
  13. </div>
  14. <a-divider class="divider">设备控制</a-divider>
  15. <div class="">
  16. <template v-for="(ctrlItem, ctrlIndex) in detailCtrl" :key="ctrlIndex">
  17. <div class="parameter-title group-parameter-title"
  18. ><SvgIcon class="icon" size="14" name="pulp-title" /><span>{{ ctrlItem.title }}</span></div
  19. >
  20. <div class="vent-margin-b-10">
  21. <div v-for="(ctrlType, index) in ctrlItem.type" :key="index">
  22. <template v-for="(ctrlTitleItem, deviceTypeIndex) in ctrlType.childTitle" :key="deviceTypeIndex">
  23. <div class="device-group">
  24. <div class="title">{{ ctrlTitleItem }}:</div>
  25. <div class="btn-group">
  26. <a-button
  27. class="btn"
  28. v-for="(device, i) in ctrlItem.items"
  29. :key="i"
  30. type="primary"
  31. @click="handlerFn(ctrlType.key[deviceTypeIndex] + device.code)"
  32. >{{ device.title }}</a-button
  33. >
  34. </div>
  35. </div>
  36. </template>
  37. </div>
  38. </div>
  39. </template>
  40. </div>
  41. </div>
  42. </BasicModal>
  43. </template>
  44. <script lang="ts" setup>
  45. import { onMounted, ref, defineEmits, onUnmounted, inject } from 'vue';
  46. import { BasicModal, useModalInner } from '/@/components/Modal';
  47. import { detailCtrl } from '../gasPump.dataCc';
  48. import { SvgIcon } from '/@/components/Icon';
  49. import { message } from 'ant-design-vue';
  50. import { ExclamationCircleFilled } from '@ant-design/icons-vue';
  51. import { deviceControlApi } from '/@/api/vent/index';
  52. const globalConfig = inject('globalConfig');
  53. const emit = defineEmits(['close', 'register']);
  54. const props = defineProps({
  55. deviceType: {
  56. type: String,
  57. required: true,
  58. },
  59. deviceId: {
  60. type: String,
  61. required: true,
  62. },
  63. });
  64. const passWord = ref('');
  65. // 注册 modal
  66. const [register, { closeModal }] = useModalInner(() => {
  67. passWord.value = '';
  68. });
  69. async function onSubmit() {
  70. emit('close');
  71. closeModal();
  72. }
  73. function handlerFn(paramcode) {
  74. if (!passWord.value) {
  75. message.warning('请先输入密码!!!');
  76. return;
  77. }
  78. let value = null;
  79. const data = {
  80. deviceid: props.deviceId,
  81. devicetype: props.deviceType,
  82. paramcode: paramcode,
  83. password: passWord.value,
  84. value: value,
  85. };
  86. deviceControlApi(data)
  87. .then((res) => {
  88. if (globalConfig.History_Type == 'remote') {
  89. message.success('指令已下发至生产管控平台成功!');
  90. } else {
  91. message.success('指令已下发成功!');
  92. }
  93. })
  94. .catch((err) => {
  95. // message.success('控制异常');
  96. });
  97. }
  98. onMounted(async () => {});
  99. onUnmounted(() => {});
  100. </script>
  101. <style scoped lang="less">
  102. @import '/@/design/vent/modal.less';
  103. @import '../../comment/less/workFace.less';
  104. @ventSpace: zxm;
  105. .@{ventSpace}-input {
  106. width: 150px;
  107. }
  108. .password-box {
  109. .warning-text {
  110. font-size: 24px;
  111. margin-left: 8px;
  112. }
  113. .input-box {
  114. margin-top: 10px;
  115. margin-left: 40px;
  116. .label {
  117. width: 80px;
  118. color: #73e8fe;
  119. }
  120. }
  121. }
  122. .btn-group {
  123. margin-bottom: 8px;
  124. .btn-item {
  125. width: calc(50% - 16px);
  126. margin: 0 4px;
  127. }
  128. }
  129. .divider {
  130. color: #fff;
  131. border-color: #73e8fe;
  132. }
  133. .parameter-title {
  134. margin-bottom: 15px;
  135. }
  136. .device-group {
  137. display: flex;
  138. align-items: center;
  139. .title {
  140. width: 100px;
  141. color: #73e8fe;
  142. }
  143. .btn {
  144. margin: 0 5px;
  145. }
  146. }
  147. </style>