index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <div class="connectAnalysis">
  4. <div class="filter-area">
  5. <Row style="width: 100%">
  6. <Col :span="6">
  7. <div class="filter-section param-section">
  8. <span class="filter-label">煤矿名称:</span>
  9. <div class="param-selector">
  10. <MineCascader
  11. v-model:value="innerValue"
  12. style="width: 300px"
  13. :sync-to-store="false"
  14. :init-from-store="false"
  15. @change="changeCascader"
  16. ></MineCascader>
  17. </div>
  18. </div>
  19. </Col>
  20. <Col :span="6">
  21. <!-- 时间选择 -->
  22. <div class="filter-section param-section">
  23. <span class="filter-label">采空区选择:</span>
  24. <Select ref="select" v-model:value="goafId" style="width: 300px" placeholder="请选择采空区">
  25. <SelectOption v-for="(item, index) in goafOption" :key="index" :value="item.value">{{ item.label }} </SelectOption>
  26. </Select>
  27. </div>
  28. </Col>
  29. <Col :span="6">
  30. <div class="filter-section param-section">
  31. <span class="filter-label">时间选择:</span>
  32. <RangePicker
  33. v-model:value="dateRange"
  34. format="YYYY-MM-DD HH:mm:ss"
  35. :placeholder="['开始时间', '结束时间']"
  36. style="width: 300px"
  37. :show-time="{ format: 'HH:mm:ss' }"
  38. @change="changeTime"
  39. />
  40. </div>
  41. </Col>
  42. <Col :span="6">
  43. <div class="filter-section">
  44. <Button type="primary" @click="generateChart">生成</Button>
  45. </div>
  46. </Col>
  47. </Row>
  48. </div>
  49. <!-- 动态图表区域-->
  50. <div class="echart-box">
  51. <div class="check-title">
  52. <CheckboxNav @checkBoxChange="checkBoxChange"></CheckboxNav>
  53. </div>
  54. <div class="echart-content">
  55. <echartContent :echartData="echartData"></echartContent>
  56. </div>
  57. <div class="check-title">
  58. <echartLengend></echartLengend>
  59. </div>
  60. </div>
  61. </div>
  62. </template>
  63. <script setup lang="ts">
  64. import { ref, onMounted, reactive } from 'vue';
  65. import dayjs from 'dayjs';
  66. import { Select, SelectOption, Row, Col, DatePicker, Button } from 'ant-design-vue';
  67. import MineCascader from '@/components/Form/src/jeecg/components/MineCascader/MineCascader.vue';
  68. import CheckboxNav from './components/checkbox-nav.vue';
  69. import echartLengend from './components/echart-lengend.vue';
  70. import echartContent from './components/echart-content.vue';
  71. import { getGoafHistory, getGoafList } from './connectAnalysis.api';
  72. import { useRouter } from 'vue-router';
  73. import { useMineDepartmentStore } from '/@/store/modules/mine';
  74. // 组件注册
  75. const RangePicker: any = DatePicker.RangePicker;
  76. const { currentRoute } = useRouter();
  77. // 筛选相关响应式数据
  78. const dateRange = ref([dayjs().add(-30, 'day'), dayjs()]); // 默认时间范围(近1天)
  79. const goafId = ref(''); //采空区id
  80. const goafOption = ref<any[]>([]); //采空区列表
  81. const mineStore = useMineDepartmentStore();
  82. const innerValue = ref('');
  83. const checkList = ref<any[]>(['coVal', 'ch4Val', 'c2h4Val', 'c2h2Val', 'co2Val', 'o2Val', 'sourcePressure', 'temperature']); //当前选中要进行显示的选项
  84. const echartData = reactive({
  85. xData: [] as any,
  86. yData: [] as any,
  87. });
  88. //煤矿选项切换
  89. function changeCascader(val) {
  90. innerValue.value = val;
  91. getGoafListData();
  92. }
  93. //时间选择选项切换
  94. function changeTime(val) {
  95. dateRange.value[0] = val[0];
  96. dateRange.value[1] = val[1];
  97. }
  98. //图表选项标签切换
  99. function checkBoxChange(val) {
  100. checkList.value = val.checkedList;
  101. generateChart();
  102. }
  103. // 生成折线图核心逻辑
  104. async function generateChart() {
  105. echartData.yData.length = 0;
  106. let startTime = dateRange.value[0].format('YYYY-MM-DD HH:mm:ss');
  107. let endTime = dateRange.value[1].format('YYYY-MM-DD HH:mm:ss');
  108. let res = await getGoafHistory({ pageNo: 1, pageSize: 1000, startTime: startTime, endTime: endTime, goafId: goafId.value });
  109. let data = res.records || [];
  110. if (data.length) {
  111. echartData.xData = data.map((e) => e.createTime);
  112. if (checkList.value.length) {
  113. checkList.value.forEach((el) => {
  114. echartData.yData.push({
  115. label: el,
  116. value: data,
  117. });
  118. });
  119. }
  120. }
  121. }
  122. //获取采空区列表
  123. async function getGoafListData() {
  124. let res = await getGoafList({ mineCode: innerValue.value });
  125. if (res.length) {
  126. goafOption.value = res.map((el) => {
  127. return {
  128. label: el.devicePos,
  129. value: el.id,
  130. };
  131. });
  132. goafId.value = goafId.value ? goafId.value : goafOption.value[0]['value'];
  133. }
  134. }
  135. onMounted(async () => {
  136. const mineCode = currentRoute.value['query']['mineCode']; //传递过来的矿ID
  137. if (mineCode) {
  138. innerValue.value = mineCode as any;
  139. } else {
  140. innerValue.value = mineStore.getMineCode.split(',')[0];
  141. await getGoafListData();
  142. await generateChart();
  143. }
  144. });
  145. </script>
  146. <style lang="less" scoped>
  147. .connectAnalysis {
  148. width: calc(100% - 10px);
  149. height: calc(100% - 20px);
  150. margin: 10px 0px 10px 10px;
  151. padding: 10px;
  152. box-sizing: border-box;
  153. border: 1px solid #c8d0dd;
  154. border-radius: 5px;
  155. .filter-area {
  156. display: flex;
  157. flex-wrap: wrap;
  158. gap: 16px;
  159. margin-bottom: 15px;
  160. padding: 20px;
  161. border: 1px solid #f0f0f0;
  162. border-radius: 10px;
  163. background: @card-bg-color;
  164. align-items: center;
  165. }
  166. .filter-section {
  167. display: flex;
  168. align-items: center;
  169. gap: 8px;
  170. }
  171. .filter-label {
  172. color: #666;
  173. min-width: 80px;
  174. flex-shrink: 0;
  175. font-weight: 500;
  176. }
  177. .param-section {
  178. flex: 1;
  179. // min-width: 300px;
  180. }
  181. .param-selector {
  182. display: flex;
  183. align-items: center;
  184. gap: 8px;
  185. position: relative;
  186. }
  187. .echart-box {
  188. width: 100%;
  189. height: calc(100% - 95px);
  190. }
  191. .check-title {
  192. height: 40px;
  193. line-height: 40px;
  194. background-color: #d0e1fa;
  195. border-radius: 3px;
  196. padding: 0px 20px;
  197. box-sizing: border-box;
  198. }
  199. .echart-content {
  200. width: 100%;
  201. height: calc(100% - 80px);
  202. }
  203. }
  204. </style>