index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  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%;flex-grow: 1">
  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)"
  167. draggable="true"
  168. @dragstart="dragStart($event, index)"
  169. @dragover.prevent
  170. @drop="drop($event, index)"
  171. >{{item.data_name}}</div>
  172. </template>
  173. </div>
  174. <div class="button-container">
  175. <el-button type="primary" plain class="top-left" @click="changeMoveUp">上移</el-button>
  176. <el-button type="primary" plain class="top-right" @click="changeMoveDown">下移</el-button>
  177. <el-button type="primary" plain class="bottom-left" @click="changeRemove">移除</el-button>
  178. <el-button type="primary" plain class="bottom-right" @click="changeCleared">清空</el-button>
  179. </div>
  180. </div>
  181. </div>
  182. <template #footer>
  183. <div class="dialog-footer">
  184. <el-button @click="cancel">取 消</el-button>
  185. <el-button type="primary" @click="submitForm">确 定</el-button>
  186. </div>
  187. </template>
  188. </el-dialog>
  189. </div>
  190. </template>
  191. <script setup lang="ts" name="useProTable">
  192. import Pagination from "@/components/ProTable/components/Pagination.vue";
  193. import SelectItem from "@/components/SelectItem/index.vue";
  194. import {ref, reactive, onMounted, onDeactivated, onActivated, computed} from "vue";
  195. import { ColumnProps } from "@/components/ProTable/interface";
  196. import {ElTable} from "element-plus";
  197. import {getDataItemList, getPlatformList, getRgDataList} from "@/api/modules/allData";
  198. import { Platform} from "@/api/interface";
  199. import {useUserStore} from "@/stores/modules/user";
  200. const tableRef = ref<InstanceType<typeof ElTable>>();
  201. const dialog = reactive<any>({
  202. visible: false,
  203. title: ''
  204. });
  205. const cancel = () => {
  206. dialog.visible = false;
  207. }
  208. const handleSortChange = ({ column, prop, order }) => {
  209. console.log('column:', column);
  210. console.log('prop:', prop);
  211. console.log('order:', order);
  212. // Reset sorting if order is null
  213. if (order === null) {
  214. pageable.value.time_order = 0;
  215. pageable.value.data_order = [];
  216. getList();
  217. return;
  218. }
  219. // Handle time sorting
  220. if (prop === 'data_time_i') {
  221. pageable.value.time_order = order === 'descending' ? 0 : 1;
  222. pageable.value.data_order = [];
  223. getList();
  224. return;
  225. }
  226. // Default time order to 0
  227. pageable.value.time_order = 0;
  228. pageable.value.data_order = [];
  229. // Find the item with the matching data_id and update its order
  230. const item = pageable.value.data_items.find(item => item.data_id === prop);
  231. if (item) {
  232. item.data_order = order === 'descending' ? 0 : 1;
  233. pageable.value.data_order = [item];
  234. getList();
  235. }
  236. };
  237. const pageable = ref<any>({
  238. data_type: true,
  239. time_order: 0,
  240. as_code_list:undefined,
  241. data_items:[],
  242. data_order:[],
  243. pageNum: 1,
  244. pageSize: 20,
  245. total: 0
  246. });
  247. // 查询功能
  248. const handleQuery = () => {
  249. pageable.value.pageNum = 1;
  250. getList();
  251. };
  252. //重置功能
  253. const resetQuery = () => {
  254. const allCodes = platformList.value.map(item => item.as_code);
  255. pageable.value.as_code_list = allCodes
  256. selectedData.value = []
  257. pageable.value.pageNum = 1;
  258. pageable.value.time_order =0
  259. pageable.value.data_order =[]
  260. pageable.value.pageSize =20
  261. pageable.value.total = 0
  262. tableRef.value!.clearSort()
  263. getList();
  264. };
  265. /**
  266. * @description 每页条数改变
  267. * @param {Number} val 当前条数
  268. * @return void
  269. * */
  270. const handleSizeChange = (val: number) => {
  271. pageable.value.pageSize = val
  272. getList();
  273. };
  274. /**
  275. * @description 当前页改变
  276. * @param {Number} val 当前页
  277. * @return void
  278. * */
  279. const handleCurrentChange = (val: number) => {
  280. pageable.value.pageNum = val
  281. getList();
  282. };
  283. const processTableData = ref([]);
  284. // 表格配置项
  285. let columns = reactive<ColumnProps[]>([]);
  286. //自定义部分表头
  287. let customizeColumns= ref<any>([
  288. {
  289. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  290. data_id: 2,
  291. data_type: "风",
  292. data_item: "ER_FEN_ZHONG_PING_JUN_FENG_XIANG",
  293. data_name: "2分钟风向",
  294. data_unit: "°",
  295. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  296. data_value: "",
  297. data_order: 0,
  298. data_condition: 0
  299. },
  300. {
  301. data_id: 1,
  302. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  303. data_type: "风",
  304. data_name: "2分钟风速",
  305. data_item: "ER_FEN_ZHONG_PING_JUN_FENG_SU",
  306. data_unit: "m/s",
  307. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  308. data_value: "",
  309. data_order: 0,
  310. data_condition: 0
  311. },
  312. {
  313. data_id: 4,
  314. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  315. data_type: "风",
  316. data_name: "10分钟风向",
  317. data_item: "SHI_FEN_ZHONG_PING_JUN_FENG_XIANG",
  318. data_unit: "°",
  319. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  320. data_value: "",
  321. data_order: 0,
  322. data_condition: 0
  323. },
  324. {
  325. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  326. data_id: 3,
  327. data_type: "风",
  328. data_item: "SHI_FEN_ZHONG_PING_JUN_FENG_SU",
  329. data_name: "10分钟风速",
  330. data_unit: "m/s",
  331. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  332. data_value: "",
  333. data_order: 0,
  334. data_condition: 0
  335. },
  336. {
  337. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  338. data_id: 501,
  339. data_type: "能见度",
  340. data_item: "YI_FEN_ZHONG_PING_JUN_NENG_JIAN_DU",
  341. data_name: "1分钟平均能见度",
  342. data_unit: "m",
  343. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  344. data_value: "",
  345. data_order: 0,
  346. data_condition: 0
  347. },
  348. {
  349. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  350. data_id: 101,
  351. data_type: "温湿度",
  352. data_item: "QI_WEN",
  353. data_name: "气温",
  354. data_unit: "℃",
  355. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  356. data_value: "",
  357. data_order: 0,
  358. data_condition: 0
  359. },
  360. {
  361. data_id: 201,
  362. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  363. data_type: "气压",
  364. data_name: "水汽压",
  365. data_item: "SHUI_QI_YA",
  366. data_unit: "hPa",
  367. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  368. data_value: "",
  369. data_order: 0,
  370. data_condition: 0
  371. },
  372. {
  373. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  374. data_id: 109,
  375. data_type: "温湿度",
  376. data_item: "LU_DIAN_WEN_DU",
  377. data_name: "露点温度",
  378. data_unit: "℃",
  379. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  380. data_value: "",
  381. data_order: 0,
  382. data_condition: 0
  383. },
  384. {
  385. data_id: 202,
  386. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  387. data_type: "气压",
  388. data_name: "本站气压",
  389. data_item: "BEN_ZHAN_QI_YA",
  390. data_unit: "hPa",
  391. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  392. data_value: "",
  393. data_order: 0,
  394. data_condition: 0
  395. },{
  396. data_id: 207,
  397. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  398. data_type: "气压",
  399. data_name: "海平面气压",
  400. data_item: "HAI_PING_MIAN_QI_YA",
  401. data_unit: "hPa",
  402. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  403. data_value: "",
  404. data_order: 0,
  405. data_condition: 0
  406. },
  407. {
  408. data_r_table: "SHI_SHI_LIU_YAO_SU_SHU_JU",
  409. data_id: 312,
  410. data_type: "降水",
  411. data_item: "XIAO_SHI_LEI_JI_JIANG_SHUI_LIANG_CHENG_ZHONG",
  412. data_name: "小时累计降水量(称重)",
  413. data_unit: "mm",
  414. data_h_table: "LI_SHI_LIU_YAO_SU_SHU_JU",
  415. data_value: "",
  416. data_order: 0,
  417. data_condition: 0
  418. }
  419. ])
  420. const sensorList =ref<any>([])
  421. // 被选中当条数据下标
  422. const selectedItemIndex = ref(0)
  423. const changeMoveUp = () =>{
  424. //上移
  425. if (selectedItemIndex.value > 0) {
  426. const temp = copiedCustomizeColumns.value[selectedItemIndex.value - 1]
  427. copiedCustomizeColumns.value[selectedItemIndex.value - 1] = copiedCustomizeColumns.value[selectedItemIndex.value]
  428. copiedCustomizeColumns.value[selectedItemIndex.value] = temp
  429. selectedItemIndex.value--
  430. }
  431. }
  432. const changeMoveDown = ()=>{
  433. //下移
  434. if (selectedItemIndex.value < copiedCustomizeColumns.value.length - 1) {
  435. const temp = copiedCustomizeColumns.value[selectedItemIndex.value + 1]
  436. copiedCustomizeColumns.value[selectedItemIndex.value + 1] = copiedCustomizeColumns.value[selectedItemIndex.value]
  437. copiedCustomizeColumns.value[selectedItemIndex.value] = temp
  438. selectedItemIndex.value++
  439. }
  440. }
  441. const dragStart = (event, index) => {
  442. event.dataTransfer.effectAllowed = 'move';
  443. // 保存当前拖动的元素索引
  444. event.dataTransfer.setData('text/plain', index.toString());
  445. };
  446. const drop = (event, index) => {
  447. const draggedIndex = parseInt(event.dataTransfer.getData('text/plain'));
  448. // 移动数组中的元素来更新顺序
  449. const draggedItem = copiedCustomizeColumns.value.splice(draggedIndex, 1)[0];
  450. copiedCustomizeColumns.value.splice(index, 0, draggedItem);
  451. };
  452. const changeRemove= ()=>{
  453. //删除数据
  454. if (copiedCustomizeColumns.value.length > 0) {
  455. const custom= copiedCustomizeColumns.value[selectedItemIndex.value];
  456. const se_type = custom.se_type
  457. for (let i = 0; i < sensorList.value.length; i++) {
  458. if (sensorList.value[i].se_type === se_type) {
  459. sensorList.value[i].isSelected = false;
  460. }
  461. }
  462. copiedCustomizeColumns.value.splice(selectedItemIndex.value, 1)
  463. if (selectedItemIndex.value === copiedCustomizeColumns.value.length) {
  464. selectedItemIndex.value--
  465. }
  466. }
  467. }
  468. const changeCleared=()=>{
  469. //清空所有数据
  470. selectedItemIndex.value = 0
  471. copiedCustomizeColumns.value = []
  472. for (let i = 0; i < sensorList.value.length; i++) {
  473. sensorList.value[i].isSelected = false;
  474. }
  475. }
  476. const changeSelected = (index) =>{
  477. selectedItemIndex.value = index
  478. }
  479. const updateColumns = () => {
  480. const column = [
  481. { prop: "as_name", label: "站名", width: 100 },
  482. { prop: "as_code", label: "站号", width: 100 },
  483. { prop: "data_time_i", label: "观测时间", width: 170, sortable: true }
  484. ];
  485. const newColumns = customizeColumns.value.map(item => ({
  486. prop: item.data_id,
  487. label: item.data_name +'('+item.data_unit+')',
  488. sortable: true,
  489. width: calculateTextLengthInPixels(item.data_name)
  490. }));
  491. columns = [...column, ...newColumns];
  492. pageable.value.data_items = [...customizeColumns.value];
  493. getList();
  494. }
  495. //操作 自定义部分表头
  496. const copiedCustomizeColumns = ref<any>([...customizeColumns.value]);
  497. const userStore = useUserStore();
  498. const platformList =ref<any>(computed(() => userStore.stations))
  499. //搜索站号
  500. const selectedData= ref([])
  501. const selectedItems =(data)=>{
  502. if(data.length>0){
  503. pageable.value.as_code_list = data
  504. }else {
  505. const allCodes = platformList.value.map(item => item.as_code);
  506. pageable.value.as_code_list = allCodes
  507. }
  508. };
  509. // 查询所有人工要素字典表
  510. const elementList =ref<any>([])
  511. const getAllRgDataList = async () => {
  512. const { data } = await getRgDataList();
  513. elementList.value = data.list
  514. };
  515. const getList = async () => {
  516. if(pageable.value.as_code_list===undefined||pageable.value.as_code_list.length===0){
  517. // 没有站不给数据
  518. processTableData.value = []
  519. pageable.value.total=0
  520. return;
  521. }
  522. const { data } = await getDataItemList(pageable.value);
  523. processTableData.value = data.list
  524. pageable.value.total = data.total
  525. };
  526. // 要素的选中和取消
  527. const toggleSelection=(item)=> {
  528. item.isSelected=!item.isSelected
  529. if(item.isSelected){
  530. //添加
  531. copiedCustomizeColumns.value.push(item)
  532. }else {
  533. //删除
  534. copiedCustomizeColumns.value= copiedCustomizeColumns.value.filter(column => column.data_id !== item.data_id);
  535. }
  536. }
  537. const handleSetting = () => {
  538. copiedCustomizeColumns.value = [...customizeColumns.value]
  539. elementList.value.forEach(element => {
  540. const column = copiedCustomizeColumns.value.find(col => col.data_id === element.data_id);
  541. if (column) {
  542. element.isSelected = true;
  543. } else {
  544. element.isSelected = false;
  545. }
  546. });
  547. dialog.title = "列表字段设置"
  548. dialog.visible = true;
  549. }
  550. const submitForm = () => {
  551. dialog.visible = false;
  552. customizeColumns.value = [...copiedCustomizeColumns.value]
  553. updateColumns()
  554. saveCustomizeColumns()
  555. }
  556. // 大概计算字符串长度
  557. function calculateTextLengthInPixels(text) {
  558. return (text.length * 14)+100;
  559. }
  560. //时间戳转换为指定格式的日期字符串
  561. function formatDate(timestamp) {
  562. const date = new Date(timestamp * 1000); // 将时间戳转换为毫秒
  563. const year = date.getFullYear();
  564. const month = String(date.getMonth() + 1).padStart(2, '0');
  565. const day = String(date.getDate()).padStart(2, '0');
  566. const hours = String(date.getHours()).padStart(2, '0');
  567. const minutes = String(date.getMinutes()).padStart(2, '0');
  568. return `${year}-${month}-${day} ${hours}:${minutes}`;
  569. }
  570. onMounted(() => {
  571. const allCodes = platformList.value.map(item => item.as_code);
  572. pageable.value.as_code_list = allCodes
  573. loadCustomizeColumns()
  574. updateColumns()
  575. getAllRgDataList()
  576. })
  577. // 保存customizeColumns数组到localStorage
  578. function saveCustomizeColumns() {
  579. const jsonString = JSON.stringify(customizeColumns.value);
  580. localStorage.setItem('customizeColumns', jsonString);
  581. }
  582. // 从localStorage中获取customizeColumns数组
  583. function loadCustomizeColumns() {
  584. const jsonString = localStorage.getItem('customizeColumns');
  585. if (jsonString) {
  586. customizeColumns.value = JSON.parse(jsonString);
  587. }
  588. }
  589. let intervalId;
  590. onActivated(() => {
  591. intervalId = setInterval(() => {
  592. getList();
  593. }, 30 * 1000);
  594. });
  595. onDeactivated(() => {
  596. clearInterval(intervalId);
  597. });
  598. </script>