• Vue-SplitPane可拖拽分隔面板(随意拖动div)


    npm install vue-splitpane
    

    一、使用

    (1)局部使用:

    vue文件中

    1. import splitPane from 'vue-splitpane'
    2. export default {
    3. componnets: { splitPane }
    4. }

    (2)全局使用:

    在main.js文件注册

    1. import splitPane from 'vue-splitpane'
    2. // 注册为全局组件
    3. Vue.component('split-pane', splitPane);

    二、使用局部在vue文件中使用例子

    先分割成左右(注意只能两个两个分割,自由选择竖直还是水平分割)

    重点是:

    1. <split-pane
    2. split="vertical"
    3. @resize="resizeSplit"
    4. :default-percent="defaultPercent1"
    5. >
    6. <template slot="paneL">template>
    7. <template slot="paneR">template>
    8. split-pane>

    html:代码

    data代码:

    1. defaultPercent1:
    2. sessionStorage.getItem("defaultPercent1") == null
    3. ? 50
    4. : parseFloat(sessionStorage.getItem("defaultPercent1")),
    5. defaultPercent2:
    6. sessionStorage.getItem("defaultPercent2") == null
    7. ? 20
    8. : parseFloat(sessionStorage.getItem("defaultPercent2")),
    9. defaultPercent3:
    10. sessionStorage.getItem("defaultPercent3") == null
    11. ? 20
    12. : parseFloat(sessionStorage.getItem("defaultPercent3")),
    13. defaultPercent4:
    14. sessionStorage.getItem("defaultPercent4") == null
    15. ? 25
    16. : parseFloat(sessionStorage.getItem("defaultPercent4")),

    method代码:

    所有代码

    1. <template>
    2. <div id="container">
    3. <split-pane
    4. split="vertical"
    5. @resize="resizeSplit"
    6. :default-percent="defaultPercent1"
    7. >
    8. <template slot="paneL">
    9. <split-pane
    10. split="horizontal"
    11. :default-percent="defaultPercent2"
    12. @resize="resizeSplit2"
    13. >
    14. <template slot="paneL">
    15. <div class="topLeft">
    16. <div class="title">空域div>
    17. <div class="contentTable">
    18. <el-table
    19. :data="maneuverTable"
    20. border
    21. height="100%"
    22. :cell-style="customCellStyle"
    23. >
    24. <el-table-column
    25. prop="beginTime"
    26. align="center"
    27. label="日期"
    28. width="100"
    29. >
    30. el-table-column>
    31. <el-table-column prop="content" align="center" label="内容">
    32. el-table-column>
    33. <el-table-column
    34. prop="source"
    35. align="center"
    36. label="通报单位"
    37. width="100"
    38. >
    39. el-table-column>
    40. el-table>
    41. div>
    42. div>
    43. template>
    44. <template slot="paneR">
    45. <div class="bottomLeft">
    46. <div class="title">军方活动div>
    47. <div class="contentTable">
    48. <el-table
    49. :data="militaryTable"
    50. border
    51. height="100%"
    52. :cell-style="customCellStyle"
    53. >
    54. <el-table-column
    55. prop="beginTime"
    56. align="center"
    57. label="日期"
    58. width="100"
    59. >
    60. el-table-column>
    61. <el-table-column prop="content" align="center" label="内容">
    62. el-table-column>
    63. <el-table-column
    64. prop="source"
    65. align="center"
    66. label="通报单位"
    67. width="100"
    68. >
    69. el-table-column>
    70. el-table>
    71. div>
    72. div>
    73. template>
    74. split-pane>
    75. template>
    76. <template slot="paneR">
    77. <split-pane
    78. split="horizontal"
    79. :default-percent="defaultPercent3"
    80. @resize="resizeSplit3"
    81. >
    82. <template slot="paneL">
    83. <div class="topRight">
    84. <div class="title">设备div>
    85. <div class="contentTable multi-rmk-col">
    86. <el-table
    87. :data="deviceTable"
    88. border
    89. height="100%"
    90. :cell-style="customCellStyle"
    91. >
    92. <el-table-column
    93. prop="beginTime"
    94. align="center"
    95. label="日期"
    96. width="100"
    97. >
    98. el-table-column>
    99. <el-table-column prop="content" align="center" label="内容">
    100. el-table-column>
    101. <el-table-column
    102. prop="source"
    103. align="center"
    104. label="通报单位"
    105. width="100"
    106. >
    107. el-table-column>
    108. el-table>
    109. div>
    110. div>
    111. template>
    112. <template slot="paneR">
    113. <split-pane
    114. split="horizontal"
    115. :default-percent="defaultPercent4"
    116. @resize="resizeSplit4"
    117. >
    118. <template slot="paneL">
    119. <div class="brTop">
    120. <div class="title">限制div>
    121. <div class="contentTable">
    122. <el-table
    123. :data="limitationTable"
    124. border
    125. height="100% "
    126. :cell-style="customCellStyle"
    127. >
    128. <el-table-column
    129. prop="beginTime"
    130. align="center"
    131. label="日期"
    132. width="100"
    133. >
    134. el-table-column>
    135. <el-table-column prop="content" align="center" label="内容">
    136. el-table-column>
    137. <el-table-column
    138. prop="source"
    139. align="center"
    140. label="通报单位"
    141. width="100"
    142. >
    143. el-table-column>
    144. el-table>
    145. div>
    146. div>
    147. template>
    148. <template slot="paneR">
    149. <div class="brBottom">
    150. <div class="title">通航div>
    151. <div class="contentTable">
    152. <el-table
    153. :data="airTable"
    154. border
    155. height="100%"
    156. :cell-style="customCellStyle"
    157. >
    158. <el-table-column
    159. prop="beginTime"
    160. align="center"
    161. label="日期"
    162. width="100"
    163. >
    164. el-table-column>
    165. <el-table-column prop="content" align="center" label="内容">
    166. el-table-column>
    167. <el-table-column
    168. prop="source"
    169. align="center"
    170. label="通报单位"
    171. width="100"
    172. >
    173. el-table-column>
    174. el-table>
    175. div>
    176. div>
    177. template>
    178. split-pane>
    179. template>
    180. split-pane>
    181. template>
    182. split-pane>
    183. div>
    184. template>
    185. <script>
    186. import splitPane from "vue-splitpane";
    187. import axios from "axios";
    188. import { getAtcRecord } from "@/api/operationInformation.js";
    189. let getDataInt = null; //获取各业务数据定时返回的ID
    190. export default {
    191. components: { splitPane },
    192. data() {
    193. return {
    194. items: "",
    195. airTable: [],
    196. limitationTable: [],
    197. deviceTable: [],
    198. militaryTable: [],
    199. maneuverTable: [],
    200. // div变动
    201. defaultPercent1:
    202. sessionStorage.getItem("defaultPercent1") == null
    203. ? 50
    204. : parseFloat(sessionStorage.getItem("defaultPercent1")),
    205. defaultPercent2:
    206. sessionStorage.getItem("defaultPercent2") == null
    207. ? 20
    208. : parseFloat(sessionStorage.getItem("defaultPercent2")),
    209. defaultPercent3:
    210. sessionStorage.getItem("defaultPercent3") == null
    211. ? 20
    212. : parseFloat(sessionStorage.getItem("defaultPercent3")),
    213. defaultPercent4:
    214. sessionStorage.getItem("defaultPercent4") == null
    215. ? 25
    216. : parseFloat(sessionStorage.getItem("defaultPercent4")),
    217. };
    218. },
    219. mounted() {
    220. //监听页面显隐状态
    221. window.addEventListener("message", (event) => {
    222. let topic = event.data.closeIframe;
    223. if (topic) {
    224. window.clearInterval(getDataInt);
    225. } else if (topic == false) {
    226. if (getDataInt) {
    227. window.clearInterval(getDataInt);
    228. }
    229. //开启轮询模式
    230. this.setIntervalMethod();
    231. }
    232. });
    233. //开启轮询模式
    234. this.setIntervalMethod();
    235. },
    236. methods: {
    237. //开启轮询模式
    238. setIntervalMethod() {
    239. this.onQuery();
    240. //定时每2秒获取一次各业务数据
    241. this.$nextTick(() => {
    242. getDataInt = setInterval(() => {
    243. this.onQuery();
    244. }, 2000);
    245. });
    246. },
    247. onQuery() {
    248. axios
    249. .get(window.operationInformationPath)
    250. .then((res) => {
    251. this.items = res.data.data;
    252. if (Array.isArray(this.items)) {
    253. for (let x of this.items) {
    254. x.beginTime = this.parseTime(x.beginTime);
    255. }
    256. const filteredData = this.items.filter(
    257. (item) => item.dept === "进近管制室"
    258. );
    259. this.limitationTable = filteredData.filter(
    260. (record) => record.type === "限制相邻"
    261. );
    262. this.deviceTable = filteredData.filter(
    263. (record) => record.type === "设备"
    264. );
    265. this.militaryTable = filteredData.filter(
    266. (record) => record.type === "军航活动"
    267. );
    268. this.airTable = filteredData.filter(
    269. (record) => record.type === "通用航空"
    270. );
    271. this.maneuverTable = filteredData.filter(
    272. (record) => record.type === "机动空域"
    273. );
    274. }
    275. })
    276. .catch((error) => {
    277. console.log(error);
    278. });
    279. // getAtcRecord().then((res) => {
    280. // console.log(res)
    281. // })
    282. },
    283. parseTime(originalDateString) {
    284. // 创建日期对象
    285. const date = new Date(originalDateString);
    286. // 获取日期、小时和分钟
    287. const month = (date.getMonth() + 1).toString().padStart(2, "0"); // 月份从0开始,需要加1
    288. const day = date.getDate().toString().padStart(2, "0");
    289. const hours = date.getHours().toString().padStart(2, "0");
    290. const minutes = date.getMinutes().toString().padStart(2, "0");
    291. // 格式化日期
    292. const formattedDate = `${month}-${day} ${hours}:${minutes}`;
    293. return formattedDate;
    294. },
    295. customCellStyle({ row, column }) {
    296. if (column.property === "source") {
    297. return {
    298. "text-align": "center", // 设置内容水平居中
    299. };
    300. } else {
    301. return {
    302. "text-align": "left", // 设置内容左对齐
    303. };
    304. }
    305. },
    306. // div随意变动
    307. resizeSplit(val) {
    308. this.defaultPercent1 = val;
    309. sessionStorage.setItem("defaultPercent1", this.defaultPercent1);
    310. },
    311. resizeSplit2(val) {
    312. this.defaultPercent2 = val;
    313. sessionStorage.setItem("defaultPercent2", this.defaultPercent2);
    314. },
    315. resizeSplit3(val) {
    316. this.defaultPercent3 = val;
    317. sessionStorage.setItem("defaultPercent3", this.defaultPercent3);
    318. },
    319. resizeSplit4(val) {
    320. this.defaultPercent4 = val;
    321. sessionStorage.setItem("defaultPercent4", this.defaultPercent4);
    322. },
    323. },
    324. };
    325. script>
    326. <style scoped>
    327. #container {
    328. width: 100%;
    329. height: 100%;
    330. padding: 10px;
    331. }
    332. .topLeft {
    333. height: 100%;
    334. width: calc(100% - 4px);
    335. margin-right: 4px;
    336. display: flex;
    337. flex-direction: column;
    338. padding: 10px;
    339. background-color: #4a4a4a;
    340. }
    341. .topRight {
    342. height: 100%;
    343. display: flex;
    344. flex-direction: column;
    345. padding: 10px;
    346. background-color: #4a4a4a;
    347. }
    348. .bottomLeft {
    349. width: calc(100% - 4px);
    350. margin-right: 4px;
    351. height: calc(100% - 8px);
    352. margin-top: 8px;
    353. display: flex;
    354. flex-direction: column;
    355. padding: 10px;
    356. background-color: #4a4a4a;
    357. }
    358. .brTop {
    359. height: calc(100% - 8px);
    360. margin-top: 8px;
    361. display: flex;
    362. flex-direction: column;
    363. padding: 10px;
    364. background-color: #4a4a4a;
    365. }
    366. .brBottom {
    367. height: calc(100% - 8px);
    368. margin-top: 8px;
    369. display: flex;
    370. flex-direction: column;
    371. padding: 10px;
    372. background-color: #4a4a4a;
    373. }
    374. .title {
    375. height: 26px;
    376. color: #9fe1f9;
    377. font-weight: 700;
    378. font-size: 16px;
    379. padding-left: 5px;
    380. }
    381. .contentTable {
    382. flex: 1;
    383. height: calc(100% - 26px);
    384. overflow: auto;
    385. }
    386. .contentTable >>> .el-table__body-wrapper::-webkit-scrollbar {
    387. width: 10px;
    388. height: 8px;
    389. }
    390. /* 修改每行高度 */
    391. /* .topRight >>> .el-table__row {
    392. height: 100px !important;
    393. } */
    394. /* .splitter-pane-resizer {
    395. background: transparent!important;
    396. } */
    397. .vue-splitter-container >>> .splitter-pane-resizer{
    398. background: transparent!important;
    399. }
    400. style>

  • 相关阅读:
    Axure RP医疗在线挂号问诊原型图医院APP原形模板
    FPGA的DQPSK调制解调Verilog
    Node与ES6模块
    一、综合——通信职业道德
    4K投影仪为什么比1080P投影仪更值得买?答案显而易见!
    数据结构中的判定转状态+扫描线:P1502
    计算机毕业设计Java电子产品购物平台(源码+系统+mysql数据库+lw文档)
    非分布式-多线程事务控制核心代码1
    OOP面向对象编程
    剑指offer——JZ25 合并两个排序的链表 解题思路与具体代码【C++】
  • 原文地址:https://blog.csdn.net/qq_42192641/article/details/134253667