|
@@ -35,7 +35,7 @@
|
|
|
@del-remove="delSubmitHandler"
|
|
|
@del-rest="delDialogHide"
|
|
|
@submit-form="serviceSubmitHandler"
|
|
|
- @reset-form="serviceDialogHide"
|
|
|
+ @reset-form="addServiceDialogHide"
|
|
|
>
|
|
|
<el-form
|
|
|
ref="serviceFormRef"
|
|
@@ -172,8 +172,8 @@
|
|
|
<el-date-picker
|
|
|
v-model="serviceForm.startTime"
|
|
|
type="datetime"
|
|
|
- format="yyyy-MM-dd HH:mm"
|
|
|
- value-format="yyyy-MM-dd HH:mm"
|
|
|
+ format="YYYY-MM-DD HH:mm"
|
|
|
+ value-format="YYYY-MM-DD HH:mm"
|
|
|
placeholder="请选择启动时间"
|
|
|
/>
|
|
|
</el-form-item>
|
|
@@ -183,8 +183,8 @@
|
|
|
<el-date-picker
|
|
|
v-model="serviceForm.stopTime"
|
|
|
type="datetime"
|
|
|
- format="yyyy-MM-dd HH:mm"
|
|
|
- value-format="yyyy-MM-dd HH:mm"
|
|
|
+ format="YYYY-MM-DD HH:mm"
|
|
|
+ value-format="YYYY-MM-DD HH:mm"
|
|
|
placeholder="请选择停止时间"
|
|
|
/>
|
|
|
</el-form-item>
|
|
@@ -315,12 +315,13 @@ import DataTable from '@/components/tableTemp/index.vue'
|
|
|
import MinHeader from '@/components/minheader/index.vue'
|
|
|
import Dialog from '@/components/dialog/index.vue'
|
|
|
import { ElMessage, FormInstance } from 'element-plus'
|
|
|
-import { Query } from '@/api/dataIntegration'
|
|
|
import {
|
|
|
CommonTableColumn,
|
|
|
CommonQueryResult,
|
|
|
SelectOptionQueryResult,
|
|
|
} from '~/common'
|
|
|
+import request from '@/utils/axiosReq'
|
|
|
+import { Query, GeneralDataReception } from '@/api/webApi'
|
|
|
|
|
|
interface DataSource {
|
|
|
dataSourceID: string | number
|
|
@@ -331,6 +332,8 @@ interface Protocol {
|
|
|
protocolName: string
|
|
|
}
|
|
|
|
|
|
+const router = useRouter()
|
|
|
+
|
|
|
// 表格
|
|
|
const tableColumns = ref<CommonTableColumn[]>([])
|
|
|
const tableData = ref<any[]>([])
|
|
@@ -340,6 +343,12 @@ const rowTitle = ref('')
|
|
|
onMounted(() => {
|
|
|
getTableData()
|
|
|
})
|
|
|
+const resetTable = () => {
|
|
|
+ page.value = 0
|
|
|
+ noMore.value = false
|
|
|
+ tableData.value = []
|
|
|
+ getTableData()
|
|
|
+}
|
|
|
const getTableData = async () => {
|
|
|
try {
|
|
|
const {
|
|
@@ -368,9 +377,9 @@ const getTableData = async () => {
|
|
|
...column,
|
|
|
}))
|
|
|
tableData.value.push(...listValues)
|
|
|
- } catch (error: any) {
|
|
|
+ } catch (error) {
|
|
|
page.value--
|
|
|
- ElMessage.error(error.message)
|
|
|
+ console.error(error)
|
|
|
}
|
|
|
}
|
|
|
const tableBtnGroup = [
|
|
@@ -395,41 +404,133 @@ const tableBtnGroup = [
|
|
|
param: 4,
|
|
|
},
|
|
|
]
|
|
|
-const tableButtonClickHandler = (
|
|
|
- rowIndex: number,
|
|
|
- row: object,
|
|
|
- param: number
|
|
|
-) => {
|
|
|
+const tableButtonClickHandler = (rowIndex: number, row: any, param: number) => {
|
|
|
switch (param) {
|
|
|
case 1:
|
|
|
+ router.push({
|
|
|
+ path: '/systemSettings/serviceTopology',
|
|
|
+ query: {
|
|
|
+ serviceID: row['serviceID'],
|
|
|
+ serviceName: row['serviceName'],
|
|
|
+ },
|
|
|
+ })
|
|
|
break
|
|
|
case 2:
|
|
|
+ router.push({
|
|
|
+ path: '/systemSettings/serviceTopology',
|
|
|
+ query: {
|
|
|
+ serviceID: row['serviceID'],
|
|
|
+ serviceName: row['serviceName'],
|
|
|
+ },
|
|
|
+ })
|
|
|
break
|
|
|
case 3:
|
|
|
+ changeServiceState(row['serviceID'], row['runState'])
|
|
|
break
|
|
|
case 4:
|
|
|
+ delID = row['serviceID']
|
|
|
+ delDialogShow(row)
|
|
|
break
|
|
|
default:
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
+const changeServiceState = async (serviceID: number, runState: string) => {
|
|
|
+ const operate = runState === '运行' ? 'stop' : 'start'
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ code,
|
|
|
+ returnData: { listValues },
|
|
|
+ message,
|
|
|
+ } = await Query({
|
|
|
+ id: DATACONTENT_ID.sysServiceNodeList,
|
|
|
+ dataContent: [serviceID],
|
|
|
+ })
|
|
|
+ if (Number(code) !== 0) {
|
|
|
+ throw new Error(message ?? '失败')
|
|
|
+ }
|
|
|
+ if (!listValues.length) {
|
|
|
+ throw new Error('无部署机器')
|
|
|
+ }
|
|
|
+ Promise.all(
|
|
|
+ listValues.map(node => {
|
|
|
+ request({
|
|
|
+ url: `${node.serviceURL}${operate}`,
|
|
|
+ method: 'post',
|
|
|
+ data: {
|
|
|
+ serviceId: serviceID,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ })
|
|
|
+ )
|
|
|
+ .then((results: any) => {
|
|
|
+ if (results.every(result => Number(result.code) === 0)) {
|
|
|
+ ElMessage.success('操作成功')
|
|
|
+ } else {
|
|
|
+ ElMessage.error('操作失败')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ throw new Error(error)
|
|
|
+ })
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
// 新增/删除服务-弹窗
|
|
|
const serviceDialogVisible = ref(false) // 弹窗开关
|
|
|
-const serviceDialogType = ref('del') // 弹窗类型是否删除
|
|
|
+const serviceDialogType = ref('') // 弹窗类型是否删除
|
|
|
const serviceDialogWidth = computed(() =>
|
|
|
serviceDialogType.value === 'del' ? '600px' : '878px'
|
|
|
)
|
|
|
const delName = ref('') // 删除对象名
|
|
|
-const msgTitle = '新增服务管理' // 新增弹窗-标题
|
|
|
+let delID // 删除对象ID
|
|
|
+const msgTitle = ref('') // 服务弹窗-标题
|
|
|
+const delDialogShow = row => {
|
|
|
+ serviceDialogType.value = 'del'
|
|
|
+ msgTitle.value = '删除服务'
|
|
|
+ delName.value = row['serviceName']
|
|
|
+ serviceDialogVisible.value = true
|
|
|
+}
|
|
|
+const delDialogHide = () => {
|
|
|
+ serviceDialogVisible.value = false
|
|
|
+}
|
|
|
+const delSubmitHandler = async () => {
|
|
|
+ try {
|
|
|
+ await deleteService()
|
|
|
+ delDialogHide()
|
|
|
+ resetTable()
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
+ }
|
|
|
+}
|
|
|
+const deleteService = async () => {
|
|
|
+ try {
|
|
|
+ const dataContent = {
|
|
|
+ serviceID: delID,
|
|
|
+ event: 3,
|
|
|
+ }
|
|
|
+ const { code, message } = await GeneralDataReception({
|
|
|
+ serviceID: SERVICE_ID.sysServiceEdit,
|
|
|
+ dataContent: JSON.stringify(dataContent),
|
|
|
+ })
|
|
|
+ if (Number(code) === 0) {
|
|
|
+ ElMessage.success(message ?? '成功')
|
|
|
+ } else {
|
|
|
+ throw new Error(message ?? '失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ return Promise.reject(error)
|
|
|
+ }
|
|
|
+}
|
|
|
const addServiceDialogShow = () => {
|
|
|
getSelectOptions(DATACONTENT_ID.dataSourceOptions)
|
|
|
serviceDialogType.value = 'add'
|
|
|
+ msgTitle.value = '新增服务管理'
|
|
|
serviceDialogVisible.value = true
|
|
|
}
|
|
|
-const delSubmitHandler = () => {}
|
|
|
-const delDialogHide = () => {}
|
|
|
-const serviceDialogHide = () => {
|
|
|
+const addServiceDialogHide = () => {
|
|
|
serviceFormRef.value?.resetFields()
|
|
|
serviceDialogVisible.value = false
|
|
|
}
|
|
@@ -468,7 +569,47 @@ const serviceFormRules = {
|
|
|
}
|
|
|
const dataSourceList = ref<DataSource[]>([])
|
|
|
const serviceSubmitHandler = () => {
|
|
|
- serviceDialogHide()
|
|
|
+ serviceFormRef.value!.validate(async valid => {
|
|
|
+ if (valid) {
|
|
|
+ try {
|
|
|
+ await createService()
|
|
|
+ addServiceDialogHide()
|
|
|
+ resetTable()
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+const createService = async () => {
|
|
|
+ try {
|
|
|
+ Object.keys(serviceForm).forEach(key => {
|
|
|
+ if (
|
|
|
+ ![
|
|
|
+ 'sourceObjectName',
|
|
|
+ 'lifeCycleCol',
|
|
|
+ 'computingMethod',
|
|
|
+ 'validationExpression',
|
|
|
+ 'logList',
|
|
|
+ ].includes(key) &&
|
|
|
+ serviceForm[key] === ''
|
|
|
+ ) {
|
|
|
+ serviceForm[key] = null
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const dataContent = { ...serviceForm, event: 1 }
|
|
|
+ const { code, message } = await GeneralDataReception({
|
|
|
+ serviceID: SERVICE_ID.sysServiceEdit,
|
|
|
+ dataContent: JSON.stringify(dataContent),
|
|
|
+ })
|
|
|
+ if (Number(code) === 0) {
|
|
|
+ ElMessage.success(message ?? '成功')
|
|
|
+ } else {
|
|
|
+ throw new Error(message ?? '失败')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ return Promise.reject(error)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 新增数据来源-弹窗
|
|
@@ -504,7 +645,7 @@ const getSelectOptions = async (id: number) => {
|
|
|
dataContent: [],
|
|
|
})
|
|
|
if (Number(code) !== 0) {
|
|
|
- throw new Error(message || '失败')
|
|
|
+ throw new Error(message ?? '失败')
|
|
|
}
|
|
|
const options = listValues.map(item => ({
|
|
|
[item.setlabel]: item.k,
|
|
@@ -520,8 +661,8 @@ const getSelectOptions = async (id: number) => {
|
|
|
default:
|
|
|
break
|
|
|
}
|
|
|
- } catch (error: any) {
|
|
|
- ElMessage.error(error.message)
|
|
|
+ } catch (error) {
|
|
|
+ console.error(error)
|
|
|
}
|
|
|
}
|
|
|
</script>
|