index.vue
5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<template>
<div>
<el-row class="mt30">
<el-col :span="4" class="ml50">
<el-input v-model="groupname" placeholder="部门名称"></el-input>
</el-col>
<el-col :span="4" class="ml50">
<el-button type="primary" icon="el-icon-search" @click="searchGroup()">查询</el-button>
<el-button type="primary" icon="el-icon-plus" @click="addgroupdialog=true">创建</el-button>
</el-col>
</el-row>
<el-row>
<el-table :data="grtableData" style="width:98%;margin:20px auto;" class="mt20">
<el-table-column type="index" width="">
</el-table-column>
<el-table-column prop="name" label="部门名称" width="">
</el-table-column>
<el-table-column label="创建时间" width="">
<template slot-scope="scope">
<span>{{showLocalTime(scope.row.create_dt)}}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="">
<template slot-scope="scope">
<div class="tab-btn-box">
<span class="table-btn dengers" size="" @click="DeleteGroup(scope.$index, scope.row)">删除部门</span>
</div>
</template>
</el-table-column>
</el-table>
</el-row>
<el-row>
<el-pagination class="grouppage" @size-change="handleSizeChange" @current-change="handleCurrentChange"
:current-page.sync="currentPage" :page-size="page.limit" layout="total,prev, pager, next, jumper" :total="page.total">
</el-pagination>
</el-row>
<div class="creategrop-box">
<el-dialog title="添加部门" :visible.sync="addgroupdialog" width="30%">
<div>
<el-form ref="addgroupform" :model="addform" label-width="80px">
<el-form-item label="部门名称" prop="name" :rules="[{ required: true, message: '部门不能为空'}]">
<el-input v-model="addform.name"></el-input>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="addgroupdialog = false">取 消</el-button>
<el-button type="primary" @click="addGroup">确 定</el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
export default {
data() {
return {
groupname: "",
grtableData: [],
currentPage: 1,
addressData: [],
curEditData: "",
page: {
total: 0,
offset: 0,
limit: 20
},
dialogVisible: false,
addgroupdialog: false,
form: {
name: "",
org: "",
worktime: ""
},
addform: {
name: ""
},
editData: "",
gridData: []
};
},
methods: {
//搜索
searchGroup() {
this.getGroups();
},
/**删除部门 */
DeleteGroup(index, row) {
var data = {
name: row.name,
is_active: false
};
var Vthis = this;
this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then(() => {
this.axios
.post(this.API.auth.delugrps(row.ugrp_unid), data)
.then(function (response) {
Vthis.$message({
type: "info",
message: "删除成功!"
});
Vthis.getGroups();
});
})
.catch(() => {
this.$message({
type: "info",
message: "已取消删除"
});
});
},
handleSizeChange(val) {},
handleCurrentChange(val) {
this.currentPage = val;
this.page.offset = (val - 1) * this.page.limit;
},
addGroup() {
this.$refs["addgroupform"].validate(valid => {
if (valid) {
var Vthis = this;
this.axios
.post(this.API.auth.ugrps, this.addform)
.then(function (response) {
Vthis.$message({
type: "info",
message: "创建成功!"
});
Vthis.addgroupdialog = false;
Vthis.getGroups();
Vthis.$refs["addgroupform"].resetFields();
});
} else {
console.log("error submit!!");
return false;
}
});
},
getGroups() {
var Vthis = this;
this.axios
.get(this.API.auth.ugrps, {
params: {
offset: Vthis.offset,
limit: Vthis.page.limit,
name__like: Vthis.groupname,
is_active: true
}
})
.then(function (response) {
Vthis.grtableData = response.data.list_data;
Vthis.page.total = response.data.total_num;
});
},
},
created() {
this.getGroups();
}
};
</script>
<style lang="stylus" scoped>
.grouppage {
float: right;
margin-right: 20px;
}
.g-btn {
width: 100%;
}
</style>