|
@@ -7,11 +7,7 @@
|
|
|
|
|
|
<!-- 添加点击对话框 -->
|
|
|
<a-modal v-model:visible="Visible" title="Title" @ok="handleOk">
|
|
|
- <template #footer>
|
|
|
- <a-button key="back" @click="cancel">关闭</a-button>
|
|
|
- <a-button key="back" @click="resetForm">Reset</a-button>
|
|
|
- <a-button key="submit" type="primary" @click="onSubmit">Submit</a-button>
|
|
|
- </template>
|
|
|
+
|
|
|
<a-form
|
|
|
ref="formRef"
|
|
|
:model="formState"
|
|
@@ -38,6 +34,10 @@
|
|
|
<label>url:</label>
|
|
|
<a-input v-model:value="formState.url" placeholder="输入切换地址url"/>
|
|
|
</a-form-item>
|
|
|
+ <a-form-item ref="urlstatus" name="urlstatus">
|
|
|
+ <label>urlstatus:</label>
|
|
|
+ <a-input v-model:value="formState.urlstatus" placeholder="输入状态"/>
|
|
|
+ </a-form-item>
|
|
|
<a-form-item>
|
|
|
<label>ping类型:</label>
|
|
|
<a-select v-model:value="formState.pingType" placeholder="选择ping类型">
|
|
@@ -45,38 +45,51 @@
|
|
|
<a-select-option :value=1>tcpping</a-select-option>
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
|
-<!-- <a-form-item :wrapper-col="{ span: 14, offset: 4 }">-->
|
|
|
-<!-- <a-button type="primary" @click="onSubmit">Create</a-button>-->
|
|
|
-<!-- <a-button style="margin-left: 10px" @click="resetForm">Reset</a-button>-->
|
|
|
-<!-- </a-form-item>-->
|
|
|
+
|
|
|
+<!-- <template #footer>-->
|
|
|
+<!-- <a-button key="back" @click="cancel">关闭</a-button>-->
|
|
|
+<!-- <a-button key="back" @click="resetForm">Reset</a-button>-->
|
|
|
+<!-- <a-button key="submit" type="primary" @click="onSubmit">Submit</a-button>-->
|
|
|
+<!-- </template>-->
|
|
|
+ <a-form-item :wrapper-col="{ span: 14, offset: 4 }">
|
|
|
+
|
|
|
+ <a-button v-if="formState.isedit === false" type="primary" @click="onSubmit(true)">编辑</a-button>
|
|
|
+ <a-button v-else type="primary" @click="onSubmit(false)">Create</a-button>
|
|
|
+
|
|
|
+ <a-button style="margin-left: 10px" @click="resetForm">Reset</a-button>
|
|
|
+ </a-form-item>
|
|
|
</a-form>
|
|
|
</a-modal>
|
|
|
|
|
|
<!-- 加载节点信息 -->
|
|
|
<a-table :row-selection="rowSelection" :columns="columns" :data-source="datalist" rowKey="id" :style="{ height: '100%', borderRight: 0 }">
|
|
|
-
|
|
|
- <template #delete="{ record }">
|
|
|
+ <template v-slot:bodyCell="{column , record}">
|
|
|
+ <template v-if="column.dataIndex === 'delete'">
|
|
|
<a-popconfirm
|
|
|
v-if="datalist.length"
|
|
|
title="是否删除这条记录"
|
|
|
@confirm="onDeleteNode(record)"
|
|
|
>
|
|
|
- <a>删除</a>
|
|
|
+ <a>删除</a>
|
|
|
</a-popconfirm>
|
|
|
- </template>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template v-if="column.dataIndex === 'edit'">
|
|
|
+ <a @click="onEditNode(record)">编辑</a>
|
|
|
+ <!-- <a-popconfirm-->
|
|
|
+ <!-- v-if="datalist.length"-->
|
|
|
+ <!-- title="编辑"-->
|
|
|
+ <!-- @confirm="onDeleteNode(record)"-->
|
|
|
+ <!-- >-->
|
|
|
+ <!-- <a>Delete</a>-->
|
|
|
+ <!-- </a-popconfirm>-->
|
|
|
+ </template>
|
|
|
|
|
|
- <template #edit="{ record }">
|
|
|
- <a @click="onEditNode(record)">编辑</a>
|
|
|
-<!-- <a-popconfirm-->
|
|
|
-<!-- v-if="datalist.length"-->
|
|
|
-<!-- title="编辑"-->
|
|
|
-<!-- @confirm="onDeleteNode(record)"-->
|
|
|
-<!-- >-->
|
|
|
-<!-- <a>Delete</a>-->
|
|
|
-<!-- </a-popconfirm>-->
|
|
|
</template>
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
</a-table>
|
|
|
</template>
|
|
|
|
|
@@ -94,7 +107,7 @@ import {
|
|
|
unref
|
|
|
} from "vue";
|
|
|
import {INode, NodeAddParam} from "/@/model/node";
|
|
|
-import {delNodeReqUse, nodeAddReqUse, nodeReqUse} from "/@/apis/node";
|
|
|
+import {delNodeReqUse, editNodeReqUse, nodeAddReqUse, nodeReqUse} from "/@/apis/node";
|
|
|
import { ColumnProps } from "ant-design-vue/lib/table";
|
|
|
import {it} from "node:test";
|
|
|
import {message} from "ant-design-vue";
|
|
@@ -117,12 +130,11 @@ export default defineComponent({
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- console.log(this.addRoleVisible);
|
|
|
- console.log('mounted!')
|
|
|
+
|
|
|
},
|
|
|
setup() {
|
|
|
const formRef = ref()
|
|
|
- const reload: any = inject('reload')
|
|
|
+ // const reload: any = inject('reload')
|
|
|
//const reload = inject("reload");
|
|
|
const columns = [
|
|
|
{
|
|
@@ -181,13 +193,13 @@ export default defineComponent({
|
|
|
title: 'Delete',
|
|
|
key: 'delete',
|
|
|
dataIndex: 'delete',
|
|
|
- slots: { customRender: 'delete' },
|
|
|
+ // slots: { customRender: 'delete' },
|
|
|
},
|
|
|
{
|
|
|
title: 'Edit',
|
|
|
key: 'edit',
|
|
|
dataIndex: 'edit',
|
|
|
- slots: { customRender: 'edit' },
|
|
|
+ // slots: { customRender: 'edit' },
|
|
|
},
|
|
|
];
|
|
|
let ids = ""
|
|
@@ -214,7 +226,6 @@ export default defineComponent({
|
|
|
const getNodeList = async () => {
|
|
|
const node_list = await nodeReqUse(null)
|
|
|
state.datalist = node_list.data.nodeList
|
|
|
- reload()
|
|
|
}
|
|
|
|
|
|
const addNodeList = async (data) => {
|
|
@@ -235,6 +246,22 @@ export default defineComponent({
|
|
|
|
|
|
}
|
|
|
|
|
|
+ const editNode = async (data) => {
|
|
|
+ let ret = await editNodeReqUse(data)
|
|
|
+ if (ret.code == 0)
|
|
|
+ {
|
|
|
+ console.log(state.Visible);
|
|
|
+ state.Visible = false
|
|
|
+ await getNodeList()
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ console.log(state.Visible);
|
|
|
+ state.Visible = true
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
const delNodeById = async (data) => {
|
|
|
|
|
@@ -258,11 +285,14 @@ export default defineComponent({
|
|
|
})
|
|
|
|
|
|
const formState = reactive({
|
|
|
+ id: 0,
|
|
|
name: "",
|
|
|
host: "",
|
|
|
port: 22,
|
|
|
url: "",
|
|
|
pingType: undefined,
|
|
|
+ isedit : false,
|
|
|
+ urlstatus: 0
|
|
|
})
|
|
|
|
|
|
|
|
@@ -280,27 +310,32 @@ export default defineComponent({
|
|
|
formRef.value.resetFields();
|
|
|
};
|
|
|
|
|
|
- const onSubmit = () =>{
|
|
|
-
|
|
|
+ const onSubmit = (isedit) =>{
|
|
|
const reqdata = {
|
|
|
+ "id" : toRaw(formState).id,
|
|
|
"name" : toRaw(formState).name,
|
|
|
"host" : toRaw(formState).host,
|
|
|
"port" : toRaw(formState).port,
|
|
|
"url" : toRaw(formState).url,
|
|
|
- "pingType": toRaw(formState).pingType
|
|
|
+ "pingType": toRaw(formState).pingType,
|
|
|
+ "urlstatus": toRaw(formState).urlstatus
|
|
|
+ }
|
|
|
+ if (isedit){
|
|
|
+ editNode(reqdata)
|
|
|
+ } else {
|
|
|
+ addNodeList(reqdata)
|
|
|
}
|
|
|
- addNodeList(reqdata)
|
|
|
- console.log(reqdata);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
const onEditNode = (record) => {
|
|
|
+ formState.id = record.id
|
|
|
formState.name = record.name
|
|
|
formState.host = record.host
|
|
|
formState.port = record.port
|
|
|
formState.url = record.url
|
|
|
formState.pingType = record.pingType
|
|
|
+ formState.urlstatus = record.urlstatus
|
|
|
+ formState.isedit = false
|
|
|
state.Visible = true
|
|
|
|
|
|
}
|
|
@@ -311,6 +346,8 @@ export default defineComponent({
|
|
|
formState.port = 22
|
|
|
formState.url = ""
|
|
|
formState.pingType = undefined
|
|
|
+ formState.urlstatus = 0
|
|
|
+ formState.isedit = true
|
|
|
state.Visible = true;
|
|
|
}
|
|
|
const handleOk= () =>{
|