master
parent
cb3b7b5126
commit
78df620162
@ -0,0 +1,139 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<vxe-modal
|
||||||
|
:z-index="zIndex"
|
||||||
|
:value="isShow"
|
||||||
|
show-footer
|
||||||
|
title="公共文件柜栏目"
|
||||||
|
show-confirm-button
|
||||||
|
:width="600"
|
||||||
|
:height="400"
|
||||||
|
:fullscreen="$store.getters.device === 'mobile'"
|
||||||
|
esc-closable
|
||||||
|
@input="e => $emit('update:isShow',e)"
|
||||||
|
>
|
||||||
|
<el-form ref="elForm" :model="form" :rules="rules" label-position="top" label-width="100">
|
||||||
|
<el-form-item label="父级栏目" prop="pid" required>
|
||||||
|
<Treeselect
|
||||||
|
v-model="form.pid"
|
||||||
|
:options="formatList"
|
||||||
|
no-children-text="无子菜单"
|
||||||
|
:normalizer="node => ({
|
||||||
|
id: node.id,
|
||||||
|
label: node.name,
|
||||||
|
children: node.children,
|
||||||
|
isDefaultExpanded: true
|
||||||
|
})"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="名称" prop="name">
|
||||||
|
<el-input v-model="form.name" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="授权人员" prop="update_children_ids">
|
||||||
|
<el-select
|
||||||
|
style="width: 100%;"
|
||||||
|
multiple
|
||||||
|
popper-append-to-body
|
||||||
|
:value="form.update_children_ids ? form.update_children_ids.split(',').map(i => Number(i)) : []"
|
||||||
|
@input="e => form.update_children_ids = e.toString()"
|
||||||
|
>
|
||||||
|
<el-option v-for="user in users" :key="user.id" :value="user.id" :label="user.name" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="排序" prop="myindex">
|
||||||
|
<el-input-number v-model="form.myindex" :controls="false" :precision="0" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button type="primary" :loading="loading" @click="submit">确认</el-button>
|
||||||
|
</template>
|
||||||
|
</vxe-modal>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { menuSave } from '@/api/document'
|
||||||
|
import { PopupManager } from "element-ui/lib/utils/popup";
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
list: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
isShow: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
users: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
zIndex: PopupManager.nextZIndex(),
|
||||||
|
loading: false,
|
||||||
|
form: {
|
||||||
|
pid: 0,
|
||||||
|
name: '',
|
||||||
|
update_children_ids: '',
|
||||||
|
myindex: ''
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
pid: [
|
||||||
|
{ required: true, message: '请选择上级目录' }
|
||||||
|
],
|
||||||
|
name: [
|
||||||
|
{ required: true, message: '请输入名称' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
formatList() {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
name: '#根目录',
|
||||||
|
id: 0
|
||||||
|
},
|
||||||
|
...this.list
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
isShow(newVal) {
|
||||||
|
if(newVal) {
|
||||||
|
this.zIndex = PopupManager.nextZIndex()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
setPid(pid) {
|
||||||
|
this.form.pid = pid
|
||||||
|
},
|
||||||
|
|
||||||
|
submit() {
|
||||||
|
this.$refs['elForm'].validate(async valid => {
|
||||||
|
if (valid) {
|
||||||
|
this.loading = true
|
||||||
|
try {
|
||||||
|
await menuSave(this.form)
|
||||||
|
this.$message.success('新增成功')
|
||||||
|
this.$emit('refresh')
|
||||||
|
this.$emit('update:isShow', false)
|
||||||
|
this.loading = false
|
||||||
|
this.$refs['elForm'].resetFields()
|
||||||
|
} catch (err) {
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
</style>
|
||||||
@ -0,0 +1,203 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<card-container>
|
||||||
|
<vxe-toolbar>
|
||||||
|
<template #buttons>
|
||||||
|
<el-button icon="el-icon-plus" type="primary" size="small" @click="isShowAdd = true">新增</el-button>
|
||||||
|
<el-button icon="el-icon-search" type="primary" plain size="small" @click="getList">搜索</el-button>
|
||||||
|
</template>
|
||||||
|
</vxe-toolbar>
|
||||||
|
<vxe-table
|
||||||
|
ref="table"
|
||||||
|
style="margin-top: 10px;"
|
||||||
|
:loading="loading"
|
||||||
|
keep-source
|
||||||
|
:row-config="{ useKey: 'id', isHover: true }"
|
||||||
|
:column-config="{ resizable: true }"
|
||||||
|
:edit-rules="validRules"
|
||||||
|
:edit-config="{ trigger: 'manual', mode: 'row', showStatus: true, autoClear: false, expandALl: true }"
|
||||||
|
:tree-config="{ rowField: 'id', parentField: 'pid' }"
|
||||||
|
:data="tableData"
|
||||||
|
>
|
||||||
|
<vxe-column type="seq" width="58" align="center" />
|
||||||
|
<vxe-column tree-node field="name" width="170" title="名称" :edit-render="{ name: 'input', attrs: { type: 'text' } }" />
|
||||||
|
<vxe-column field="update_children" title="授权人员" min-width="160" :edit-render="{}">
|
||||||
|
<template #edit="{ row }">
|
||||||
|
<el-select
|
||||||
|
collapse-tags
|
||||||
|
style="width: 100%;"
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
:value="row.update_children_ids ? row.update_children_ids.split(',').map(i => Number(i)) : []"
|
||||||
|
@input="e => row.update_children_ids = e.toString()"
|
||||||
|
>
|
||||||
|
<el-option v-for="user in users" :key="user.id" :value="user.id" :label="user.name" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
<vxe-column field="myindex" width="180" title="排序" align="center" :edit-render="{ name: 'input', attrs: { type: 'number' } }" />
|
||||||
|
<vxe-column field="operate" title="操作" min-width="220">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<template v-if="isActiveStatus(row)">
|
||||||
|
<el-button size="small" type="primary" @click="saveRowEvent(row)">保存</el-button>
|
||||||
|
<el-button size="small" type="primary" plain @click="cancelRowEvent(row)">取消</el-button>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<el-button size="small" type="success" @click="$refs['AddDocumentMenu'].setPid(row.id),isShowAdd = true">子栏目</el-button>
|
||||||
|
<el-button size="small" type="warning" @click="editRowEvent(row)">编辑</el-button>
|
||||||
|
<el-button size="small" type="danger" @click="destroyRowEvent(row)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</vxe-column>
|
||||||
|
</vxe-table>
|
||||||
|
</card-container>
|
||||||
|
<add-document-menu ref="AddDocumentMenu" :users="users" :list="tableData" :is-show.sync="isShowAdd" @refresh="getList" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { deepCopy } from '@/utils'
|
||||||
|
import { menuSave, menuIndex, menuDestroy } from '@/api/document'
|
||||||
|
import { index as userIndex } from '@/api/user'
|
||||||
|
import AddDocumentMenu from './components/AddDocumentMenu.vue'
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
AddDocumentMenu
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
users: [],
|
||||||
|
isShowAdd: false,
|
||||||
|
|
||||||
|
loading: false,
|
||||||
|
select: {
|
||||||
|
page: 1,
|
||||||
|
page_size: 20
|
||||||
|
},
|
||||||
|
allAlign: null,
|
||||||
|
tableData: [],
|
||||||
|
validRules: {
|
||||||
|
name: [
|
||||||
|
{ required: true, message: '请输入角色' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
form: {
|
||||||
|
id: '',
|
||||||
|
pid: '',
|
||||||
|
name: '',
|
||||||
|
myindex: '',
|
||||||
|
update_children_ids: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
isActiveStatus() {
|
||||||
|
return function(row) {
|
||||||
|
if (this.$refs['table']) {
|
||||||
|
return this.$refs['table'].isEditByRow(row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getUsers()
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
editRowEvent(row) {
|
||||||
|
if (this.$refs['table']) {
|
||||||
|
this.$refs['table'].setEditRow(row)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cancelRowEvent(row) {
|
||||||
|
if (this.$refs['table']) {
|
||||||
|
this.$refs['table'].clearEdit().then(() => {
|
||||||
|
// 还原行数据
|
||||||
|
this.$refs['table'].revertData(row)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getUsers() {
|
||||||
|
try {
|
||||||
|
const res = await userIndex({
|
||||||
|
rows: 999
|
||||||
|
})
|
||||||
|
this.users = res.data
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async getList() {
|
||||||
|
this.loading = true
|
||||||
|
try {
|
||||||
|
const res = await menuIndex(this.select)
|
||||||
|
this.tableData = res
|
||||||
|
this.loading = false
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.$refs['table'].setAllTreeExpand(true)
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async saveRowEvent(row) {
|
||||||
|
try {
|
||||||
|
await this.$confirm('确认保存?', '提示', {
|
||||||
|
confirmButtonText: '确认',
|
||||||
|
cancelButtonText: '取消'
|
||||||
|
})
|
||||||
|
await this.$refs['table'].clearEdit()
|
||||||
|
const form = deepCopy(this.form)
|
||||||
|
for (const key in form) {
|
||||||
|
form[key] = row[key]
|
||||||
|
}
|
||||||
|
if (!form.password) {
|
||||||
|
delete form.password
|
||||||
|
}
|
||||||
|
this.loading = true
|
||||||
|
await menuSave(form)
|
||||||
|
await this.getList()
|
||||||
|
this.loading = false
|
||||||
|
} catch (err) {
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async destroyRowEvent(row) {
|
||||||
|
try {
|
||||||
|
await this.$confirm('确认删除?', '提示', {
|
||||||
|
confirmButtonText: '确认',
|
||||||
|
cancelButtonText: '取消'
|
||||||
|
})
|
||||||
|
this.loading = true
|
||||||
|
if (row.id) {
|
||||||
|
await menuDestroy({
|
||||||
|
id: row.id
|
||||||
|
})
|
||||||
|
await this.getList()
|
||||||
|
} else {
|
||||||
|
console.log(row)
|
||||||
|
this.tableData.splice(this.tableData.findIndex(i => i._X_ROW_KEY === row._X_ROW_KEY), 1)
|
||||||
|
}
|
||||||
|
this.loading = false
|
||||||
|
} catch (err) {
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.total {
|
||||||
|
color: #666;
|
||||||
|
text-align: right;
|
||||||
|
line-height: 3;
|
||||||
|
}
|
||||||
|
::v-deep .el-tag + .el-tag {
|
||||||
|
margin-left: 4px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -0,0 +1,121 @@
|
|||||||
|
<template>
|
||||||
|
<div class="container">
|
||||||
|
<el-card shadow="always">
|
||||||
|
<el-input
|
||||||
|
v-model="filterText"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
placeholder="输入关键字进行过滤"
|
||||||
|
/>
|
||||||
|
<el-tree
|
||||||
|
ref="tree"
|
||||||
|
:indent="10"
|
||||||
|
style="margin-top: 8px;"
|
||||||
|
class="filter-tree"
|
||||||
|
:data="types"
|
||||||
|
:props="{
|
||||||
|
label: 'name',
|
||||||
|
}"
|
||||||
|
default-expand-all
|
||||||
|
:filter-node-method="filterNode"
|
||||||
|
/>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<card-container>
|
||||||
|
<vxe-toolbar>
|
||||||
|
<template #buttons>
|
||||||
|
<el-button icon="el-icon-plus" type="primary" size="small" @click="isShowAdd = true">新增</el-button>
|
||||||
|
<el-button icon="el-icon-search" type="primary" plain size="small" @click="getList">搜索</el-button>
|
||||||
|
</template>
|
||||||
|
</vxe-toolbar>
|
||||||
|
<vxe-table
|
||||||
|
ref="table"
|
||||||
|
stripe
|
||||||
|
style="margin-top: 10px;"
|
||||||
|
:loading="loading"
|
||||||
|
keep-source
|
||||||
|
show-overflow
|
||||||
|
:column-config="{ resizable: true }"
|
||||||
|
:edit-rules="validRules"
|
||||||
|
:edit-config="{ trigger: 'manual', mode: 'row', showStatus: true, isHover: true, autoClear: false }"
|
||||||
|
:data="tableData"
|
||||||
|
>
|
||||||
|
<vxe-column type="seq" width="64" align="center" />
|
||||||
|
|
||||||
|
</vxe-table>
|
||||||
|
</card-container>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { menuIndex, index } from '@/api/document'
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
filterText: '',
|
||||||
|
isShowAdd: false,
|
||||||
|
loading: false,
|
||||||
|
validRules: {
|
||||||
|
},
|
||||||
|
tableData: [],
|
||||||
|
types: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {},
|
||||||
|
watch: {
|
||||||
|
filterText(val) {
|
||||||
|
this.$refs.tree.filter(val)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getTypes()
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
filterNode(value, data) {
|
||||||
|
if (!value) return true
|
||||||
|
return data.name.indexOf(value) !== -1
|
||||||
|
},
|
||||||
|
|
||||||
|
async getList() {
|
||||||
|
try {
|
||||||
|
const res = await index()
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async getTypes() {
|
||||||
|
try {
|
||||||
|
const res = await menuIndex()
|
||||||
|
this.types = res
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
& > div:nth-child(1) {
|
||||||
|
flex-basis: 20%;
|
||||||
|
}
|
||||||
|
& > div:nth-child(2) {
|
||||||
|
flex-basis: 78%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.container {
|
||||||
|
display: initial;
|
||||||
|
|
||||||
|
& > div:nth-child(2) {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Loading…
Reference in new issue