cnas/client/src/views/employee/employee.vue

169 lines
5.2 KiB
Python

<template>
<div class="app-container">
<div style="display:flex">
<treeselect v-model="listQuery.cert_field" :multiple="false" :options="typeOptions" placeholder="认证类型" @input="handleFilter" style="width: 260px" clearable/>
<!-- <el-select
v-model="listQuery.cert_field"
placeholder="认证类型"
clearable
style="width: 200px"
class="filter-item"
@change="handleFilter"
>
<el-option
v-for="item in typeOptions"
:key="item.key"
:label="item.display_name"
:value="item.key"
/>
</el-select> -->
<el-input
v-model="listQuery.search"
placeholder="规则名称/编号"
style="width: 300px;"
class="filter-item"
@keyup.enter.native="handleFilter"
/>
<el-button
class="filter-item"
type="primary"
icon="el-icon-search"
@click="handleFilter"
>搜索</el-button>
<el-button
class="filter-item"
style="margin-left: 10px;"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter"
>刷新重置</el-button>
</div>
<!-- <div style="margin-top:6px">
<el-button type="primary" icon="el-icon-plus" @click="handleCreate">新增</el-button>
</div> -->
<el-table
v-loading="listLoading"
:data="tableData.results"
style="width: 100%;margin-top:10px;"
border
fit
stripe
highlight-current-row
max-height="600"
>
<el-table-column type="index" width="50" />
<el-table-column align="header-center" label="编号">
<template slot-scope="scope">{{ scope.row.code }}</template>
</el-table-column>
<el-table-column align="header-center" label="账号">
<template slot-scope="scope">{{ scope.row.user.username }}</template>
</el-table-column>
<el-table-column align="center" label="名称">
<template slot-scope="scope">{{ scope.row.user.name }}</template>
</el-table-column>
<el-table-column align="center" label="所属部门">
<template slot-scope="scope">{{ scope.row.user.dept_name }}</template>
</el-table-column>
<el-table-column align="header-center" label="职务/岗位">
<template slot-scope="scope">{{ scope.row.user.position }}</template>
</el-table-column>
<el-table-column label="创建日期">
<template slot-scope="scope">
<span>{{ scope.row.create_time }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作" width="260px">
<template slot-scope="scope">
<el-button
type="primary"
size="small"
:disabled="!checkPermission(['employee_update'])"
@click="handleUpdate(scope)"
>编辑</el-button>
<el-button
type="danger"
size="small"
:disabled="!checkPermission(['employee_delete'])"
@click="handleDelete(scope)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="tableData.count>0"
:total="tableData.count"
:page.sync="listQuery.page"
:limit.sync="listQuery.page_size"
@pagination="getList"
/>
</div>
</template>
<script>
import { getEmployeeList, deleteEmployee } from "@/api/employee"
import { getDictList } from "@/api/dict"
import Pagination from "@/components/Pagination"
import checkPermission from '@/utils/permission'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { genTree } from '../../utils'
export default {
components: { Pagination, Treeselect },
data() {
return {
tableData: {count:0},
listLoading: true,
listQuery: {
page: 1,
page_size: 20
},
typeOptions: [],
};
},
created() {
this.getList();
this.getTypeOptions()
},
methods: {
checkPermission,
getList() {
this.listLoading = true;
getEmployeeList(this.listQuery).then(response => {
if (response.data) {
this.tableData = response.data
}
this.listLoading = false
});
},
getTypeOptions() {
getDictList({type__code:'cert_field'}).then(res=>{
this.typeOptions = genTree(res.data)
})
},
resetFilter() {
this.listQuery = {
page: 1,
page_size: 20
}
this.getList()
},
handleFilter() {
this.listQuery.page = 1
this.getList()
},
// handleCreate() {
// this.$router.push({path:"/certset/implementrule/create"})
// },
handleUpdate(scope) {
this.$router.push({name:"EmployeeUpdate",params:{id:scope.row.id}})
},
handleDelete(scope) {
deleteEmployee(scope.row.id).then(res=>{
this.$message.success('成功')
this.getList()
})
}
}
};
</script>