index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <div class="table-box">
  3. <div class="card table-main">
  4. <!-- 表格头部 操作按钮 -->
  5. <div class="table-header">
  6. <div class="header-button-lf">
  7. <el-form :model="pageable" label-width="auto" :inline="true">
  8. <el-form-item label="自动站:">
  9. <SelectItem :select-data="selectedData" :select-list="platformList" :is-checkbox="false" @update:selectedItems="selectedItems" style="width: 200px"> </SelectItem>
  10. </el-form-item>
  11. <el-form-item>
  12. <el-button type="primary" @click="handleQuery"> 查询 </el-button>
  13. <el-button style="margin-left: 10px" @click="resetQuery"> 重置 </el-button>
  14. </el-form-item>
  15. </el-form>
  16. </div>
  17. <div class="header-button-ri">
  18. <slot name="toolButton">
  19. <img class="setting" src="@/assets/images/setting2.png" @click="handleSetting" />
  20. </slot>
  21. </div>
  22. </div>
  23. <!-- 表格主体 -->
  24. <el-table stripe ref="tableRef" :border="true" :data="processTableData" size="small" @sort-change="handleSortChange">
  25. <el-table-column align="left" label="序号" width="80px" :show-overflow-tooltip="true">
  26. <template #default="scope">
  27. {{ (pageable.pageNum - 1) * pageable.pageSize + scope.$index + 1 }}
  28. </template>
  29. </el-table-column>
  30. <template v-for="item in columns" :key="item">
  31. <el-table-column v-bind="item" :align="item.align ?? 'left'" :reserve-selection="item.type == 'selection'" :sortable="item.sortable" :show-overflow-tooltip="true">
  32. <template #default="scope">
  33. <template v-if="item.prop === 'data_time_i'">
  34. {{formatDate(scope.row.data_time_i)}}
  35. </template>
  36. </template>
  37. </el-table-column>
  38. </template>
  39. <!-- 无数据 -->
  40. <template #empty>
  41. <div class="table-empty">
  42. <slot name="empty">
  43. <img src="@/assets/images/notData.png" alt="notData" />
  44. <div>暂无数据</div>
  45. </slot>
  46. </div>
  47. </template>
  48. </el-table>
  49. <!-- 分页组件 -->
  50. <Pagination :pageable="pageable" :handle-size-change="handleSizeChange" :handle-current-change="handleCurrentChange" />
  51. </div>
  52. <!-- 添加或修改岗位对话框 -->
  53. <el-dialog :title="dialog.title" v-model="dialog.visible" width="1200px" append-to-body>
  54. <div style="height: 500px;display: flex">
  55. <el-tabs tab-position="left" class="demo-tabs" style="height: 100%">
  56. <el-tab-pane label="风">
  57. <div class="container-tag">
  58. <template v-for="item in elementList" :key="item.id" >
  59. <div v-if="item.data_type==='风'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  60. </template>
  61. </div>
  62. </el-tab-pane>
  63. <el-tab-pane label="温湿度">
  64. <div class="container-tag">
  65. <template v-for="item in elementList" :key="item.id" >
  66. <div v-if="item.data_type==='温湿度'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  67. </template>
  68. </div>
  69. </el-tab-pane>
  70. <el-tab-pane label="气压">
  71. <div class="container-tag">
  72. <template v-for="item in elementList" :key="item.id" >
  73. <div v-if="item.data_type==='气压'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  74. </template>
  75. </div>
  76. </el-tab-pane>
  77. <el-tab-pane label="降水">
  78. <div class="container-tag">
  79. <template v-for="item in elementList" :key="item.id" >
  80. <div v-if="item.data_type==='降水'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  81. </template>
  82. </div>
  83. </el-tab-pane>
  84. <el-tab-pane label="云">
  85. <div class="container-tag">
  86. <template v-for="item in elementList" :key="item.id" >
  87. <div v-if="item.data_type==='云'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  88. </template>
  89. </div>
  90. </el-tab-pane>
  91. <el-tab-pane label="能见度">
  92. <div class="container-tag">
  93. <template v-for="item in elementList" :key="item.id" >
  94. <div v-if="item.data_type==='能见度'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  95. </template>
  96. </div>
  97. </el-tab-pane>
  98. <el-tab-pane label="天气现象">
  99. <div class="container-tag">
  100. <template v-for="item in elementList" :key="item.id" >
  101. <div v-if="item.data_type==='天气现象'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  102. </template>
  103. </div>
  104. </el-tab-pane>
  105. <el-tab-pane label="积雪">
  106. <div class="container-tag">
  107. <template v-for="item in elementList" :key="item.id" >
  108. <div v-if="item.data_type==='积雪'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  109. </template>
  110. </div>
  111. </el-tab-pane>
  112. <el-tab-pane label="地面温度">
  113. <div class="container-tag">
  114. <template v-for="item in elementList" :key="item.id" >
  115. <div v-if="item.data_type==='地面温度'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  116. </template>
  117. </div>
  118. </el-tab-pane>
  119. <el-tab-pane label="大气电场">
  120. <div class="container-tag">
  121. <template v-for="item in elementList" :key="item.id" >
  122. <div v-if="item.data_type==='大气电场'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  123. </template>
  124. </div>
  125. </el-tab-pane>
  126. <el-tab-pane label="闪电">
  127. <div class="container-tag">
  128. <template v-for="item in elementList" :key="item.id" >
  129. <div v-if="item.data_type==='闪电'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  130. </template>
  131. </div>
  132. </el-tab-pane>
  133. <el-tab-pane label="日照">
  134. <div class="container-tag">
  135. <template v-for="item in elementList" :key="item.id" >
  136. <div v-if="item.data_type==='日照'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  137. </template>
  138. </div>
  139. </el-tab-pane>
  140. <el-tab-pane label="总辐射">
  141. <div class="container-tag">
  142. <template v-for="item in elementList" :key="item.id" >
  143. <div v-if="item.data_type==='总辐射'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  144. </template>
  145. </div>
  146. </el-tab-pane>
  147. <el-tab-pane label="日照文">
  148. <div class="container-tag">
  149. <template v-for="item in elementList" :key="item.id" >
  150. <div v-if="item.data_type==='日照文'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  151. </template>
  152. </div>
  153. </el-tab-pane>
  154. <el-tab-pane label="水文">
  155. <div class="container-tag">
  156. <template v-for="item in elementList" :key="item.id" >
  157. <div v-if="item.data_type==='水文'" :class="item.isSelected?'item-tag-active':'item-tag'" @click="toggleSelection(item)" >{{item.data_name}}</div>
  158. </template>
  159. </div>
  160. </el-tab-pane>
  161. </el-tabs>
  162. <div class="selected-list-box">
  163. <div class="disposition-title" style="margin-top: 0px">已选要素</div>
  164. <div class="selected-list-c">
  165. <template v-for="(item,index) in copiedCustomizeColumns" :key="item.id">
  166. <div :class="selectedItemIndex===index?'selected-item-tag-active':'selected-item-tag'" @click="changeSelected(index)">{{item.data_name}}</div>
  167. </template>
  168. </div>
  169. <div class="button-container">
  170. <el-button type="primary" plain class="top-left" @click="changeMoveUp">上移</el-button>
  171. <el-button type="primary" plain class="top-right" @click="changeMoveDown">下移</el-button>
  172. <el-button type="primary" plain class="bottom-left" @click="changeRemove">移除</el-button>
  173. <el-button type="primary" plain class="bottom-right" @click="changeCleared">清空</el-button>
  174. </div>
  175. </div>
  176. </div>
  177. <template #footer>
  178. <div class="dialog-footer">
  179. <el-button @click="cancel">取 消</el-button>
  180. <el-button type="primary" @click="submitForm">确 定</el-button>
  181. </div>
  182. </template>
  183. </el-dialog>
  184. </div>
  185. </template>
  186. <script setup lang="ts" name="useProTable">
  187. import Pagination from "@/components/ProTable/components/Pagination.vue";
  188. import SelectItem from "@/components/SelectItem/index.vue";
  189. import {ref, reactive, onMounted, onDeactivated, onActivated, computed} from "vue";
  190. import { ColumnProps } from "@/components/ProTable/interface";
  191. import {ElTable} from "element-plus";
  192. import {getDataItemList, getPlatformList, getRgDataList} from "@/api/modules/allData";
  193. import { Platform} from "@/api/interface";
  194. import {useUserStore} from "@/stores/modules/user";
  195. const tableRef = ref<InstanceType<typeof ElTable>>();
  196. const dialog = reactive<any>({
  197. visible: false,
  198. title: ''
  199. });
  200. const cancel = () => {
  201. dialog.visible = false;
  202. }
  203. const handleSortChange = ({ column, prop, order }) => {
  204. console.log('column:', column);
  205. console.log('prop:', prop);
  206. console.log('order:', order);
  207. // Reset sorting if order is null
  208. if (order === null) {
  209. pageable.value.time_order = 0;
  210. pageable.value.data_order = [];
  211. getList();
  212. return;
  213. }
  214. // Handle time sorting
  215. if (prop === 'data_time_i') {
  216. pageable.value.time_order = order === 'descending' ? 0 : 1;
  217. pageable.value.data_order = [];
  218. getList();
  219. return;
  220. }
  221. // Default time order to 0
  222. pageable.value.time_order = 0;
  223. pageable.value.data_order = [];
  224. // Find the item with the matching data_id and update its order
  225. const item = pageable.value.data_items.find(item => item.data_id === prop);
  226. if (item) {
  227. item.data_order = order === 'descending' ? 0 : 1;
  228. pageable.value.data_order = [item];
  229. getList();
  230. }
  231. };
  232. const pageable = ref<any>({
  233. data_type: true,
  234. time_order: 0,
  235. as_code_list:undefined,
  236. data_items:[],
  237. data_order:[],
  238. pageNum: 1,
  239. pageSize: 20,
  240. total: 0
  241. });
  242. // 查询功能
  243. const handleQuery = () => {
  244. pageable.value.pageNum = 1;
  245. getList();
  246. };
  247. //重置功能
  248. const resetQuery = () => {
  249. const allCodes = platformList.value.map(item => item.as_code);
  250. pageable.value.as_code_list = allCodes
  251. selectedData.value = []
  252. pageable.value.pageNum = 1;
  253. pageable.value.time_order =0
  254. pageable.value.data_order =[]
  255. pageable.value.pageSize =20
  256. pageable.value.total = 0
  257. tableRef.value!.clearSort()
  258. getList();
  259. };
  260. /**
  261. * @description 每页条数改变
  262. * @param {Number} val 当前条数
  263. * @return void
  264. * */
  265. const handleSizeChange = (val: number) => {
  266. pageable.value.pageSize = val
  267. getList();
  268. };
  269. /**
  270. * @description 当前页改变
  271. * @param {Number} val 当前页
  272. * @return void
  273. * */
  274. const handleCurrentChange = (val: number) => {
  275. pageable.value.pageNum = val
  276. getList();
  277. };
  278. const processTableData = ref([]);
  279. // 表格配置项
  280. let columns = reactive<ColumnProps[]>([]);
  281. //自定义部分表头
  282. let customizeColumns= ref<any>([
  283. {
  284. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  285. data_id: 2,
  286. data_type: "风",
  287. data_item: "ER_FEN_ZHONG_PING_JUN_FENG_XIANG",
  288. data_name: "2分钟风向",
  289. data_unit: "°",
  290. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  291. data_value: "",
  292. data_order: 0,
  293. data_condition: 0
  294. },
  295. {
  296. data_id: 1,
  297. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  298. data_type: "风",
  299. data_name: "2分钟风速",
  300. data_item: "ER_FEN_ZHONG_PING_JUN_FENG_SU",
  301. data_unit: "m/s",
  302. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  303. data_value: "",
  304. data_order: 0,
  305. data_condition: 0
  306. },
  307. {
  308. data_id: 4,
  309. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  310. data_type: "风",
  311. data_name: "10分钟风向",
  312. data_item: "SHI_FEN_ZHONG_PING_JUN_FENG_XIANG",
  313. data_unit: "°",
  314. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  315. data_value: "",
  316. data_order: 0,
  317. data_condition: 0
  318. },
  319. {
  320. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  321. data_id: 3,
  322. data_type: "风",
  323. data_item: "SHI_FEN_ZHONG_PING_JUN_FENG_SU",
  324. data_name: "10分钟风速",
  325. data_unit: "m/s",
  326. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  327. data_value: "",
  328. data_order: 0,
  329. data_condition: 0
  330. },
  331. {
  332. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  333. data_id: 501,
  334. data_type: "能见度",
  335. data_item: "YI_FEN_ZHONG_PING_JUN_NENG_JIAN_DU",
  336. data_name: "1分钟平均能见度",
  337. data_unit: "m",
  338. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  339. data_value: "",
  340. data_order: 0,
  341. data_condition: 0
  342. },
  343. {
  344. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  345. data_id: 101,
  346. data_type: "温湿度",
  347. data_item: "QI_WEN",
  348. data_name: "气温",
  349. data_unit: "℃",
  350. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  351. data_value: "",
  352. data_order: 0,
  353. data_condition: 0
  354. },
  355. {
  356. data_id: 201,
  357. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  358. data_type: "气压",
  359. data_name: "水汽压",
  360. data_item: "SHUI_QI_YA",
  361. data_unit: "hPa",
  362. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  363. data_value: "",
  364. data_order: 0,
  365. data_condition: 0
  366. },
  367. {
  368. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  369. data_id: 109,
  370. data_type: "温湿度",
  371. data_item: "LU_DIAN_WEN_DU",
  372. data_name: "露点温度",
  373. data_unit: "℃",
  374. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  375. data_value: "",
  376. data_order: 0,
  377. data_condition: 0
  378. },
  379. {
  380. data_id: 202,
  381. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  382. data_type: "气压",
  383. data_name: "本站气压",
  384. data_item: "BEN_ZHAN_QI_YA",
  385. data_unit: "hPa",
  386. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  387. data_value: "",
  388. data_order: 0,
  389. data_condition: 0
  390. },{
  391. data_id: 207,
  392. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  393. data_type: "气压",
  394. data_name: "海平面气压",
  395. data_item: "HAI_PING_MIAN_QI_YA",
  396. data_unit: "hPa",
  397. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  398. data_value: "",
  399. data_order: 0,
  400. data_condition: 0
  401. },
  402. {
  403. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  404. data_id: 312,
  405. data_type: "降水",
  406. data_item: "XIAO_SHI_LEI_JI_JIANG_SHUI_LIANG_CHENG_ZHONG",
  407. data_name: "小时累计降水量(称重)",
  408. data_unit: "mm",
  409. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  410. data_value: "",
  411. data_order: 0,
  412. data_condition: 0
  413. }
  414. ])
  415. const sensorList =ref<any>([])
  416. // 被选中当条数据下标
  417. const selectedItemIndex = ref(0)
  418. const changeMoveUp = () =>{
  419. //上移
  420. if (selectedItemIndex.value > 0) {
  421. const temp = copiedCustomizeColumns.value[selectedItemIndex.value - 1]
  422. copiedCustomizeColumns.value[selectedItemIndex.value - 1] = copiedCustomizeColumns.value[selectedItemIndex.value]
  423. copiedCustomizeColumns.value[selectedItemIndex.value] = temp
  424. selectedItemIndex.value--
  425. }
  426. }
  427. const changeMoveDown = ()=>{
  428. //下移
  429. if (selectedItemIndex.value < copiedCustomizeColumns.value.length - 1) {
  430. const temp = copiedCustomizeColumns.value[selectedItemIndex.value + 1]
  431. copiedCustomizeColumns.value[selectedItemIndex.value + 1] = copiedCustomizeColumns.value[selectedItemIndex.value]
  432. copiedCustomizeColumns.value[selectedItemIndex.value] = temp
  433. selectedItemIndex.value++
  434. }
  435. }
  436. const changeRemove= ()=>{
  437. //删除数据
  438. if (copiedCustomizeColumns.value.length > 0) {
  439. const custom= copiedCustomizeColumns.value[selectedItemIndex.value];
  440. const se_type = custom.se_type
  441. for (let i = 0; i < sensorList.value.length; i++) {
  442. if (sensorList.value[i].se_type === se_type) {
  443. sensorList.value[i].isSelected = false;
  444. }
  445. }
  446. copiedCustomizeColumns.value.splice(selectedItemIndex.value, 1)
  447. if (selectedItemIndex.value === copiedCustomizeColumns.value.length) {
  448. selectedItemIndex.value--
  449. }
  450. }
  451. }
  452. const changeCleared=()=>{
  453. //清空所有数据
  454. selectedItemIndex.value = 0
  455. copiedCustomizeColumns.value = []
  456. for (let i = 0; i < sensorList.value.length; i++) {
  457. sensorList.value[i].isSelected = false;
  458. }
  459. }
  460. const changeSelected = (index) =>{
  461. selectedItemIndex.value = index
  462. }
  463. const updateColumns = () => {
  464. const column = [
  465. { prop: "as_name", label: "站名", width: 100 },
  466. { prop: "as_code", label: "站号", width: 100 },
  467. { prop: "data_time_i", label: "观测时间", width: 170, sortable: true }
  468. ];
  469. const newColumns = customizeColumns.value.map(item => ({
  470. prop: item.data_id,
  471. label: item.data_name +'('+item.data_unit+')',
  472. sortable: true,
  473. width: calculateTextLengthInPixels(item.data_name)
  474. }));
  475. columns = [...column, ...newColumns];
  476. pageable.value.data_items = [...customizeColumns.value];
  477. getList();
  478. }
  479. //操作 自定义部分表头
  480. const copiedCustomizeColumns = ref<any>([...customizeColumns.value]);
  481. const userStore = useUserStore();
  482. const platformList =ref<any>(computed(() => userStore.stations))
  483. //搜索站号
  484. const selectedData= ref([])
  485. const selectedItems =(data)=>{
  486. if(data.length>0){
  487. pageable.value.as_code_list = data
  488. }else {
  489. const allCodes = platformList.value.map(item => item.as_code);
  490. pageable.value.as_code_list = allCodes
  491. }
  492. };
  493. // 查询所有人工要素字典表
  494. const elementList =ref<any>([])
  495. const getAllRgDataList = async () => {
  496. const { data } = await getRgDataList();
  497. elementList.value = data.list
  498. };
  499. const getList = async () => {
  500. if(pageable.value.as_code_list===undefined||pageable.value.as_code_list.length===0){
  501. // 没有站不给数据
  502. processTableData.value = []
  503. pageable.value.total=0
  504. return;
  505. }
  506. const { data } = await getDataItemList(pageable.value);
  507. processTableData.value = data.list
  508. pageable.value.total = data.total
  509. };
  510. // 要素的选中和取消
  511. const toggleSelection=(item)=> {
  512. item.isSelected=!item.isSelected
  513. if(item.isSelected){
  514. //添加
  515. copiedCustomizeColumns.value.push(item)
  516. }else {
  517. //删除
  518. copiedCustomizeColumns.value= copiedCustomizeColumns.value.filter(column => column.data_id !== item.data_id);
  519. }
  520. }
  521. const handleSetting = () => {
  522. copiedCustomizeColumns.value = [...customizeColumns.value]
  523. elementList.value.forEach(element => {
  524. const column = copiedCustomizeColumns.value.find(col => col.data_id === element.data_id);
  525. if (column) {
  526. element.isSelected = true;
  527. } else {
  528. element.isSelected = false;
  529. }
  530. });
  531. dialog.title = "列表字段设置"
  532. dialog.visible = true;
  533. }
  534. const submitForm = () => {
  535. dialog.visible = false;
  536. customizeColumns.value = [...copiedCustomizeColumns.value]
  537. updateColumns()
  538. saveCustomizeColumns()
  539. }
  540. // 大概计算字符串长度
  541. function calculateTextLengthInPixels(text) {
  542. return (text.length * 14)+100;
  543. }
  544. //时间戳转换为指定格式的日期字符串
  545. function formatDate(timestamp) {
  546. const date = new Date(timestamp * 1000); // 将时间戳转换为毫秒
  547. const year = date.getFullYear();
  548. const month = String(date.getMonth() + 1).padStart(2, '0');
  549. const day = String(date.getDate()).padStart(2, '0');
  550. const hours = String(date.getHours()).padStart(2, '0');
  551. const minutes = String(date.getMinutes()).padStart(2, '0');
  552. return `${year}-${month}-${day} ${hours}:${minutes}`;
  553. }
  554. onMounted(() => {
  555. const allCodes = platformList.value.map(item => item.as_code);
  556. pageable.value.as_code_list = allCodes
  557. loadCustomizeColumns()
  558. updateColumns()
  559. getAllRgDataList()
  560. })
  561. // 保存customizeColumns数组到localStorage
  562. function saveCustomizeColumns() {
  563. const jsonString = JSON.stringify(customizeColumns.value);
  564. localStorage.setItem('customizeColumns', jsonString);
  565. }
  566. // 从localStorage中获取customizeColumns数组
  567. function loadCustomizeColumns() {
  568. const jsonString = localStorage.getItem('customizeColumns');
  569. if (jsonString) {
  570. customizeColumns.value = JSON.parse(jsonString);
  571. }
  572. }
  573. let intervalId;
  574. onActivated(() => {
  575. intervalId = setInterval(() => {
  576. getList();
  577. }, 60 * 1000);
  578. });
  579. onDeactivated(() => {
  580. clearInterval(intervalId);
  581. });
  582. </script>