241 lines
6.5 KiB
Vue
241 lines
6.5 KiB
Vue
<template>
|
|
<div class="app-container">
|
|
<div class="filter-container">
|
|
<el-button class="filter-item" style="margin-left: 10px;" type="primary" @click="handleCreate">
|
|
新增
|
|
</el-button>
|
|
</div>
|
|
<el-table
|
|
:data="apigates"
|
|
border
|
|
fit
|
|
highlight-current-row
|
|
style="width: 100%;"
|
|
|
|
:empty-text="emptytext"
|
|
height="480"
|
|
>
|
|
<el-table-column
|
|
label="host(ip)"
|
|
prop="apigate_host"
|
|
/>
|
|
<el-table-column
|
|
label="port"
|
|
prop="apigate_port"
|
|
/>
|
|
<el-table-column
|
|
label="是否生效"
|
|
prop="enable"
|
|
>
|
|
<template slot-scope="scope">
|
|
<svg-icon v-if="scope.row.enable === 0" icon-class="no" style="font-size: 20px;" />
|
|
<svg-icon v-else icon-class="ok" style="font-size: 20px;" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column
|
|
fixed="right"
|
|
label="操作"
|
|
>
|
|
<template slot-scope="scope">
|
|
<el-button type="text" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
<el-pagination
|
|
background
|
|
:current-page="curpage"
|
|
:page-size="page_size"
|
|
:page-count="totalpage"
|
|
layout="prev, pager, next"
|
|
@current-change="handleCurrentChange"
|
|
/>
|
|
<el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" :close-on-click-modal="false" @close="handleDialogClose()">
|
|
<el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="130px" style="width: 400px; margin-left:50px;">
|
|
<el-form-item label="host(ip)" prop="apigate_host">
|
|
<el-input v-model="form.apigate_host" />
|
|
</el-form-item>
|
|
<el-form-item label="port" prop="apigate_port">
|
|
<el-input v-model.number="form.apigate_port" />
|
|
</el-form-item>
|
|
<el-form-item label="是否生效" prop="enable">
|
|
<el-switch
|
|
v-model="form.enable"
|
|
:active-value="1"
|
|
:inactive-value="0"
|
|
active-color="#13ce66"
|
|
inactive-color="#ff4949"
|
|
/>
|
|
</el-form-item>
|
|
</el-form>
|
|
<div slot="footer" class="dialog-footer">
|
|
<el-button @click="dialogFormVisible = handleDialogClose()">
|
|
Cancel
|
|
</el-button>
|
|
<el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">
|
|
Confirm
|
|
</el-button>
|
|
</div>
|
|
</el-dialog>
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
// import Pagination from '@/components/Pagination/index.vue'
|
|
import { addApigate, getApigateList, updateApigate } from '@/api/workertool'
|
|
import { parseTime } from '@/utils'
|
|
|
|
export default {
|
|
components: {
|
|
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
form: {
|
|
idx: '',
|
|
apigate_host: '',
|
|
apigate_port: '',
|
|
enable: 1
|
|
},
|
|
dialogFormVisible: false,
|
|
dialogStatus: '',
|
|
apigates: [],
|
|
dialogTitle: '新增',
|
|
emptytext: ' ',
|
|
totalpage: 0,
|
|
curpage: 1,
|
|
page_size: 8,
|
|
rules: {
|
|
apigate_host: [{ required: true, message: 'required', trigger: 'blur' }],
|
|
apigate_port: [{ required: true, message: 'required', trigger: 'blur' }],
|
|
type: [{ required: true, message: 'required', trigger: 'blur' }]
|
|
},
|
|
uploadUrl: '',
|
|
uploadData: {
|
|
file: ''
|
|
},
|
|
filelist: []
|
|
}
|
|
},
|
|
created() {
|
|
this.getList()
|
|
},
|
|
methods: {
|
|
parseTime,
|
|
handleDialogClose() {
|
|
// this.getList()
|
|
},
|
|
handleUpdate(row) {
|
|
this.form.enable = row.enable
|
|
this.form.idx = row.idx
|
|
this.form.apigate_host = row.apigate_host
|
|
this.form.apigate_port = row.apigate_port
|
|
this.dialogStatus = 'update'
|
|
this.dialogTitle = '编辑'
|
|
this.dialogFormVisible = true
|
|
this.$nextTick(() => {
|
|
this.$refs['form'].clearValidate()
|
|
})
|
|
},
|
|
/* handleDel(row) {
|
|
this.$confirm('此操作将无法恢复, 是否继续?', '提示', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
}).then(() => {
|
|
delWhiteList({ apigate_host: row.apigate_host }).then(response => {
|
|
if (response.code === 0) {
|
|
if (this.apigates.length === 1 && this.curpage === this.totalpage && this.curpage > 1) {
|
|
this.curpage--
|
|
}
|
|
this.getList()
|
|
this.$notify({
|
|
title: 'Success',
|
|
message: 'Deleted Successfully',
|
|
type: 'success',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}).catch(() => {
|
|
})
|
|
}, */
|
|
getList() {
|
|
const data = {
|
|
'page_dto': {
|
|
'page': this.curpage,
|
|
'pageSize': this.page_size
|
|
}
|
|
}
|
|
getApigateList(data).then(response => {
|
|
this.apigates = response.data
|
|
this.totalpage = response.total_page
|
|
this.curpage = response.cur_page
|
|
if (this.apigates === undefined || this.apigates.length <= 0) {
|
|
this.emptytext = 'No data'
|
|
}
|
|
})
|
|
},
|
|
handleCurrentChange(val) {
|
|
this.curpage = val
|
|
this.getList()
|
|
},
|
|
handleCreate() {
|
|
this.resetTemp()
|
|
this.dialogStatus = 'create'
|
|
this.dialogTitle = '新增'
|
|
this.dialogFormVisible = true
|
|
this.$nextTick(() => {
|
|
this.$refs['form'].clearValidate()
|
|
})
|
|
},
|
|
resetTemp() {
|
|
this.form = {
|
|
idx: '',
|
|
apigate_host: '',
|
|
apigate_port: '',
|
|
enable: 0
|
|
}
|
|
},
|
|
createData() {
|
|
this.$refs['form'].validate((valid) => {
|
|
if (valid) {
|
|
addApigate(this.form).then(response => {
|
|
if (response.code === 0) {
|
|
this.dialogFormVisible = false
|
|
this.getList()
|
|
this.$notify({
|
|
title: 'Success',
|
|
message: 'Created Successfully',
|
|
type: 'success',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
updateData() {
|
|
this.$refs['form'].validate((valid) => {
|
|
if (valid) {
|
|
updateApigate(this.form).then(response => {
|
|
if (response.code === 0) {
|
|
this.dialogFormVisible = false
|
|
this.getList()
|
|
this.$notify({
|
|
title: 'Success',
|
|
message: 'Updated Successfully',
|
|
type: 'success',
|
|
duration: 2000
|
|
})
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|