代码优化

This commit is contained in:
Elune
2019-12-18 13:24:39 +08:00
parent 47d83846ef
commit b3528e88d0
15 changed files with 91 additions and 113 deletions

View File

@@ -43,7 +43,7 @@
</el-dialog>
<!--表格渲染-->
<el-table ref="table" v-loading="crud.loading" :tree-props="{children: 'children', hasChildren: 'hasChildren'}" default-expand-all :data="crud.data" row-key="id" @select="crud.selectChange" @select-all="crud.selectAllChange" @selection-change="crud.selectionChangeHandler">
<el-table-column type="selection" width="55" />
<el-table-column :selectable="checkboxT" type="selection" width="55" />
<el-table-column v-if="columns.visible('name')" label="名称" prop="name" />
<el-table-column v-if="columns.visible('enabled')" label="状态" align="center" prop="enabled">
<template slot-scope="scope">
@@ -148,6 +148,9 @@ export default {
}).catch(() => {
data.enabled = !data.enabled
})
},
checkboxT(row, rowIndex) {
return row.id !== 1
}
}
}

View File

@@ -95,7 +95,7 @@ const defaultForm = {
sort: 999,
enabled: true,
dept: {
id: null
id: 1
}
}
export default {

View File

@@ -134,7 +134,7 @@ import '@riophae/vue-treeselect/dist/vue-treeselect.css'
// crud交由presenter持有
const defaultCrud = CRUD({ title: '角色', url: 'api/roles', sort: 'level,asc', crudMethod: { ...crudRoles }})
const defaultForm = { name: null, depts: [], remark: null, dataScope: null, level: 3, permission: null }
const defaultForm = { name: null, depts: [], remark: null, dataScope: '全部', level: 3, permission: null }
export default {
name: 'Role',
components: { Treeselect, pagination, crudOperation, rrOperation, udOperation },
@@ -172,7 +172,6 @@ export default {
},
// 编辑前
[CRUD.HOOK.beforeToEdit](crud, form) {
console.log(form.dataScope)
if (form.dataScope === '自定义') {
this.getDepts()
}
@@ -181,7 +180,6 @@ export default {
depts.push(dept.id)
})
form.depts = depts
console.log(form)
},
// 提交前做的操作
[CRUD.HOOK.afterValidateCU](crud) {