ConfigManage.vue 9.4 KB

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