Skip to content

Commit

Permalink
perf(Users,Dept,Role): 优化三员管理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Sep 10, 2020
1 parent bcc149e commit 5d6e93a
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 1,371 deletions.
2 changes: 1 addition & 1 deletion src/components/FormDesigner/GenerateFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ export default class GenerateFormItem extends Vue {
crud(DML.SELECT, 'ad_codelist', {
searchCondition: [
{
field: 'codetype',
field: 'codeType',
operator: 'eq',
value: this.widget.options.dictType,
},
Expand Down
4 changes: 2 additions & 2 deletions src/views/dashboard/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<template>
<div class="workboard-container">
<img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3320765880,3678643770&fm=26&gp=0.jpg">
<img class="home-page" src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=3320765880,3678643770&fm=26&gp=0.jpg">
</div>
</template>

Expand All @@ -17,7 +17,7 @@ import { Vue } from 'vue-property-decorator';
export default class Dashboard extends Vue {}
</script>
<style lang="scss" scoped>
img {
.home-page {
position: fixed;
left:50%;
top:50%;
Expand Down
64 changes: 7 additions & 57 deletions src/views/system/Dept.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,87 +19,37 @@
conditionTitle: false,
actionColumnBtnAdd: true,
}"
fullHeight
:showPagination="false"
:prefill="{
parentId:'id'
}"
:promiseForSelect="promiseForSelect"
:btnRowAddOnClick="btnRowAddOnClick"
:btnEditOnClick="btnEditOnClick" />
<!-- 添加/编辑对话框 -->
<DeptDialog ref="deptDialog"
:textMap="textMap"
@afterSave="saveDialog" />

fullHeight />
</div>
</template>

<script>
import { DML, crud } from '@/api/public/crud';
import DeptDialog from './components/DeptDialog.vue';
// 对话框状态枚举
const STATUS = {
CREATE: 0,
UPDATE: 1,
};
export default {
name: 'Dept',
data() {
return {
textMap: {
add: '添加',
edit: '编辑',
},
};
},
components: {
DeptDialog,
return {};
},
created() {},
methods: {
// 表格查询代理
promiseForSelect() {
return new Promise((resolve, reject) => {
crud(DML.TREE, 'dept', {}, {
type: this.$store.getters.isAdmin ? null : '1',
})
crud(DML.TREE, 'dept')
.then((res) => {
resolve(res);
})
.catch(err => reject(err));
});
},
// 添加
btnRowAddOnClick(row) {
this.textMap.add = `添加到${row.name}`;
const params = {
companyid: row.companyid || this.$store.getters.companyid,
parentid: row.id,
flowregion: row.flowregion,
region: row.region,
namesx: row.namesx,
};
this.$refs.deptDialog.showDialog(
params,
STATUS.CREATE,
);
},
// 编辑
btnEditOnClick(row) {
this.textMap.edit = `编辑${row.name}`;
this.$refs.deptDialog.showDialog({ id: row.id }, STATUS.UPDATE, row);
},
// 对话框保存后刷新表格
saveDialog() {
this.$refs.table.tableReload();
},
},
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.page-container {
.tree {
height: 500px;
}
}
</style>
26 changes: 2 additions & 24 deletions src/views/system/Role.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,16 @@
<CrudTable ref="table"
tableName="role"
tableTitle="角色列表"
:btnAddOnClick="btnAddOnClick"
:btnEditOnClick="btnEditOnClick"
fullHeight
:visibleList="{
:visibleList="{
tableTitle:false,
btnDel:true,
}"/>
<!-- 角色编辑对话框 -->
<RoleDialog ref="dialog"
tableName="role"
@afterSave="roleDialogOnClose" />
}" />
</div>
</template>

<script>
import RoleDialog from './components/RoleDialog.vue';
export default {
name: 'Role',
components: {
RoleDialog,
},
methods: {
btnAddOnClick() {
this.$refs.dialog.showDialog();
},
btnEditOnClick(row) {
this.$refs.dialog.showDialog({ id: row.id }, 1, row);
},
roleDialogOnClose() {
this.$refs.table.tableReload();
},
},
};
</script>
74 changes: 11 additions & 63 deletions src/views/system/Users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
-->
<template>
<div class="page-container">
<el-row :gutter="15" class="full-height">
<el-col :span="5" class="full-height">
<div class="full-height" style="overflow:auto">
<el-row :gutter="15"
class="full-height">
<el-col :span="5"
class="full-height">
<div class="full-height"
style="overflow:auto">
<el-input placeholder="请输入查询内容"
v-model="filterText"
prefix-icon="el-icon-search"> </el-input>
Expand Down Expand Up @@ -42,12 +45,10 @@
<CrudTable ref="table"
table-name="users"
:tableTitle="tableTitle"
:btnAddOnClick="btnAddOnClick"
:btnEditOnClick="btnEditOnClick"
:remoteFuncs="remoteFuncs"
fullHeight
:prefill="tableParams"
:actionColumnWidth="300"
:promiseForSelect="promiseForSelect"
:tableParams="tableParams"
:visibleList="{
tableTitle: true,
Expand Down Expand Up @@ -87,23 +88,16 @@
</CrudTable>
</el-col>
</el-row>
<!-- 用户编辑对话框 -->
<UserDialog ref="dialog"
:remoteFuncs="remoteFuncs"
@afterSave="dialogOnClose" />
</div>
</template>

<script>
import { DML, crud } from '@/api/public/crud';
import { mapGetters } from 'vuex';
import UserDialog from './components/UserDialog.vue';
export default {
name: 'Users',
components: {
UserDialog,
},
created() {
this.loadDeptTree();
},
Expand Down Expand Up @@ -162,10 +156,6 @@ export default {
crud(
DML.TREE,
'dept',
{},
{
type: this.$store.getters.isAdmin ? null : '1',
},
).then((res) => {
resolve(res.data);
});
Expand All @@ -174,11 +164,6 @@ export default {
};
},
methods: {
promiseForSelect(data) {
return crud(DML.SELECT, 'users', data, {
type: this.$store.getters.isAdmin ? null : '1',
});
},
handleAvatarSuccess(res, file) {
this.$refs.table.tableReload();
},
Expand Down Expand Up @@ -218,46 +203,11 @@ export default {
});
});
},
freezePassword(user, logincount) {
const message = logincount === '0' ? '确认解锁该账号?' : '确认锁定该账号?';
this.$confirm(message, '提示', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
const data = { ...user };
data.logincount = logincount;
crud(DML.UPDATE, 'users', data).then((res) => {
if (res.code === 200) {
this.$refs.table.tableReload();
this.$message('操作成功');
}
});
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消',
});
});
},
btnAddOnClick() {
this.$refs.dialog.showDialog({}, 0, {
deptid: this.tableParams.deptid,
});
},
// 请求部门树
loadDeptTree(data) {
this.loading = true;
crud(
DML.TREE,
'dept',
{},
{
type: this.$store.getters.name !== 'admin' ? '1' : null,
},
).then((res) => {
crud(DML.TREE, 'dept').then((res) => {
this.deptTree.data = [
{
name: '全部',
Expand All @@ -269,9 +219,7 @@ export default {
this.deptTree.expandedKeys.push(this.deptTree.rootId);
});
},
btnEditOnClick(row) {
this.$refs.dialog.showDialog({ id: row.id }, 1, row);
},
dialogOnClose() {
this.$refs.table.tableReload();
},
Expand Down
Loading

0 comments on commit 5d6e93a

Please sign in to comment.