|
@@ -1,166 +1,276 @@
|
|
|
<template>
|
|
|
- <div id="service-publish" class="page-list">
|
|
|
- <ListHeader title="数据列表" :add-btn-name="'新建服务'" @add-item="handleAdd"/>
|
|
|
- <div class="list-main">
|
|
|
- <el-table :data="tableData.value" ref="table" class="table-default" id="table-list" stripe>
|
|
|
- <el-table-column type="index" :index="indexCreate" label="序号" min-width="50"/>
|
|
|
- <el-table-column label="服务名称" min-width="100" prop="name" show-overflow-tooltip/>
|
|
|
- <el-table-column label="服务类型" min-width="100" prop="type" show-overflow-tooltip/>
|
|
|
- <el-table-column label="资源名称" min-width="100" prop="resName" show-overflow-tooltip/>
|
|
|
- <el-table-column label="资源类别" min-width="100" prop="resCata" show-overflow-tooltip/>
|
|
|
- <el-table-column label="服务状态" min-width="100">
|
|
|
- <template #default="scope">
|
|
|
+ <div id="service-publish" class="page-list">
|
|
|
+ <ListHeader title="数据列表" :add-btn-name="'新建服务'" @add-item="handleAdd"/>
|
|
|
+ <div class="list-main">
|
|
|
+ <el-table :data="tableData.value" ref="table" class="table-default" id="table-list" stripe>
|
|
|
+ <el-table-column type="index" :index="indexCreate" label="序号" min-width="50"/>
|
|
|
+ <el-table-column label="服务名称" min-width="100" prop="serviceName" show-overflow-tooltip/>
|
|
|
+ <el-table-column label="服务类型" min-width="100" prop="serviceTypeName" show-overflow-tooltip/>
|
|
|
+ <el-table-column label="资源名称" min-width="100" prop="tresourceName" show-overflow-tooltip/>
|
|
|
+ <el-table-column label="资源类别" min-width="100" prop="tresourceTypeName" show-overflow-tooltip/>
|
|
|
+ <el-table-column label="服务状态" min-width="100">
|
|
|
+ <template #default="scope">
|
|
|
<span
|
|
|
- class="table-column-state"
|
|
|
- :class="{
|
|
|
- 'state-green':scope.row.serviceState==='正在运行',
|
|
|
- 'state-gray':scope.row.serviceState==='停止',
|
|
|
- 'state-red':scope.row.serviceState==='运行异常'||scope.row.serviceState==='发布失败',
|
|
|
- 'state-blue':scope.row.serviceState==='待发布',
|
|
|
- }"
|
|
|
- >{{ scope.row.serviceState }}</span>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- <el-table-column label="服务权限" min-width="100" prop="serviceAuth" show-overflow-tooltip/>
|
|
|
- <el-table-column label="最新发布时间" min-width="100" prop="publishTime" show-overflow-tooltip/>
|
|
|
- <el-table-column fixed="right" label="操作" min-width="120">
|
|
|
- <template #default="scope">
|
|
|
- <el-button link type="primary" @click="toDetail(scope.row)">详情</el-button>
|
|
|
- <el-button link type="primary" @click="toActivate(scope.row)">启用</el-button>
|
|
|
- <el-button link type="primary" @click="toEdit(scope.row)">编辑</el-button>
|
|
|
- <el-popconfirm title="确认删除此条?" @confirm="handleDelete(scope.row)">
|
|
|
- <template #reference>
|
|
|
- <el-button link type="primary">删除</el-button>
|
|
|
- </template>
|
|
|
- </el-popconfirm>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
- </el-table>
|
|
|
- <Pagination :total="tableTotal" :page-size="pageSize" @pageChange="pagi_changePage" />
|
|
|
+ class="table-column-state"
|
|
|
+ :class="{
|
|
|
+ 'state-green':scope.row.stateName==='正在发布',
|
|
|
+ 'state-gray':scope.row.stateName==='停止',
|
|
|
+ 'state-red':scope.row.stateName==='发布异常'||scope.row.stateName==='运行异常',
|
|
|
+ 'state-blue':scope.row.stateName==='待发布',
|
|
|
+ }">
|
|
|
+ {{ scope.row.stateName }}
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="服务权限" min-width="100" prop="permissionTypeName" show-overflow-tooltip/>
|
|
|
+ <el-table-column label="最新发布时间" min-width="100" prop="lastUpdateTime" show-overflow-tooltip/>
|
|
|
+ <el-table-column fixed="right" label="操作" min-width="120">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button link type="primary" @click="toDetail(scope.row)">详情</el-button>
|
|
|
+ <el-popconfirm title="确认启用此条?" @confirm="toActivate(scope.row)">
|
|
|
+ <template #reference>
|
|
|
+ <el-button link type="primary">启动</el-button>
|
|
|
+ </template>
|
|
|
+ </el-popconfirm>
|
|
|
+ <el-popconfirm title="确认停止此条?" @confirm="toStop(scope.row)" >
|
|
|
+ <template #reference>
|
|
|
+ <el-button link type="primary">停止</el-button>
|
|
|
+ </template>
|
|
|
+ </el-popconfirm>
|
|
|
+ <el-button link type="primary" @click="toEdit(scope.row)">编辑</el-button>
|
|
|
+ <el-popconfirm title="确认删除此条?" @confirm="handleDelete(scope.row)">
|
|
|
+ <template #reference>
|
|
|
+ <el-button link type="primary">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-popconfirm>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <Pagination :total="tableTotal" :page-size="pageSize" @pageChange="pagi_changePage"/>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { reactive, ref, onMounted } from 'vue'
|
|
|
-import ListHeader from '../../components/ListHeader.vue';
|
|
|
-import { useRouter, useRoute } from 'vue-router'
|
|
|
-import Pagination from '../../components/Pagination.vue';
|
|
|
-
|
|
|
-onMounted(() => {
|
|
|
- let tableH = document.getElementById('table-list').getElementsByClassName('el-table__body-wrapper')[0].clientHeight
|
|
|
- let rowH = 60/1920*document.body.clientWidth
|
|
|
- pageSize.value = Math.floor(tableH/rowH)
|
|
|
- getData(1, pageSize.value)
|
|
|
-})
|
|
|
-
|
|
|
-const currentPage = ref(1)
|
|
|
-const pageSize = ref(10)
|
|
|
-const tableTotal = ref(20)
|
|
|
-
|
|
|
-function pagi_changePage(page) {
|
|
|
- currentPage.value = page
|
|
|
- getData(page, pageSize.value)
|
|
|
-}
|
|
|
-
|
|
|
-function indexCreate(index) {
|
|
|
- return index + 1 + pageSize.value*(currentPage.value - 1)
|
|
|
-}
|
|
|
-
|
|
|
-function getData(page, size) {
|
|
|
- tableData.value=[]
|
|
|
- for(let i=(page-1)*size; i<page*size&&i<tableTotal.value; i++) {
|
|
|
- let state = ''
|
|
|
- switch(Math.floor(Math.random()*5)) {
|
|
|
- case 0:
|
|
|
- state = '正在运行'
|
|
|
- break
|
|
|
- case 1:
|
|
|
- state = '停止'
|
|
|
- break
|
|
|
- case 2:
|
|
|
- state = '发布失败'
|
|
|
- break
|
|
|
- case 3:
|
|
|
- state = '运行异常'
|
|
|
- break
|
|
|
- case 4:
|
|
|
- state = '待发布'
|
|
|
- break
|
|
|
+ import {reactive, ref, onMounted} from 'vue'
|
|
|
+ import ListHeader from '../../components/ListHeader.vue';
|
|
|
+ import {useRouter, useRoute} from 'vue-router'
|
|
|
+ import Pagination from '../../components/Pagination.vue';
|
|
|
+ import {
|
|
|
+ ServicePublishList,
|
|
|
+ ServicePublishDelete,
|
|
|
+ ServicePublishStart,
|
|
|
+ ServicePublishStop
|
|
|
+ } from '../../service/servicePublish'
|
|
|
+ import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ let tableH = document.getElementById('table-list').getElementsByClassName('el-table__body-wrapper')[0].clientHeight
|
|
|
+ let rowH = 60 / 1920 * document.body.clientWidth
|
|
|
+ pageSize.value = Math.floor(tableH / rowH)
|
|
|
+ getData(currentPage.value, pageSize.value)
|
|
|
+ })
|
|
|
+
|
|
|
+ const currentPage = ref(1)
|
|
|
+ const pageSize = ref(10)
|
|
|
+ const quickSearch = ref("{\"serviceName\":\"\"}")
|
|
|
+ const tableTotal = ref(20)
|
|
|
+
|
|
|
+ function pagi_changePage(page) {
|
|
|
+ currentPage.value = page
|
|
|
+ getData(currentPage.value, pageSize.value, quickSearch.value)
|
|
|
+ }
|
|
|
+
|
|
|
+ function indexCreate(index) {
|
|
|
+ return index + 1 + pageSize.value * (currentPage.value - 1)
|
|
|
}
|
|
|
- tableData.value.push({
|
|
|
- name: '轨道交通站点'+(i+1),
|
|
|
- type: '栅格切片',
|
|
|
- resName: '轨道交通站点',
|
|
|
- resCata: '基础目录',
|
|
|
- serviceState: state,
|
|
|
- serviceAuth: '自由服务',
|
|
|
- publishTime: '2022-01-01 16:30',
|
|
|
|
|
|
+ function getData() {
|
|
|
+ ServicePublishList(currentPage.value, pageSize.value, quickSearch.value).then(res => {
|
|
|
+ tableData.value = res.data.records
|
|
|
+ tableTotal.value = res.total
|
|
|
+ for (let data of tableData.value) {
|
|
|
+ switch (data.state) {
|
|
|
+ case 1:
|
|
|
+ data.stateName = '待发布'
|
|
|
+ break
|
|
|
+ case 2:
|
|
|
+ data.stateName = '正在发布'
|
|
|
+ break
|
|
|
+ case 3:
|
|
|
+ data.stateName = '发布异常'
|
|
|
+ break
|
|
|
+ case 4:
|
|
|
+ data.stateName = '停止'
|
|
|
+ break
|
|
|
+ case 5:
|
|
|
+ data.stateName = '运行异常'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ switch (data.serviceType) {
|
|
|
+ case 0:
|
|
|
+ data.serviceTypeName = '栅格切片'
|
|
|
+ break
|
|
|
+ case 1:
|
|
|
+ data.serviceTypeName = '三维服务'
|
|
|
+ break
|
|
|
+ case 2:
|
|
|
+ data.serviceTypeName = '要素服务'
|
|
|
+ break
|
|
|
+ case 3:
|
|
|
+ data.serviceTypeName = '动态服务'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ switch (data.tresourceType) {
|
|
|
+ case '0':
|
|
|
+ data.tresourceTypeName = '资源编目'
|
|
|
+ break
|
|
|
+ case '1':
|
|
|
+ data.tresourceTypeName = '专题目录'
|
|
|
+ break
|
|
|
+
|
|
|
+ }
|
|
|
+ switch (data.permissionType) {
|
|
|
+ case '0':
|
|
|
+ data.permissionTypeName = '自由服务'
|
|
|
+ break
|
|
|
+ case '1':
|
|
|
+ data.permissionTypeName = '安全服务'
|
|
|
+ break
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const table = ref(null)
|
|
|
+
|
|
|
+ const tableData = reactive({
|
|
|
+ value: []
|
|
|
})
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
-const table = ref(null)
|
|
|
+ const route = useRoute()
|
|
|
+ const router = useRouter()
|
|
|
|
|
|
-const tableData = reactive({value: []})
|
|
|
+ function handleAdd() {
|
|
|
+ router.push({
|
|
|
+ name: 'ServicePublishDataDetail',
|
|
|
+ params: {
|
|
|
+ type: 'add',
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
-const route = useRoute()
|
|
|
-const router = useRouter()
|
|
|
+ function toDetail(row) {
|
|
|
+ console.log('row', row)
|
|
|
|
|
|
-function handleAdd () {
|
|
|
- router.push({
|
|
|
- name: 'ServicePublishDataDetail',
|
|
|
- params: {
|
|
|
- type: 'add'
|
|
|
+ router.push({
|
|
|
+ name: 'ServicePublishDataDetail',
|
|
|
+ params: {
|
|
|
+ type: 'detail',
|
|
|
+ id: row.id
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-function toDetail() {
|
|
|
- router.push({
|
|
|
- name: 'ServicePublishDataDetail',
|
|
|
- params: {
|
|
|
- type: 'detail',
|
|
|
- id: row.id
|
|
|
+
|
|
|
+ function toActivate(row) {
|
|
|
+ ServicePublishStart(row.id).then(res => {
|
|
|
+ if (res.code == '200' && res.msg === '启动成功') {
|
|
|
+ ElMessage({type: 'success', message: '已启动'})
|
|
|
+ getData(currentPage.value, pageSize.value)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // ElMessageBox.confirm(
|
|
|
+ // '确认启用?',
|
|
|
+ // '提示',
|
|
|
+ // {
|
|
|
+ // confirmButtonText: '确认',
|
|
|
+ // cancelButtonText: '取消',
|
|
|
+ // type: 'warning',
|
|
|
+ // }
|
|
|
+ // )
|
|
|
+ // .then(() => {
|
|
|
+ // ServicePublishStart(row.id).then(res => {
|
|
|
+ // if (res.code === 200) {
|
|
|
+ // ElMessage({
|
|
|
+ // type: 'success',
|
|
|
+ // message: '已启动',
|
|
|
+ // })
|
|
|
+ // this.getData()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // .catch(() => {
|
|
|
+ // ElMessage({
|
|
|
+ // type: 'info',
|
|
|
+ // message: '已取消',
|
|
|
+ // })
|
|
|
+ // })
|
|
|
}
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-function toActivate() {
|
|
|
- this.$confirm('确认启用吗', '提示', {
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- StartService({ code: row.code }).then(res => {
|
|
|
- if(res.code == 200) {
|
|
|
- this.$notify({type: 'success', message: '已撤销'});
|
|
|
- this.getData()
|
|
|
- }
|
|
|
- })
|
|
|
- }).catch(() => {
|
|
|
- this.$notify({type: 'info', message: '已取消'});
|
|
|
- })
|
|
|
-}
|
|
|
-
|
|
|
-function toEdit() {
|
|
|
- router.push({
|
|
|
- name: 'ServicePublishDataDetail',
|
|
|
- params: {
|
|
|
- type: 'edit',
|
|
|
- id: row.id
|
|
|
+
|
|
|
+ const toStop = (row) => {
|
|
|
+ ServicePublishStop(row.id).then(res => {
|
|
|
+ if (res.code == '200' && res.msg === '停止成功') {
|
|
|
+ ElMessage({type: 'success', message: '已停止'})
|
|
|
+ getData(currentPage.value, pageSize.value)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // ElMessageBox.confirm(
|
|
|
+ // '确认停止?',
|
|
|
+ // '提示',
|
|
|
+ // {
|
|
|
+ // confirmButtonText: '确认',
|
|
|
+ // cancelButtonText: '取消',
|
|
|
+ // type: 'warning',
|
|
|
+ // }
|
|
|
+ // )
|
|
|
+ // .then(() => {
|
|
|
+ // ServicePublishStop(row.id).then(res => {
|
|
|
+ // if (res.code === 200) {
|
|
|
+ // ElMessage({
|
|
|
+ // type: 'success',
|
|
|
+ // message: '已停止',
|
|
|
+ // })
|
|
|
+ // this.getData()
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ // .catch(() => {
|
|
|
+ // ElMessage({
|
|
|
+ // type: 'info',
|
|
|
+ // message: '已取消',
|
|
|
+ // })
|
|
|
+ // })
|
|
|
+ }
|
|
|
+
|
|
|
+ function toEdit(row) {
|
|
|
+ router.push({
|
|
|
+ name: 'ServicePublishDataDetail',
|
|
|
+ params: {
|
|
|
+ type: 'edit',
|
|
|
+ id: row.id
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
- })
|
|
|
-}
|
|
|
|
|
|
-function handleDelete(row) {
|
|
|
- console.log(row)
|
|
|
-}
|
|
|
+ function handleDelete(row) {
|
|
|
+ ServicePublishDelete(row.id).then(res => {
|
|
|
+ if (res.code == '200' && res.msg === '删除成功') {
|
|
|
+ ElMessage({type: 'success', message: '已删除'})
|
|
|
+ if (currentPage.value !== 1 && tableData.value.length === 1) {
|
|
|
+ getData(currentPage.value - 1)
|
|
|
+ } else {
|
|
|
+ getData(currentPage.value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
-#service-publish {
|
|
|
-
|
|
|
-}
|
|
|
-
|
|
|
+ #service-publish {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
</style>
|