index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="gas-verify">
  4. <CustomHeader> 瓦斯抽采达标能力核定 </CustomHeader>
  5. <div class="flex mt-90px">
  6. <div class="nav-l"> 瓦斯抽采达标生产能力:{{ floor(data.gasExtractionSystemCapacityResultLarge, 2) }} t/a </div>
  7. <div class="nav">
  8. <Tabs v-model:active-key="actived" :tabBarStyle="{ color: 'red' }">
  9. <TabPane key="product" tab="矿井瓦斯抽采达标生产能力核定" />
  10. <TabPane key="extract" tab="矿井瓦斯抽采能力核定" />
  11. </Tabs>
  12. </div>
  13. <div class="nav-r"> 瓦斯抽采能力:{{ floor(data.gasExtractionSystemCapacityResultSmall, 2) }} m<sup>3</sup>/min </div>
  14. </div>
  15. <div class="flex">
  16. <div :style="{ flex: 1 }">
  17. 矿井瓦斯抽采系统能力统计图
  18. <Bar :chart-data="productChartData" x-axis-prop-type="x" series-prop-type="y" height="300px" />
  19. 矿井瓦斯抽采能力统计图
  20. <Bar :chart-data="extractChartData" x-axis-prop-type="x" series-prop-type="y" height="300px" />
  21. </div>
  22. <div class="gas-verify__content">
  23. <div v-show="true">
  24. <div class="flex flex-justify-between flex-items-center">
  25. <FormTitle class="flex-grow-1" icon="pump" title="矿井基本信息" />
  26. <Button class="mr-10px" @click="addPubFormSchema">添加回风井</Button>
  27. <Button class="mr-10px" @click="calculateBasicForm">计算</Button>
  28. <Button type="primary" @click="submitBasicForm">提交</Button>
  29. </div>
  30. <BasicForm :schemas="publicFormSchema" @register="regBasicForm" />
  31. </div>
  32. <div v-show="actived === 'product'">
  33. <div class="flex flex-justify-between flex-items-center">
  34. <FormTitle
  35. class="flex-grow-1"
  36. icon="pump"
  37. :title="`根据矿井实际抽采瓦斯量核定:${floor(data.gasExtractionVolumeVerificationTotal, 2)}`"
  38. />
  39. <Button type="primary" @click="submitGasvalForm">提交</Button>
  40. </div>
  41. <BasicForm :schemas="valFormSchema" @register="regGasvalForm" />
  42. </div>
  43. <div v-show="actived === 'product'">
  44. <div class="flex flex-justify-between flex-items-center">
  45. <FormTitle class="flex-grow-1" icon="pump" :title="`根据矿井瓦斯抽采率核定:${floor(data.gasExtractionRateVerificationTotal, 2)}`" />
  46. <Button class="mr-10px" @click="calculateGasrateForm">计算</Button>
  47. <Button type="primary" @click="submitGasrateForm">提交</Button>
  48. </div>
  49. <BasicForm :schemas="rateFormSchema" @register="regGasrateForm" />
  50. </div>
  51. <div v-show="false">
  52. <div class="flex flex-justify-between flex-items-center">
  53. <FormTitle class="flex-grow-1" icon="pump" title="核定区域信息" />
  54. <Button type="primary" @click="submitCheckForm">提交</Button>
  55. </div>
  56. <BasicForm :schemas="checkFormSchema" @register="regCheckForm" />
  57. </div>
  58. <div class="flex flex-justify-between flex-items-center">
  59. <FormTitle
  60. class="flex-grow-1"
  61. :title="
  62. {
  63. extract: `按瓦斯抽采泵站装机能力核定:${floor(data.gasExtractionPumpStationCapacitySmall, 2)}`,
  64. product: `按矿井瓦斯抽采泵站装机能力核定:${floor(data.gasExtractionPumpStationCapacityLarge, 2)}`,
  65. }[actived]
  66. "
  67. />
  68. <Button type="primary" @click="editPumpHandler()">添加</Button>
  69. </div>
  70. <BasicTable class="mb-20px" :columns="pumpTableColumns" :data-source="pumpTableData" @register="regPumpTable">
  71. <template #action="{ record }">
  72. <a class="mr-5px" @click.prevent="editPumpHandler(record)">编辑</a>
  73. <Popconfirm @confirm="deletePumpHandler(record)"><a>删除</a></Popconfirm>
  74. </template>
  75. </BasicTable>
  76. <div class="flex flex-justify-between flex-items-center">
  77. <FormTitle
  78. class="flex-grow-1"
  79. :title="
  80. {
  81. extract: `按矿井瓦斯主管道系统能力核定:${floor(data.gasExtractionMainPipelineCapacitySmall, 2)}`,
  82. product: `按矿井瓦斯抽采主管道系统能力核定:${floor(data.gasExtractionMainPipelineCapacityLarge, 2)}`,
  83. }[actived]
  84. "
  85. />
  86. <Button type="primary" @click="editPipeHandler()">添加</Button>
  87. </div>
  88. <BasicTable :columns="pipeTableColumns" :data-source="pipeTableData" @register="regPipeTable">
  89. <template #action="{ record }">
  90. <a class="mr-5px" @click.prevent="editPipeHandler(record)">编辑</a>
  91. <Popconfirm @confirm="deletePipeHandler(record)"><a>删除</a></Popconfirm>
  92. </template>
  93. </BasicTable>
  94. <!-- <BasicTable :columns="workfaceTableColumns" :data-source="[{ ccbz: `1111` }, { ccbz: `2222` }]" @register="regTable">
  95. <template #action="{ record }">
  96. <a class="mr-5px" @click.prevent="openModal()">编辑</a>
  97. <a>删除</a>
  98. </template>
  99. </BasicTable> -->
  100. <BasicModal @register="regPipeModal" title="能力核定表单" @ok="submitPipeForm">
  101. <BasicForm :schemas="pipeFormSchema" @register="regPipeForm" />
  102. </BasicModal>
  103. <BasicModal @register="regPumpModal" title="能力核定表单" @ok="submitPumpForm">
  104. <BasicForm :schemas="pumpFormSchema" @register="regPumpForm" />
  105. </BasicModal>
  106. </div>
  107. </div>
  108. </div>
  109. </template>
  110. <script lang="ts" setup>
  111. import CustomHeader from '/@/components/vent/customHeader.vue';
  112. import { computed, nextTick, ref } from 'vue';
  113. import { message, TabPane, Tabs, Button, Popconfirm } from 'ant-design-vue';
  114. import { onMounted } from 'vue';
  115. import FormTitle from '@/views/vent/gas/components/form/formTitle.vue';
  116. import { useForm, BasicForm, FormSchema } from '/@/components/Form';
  117. import Bar from '/@/components/chart/Bar.vue';
  118. import {
  119. getGasMainAllInfo,
  120. getGasMainpipesystemAllInfo,
  121. getGasPumpstationAllInfo,
  122. deleteGasMainpipesystem,
  123. deleteGasPumpstation,
  124. updateGasMain,
  125. updateGasMainpipesystem,
  126. updateGasPumpstation,
  127. } from './gasPumpSetting.api';
  128. import {
  129. publicFormSchema,
  130. valFormSchema,
  131. rateFormSchema,
  132. pumpTableColumns,
  133. pipeTableColumns,
  134. checkFormSchema,
  135. pipeFormSchema,
  136. pumpFormSchema,
  137. // workfaceTableColumns,
  138. } from './gasPumpSetting.data';
  139. import { BasicTable, useTable } from '/@/components/Table';
  140. import { BasicModal, useModal } from '/@/components/Modal';
  141. import { get, inRange, floor } from 'lodash-es';
  142. const actived = ref<'extract' | 'product'>('product');
  143. /** 计算参数相关的表单通用配置 */
  144. const formProps = {
  145. showActionButtonGroup: false,
  146. labelCol: { span: 10 },
  147. baseColProps: {
  148. flex: '20%',
  149. },
  150. };
  151. function submitHandler() {
  152. const data1 = ctxBasicForm.getFieldsValue();
  153. const data2 = ctxGasvalForm.getFieldsValue();
  154. const data3 = ctxGasrateForm.getFieldsValue();
  155. updateGasMain({
  156. ...data3,
  157. ...data2,
  158. ...data1,
  159. returnAirVolume: get(data.value, 'returnAirVolume', [])
  160. .filter((e) => Boolean(e))
  161. .join(','),
  162. })
  163. .then(() => {
  164. message.success('提交成功');
  165. refresh();
  166. })
  167. .catch(() => {
  168. message.error('操作失败');
  169. });
  170. }
  171. const [regBasicForm, ctxBasicForm] = useForm(formProps);
  172. function submitBasicForm() {
  173. ctxBasicForm.validate().then(() => {
  174. submitHandler();
  175. });
  176. }
  177. /** 计算部分可以自动计算的参数 */
  178. function calculateBasicForm() {
  179. const { mineGasExtractionRate } = ctxBasicForm.getFieldsValue();
  180. const airVolumeArr = get(data.value, 'returnAirVolume', [])
  181. .filter((e) => Boolean(e))
  182. .map((e) => parseFloat(e));
  183. ctxBasicForm.setFieldsValue({
  184. mineMaxTotalReturnAirVolume: airVolumeArr.reduce((t, n) => t + n, 0),
  185. });
  186. // 根据抽采率生成总回瓦斯浓度
  187. if (mineGasExtractionRate) {
  188. const n = parseInt(mineGasExtractionRate);
  189. const config: [[number, number], number][] = [
  190. [[0, 35], 0.35],
  191. [[34.99, 40], 0.375],
  192. [[39.99, 45], 0.425],
  193. [[44.99, 50], 0.475],
  194. [[49.99, 55], 0.525],
  195. [[54.99, 60], 0.575],
  196. [[59.99, 100], 0.7],
  197. ];
  198. config.forEach((e) => {
  199. if (inRange(n, e[0][0], e[0][1])) {
  200. ctxBasicForm.setFieldsValue({
  201. mineTotalReturnAirGasConcentration: e[1],
  202. });
  203. }
  204. });
  205. }
  206. }
  207. /** 根据矿井实际抽采瓦斯量核定的表单数据 */
  208. const [regGasvalForm, ctxGasvalForm] = useForm(formProps);
  209. function submitGasvalForm() {
  210. ctxGasvalForm.validate().then(() => {
  211. submitHandler();
  212. });
  213. }
  214. /** 根据矿井瓦斯抽采率核定的表单数据 */
  215. const [regGasrateForm, ctxGasrateForm] = useForm(formProps);
  216. function submitGasrateForm() {
  217. ctxGasrateForm.validate().then(() => {
  218. submitHandler();
  219. });
  220. }
  221. /** 计算部分可以自动计算的参数 */
  222. function calculateGasrateForm() {
  223. const { mineGasExtractionRate } = ctxGasrateForm.getFieldsValue();
  224. // 根据抽采率生成最大绝对涌出量
  225. if (mineGasExtractionRate) {
  226. const n = parseInt(mineGasExtractionRate);
  227. const config: [[number, number], number][] = [
  228. [[0, 35], 20],
  229. [[34.99, 40], 30],
  230. [[39.99, 45], 60],
  231. [[44.99, 50], 120],
  232. [[49.99, 55], 230],
  233. [[54.99, 60], 400],
  234. [[59.99, 100], 500],
  235. ];
  236. config.forEach((e) => {
  237. if (inRange(n, e[0][0], e[0][1])) {
  238. ctxGasrateForm.setFieldsValue({
  239. maxAllowableAbsoluteGasEmission: e[1],
  240. });
  241. }
  242. });
  243. }
  244. }
  245. /** 核定区域信息的表单数据 */
  246. // const checkFormModel = ref<any>({});
  247. const [regCheckForm, ctxCheckForm] = useForm(formProps);
  248. function submitCheckForm() {
  249. ctxCheckForm.validate().then(() => {
  250. submitHandler();
  251. });
  252. }
  253. /** 矿井基本信息的表单配置,需要动态添加回风井。根据表单数据设置矿井基本信息的表单配置 */
  254. function resetPublicFormSchema() {
  255. const extra: FormSchema[] = data.value.returnAirVolume.map((num, inx) => {
  256. return {
  257. label: `回风井${inx + 1}`,
  258. field: `__${inx + 1}`,
  259. defaultValue: num,
  260. component: 'Input',
  261. componentProps: {
  262. onChange: ({ target }) => {
  263. data.value.returnAirVolume[inx] = target.value;
  264. },
  265. },
  266. };
  267. });
  268. ctxBasicForm.resetSchema([...publicFormSchema, ...extra]);
  269. }
  270. /** 添加一项公用参数表单项 */
  271. function addPubFormSchema() {
  272. if (!data.value.returnAirVolume) return;
  273. data.value.returnAirVolume.push('');
  274. resetPublicFormSchema();
  275. }
  276. /** 生产能力核定/抽采能力核定的数据,也是组件的数据依赖其一 */
  277. const data = ref<Record<string, any>>({});
  278. /** 按矿井瓦斯抽采主管道系统能力核定的表格 */
  279. const pipeTableData = ref<any[]>([]);
  280. const [regPipeModal, ctxPipeModal] = useModal();
  281. const [regPipeTable] = useTable({
  282. pagination: false,
  283. });
  284. const [regPipeForm, ctxPipeForm] = useForm({
  285. showActionButtonGroup: false,
  286. labelCol: { span: 10 },
  287. });
  288. function submitPipeForm() {
  289. ctxPipeForm.validate().then((data) => {
  290. updateGasMainpipesystem(data)
  291. .then(() => {
  292. ctxPipeModal.closeModal();
  293. refresh();
  294. })
  295. .catch(() => {
  296. message.error('操作失败');
  297. });
  298. });
  299. }
  300. function editPipeHandler(record?: Record<string, any>) {
  301. ctxPipeModal.openModal();
  302. nextTick(() => {
  303. if (record) {
  304. ctxPipeForm.setFieldsValue(record);
  305. } else {
  306. ctxPipeForm.resetFields();
  307. }
  308. });
  309. }
  310. function deletePipeHandler({ id }) {
  311. deleteGasMainpipesystem({ id })
  312. .then(() => {
  313. refresh();
  314. })
  315. .catch(() => {
  316. message.error('操作失败');
  317. });
  318. }
  319. /** 按矿井瓦斯抽采泵站装机能力核定的表格 */
  320. const pumpTableData = ref<any[]>([]);
  321. const [regPumpModal, ctxPumpModal] = useModal();
  322. const [regPumpTable] = useTable({
  323. pagination: false,
  324. });
  325. const [regPumpForm, ctxPumpForm] = useForm({
  326. showActionButtonGroup: false,
  327. labelCol: { span: 10 },
  328. });
  329. function submitPumpForm() {
  330. ctxPumpForm.validate().then((data) => {
  331. updateGasPumpstation(data)
  332. .then(() => {
  333. ctxPumpModal.closeModal();
  334. refresh();
  335. })
  336. .catch(() => {
  337. message.error('操作失败');
  338. });
  339. });
  340. }
  341. function editPumpHandler(record?: Record<string, any>) {
  342. ctxPumpModal.openModal();
  343. nextTick(() => {
  344. if (record) {
  345. ctxPumpForm.setFieldsValue(record);
  346. } else {
  347. ctxPumpForm.resetFields();
  348. }
  349. });
  350. }
  351. function deletePumpHandler({ id }) {
  352. deleteGasPumpstation({ id })
  353. .then(() => {
  354. refresh();
  355. })
  356. .catch(() => {
  357. message.error('操作失败');
  358. });
  359. }
  360. function refresh() {
  361. Promise.all([getGasMainAllInfo({}), getGasMainpipesystemAllInfo({}), getGasPumpstationAllInfo({})]).then((res) => {
  362. const [r1, r2, r3] = res.map((e) => e.obj);
  363. r1[0].returnAirVolume = r1[0].returnAirVolume.split(',');
  364. ctxBasicForm.resetFields().then(() => {
  365. ctxBasicForm.setFieldsValue(r1[0]);
  366. });
  367. ctxGasvalForm.resetFields().then(() => {
  368. ctxGasvalForm.setFieldsValue(r1[0]);
  369. });
  370. ctxGasrateForm.resetFields().then(() => {
  371. ctxGasrateForm.setFieldsValue(r1[0]);
  372. });
  373. pipeTableData.value = r2;
  374. pumpTableData.value = r3;
  375. data.value = r1[0];
  376. resetPublicFormSchema();
  377. });
  378. }
  379. // function getNum(data, path, defaultValue) {
  380. // const r = get(data, path);
  381. // return isNil(r) ? defaultValue : parseFloat(r);
  382. // }
  383. const productChartData = computed(() => {
  384. return [
  385. {
  386. x: '抽采系统能力',
  387. y: data.value.gasExtractionSystemCapacityResultSmall || 0,
  388. },
  389. {
  390. x: '实际抽采量',
  391. y: data.value.gasExtractionVolumeVerificationTotal || 0,
  392. },
  393. {
  394. x: '瓦斯抽采率',
  395. y: data.value.gasExtractionRateVerificationTotal || 0,
  396. },
  397. // {
  398. // x: '防突抽采',
  399. // y: data.value.ftcc || 0,
  400. // },
  401. ];
  402. });
  403. const extractChartData = computed(() => {
  404. const keyMap = {
  405. extract: ['gasExtractionPumpStationCapacitySmall', 'gasExtractionPumpStationCapacityLarge'],
  406. product: ['gasExtractionMainPipelineCapacitySmall', 'gasExtractionMainPipelineCapacityLarge'],
  407. };
  408. return [
  409. {
  410. x: '瓦斯抽采泵装机能力',
  411. y: get(data.value, keyMap[actived.value][0], 0),
  412. },
  413. {
  414. x: '瓦斯抽采主管道系统能力',
  415. y: get(data.value, keyMap[actived.value][1], 0),
  416. },
  417. ];
  418. });
  419. onMounted(() => {
  420. refresh();
  421. });
  422. </script>
  423. <style lang="less" scoped>
  424. @import '/@/design/theme.less';
  425. .gas-verify {
  426. --image-verify-nav-bg-l: url('/@/assets/images/vent/gas/verify-nav-bg-l.png');
  427. --image-verify-nav-bg-r: url('/@/assets/images/vent/gas/verify-nav-bg-r.png');
  428. --image-verify-nav-bg: url('/@/assets/images/vent/gas/verify-nav-bg.png');
  429. color: var(--vent-font-color);
  430. padding: 0 20px;
  431. .nav-l {
  432. flex: 1;
  433. height: 83px;
  434. padding-top: 31px;
  435. text-align: center;
  436. background-repeat: no-repeat;
  437. background-size: 100% 85px;
  438. background-position: center 12px;
  439. background-image: var(--image-verify-nav-bg-l);
  440. }
  441. .nav {
  442. flex: 3;
  443. height: 83px;
  444. padding: 20px 40px 0 40px;
  445. background-repeat: no-repeat;
  446. background-size: 100% 70px;
  447. background-position: center 0;
  448. background-image: var(--image-verify-nav-bg);
  449. }
  450. .nav-r {
  451. flex: 1;
  452. height: 83px;
  453. padding-top: 31px;
  454. text-align: center;
  455. background-repeat: no-repeat;
  456. background-size: 100% 85px;
  457. background-position: center 12px;
  458. background-image: var(--image-verify-nav-bg-r);
  459. }
  460. .gas-verify__content {
  461. flex: 4;
  462. height: 740px;
  463. overflow-y: auto;
  464. }
  465. }
  466. :deep(.zxm-tabs-ink-bar) {
  467. display: none;
  468. }
  469. :deep(.form-title) {
  470. background-size: 800px 100%;
  471. }
  472. </style>