parent
39a253d476
commit
60325225ec
@ -1,96 +0,0 @@ |
||||
<template> |
||||
<form-dialog :loading="loading" title="编辑" :value="value" @close="cancel" @open="open"> |
||||
<abstract-form :model="form" :rules="rules" size=""> |
||||
<el-form-item label="名 称" prop="name"> |
||||
<el-input :value="form.fullname" readonly/> |
||||
</el-form-item> |
||||
<el-form-item label="访问路径" prop="url"> |
||||
<el-input :value="form.url" readonly/> |
||||
</el-form-item> |
||||
<el-form-item label="总频率" prop="totalRate"> |
||||
<el-input-number |
||||
v-model="form.totalRate" |
||||
controls-position="right" |
||||
:min="1" |
||||
:step="1" |
||||
step-strictly size="small" |
||||
/> |
||||
</el-form-item> |
||||
<el-form-item label="单个IP频率" prop="ipRate"> |
||||
<el-input-number |
||||
v-model="form.ipRate" |
||||
controls-position="right" |
||||
:min="1" |
||||
:step="1" |
||||
step-strictly size="small" |
||||
/> |
||||
</el-form-item> |
||||
</abstract-form> |
||||
|
||||
<template v-slot:footer> |
||||
<el-button plain size="small" @click="closeDialog">取 消</el-button> |
||||
<el-button size="small" type="primary" @click="confirm">确 定</el-button> |
||||
</template> |
||||
</form-dialog> |
||||
</template> |
||||
|
||||
<script> |
||||
import dialogMixin from "@/mixin/dialogMixin" |
||||
import AbstractForm from "@/component/AbstractForm" |
||||
import FormDialog from '@/component/FormDialog' |
||||
import {updateResource} from "@/api/system/resource" |
||||
import {mergeObj, resetObj} from '@/util' |
||||
|
||||
export default { |
||||
name: "EditDialog", |
||||
|
||||
mixins: [dialogMixin], |
||||
|
||||
components: {AbstractForm, FormDialog}, |
||||
|
||||
props: { |
||||
value: {type: Boolean, default: false}, |
||||
data: {type: Object, default: () => ({})}, |
||||
}, |
||||
|
||||
data() { |
||||
return { |
||||
loading: false, |
||||
form: { |
||||
id: null, |
||||
fullname: null, |
||||
url: null, |
||||
totalRate: 0, |
||||
ipRate: 0 |
||||
}, |
||||
rules: { |
||||
totalRate: [{required: true, message: '总频率不能为空', trigger: 'change'}], |
||||
ipRate: [{required: true, message: '单个ip的频率不能为空', trigger: 'change'}], |
||||
} |
||||
} |
||||
}, |
||||
|
||||
methods: { |
||||
open() { |
||||
this.$nextTick(() => mergeObj(this.form, this.data)) |
||||
}, |
||||
|
||||
cancel() { |
||||
this.closeDialog() |
||||
resetObj(this.form) |
||||
this.$nextTick(() => this.$refs.form.clearValidate()) |
||||
}, |
||||
|
||||
confirm() { |
||||
if (this.loading) return |
||||
this.$refs.form.validate(v => { |
||||
if (!v) return |
||||
this.loading = true |
||||
updateResource(this.form) |
||||
.then(({msg}) => this.$emit('success', msg)) |
||||
.finally(() => this.loading = false) |
||||
}) |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
@ -1,73 +0,0 @@ |
||||
<template> |
||||
<el-card v-loading="config.operating"> |
||||
<el-row> |
||||
<el-button icon="el-icon-search" size="small" type="success" @click="search">查 询</el-button> |
||||
<el-button v-if="canUpdate" icon="el-icon-edit" size="small" type="primary" @click="edit">编 辑</el-button> |
||||
</el-row> |
||||
|
||||
<el-row v-loading="config.loading" class="table-container"> |
||||
<abstract-table :data="tableData" @row-click="rowClick"> |
||||
<el-table-column label="名称" prop="fullname" show-overflow-tooltip/> |
||||
<el-table-column label="访问路径" prop="url" show-overflow-tooltip/> |
||||
<el-table-column label="总频率" prop="totalRate" show-overflow-tooltip/> |
||||
<el-table-column label="单个IP频率" prop="ipRate" show-overflow-tooltip/> |
||||
</abstract-table> |
||||
</el-row> |
||||
|
||||
<edit-dialog v-model="editDialog" :data="row" :type="type" @success="success"/> |
||||
</el-card> |
||||
</template> |
||||
|
||||
<script> |
||||
import tableMixin from '@/mixin/tablePageMixin' |
||||
import EditDialog from './EditDialog' |
||||
import SearchForm from "@/component/SearchForm" |
||||
import SearchFormItem from "@/component/SearchForm/SearchFormItem" |
||||
import {baseUrl, getAllResources} from "@/api/system/resource" |
||||
import {auth} from "@/util/auth" |
||||
import {elError, elSuccess} from "@/util/message" |
||||
import {createTreeByWorker} from "@/util/tree" |
||||
|
||||
export default { |
||||
name: "resourceManagement", |
||||
|
||||
mixins: [tableMixin], |
||||
|
||||
components: {EditDialog, SearchForm, SearchFormItem}, |
||||
|
||||
data() { |
||||
return { |
||||
editDialog: false |
||||
} |
||||
}, |
||||
|
||||
computed: { |
||||
canUpdate() { |
||||
return auth(`${baseUrl}/update`) |
||||
} |
||||
}, |
||||
|
||||
methods: { |
||||
search() { |
||||
if (this.config.loading) return |
||||
this.config.loading = true |
||||
this.row = null |
||||
getAllResources() |
||||
.then(data => createTreeByWorker(data)) |
||||
.then(data => this.tableData = data) |
||||
.finally(() => this.config.loading = false) |
||||
}, |
||||
|
||||
edit() { |
||||
if (!this.row) return elError('请选择要编辑的资源') |
||||
this.editDialog = true |
||||
}, |
||||
|
||||
success(msg) { |
||||
elSuccess(msg) |
||||
this.editDialog = false |
||||
this.search() |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
Loading…
Reference in new issue