| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- <template>
- <div class="ele-body">
- <el-card shadow="never">
- <div>
- <!-- 搜索区域 -->
- <div class="search-area">
- <seek-page
- :seekList="seekList"
- @search="handleSearch"
- :formLength="4"
- />
- </div>
- <!-- 列表视图 -->
- <div class="list-view">
- <ele-pro-table
- ref="table"
- row-key="id"
- :columns="columns"
- :datasource="datasource"
- :cache-key="cacheKeyUrl"
- height="calc(100vh - 350px)"
- @columns-change="handleColumnChange"
- >
- <template v-slot:toolbar>
- <div class="toolbar-left">
- <el-button
- type="primary"
- size="small"
- icon="el-icon-plus"
- v-if="$hasPermission('ehs:offlineTraining:save')"
- @click="handleAdd"
- >添加记录</el-button
- >
- </div>
- </template>
- <template v-slot:action="{ row }">
- <div class="action-links">
- <el-link
- type="primary"
- :underline="false"
- @click="handleView(row)"
- >查看</el-link
- >
- <el-link
- type="primary"
- :underline="false"
- v-if="$hasPermission('ehs:offlineTraining:update')"
- @click="handleEdit(row)"
- >编辑</el-link
- >
- <el-link
- type="primary"
- :underline="false"
- v-if="$hasPermission('ehs:offlineTraining:update')"
- @click="handleSummary(row)"
- >培训总结</el-link
- >
- <el-link
- type="danger"
- :underline="false"
- v-if="$hasPermission('ehs:offlineTraining:delete')"
- @click="handleDelete(row)"
- >删除</el-link
- >
- </div>
- </template>
- </ele-pro-table>
- </div>
- <!-- 新增/编辑/查看弹窗 -->
- <add ref="dialogRef" @reload="handleReload" />
- <!-- 培训总结 -->
- <summary-dialog ref="summaryRef" @reload="handleReload" />
- </div>
- </el-card>
- </div>
- </template>
- <script>
- import add from './add.vue';
- import summaryDialog from './summary.vue';
- import tabMixins from '@/mixins/tableColumnsMixin';
- import { getPage, remove } from '@/api/offlineTraining/index.js';
- import { TRAINING_TYPE_OPTIONS, getOptionLabel } from '../constants';
- export default {
- components: {
- add,
- summaryDialog
- },
- mixins: [tabMixins],
- data() {
- return {
- // 表格列配置
- columns: [
- {
- columnKey: 'index',
- label: '序号',
- type: 'index',
- width: 60,
- align: 'center'
- },
- {
- prop: 'trainingProject',
- label: '培训项目',
- align: 'center',
- minWidth: 180,
- showOverflowTooltip: true
- },
- {
- prop: 'organizationName',
- label: '组织单位',
- align: 'center',
- minWidth: 140,
- showOverflowTooltip: true
- },
- {
- prop: 'trainingUnitName',
- label: '培训单位',
- align: 'center',
- minWidth: 140,
- showOverflowTooltip: true
- },
- {
- prop: 'trainingLecturer',
- label: '培训讲师',
- align: 'center',
- minWidth: 110
- },
- {
- prop: 'location',
- label: '地点',
- align: 'center',
- minWidth: 130,
- showOverflowTooltip: true
- },
- {
- prop: 'trainingType',
- label: '培训类型',
- align: 'center',
- minWidth: 110,
- formatter: (row) =>
- getOptionLabel(TRAINING_TYPE_OPTIONS, row.trainingType)
- },
- {
- prop: 'startTime',
- label: '开始时间',
- align: 'center',
- minWidth: 160
- },
- {
- prop: 'endTime',
- label: '结束时间',
- align: 'center',
- minWidth: 160
- },
- {
- prop: 'plannedCount',
- label: '计划人数',
- align: 'center',
- minWidth: 100
- },
- {
- prop: 'actualCount',
- label: '实到人数',
- align: 'center',
- minWidth: 100
- },
- {
- prop: 'createTime',
- label: '创建时间',
- align: 'center',
- minWidth: 160
- },
- {
- columnKey: 'action',
- label: '操作',
- width: 230,
- align: 'center',
- slot: 'action'
- }
- ],
- cacheKeyUrl: 'ehs-offlineTrainingRecords-list'
- };
- },
- computed: {
- seekList() {
- return [
- {
- label: '培训项目:',
- value: 'trainingProject',
- type: 'input',
- width: 220,
- placeholder: '请输入培训项目'
- },
- {
- label: '地点:',
- value: 'location',
- type: 'input',
- width: 220,
- placeholder: '请输入地点'
- },
- {
- label: '培训类型:',
- value: 'trainingType',
- type: 'select',
- width: 220,
- placeholder: '请选择培训类型',
- planList: TRAINING_TYPE_OPTIONS
- }
- ];
- }
- },
- methods: {
- // 新增
- handleAdd() {
- this.$refs.dialogRef.open();
- },
- // 编辑
- handleEdit(row) {
- this.$refs.dialogRef.open(row, 'edit');
- },
- // 查看
- handleView(row) {
- this.$refs.dialogRef.open(row, 'view');
- },
- // 培训总结
- handleSummary(row) {
- this.$refs.summaryRef.open(row);
- },
- // 删除
- handleDelete(row) {
- this.$confirm('确认删除该培训记录吗?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(() => remove([row.id]))
- .then((message) => {
- this.$message.success(message || '删除成功');
- this.$refs.table.reload();
- })
- .catch(() => {});
- },
- // 搜索
- handleSearch(where) {
- this.$refs.table.reload({ page: 1, where });
- },
- handleReload() {
- this.$refs.table.reload();
- },
- // 表格数据源
- datasource({ page, limit, where }) {
- const body = {
- ...where,
- pageNum: page,
- size: limit
- };
- Object.keys(body).forEach((key) => {
- if (body[key] === '' || body[key] === null) {
- delete body[key];
- }
- });
- return getPage(body);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .search-area {
- margin-bottom: 15px;
- padding-bottom: 15px;
- border-bottom: 1px solid #ebeef5;
- }
- .list-view {
- ::v-deep .ele-pro-table {
- .el-table {
- border: 1px solid #ebeef5;
- border-radius: 4px;
- }
- }
- }
- .action-links {
- display: flex;
- flex-wrap: wrap;
- justify-content: center;
- gap: 8px;
- .el-link {
- font-size: 12px;
- }
- }
- </style>
|