DetailModal.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. <div class="">
  15. <a-divider class="divider">公共设备控制</a-divider>
  16. <div>
  17. <div v-for="(pumpType, index) in publicPumpCtrlType" :key="index">
  18. <div class="device-group" v-for="key in 2" :key="key">
  19. <div class="title">#{{ key }}{{ pumpType.title }}:</div>
  20. <div class="btn-group">
  21. <a-button
  22. class="btn"
  23. v-for="(pump, i) in PumpCtrlItems"
  24. :key="i"
  25. type="primary"
  26. @click="handlerFn(`${pumpType.code}${key}${pump.code}`)"
  27. >#{{ key }}{{ pumpType.title }}{{ pump.title }}</a-button
  28. >
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="">
  35. <a-divider class="divider">单动控制</a-divider>
  36. <div class="parameter-title group-parameter-title"><SvgIcon class="icon" size="14" name="pulp-title" /><span>泵站控制</span></div>
  37. <div class="vent-margin-b-10">
  38. <div v-for="(pumpType, index) in pumpCtrlType" :key="index">
  39. <div class="device-group" v-for="key in 2" :key="key">
  40. <div class="title">#{{ key }}{{ pumpType.title }}:</div>
  41. <div class="btn-group">
  42. <a-button
  43. class="btn"
  44. v-for="(pump, i) in PumpCtrlItems"
  45. :key="i"
  46. type="primary"
  47. @click="handlerFn(`${pumpType.code}${key}${pump.code}`)"
  48. >#{{ key }}{{ pumpType.title }}{{ pump.title }}</a-button
  49. >
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="parameter-title group-parameter-title"><SvgIcon class="icon" size="14" name="pulp-title" /><span>阀门控制</span></div>
  55. <div v-for="key in 2" :key="key">
  56. <div class="device-group" v-for="(valveType, index) in valveCtrlType" :key="index">
  57. <div class="title">#{{ key }}{{ valveType.title }}:</div>
  58. <div class="btn-group">
  59. <a-button
  60. class="btn"
  61. v-for="(valve, i) in valveCtrl"
  62. :key="i"
  63. type="primary"
  64. @click="handlerFn(`CentrifugalPump${key}_${valveType.code}${valve.code}`)"
  65. >#{{ key }}{{ valveType.title }}{{ valve.title }}</a-button
  66. >
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </BasicModal>
  73. </template>
  74. <script lang="ts" setup>
  75. import { onMounted, ref, defineEmits, onUnmounted, inject } from 'vue';
  76. import { BasicModal, useModalInner } from '/@/components/Modal';
  77. import { pumpCtrlType, valveCtrlType, valveCtrl, PumpCtrlItems, publicPumpCtrlType } from '../gasPump.data';
  78. import { SvgIcon } from '/@/components/Icon';
  79. import { message } from 'ant-design-vue';
  80. import { ExclamationCircleFilled } from '@ant-design/icons-vue';
  81. import { deviceControlApi } from '/@/api/vent/index';
  82. const globalConfig = inject('globalConfig');
  83. const emit = defineEmits(['close', 'register']);
  84. const props = defineProps({
  85. deviceType: {
  86. type: String,
  87. required: true,
  88. },
  89. deviceId: {
  90. type: String,
  91. required: true,
  92. },
  93. });
  94. const passWord = ref('');
  95. // 注册 modal
  96. const [register, { closeModal }] = useModalInner(() => {
  97. passWord.value = '';
  98. });
  99. async function onSubmit() {
  100. emit('close');
  101. closeModal();
  102. }
  103. function handlerFn(paramcode) {
  104. if (!passWord.value) {
  105. message.warning('请先输入密码!!!');
  106. return;
  107. }
  108. let value = null;
  109. const data = {
  110. deviceid: props.deviceId,
  111. devicetype: props.deviceType,
  112. paramcode: paramcode,
  113. password: passWord.value,
  114. value: value,
  115. };
  116. deviceControlApi(data)
  117. .then((res) => {
  118. if (globalConfig.History_Type == 'remote') {
  119. message.success('指令已下发至生产管控平台成功!');
  120. } else {
  121. message.success('指令已下发成功!');
  122. }
  123. })
  124. .catch((err) => {
  125. // message.success('控制异常');
  126. });
  127. }
  128. onMounted(async () => {});
  129. onUnmounted(() => {});
  130. </script>
  131. <style scoped lang="less">
  132. @import '/@/design/vent/modal.less';
  133. @import '../../comment/less/workFace.less';
  134. @ventSpace: zxm;
  135. .@{ventSpace}-input {
  136. width: 150px;
  137. }
  138. .password-box {
  139. .warning-text {
  140. font-size: 24px;
  141. margin-left: 8px;
  142. }
  143. .input-box {
  144. margin-top: 10px;
  145. margin-left: 40px;
  146. .label {
  147. width: 80px;
  148. color: #73e8fe;
  149. }
  150. }
  151. }
  152. .btn-group {
  153. margin-bottom: 8px;
  154. .btn-item {
  155. width: calc(50% - 16px);
  156. margin: 0 4px;
  157. }
  158. }
  159. .divider {
  160. color: #fff;
  161. border-color: #73e8fe;
  162. }
  163. .parameter-title {
  164. margin-bottom: 15px;
  165. }
  166. .device-group {
  167. display: flex;
  168. align-items: center;
  169. .title {
  170. width: 100px;
  171. color: #73e8fe;
  172. }
  173. .btn {
  174. margin: 0 5px;
  175. }
  176. }
  177. </style>