Publish.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <div id="configManage">
  3. <div class="functionBtn">
  4. <el-select
  5. v-show="proxyType!='INTEGRATION'"
  6. v-model="dataType"
  7. placeholder="请选择类型"
  8. style="margin-right: 12px"
  9. default-first-option
  10. >
  11. <el-option
  12. v-for="(item, index) in selectOptions"
  13. :key="index"
  14. :label="item.label"
  15. :value="item.value"
  16. ></el-option>
  17. </el-select>
  18. <el-button
  19. type="primary"
  20. round
  21. @click="handleDetailVisible('Add')"
  22. >新增配置</el-button>
  23. <el-button
  24. v-show="proxyType!='INTEGRATION'"
  25. round
  26. @click="viewAllModel"
  27. >全部预览</el-button>
  28. <el-tooltip
  29. content="刷新"
  30. placement="right"
  31. >
  32. <el-button
  33. circle
  34. @click="refresh"
  35. ><el-icon><IconPark-refresh /></el-icon></el-button>
  36. </el-tooltip>
  37. </div>
  38. <div class="tableContent">
  39. <el-table
  40. ref="table"
  41. :data="tableData"
  42. :max-height="maxHeight"
  43. v-loading="loading"
  44. @current-change="(row)=>{this.currRow=row}"
  45. border
  46. stripe
  47. >
  48. <el-table-column
  49. prop="id"
  50. label="ID"
  51. width="60"
  52. align="center"
  53. />
  54. <el-table-column
  55. prop="key"
  56. label="标题"
  57. min-width="100"
  58. >
  59. <template #default="scope">
  60. <span style="font-weight: bold;font-family: JetBrainsMono-Regular,serif">{{scope.row.key}}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column
  64. prop="content"
  65. label="描述"
  66. min-width="120"
  67. />
  68. <el-table-column
  69. prop="proxyUrl"
  70. label="链接"
  71. min-width="180"
  72. >
  73. <template #default="scope">
  74. <span style="font-family: JetBrainsMono-Regular,serif">{{ scope.row.proxyUrl}}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column
  78. prop="operation"
  79. label="操作"
  80. min-width="120"
  81. >
  82. <template #default="scope">
  83. <el-button
  84. type="primary"
  85. size="small"
  86. @click="handleDetailVisible('Edit', scope.row)"
  87. >
  88. <el-icon><IconPark-edit /></el-icon>
  89. 修改
  90. </el-button>
  91. <el-button
  92. size="small"
  93. @click="deleteConfig(scope.row)"
  94. >
  95. <el-icon><IconPark-delete /></el-icon>
  96. 删除
  97. </el-button>
  98. <el-button
  99. v-show="proxyType!='INTEGRATION'"
  100. size="small"
  101. @click="view(scope.row)"
  102. >
  103. <el-icon><IconPark-preview-open /></el-icon>
  104. 预览
  105. </el-button>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. <div class="pagination">
  110. <el-pagination
  111. background
  112. layout="sizes, prev, pager, next, jumper, ->, total"
  113. v-model:current-page="pageInfo.page"
  114. v-model:page-size="pageInfo.pageSize"
  115. :total="pageInfo.total"
  116. />
  117. </div>
  118. </div>
  119. </div>
  120. <ConfigDetail
  121. v-model:show="detailVisible"
  122. :operation="detailOperation"
  123. :item="currRow"
  124. :is-edit="detailIsEdit"
  125. :select-options="selectOptions"
  126. :proxy-type="proxyType"
  127. :data-type="dataType"
  128. :refresh="getData"
  129. >
  130. </ConfigDetail>
  131. <CesiumMap
  132. v-if="isMapShow"
  133. :is-show="isMapShow"
  134. :type="mapType"
  135. :close="closeMap"
  136. :item="mapItem"
  137. >
  138. </CesiumMap>
  139. <AllCesiumMap
  140. v-if="isAllMapShow"
  141. :is-show="isAllMapShow"
  142. :type="allMapType"
  143. :close="closeMap"
  144. :item="tableData"
  145. >
  146. </AllCesiumMap>
  147. </template>
  148. <script>
  149. import ConfigDetail from "./dialog/ConfigDetail.vue";
  150. import CesiumMap from "./dialog/CesiumMap.vue";
  151. import AllCesiumMap from "./dialog/AllCesiumMap.vue";
  152. import api from "@/api/data/publish"
  153. export default {
  154. data() {
  155. return {
  156. maxHeight: 450,
  157. loading: false,
  158. configData: [],
  159. tableData: [],
  160. currRow: {},
  161. pageInfo: {
  162. page: 1,
  163. pageSize: 10,
  164. total: 0,
  165. },
  166. proxyType: "",
  167. dataType: "",
  168. selectOptions: [],
  169. dataTypes: {
  170. 99: {
  171. label: "数据",
  172. value: "UNKNOWN",
  173. },
  174. 0: {
  175. label: "全部",
  176. value: "ALL",
  177. },
  178. 1: {
  179. label: "地图",
  180. value: "MAP",
  181. },
  182. 2: {
  183. label: "三维模型",
  184. value: "MODEL",
  185. },
  186. 3: {
  187. label: "GLTF模型",
  188. value: "GLTF",
  189. },
  190. },
  191. routerParam: {
  192. publish_twoD: {
  193. proxyType: "PUBLISH",
  194. dataTypes: [1],
  195. },
  196. publish_threeD: {
  197. proxyType: "PUBLISH",
  198. dataTypes: [2, 3],
  199. },
  200. integration_data: {
  201. proxyType: "INTEGRATION",
  202. dataTypes: [99],
  203. },
  204. },
  205. mapTypes: {
  206. MODEL: 1,
  207. GLTF: 2,
  208. MAP: 4,
  209. },
  210. detailVisible: false,
  211. detailOperation: "",
  212. detailIsEdit: false,
  213. isMapShow: false,
  214. mapType: 0,
  215. mapItem: {},
  216. allMapType: -1,
  217. isAllMapShow: false,
  218. };
  219. },
  220. watch: {
  221. "pageInfo.page": function () {
  222. this.renderTable();
  223. },
  224. "pageInfo.pageSize": function () {
  225. this.renderTable();
  226. },
  227. dataType: function () {
  228. this.refresh();
  229. },
  230. "$route.name": function (val) {
  231. if (val) {
  232. this.initType();
  233. this.refresh();
  234. }
  235. },
  236. },
  237. components: {
  238. ConfigDetail,
  239. CesiumMap,
  240. AllCesiumMap,
  241. },
  242. created() {
  243. this.initType();
  244. },
  245. mounted() {
  246. let container = document.getElementById("configManage");
  247. this.maxHeight = container.clientHeight * 0.85;
  248. this.getData();
  249. },
  250. methods: {
  251. initType() {
  252. // let obj = this.routerParam[this.$route.name];
  253. let obj = this.routerParam["publish_twoD"];
  254. if (!obj) {
  255. return;
  256. }
  257. this.proxyType = obj.proxyType;
  258. this.dataType = "";
  259. this.selectOptions = [];
  260. //this.selectOptions.push(this.dataTypes[0])
  261. for (let index of obj.dataTypes) {
  262. this.selectOptions.push(this.dataTypes[index]);
  263. }
  264. if (this.selectOptions.length > 0) {
  265. this.dataType = this.selectOptions[0].value;
  266. }
  267. },
  268. refresh() {
  269. this.pageInfo.page = 1;
  270. this.pageInfo.pageSize = 10;
  271. this.pageInfo.total = 0;
  272. this.getData();
  273. },
  274. getData() {
  275. if (!this.dataType || this.dataType == "") {
  276. this.configData = [];
  277. this.tableData = [];
  278. this.pageInfo.total = 0;
  279. return;
  280. }
  281. let that = this;
  282. that.loading = true;
  283. let params = {
  284. proxyType: this.proxyType,
  285. dataType: this.dataType,
  286. };
  287. api.getList(params)
  288. .then((res) => {
  289. that.configData = [];
  290. if (res.code === 200) {
  291. let num = 0;
  292. that.configData = [];
  293. that.pageInfo.total = 0;
  294. if (res.content) {
  295. that.configData = JSON.parse(JSON.stringify(res.content));
  296. that.configData.forEach((i) => {
  297. i.id = num++;
  298. i.proxyUrl = systemConfig.proxyUrl.replace("{PROXYURL}", i.key);
  299. });
  300. that.pageInfo.total = that.configData.length;
  301. }
  302. this.renderTable();
  303. }
  304. that.loading = false;
  305. })
  306. .catch((err) => {
  307. that.loading = false;
  308. that.$message({ message: err.message, type: "error" });
  309. });
  310. },
  311. renderTable() {
  312. let start = (this.pageInfo.page - 1) * this.pageInfo.pageSize;
  313. let end = this.pageInfo.page * this.pageInfo.pageSize;
  314. this.tableData = this.configData.slice(start, end);
  315. },
  316. handleDetailVisible(operation, item) {
  317. this.detailOperation = operation;
  318. this.detailVisible = true;
  319. this.detailIsEdit = true;
  320. if (operation === "Add") {
  321. this.currRow = { title: "", url: "" };
  322. this.detailIsEdit = false;
  323. } else {
  324. this.currRow = JSON.parse(JSON.stringify(item));
  325. }
  326. },
  327. viewAllModel() {
  328. let type = this.mapTypes[this.dataType];
  329. if (type) {
  330. this.allMapType = type;
  331. this.isAllMapShow = true;
  332. } else {
  333. this.$message.error("该类型暂不支持预览");
  334. return;
  335. }
  336. },
  337. view(item) {
  338. // 0-GeoJson、1-3DTiles、2-gltf/glb、3-水面、4-地图
  339. this.mapItem = JSON.parse(JSON.stringify(item));
  340. let type = this.mapTypes[this.dataType];
  341. if (type) {
  342. this.mapType = type;
  343. this.isMapShow = true;
  344. } else {
  345. this.$message.error("该类型暂不支持预览");
  346. return;
  347. }
  348. },
  349. closeMap() {
  350. this.isMapShow = false;
  351. this.isAllMapShow = false;
  352. },
  353. deleteConfig(item) {
  354. let that = this;
  355. this.$msgbox.confirm("确定要删除:" + item.key + "吗?").then(() => {
  356. let params = {
  357. proxyType: this.proxyType,
  358. dataType: this.dataType,
  359. index: item.id,
  360. };
  361. api
  362. .delItem(params)
  363. .then((res) => {
  364. if (res.code === 200) {
  365. that.$message({ message: "删除成功", type: "success" });
  366. that.getData();
  367. } else {
  368. that.$message({ message: res.content, type: "error" });
  369. }
  370. })
  371. .catch((err) => {
  372. that.$message({ message: err.message, type: "error" });
  373. });
  374. });
  375. },
  376. },
  377. };
  378. </script>
  379. <style lang="less" scoped>
  380. #configManage {
  381. width: 98%;
  382. height: 100%;
  383. margin-left: 20px;
  384. .tableContent {
  385. margin-top: 1%;
  386. .pagination {
  387. margin-top: 1%;
  388. position: relative;
  389. float: right;
  390. padding-bottom: 5%;
  391. }
  392. }
  393. }
  394. </style>