balancePressHomeBD.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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 :value="avePress.isAuto" name="radioGroup" @change="changeIsAuto">
  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="openModal">控制密码修改</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. <UpdatePassword @register="updatePwdRegister" @submit="changePassword" />
  75. </a-spin>
  76. </template>
  77. <script setup lang="ts">
  78. import { ref, onMounted, onUnmounted, defineProps } from 'vue';
  79. import { mountedThree, destroy, setModelType, updateText, play } from '../balancePress.threejs';
  80. import { list, submitEdit, subList, updatePassword, validPassword } from '../balancePress.api';
  81. import ModuleCommon from '../../../home/configurable/components/ModuleCommon.vue';
  82. import { useInitConfigs } from '../../../home/configurable/hooks/useInit';
  83. import { useGlobSetting } from '/@/hooks/setting';
  84. import { settingParam1, settingParam2, settingParam3 } from '../balancePress.data';
  85. import { message } from 'ant-design-vue';
  86. import ventBox1 from '/@/components/vent/ventBox1.vue';
  87. import PasswordModal from '../../comment/components/PasswordModal.vue';
  88. import UpdatePassword from '../../comment/components/UpdatePassword.vue';
  89. import { get } from 'lodash-es';
  90. import { useModal } from '/@/components/Modal';
  91. // import { Config } from '../../../deviceManager/configurationTable/types';
  92. const props = defineProps({
  93. deviceId: {
  94. type: String,
  95. require: true,
  96. },
  97. });
  98. const { sysOrgCode } = useGlobSetting();
  99. const loading = ref(false);
  100. // 监测数据
  101. const selectData = ref();
  102. // https获取监测数据
  103. let timer: any = null;
  104. function getMonitor(flag?) {
  105. if (Object.prototype.toString.call(timer) === '[object Null]') {
  106. timer = setTimeout(
  107. async () => {
  108. if (props.deviceId) {
  109. const data = await getDataSource(props.deviceId);
  110. // Object.assign(selectData, data);
  111. updateText(selectData);
  112. selectData.value = data;
  113. }
  114. if (timer) {
  115. timer = null;
  116. }
  117. await getMonitor();
  118. loading.value = false;
  119. },
  120. flag ? 0 : 1000
  121. );
  122. }
  123. }
  124. async function getDataSource(systemID) {
  125. const res = await list({ devicetype: 'sys', systemID });
  126. const result = Array.from(res.msgTxt).reduce(
  127. (obj: any, e: any) => {
  128. obj[e.type] = e;
  129. // if (true) {
  130. if (sysOrgCode === 'sdmtjtswmk') {
  131. if (e.type.startsWith('fanlocal')) {
  132. obj.fanlocal.datalist.push(...e.datalist);
  133. }
  134. if (e.type.startsWith('safetymonitor')) {
  135. e.datalist.forEach((ele) => {
  136. if (ele.strinstallpos.includes('风门')) {
  137. obj.gate.datalist.push(ele);
  138. } else if (ele.strinstallpos.includes('风窗')) {
  139. obj.window.datalist.push(ele);
  140. } else if (ele.strinstallpos.includes('工作面')) {
  141. obj.work_surface.datalist.push(ele);
  142. } else {
  143. obj.others.datalist.push(ele);
  144. }
  145. });
  146. }
  147. }
  148. return obj;
  149. },
  150. {
  151. /** 用于归类fanlocal */
  152. fanlocal: { datalist: [] },
  153. /** 用于归类gate */
  154. gate: { datalist: [] },
  155. /** 用于归类window */
  156. window: { datalist: [] },
  157. /** 用于归类work_surface */
  158. work_surface: { datalist: [] },
  159. others: { datalist: [] },
  160. }
  161. );
  162. return result;
  163. }
  164. // const configs = ref<Config[]>([
  165. // {
  166. // deviceType: '',
  167. // moduleName: '局扇',
  168. // pageType: 'balancePressHome',
  169. // moduleData: {
  170. // header: {
  171. // show: false,
  172. // readFrom: '',
  173. // selector: {
  174. // show: false,
  175. // value: '',
  176. // },
  177. // slot: {
  178. // show: false,
  179. // value: '',
  180. // },
  181. // },
  182. // background: {
  183. // show: false,
  184. // type: 'image',
  185. // link: '',
  186. // },
  187. // layout: {
  188. // direction: 'row',
  189. // items: [
  190. // {
  191. // name: 'complex_list',
  192. // basis: '50%',
  193. // },
  194. // {
  195. // name: 'complex_list',
  196. // basis: '50%',
  197. // },
  198. // ],
  199. // },
  200. // complex_list: [
  201. // {
  202. // type: 'G',
  203. // readFrom: 'fanlocal_steml_zj',
  204. // mapFromData: false,
  205. // items: [
  206. // {
  207. // title: '主机',
  208. // contents: [
  209. // {
  210. // label: '运行状态',
  211. // value: '${datalist[0].readData.Fan1StartStatus_str}',
  212. // color: 'blue',
  213. // },
  214. // {
  215. // label: '运行频率',
  216. // value: '${datalist[0].readData.Fan1fHz}',
  217. // color: 'blue',
  218. // },
  219. // {
  220. // label: '输出电压',
  221. // value: '${datalist[0].readData.Fan1fHz}',
  222. // color: 'blue',
  223. // },
  224. // ],
  225. // },
  226. // ],
  227. // },
  228. // {
  229. // type: 'G',
  230. // readFrom: 'fanlocal_steml_zj',
  231. // mapFromData: false,
  232. // items: [
  233. // {
  234. // title: '备机',
  235. // contents: [
  236. // {
  237. // label: '运行状态',
  238. // value: '${datalist[0].readData.Fan2StartStatus_str}',
  239. // color: 'blue',
  240. // },
  241. // {
  242. // label: '运行频率',
  243. // value: '${datalist[0].readData.Fan2fHz}',
  244. // color: 'blue',
  245. // },
  246. // {
  247. // label: '输出电压',
  248. // value: '${datalist[0].readData.Fan2fHz}',
  249. // color: 'blue',
  250. // },
  251. // ],
  252. // },
  253. // ],
  254. // },
  255. // ],
  256. // to: '',
  257. // },
  258. // showStyle: {
  259. // size: 'width:380px;height:200px;',
  260. // version: '原版',
  261. // position: 'top:150px;right:0;',
  262. // },
  263. // },
  264. // {
  265. // deviceType: '',
  266. // moduleName: '其他模块A',
  267. // pageType: 'balancePressHome',
  268. // moduleData: {
  269. // header: {
  270. // show: false,
  271. // readFrom: '',
  272. // selector: {
  273. // show: false,
  274. // value: '',
  275. // },
  276. // slot: {
  277. // show: false,
  278. // value: '',
  279. // },
  280. // },
  281. // background: {
  282. // show: false,
  283. // type: 'image',
  284. // link: '',
  285. // },
  286. // layout: {
  287. // direction: 'column',
  288. // items: [
  289. // {
  290. // name: 'list',
  291. // basis: '100%',
  292. // },
  293. // ],
  294. // },
  295. // list: [
  296. // {
  297. // type: 'K',
  298. // readFrom: 'windrect_ds_four.datalist[0]',
  299. // items: [
  300. // {
  301. // label: '网络状态',
  302. // value: '${readData.netStatus_str}',
  303. // color: 'blue',
  304. // },
  305. // ],
  306. // },
  307. // ],
  308. // to: '',
  309. // },
  310. // showStyle: {
  311. // size: 'width:380px;height:230px;',
  312. // version: '原版',
  313. // position: 'top:360px;right:0;',
  314. // },
  315. // },
  316. // ]);
  317. // const { configs, fetchConfigs } = useInitConfigs();
  318. const formData = ref({
  319. isAuto: false,
  320. });
  321. // 默认初始是第一行
  322. const isAutoControl = ref('1');
  323. function changeIsAuto({ target }) {
  324. formData.value.isAuto = target.value;
  325. modalVisible.value = true;
  326. }
  327. const changeType = (isAutoControl) => {
  328. isAutoControl;
  329. //
  330. };
  331. const modalVisible = ref(false);
  332. function handleControl(password) {
  333. validPassword({
  334. id: avePress.value.id,
  335. password,
  336. })
  337. .then(() => {
  338. return submitEdit({
  339. id: avePress.value.id,
  340. isAuto: formData.value.isAuto,
  341. })
  342. .then(() => {
  343. message.success('操作成功');
  344. })
  345. .catch(() => {
  346. message.error('操作失败');
  347. });
  348. })
  349. .catch((e) => {
  350. message.error(e);
  351. })
  352. .finally(() => {
  353. modalVisible.value = false;
  354. getAvePress();
  355. });
  356. }
  357. const avePress = ref<any>({ isAuto: false });
  358. function getAvePress() {
  359. subList({
  360. strType: 'sdg_fan_sys_gate',
  361. }).then(({ records }) => {
  362. avePress.value = get(records, '[0]');
  363. });
  364. }
  365. const { configs, fetchConfigs } = useInitConfigs();
  366. const [updatePwdRegister, { openModal, closeModal, setModalProps }] = useModal();
  367. function changePassword(values) {
  368. setModalProps({ confirmLoading: true });
  369. updatePassword({
  370. id: avePress.value.id,
  371. newPassword: values.password,
  372. oldPassword: values.oldpassword,
  373. })
  374. .then(() => {
  375. message.success('操作成功');
  376. })
  377. .catch((e) => {
  378. message.error(e);
  379. })
  380. .finally(() => {
  381. setModalProps({ confirmLoading: false });
  382. closeModal();
  383. getAvePress();
  384. });
  385. }
  386. onMounted(() => {
  387. // getMonitor()
  388. fetchConfigs('balancePressHome');
  389. getAvePress();
  390. loading.value = true;
  391. mountedThree().then(async () => {
  392. await setModelType('balancePressBase'); //balancePressBase
  393. loading.value = false;
  394. timer = null;
  395. await getMonitor(true);
  396. play('startSmoke', 'top', 30, 'open', 0);
  397. });
  398. // loading.value = false;
  399. // timer = null;
  400. // getMonitor(true);
  401. });
  402. onUnmounted(() => {
  403. destroy();
  404. if (timer) {
  405. clearTimeout(timer);
  406. }
  407. });
  408. </script>
  409. <style lang="less" scoped>
  410. @import '/@/design/vent/modal.less';
  411. @import '../../comment/less/workFace.less';
  412. @ventSpace: zxm;
  413. .monitor-container {
  414. margin-top: 60px;
  415. }
  416. </style>