master
parent
32a0dbf219
commit
47af3e1ce3
@ -0,0 +1,56 @@
|
|||||||
|
import request from "@/utils/request";
|
||||||
|
function customParamsSerializer(params) {
|
||||||
|
let result = '';
|
||||||
|
for (let key in params) {
|
||||||
|
if (params.hasOwnProperty(key)) {
|
||||||
|
if (Array.isArray(params[key])) {
|
||||||
|
params[key].forEach((item, index) => {
|
||||||
|
if (item.key) {
|
||||||
|
result += `${key}[${index}][key]=${item.key}&${key}[${index}][op]=${item.op}&${key}[${index}][value]=${item.value}&`;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
result += `${key}[${index}]=${item}&`
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
result += `${key}=${params[key]}&`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.slice(0, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function index(params, isLoading = false) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/api/admin/employee-participations/index",
|
||||||
|
params,
|
||||||
|
paramsSerializer: customParamsSerializer,
|
||||||
|
isLoading
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function show(params, isLoading = true) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/api/admin/employee-participations/show",
|
||||||
|
params,
|
||||||
|
isLoading
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function save(data) {
|
||||||
|
return request({
|
||||||
|
method: "post",
|
||||||
|
url: "/api/admin/employee-participations/save",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function destroy(params) {
|
||||||
|
return request({
|
||||||
|
method: "get",
|
||||||
|
url: "/api/admin/employee-participations/destroy",
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -0,0 +1,216 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<div>
|
||||||
|
<div ref="lxHeader">
|
||||||
|
<lx-header icon="md-apps" :text="$route.meta.title" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
|
||||||
|
<div slot="content">
|
||||||
|
<div class="searchwrap" style="display: flex;align-items: center;">
|
||||||
|
<div>
|
||||||
|
<el-input v-model="select.course_name" placeholder="请输入课程名称" clearable />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<el-select v-model="select.type" placeholder="请选择类型" clearable style="width: 100%;">
|
||||||
|
<el-option label="元禾员工参与" :value="1" />
|
||||||
|
<el-option label="干部培训" :value="2" />
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<el-button type="primary" size="small" @click="select.page=1,getList()">查询</el-button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<el-button type="primary" size="small" @click="editEmployee('add')">新增</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</lx-header>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<xy-table :list="list" :total="total" :table-item="table_item" @pageIndexChange="pageIndexChange" @pageSizeChange="pageSizeChange">
|
||||||
|
<template v-slot:type>
|
||||||
|
<el-table-column align="center" label="类型" width="150" header-align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-tag v-if="scope.row.type === 1" type="primary">元禾员工参与</el-tag>
|
||||||
|
<el-tag v-else-if="scope.row.type === 2" type="success">干部培训</el-tag>
|
||||||
|
<span v-else>{{ scope.row.type }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</template>
|
||||||
|
<template v-slot:course_type_id>
|
||||||
|
<el-table-column align="center" label="课程体系" width="200" header-align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ getCourseTypeName(scope.row.course_type_id) }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</template>
|
||||||
|
<template v-slot:btns>
|
||||||
|
<el-table-column align="center" label="操作" width="180" header-align="center">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="primary" size="small" @click="editEmployee('editor',scope.row.id)">编辑</el-button>
|
||||||
|
<el-popconfirm title="确定删除吗?" style="margin:0 10px" @confirm="deleteList(scope.row.id)">
|
||||||
|
<el-button slot="reference" type="danger" size="small">删除</el-button>
|
||||||
|
</el-popconfirm>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</template>
|
||||||
|
</xy-table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<add-employee ref="addEmployee" @refresh="getList" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import addEmployee from './components/addEmployee.vue'
|
||||||
|
import { index, destroy } from '@/api/employee/index.js'
|
||||||
|
import { index as courseTypeIndex } from '@/api/course/courseType.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
addEmployee
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
select: {
|
||||||
|
course_name: '',
|
||||||
|
type: '',
|
||||||
|
page: 1,
|
||||||
|
page_size: 10
|
||||||
|
},
|
||||||
|
list: [],
|
||||||
|
total: 0,
|
||||||
|
courseTypeOptions: [],
|
||||||
|
table_item: [{
|
||||||
|
prop: 'type',
|
||||||
|
label: '类型',
|
||||||
|
align: 'center',
|
||||||
|
width: 150
|
||||||
|
}, {
|
||||||
|
prop: 'course_type_id',
|
||||||
|
label: '课程体系',
|
||||||
|
align: 'center',
|
||||||
|
width: 200
|
||||||
|
}, {
|
||||||
|
prop: 'course_name',
|
||||||
|
label: '课程名称',
|
||||||
|
align: 'left',
|
||||||
|
minWidth: 200
|
||||||
|
}, {
|
||||||
|
prop: 'start_date',
|
||||||
|
label: '开始日期',
|
||||||
|
align: 'center',
|
||||||
|
width: 150
|
||||||
|
}, {
|
||||||
|
prop: 'end_date',
|
||||||
|
label: '结束日期',
|
||||||
|
align: 'center',
|
||||||
|
width: 150
|
||||||
|
}, {
|
||||||
|
prop: 'total',
|
||||||
|
label: '数量',
|
||||||
|
align: 'center',
|
||||||
|
width: 120
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getCourseTypeList()
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
async getCourseTypeList() {
|
||||||
|
try {
|
||||||
|
const res = await courseTypeIndex({
|
||||||
|
page: 1,
|
||||||
|
page_size: 999
|
||||||
|
})
|
||||||
|
if (res && res.data) {
|
||||||
|
this.courseTypeOptions = res.data
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取课程体系列表失败:', error)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getCourseTypeName(courseTypeId) {
|
||||||
|
if (!courseTypeId) return ''
|
||||||
|
const courseType = this.courseTypeOptions.find(item => {
|
||||||
|
return String(item.id) === String(courseTypeId) || item.id === courseTypeId
|
||||||
|
})
|
||||||
|
return courseType ? courseType.name : courseTypeId
|
||||||
|
},
|
||||||
|
pageIndexChange(e) {
|
||||||
|
this.select.page = e
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
pageSizeChange(e) {
|
||||||
|
this.select.page_size = e
|
||||||
|
this.select.page = 1
|
||||||
|
this.getList()
|
||||||
|
},
|
||||||
|
editEmployee(type, id) {
|
||||||
|
if (type === 'editor') {
|
||||||
|
this.$refs.addEmployee.id = id
|
||||||
|
}
|
||||||
|
this.$refs.addEmployee.type = type
|
||||||
|
this.$refs.addEmployee.isShow = true
|
||||||
|
},
|
||||||
|
async getList() {
|
||||||
|
const params = {
|
||||||
|
page_size: this.select.page_size,
|
||||||
|
page: this.select.page
|
||||||
|
}
|
||||||
|
const filters = []
|
||||||
|
if (this.select.course_name) {
|
||||||
|
filters.push({
|
||||||
|
key: 'course_name',
|
||||||
|
op: 'like',
|
||||||
|
value: this.select.course_name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (this.select.type) {
|
||||||
|
filters.push({
|
||||||
|
key: 'type',
|
||||||
|
op: 'eq',
|
||||||
|
value: this.select.type
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (filters.length > 0) {
|
||||||
|
params.filter = filters
|
||||||
|
}
|
||||||
|
const res = await index(params, false)
|
||||||
|
this.list = res.data
|
||||||
|
this.total = res.total
|
||||||
|
},
|
||||||
|
deleteList(id) {
|
||||||
|
destroy({
|
||||||
|
id: id
|
||||||
|
}).then(response => {
|
||||||
|
this.$message.success('删除成功')
|
||||||
|
this.getList()
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error)
|
||||||
|
this.$message.error('删除失败')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.searchwrap {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
&>div {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-right: 10px;
|
||||||
|
|
||||||
|
span {
|
||||||
|
min-width: 70px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
Loading…
Reference in new issue