balancePressHomeBD.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <a-spin tip="Loading..." :spinning="loading">
  3. <div class="monitor-container">
  4. <div class="lr left-box">
  5. <ventBox1>
  6. <template #title>
  7. <div>均压与低氧参数监测与设置</div>
  8. </template>
  9. <template #container>
  10. <div class="vent-flex-row-between auto-control mt-10px mb-10px">
  11. <div class="title">自动调节:</div>
  12. <a-radio-group v-model:value="isAutoControl" name="radioGroup" @change="changeType(isAutoControl)">
  13. <a-radio value="1">关闭</a-radio>
  14. <a-radio value="2">开启</a-radio>
  15. </a-radio-group>
  16. </div>
  17. <div class="input-box">
  18. <div class="divider-line">开始条件</div>
  19. <div v-for="(item, index) in settingParam1" class="input-item" :key="index">
  20. <div class="title">{{ item.title }}:</div>
  21. <a-input-number class="input-value" v-model:value="formData[item.code]" placeholder="" />
  22. <div class="unit">{{ item.unit }}</div>
  23. </div>
  24. <div class="divider-line">调节参数</div>
  25. <div v-for="(item, index) in settingParam2" class="input-item" :key="index">
  26. <div class="title">{{ item.title }}:</div>
  27. <a-input-number class="input-value" v-model:value="formData[item.code]" placeholder="" />
  28. <div class="unit">{{ item.unit }}</div>
  29. </div>
  30. <div class="divider-line">结束时间</div>
  31. <div v-for="(item, index) in settingParam3" class="input-item" :key="index">
  32. <div class="title">{{ item.title }}:</div>
  33. <a-input-number class="input-value" v-model:value="formData[item.code]" placeholder="" />
  34. <div class="unit">{{ item.unit }}</div>
  35. </div>
  36. </div>
  37. <div class="btn-box" style="text-align: center">
  38. <div class="btn btn1" @click="modalVisible = true">提交</div>
  39. </div>
  40. </template>
  41. </ventBox1>
  42. </div>
  43. <div class="lr">
  44. <ventBox1>
  45. <template #title>
  46. <div>均压工作面风机与风门联动</div>
  47. </template>
  48. <template #container>
  49. <div class="vent-flex-row-between auto-control mt-10px mb-10px">
  50. <div class="title">自动调节:</div>
  51. <a-radio-group v-model:value="avePress.isAuto" name="radioGroup">
  52. <a-radio :value="false">关闭</a-radio>
  53. <a-radio :value="true">开启</a-radio>
  54. </a-radio-group>
  55. </div>
  56. <div class="btn-box" style="text-align: center">
  57. <div class="btn btn1" @click="modalVisible = true">提交</div>
  58. </div>
  59. </template>
  60. </ventBox1>
  61. </div>
  62. <ModuleCommon
  63. v-for="cfg in configs"
  64. :key="cfg.deviceType"
  65. :show-style="cfg.showStyle"
  66. :module-data="cfg.moduleData"
  67. :module-name="cfg.moduleName"
  68. :device-type="cfg.deviceType"
  69. :data="selectData"
  70. :visible="true"
  71. />
  72. </div>
  73. <PasswordModal :modal-is-show="modalVisible" modal-title="提交" @handle-ok="handleControl" @handle-cancel="modalVisible = false" />
  74. </a-spin>
  75. </template>
  76. <script setup lang="ts">
  77. import { ref, onMounted, onUnmounted, defineProps } from 'vue';
  78. import { mountedThree, destroy, setModelType, updateText, play } from '../balancePress.threejs';
  79. import { list, submitEdit, subList } from '../balancePress.api';
  80. import ModuleCommon from '../../../home/configurable/components/ModuleCommon.vue';
  81. import { useInitConfigs } from '../../../home/configurable/hooks/useInit';
  82. import { useGlobSetting } from '/@/hooks/setting';
  83. import { settingParam1, settingParam2, settingParam3 } from '../balancePress.data';
  84. import { message } from 'ant-design-vue';
  85. import ventBox1 from '/@/components/vent/ventBox1.vue';
  86. import PasswordModal from '../../comment/components/PasswordModal.vue';
  87. import { get } from 'lodash-es';
  88. // import { Config } from '../../../deviceManager/configurationTable/types';
  89. const props = defineProps({
  90. deviceId: {
  91. type: String,
  92. require: true,
  93. },
  94. });
  95. const { sysOrgCode } = useGlobSetting();
  96. const loading = ref(false);
  97. // 监测数据
  98. const selectData = ref();
  99. // https获取监测数据
  100. let timer: any = null;
  101. function getMonitor(flag?) {
  102. if (Object.prototype.toString.call(timer) === '[object Null]') {
  103. timer = setTimeout(
  104. async () => {
  105. if (props.deviceId) {
  106. const data = await getDataSource(props.deviceId);
  107. // Object.assign(selectData, data);
  108. updateText(selectData);
  109. selectData.value = data;
  110. }
  111. if (timer) {
  112. timer = null;
  113. }
  114. await getMonitor();
  115. loading.value = false;
  116. },
  117. flag ? 0 : 1000
  118. );
  119. }
  120. }
  121. async function getDataSource(systemID) {
  122. const res = await list({ devicetype: 'sys', systemID });
  123. const result = Array.from(res.msgTxt).reduce(
  124. (obj: any, e: any) => {
  125. obj[e.type] = e;
  126. // if (true) {
  127. if (sysOrgCode === 'sdmtjtswmk') {
  128. if (e.type.startsWith('fanlocal')) {
  129. obj.fanlocal.datalist.push(...e.datalist);
  130. }
  131. if (e.type.startsWith('safetymonitor')) {
  132. e.datalist.forEach((ele) => {
  133. if (ele.strinstallpos.includes('风门')) {
  134. obj.gate.datalist.push(ele);
  135. } else if (ele.strinstallpos.includes('风窗')) {
  136. obj.window.datalist.push(ele);
  137. } else if (ele.strinstallpos.includes('工作面')) {
  138. obj.work_surface.datalist.push(ele);
  139. } else {
  140. obj.others.datalist.push(ele);
  141. }
  142. });
  143. }
  144. }
  145. return obj;
  146. },
  147. {
  148. /** 用于归类fanlocal */
  149. fanlocal: { datalist: [] },
  150. /** 用于归类gate */
  151. gate: { datalist: [] },
  152. /** 用于归类window */
  153. window: { datalist: [] },
  154. /** 用于归类work_surface */
  155. work_surface: { datalist: [] },
  156. others: { datalist: [] },
  157. }
  158. );
  159. return result;
  160. }
  161. // const configs = ref<Config[]>([
  162. // {
  163. // deviceType: '',
  164. // moduleName: '局扇',
  165. // pageType: 'balancePressHome',
  166. // moduleData: {
  167. // header: {
  168. // show: false,
  169. // readFrom: '',
  170. // selector: {
  171. // show: false,
  172. // value: '',
  173. // },
  174. // slot: {
  175. // show: false,
  176. // value: '',
  177. // },
  178. // },
  179. // background: {
  180. // show: false,
  181. // type: 'image',
  182. // link: '',
  183. // },
  184. // layout: {
  185. // direction: 'row',
  186. // items: [
  187. // {
  188. // name: 'complex_list',
  189. // basis: '50%',
  190. // },
  191. // {
  192. // name: 'complex_list',
  193. // basis: '50%',
  194. // },
  195. // ],
  196. // },
  197. // complex_list: [
  198. // {
  199. // type: 'G',
  200. // readFrom: 'fanlocal_steml_zj',
  201. // mapFromData: false,
  202. // items: [
  203. // {
  204. // title: '主机',
  205. // contents: [
  206. // {
  207. // label: '运行状态',
  208. // value: '${datalist[0].readData.Fan1StartStatus_str}',
  209. // color: 'blue',
  210. // },
  211. // {
  212. // label: '运行频率',
  213. // value: '${datalist[0].readData.Fan1fHz}',
  214. // color: 'blue',
  215. // },
  216. // {
  217. // label: '输出电压',
  218. // value: '${datalist[0].readData.Fan1fHz}',
  219. // color: 'blue',
  220. // },
  221. // ],
  222. // },
  223. // ],
  224. // },
  225. // {
  226. // type: 'G',
  227. // readFrom: 'fanlocal_steml_zj',
  228. // mapFromData: false,
  229. // items: [
  230. // {
  231. // title: '备机',
  232. // contents: [
  233. // {
  234. // label: '运行状态',
  235. // value: '${datalist[0].readData.Fan2StartStatus_str}',
  236. // color: 'blue',
  237. // },
  238. // {
  239. // label: '运行频率',
  240. // value: '${datalist[0].readData.Fan2fHz}',
  241. // color: 'blue',
  242. // },
  243. // {
  244. // label: '输出电压',
  245. // value: '${datalist[0].readData.Fan2fHz}',
  246. // color: 'blue',
  247. // },
  248. // ],
  249. // },
  250. // ],
  251. // },
  252. // ],
  253. // to: '',
  254. // },
  255. // showStyle: {
  256. // size: 'width:380px;height:200px;',
  257. // version: '原版',
  258. // position: 'top:150px;right:0;',
  259. // },
  260. // },
  261. // {
  262. // deviceType: '',
  263. // moduleName: '其他模块A',
  264. // pageType: 'balancePressHome',
  265. // moduleData: {
  266. // header: {
  267. // show: false,
  268. // readFrom: '',
  269. // selector: {
  270. // show: false,
  271. // value: '',
  272. // },
  273. // slot: {
  274. // show: false,
  275. // value: '',
  276. // },
  277. // },
  278. // background: {
  279. // show: false,
  280. // type: 'image',
  281. // link: '',
  282. // },
  283. // layout: {
  284. // direction: 'column',
  285. // items: [
  286. // {
  287. // name: 'list',
  288. // basis: '100%',
  289. // },
  290. // ],
  291. // },
  292. // list: [
  293. // {
  294. // type: 'K',
  295. // readFrom: 'windrect_ds_four.datalist[0]',
  296. // items: [
  297. // {
  298. // label: '网络状态',
  299. // value: '${readData.netStatus_str}',
  300. // color: 'blue',
  301. // },
  302. // ],
  303. // },
  304. // ],
  305. // to: '',
  306. // },
  307. // showStyle: {
  308. // size: 'width:380px;height:230px;',
  309. // version: '原版',
  310. // position: 'top:360px;right:0;',
  311. // },
  312. // },
  313. // ]);
  314. // const { configs, fetchConfigs } = useInitConfigs();
  315. const formData = ref({});
  316. // 默认初始是第一行
  317. const isAutoControl = ref('1');
  318. const changeType = (isAutoControl) => {
  319. isAutoControl;
  320. //
  321. };
  322. const modalVisible = ref(false);
  323. function handleControl(password) {
  324. submitEdit({
  325. id: avePress.value.id,
  326. password,
  327. isAuto: avePress.value.isAuto,
  328. })
  329. .then(() => {
  330. message.success('操作成功');
  331. getAvePress();
  332. })
  333. .catch(() => {
  334. message.error('操作失败');
  335. })
  336. .finally(() => {
  337. modalVisible.value = false;
  338. });
  339. }
  340. const avePress = ref<any>({ isAuto: false });
  341. function getAvePress() {
  342. subList({
  343. strType: 'sdg_fan_sys_gate',
  344. }).then(({ records }) => {
  345. avePress.value = get(records, '[0]');
  346. });
  347. }
  348. const { configs, fetchConfigs } = useInitConfigs();
  349. onMounted(() => {
  350. // getMonitor()
  351. // fetchConfigs('balancePressHome');
  352. getAvePress();
  353. loading.value = true;
  354. mountedThree().then(async () => {
  355. await setModelType('balancePressBase'); //balancePressBase
  356. loading.value = false;
  357. timer = null;
  358. await getMonitor(true);
  359. play('startSmoke', 'top', 30, 'open', 0);
  360. });
  361. // loading.value = false;
  362. // timer = null;
  363. // getMonitor(true);
  364. });
  365. onUnmounted(() => {
  366. destroy();
  367. if (timer) {
  368. clearTimeout(timer);
  369. }
  370. });
  371. </script>
  372. <style lang="less" scoped>
  373. @import '/@/design/vent/modal.less';
  374. @import '../../comment/less/workFace.less';
  375. @ventSpace: zxm;
  376. .monitor-container {
  377. margin-top: 60px;
  378. }
  379. </style>