培训计划调整

This commit is contained in:
Yjhon 2022-03-14 16:56:22 +08:00
parent 289c1263f5
commit feff92f79e
3 changed files with 68 additions and 31 deletions

View File

@ -2,7 +2,9 @@ import request from '@/utils/request'
const trainPlanAPI = {
add: '/trainPlan/add',
list: '/trainPlan/list'
list: '/trainPlan/list',
get: '/trainPlan/get',
del: '/trainPlan/del'
}
export function trainPlanAdd(params) {
@ -19,4 +21,20 @@ export function trainPlanList(params) {
method: 'get',
params: params
})
}
export function trainPlanGet(params) {
return request({
url: trainPlanAPI.get,
method: 'get',
params: params
})
}
export function trainPlanDel(params) {
return request({
url: trainPlanAPI.del,
method: 'delete',
params: params
})
}

View File

@ -2,20 +2,20 @@
<a-card :bordered="false" :title="title">
<a-form-model ref="form" :rules="rules" :model="form" :layout="'horizontal'">
<a-form-model-item label="培训计划名称" prop="name">
<a-input v-model="form.name" />
<a-input v-model="form.name" :disabled="disabled" />
</a-form-model-item>
<a-form-model-item label="培训计划年度" prop="year">
<a-select v-model="form.year" placeholder="--请选择--">
<a-select v-model="form.year" placeholder="--请选择--" :disabled="disabled">
<a-select-option v-for="entity in years" :key="entity"> {{ entity }}年度 </a-select-option>
</a-select>
</a-form-model-item>
<a-button type="primary" size="default" icon="plus" @click="showDrawer" style="margin-right: 8px;">选择项目</a-button>
<a-button v-if="!disabled" type="primary" size="default" icon="plus" @click="showDrawer" style="margin-right: 8px;">选择项目</a-button>
<a-table v-if="selectedRows.length > 0" rowKey="id" :columns="columns" :data-source="selectedRows" :pagination="false"></a-table>
<a-form-model-item label="备注">
<a-input v-model="form.remark" type="textarea" />
<a-input v-model="form.remark" type="textarea" :disabled="disabled" />
</a-form-model-item>
<a-col :span="24" style="text-align: center;">
<a-button type="primary" size="default" @click="handleSave" style="margin-right: 8px;">保存</a-button>
<a-button v-if="!disabled" type="primary" size="default" @click="handleSave" style="margin-right: 8px;">保存</a-button>
<a-button type="danger" size="default" @click="showConfirm">关闭</a-button>
</a-col>
</a-form-model>
@ -32,7 +32,7 @@
// import from ''
import { STable } from '@/components'
import { getProjectList } from '@/api/project/project'
import { trainPlanAdd } from '@/api/trainplan';
import { trainPlanAdd, trainPlanGet } from '@/api/trainplan';
export default {
// import使
@ -41,6 +41,7 @@ export default {
data() {
//
return {
disabled: false,
title: '年度培训计划',
queryParam: {
pageNum: 1,
@ -56,7 +57,6 @@ export default {
projectIds: [],
status: 1, //
},
rowSelection: {},
selectedRows: [],
selectedRowKeys: [],
rules: {
@ -120,10 +120,19 @@ export default {
/** 提示框 START */
showConfirm() {
this.$confirm({
title: '提示',
content: h => <span style="color:red;font-size:15px;">关闭后当前未保存的数据将丢失! 确认关闭吗?</span>,
onOk() { console.log('OK'); },
onOk() {
this.$router.push({
path: '/trainPlan/list/' + this.$route.query.t,
query: {
t: this.queryParam.type, //
trainPlanPageNum: this.$route.query.trainPlanPageNum, //
},
})
},
onCancel() { console.log('Cancel'); },
class: 'test',
});
@ -183,9 +192,20 @@ export default {
},
// - 访this
created() {
let id = this.$route.query.trainPlanId;
this.initYears();
if (id) {
trainPlanGet({ id: id }).then((res) => {
this.form = res.data;
this.selectedRows = res.data.projects;
this.selectedRowKeys = res.data.projectIds;
this.disabled = this.$route.query.showDetail === 'true' ? true : false;
})
}
if (this.$route.query.t != 'year') {
this.queryParam.type = 3; //
this.form.type = 3;
this.title = '单位培训计划'
}
},

View File

@ -23,9 +23,13 @@
</span>
<span slot="action" slot-scope="text, record">
<template>
<a-popconfirm title="是否发布?" @confirm="() => handledRelease(record)">
<a href="javascript:;">发布</a>
<a-popconfirm title="确定要删除当前培训计划吗?" @confirm="() => handledDelete(record)">
<a v-if="year < record.year" href="javascript:;">删除</a>
</a-popconfirm>
<a-divider type="vertical" v-if="year < record.year" />
<a v-if="year < record.year" href="javascript:;" @click="handledCreate(record)">编辑</a>
<a-divider type="vertical" v-if="year < record.year" />
<a href="javascript:;" @click="handledCreate(record,true)">详情</a>
</template>
</span>
</s-table>
@ -36,7 +40,7 @@
// jsjsjson
// import from ''
import { STable } from '@/components'
import { trainPlanList } from '@/api/trainplan'
import { trainPlanList, trainPlanDel } from '@/api/trainplan'
export default {
// import使
@ -53,30 +57,13 @@ export default {
year: '',
type: '',
},
year: new Date().getFullYear(),
//
columns: [
{ title: '序号', key: 'id', dataIndex: 'id', width: 60, scopedSlots: { customRender: 'serial' } },
{ title: '计划名称', dataIndex: 'name', key: 'name' },
{ title: '年度', dataIndex: 'year', key: 'year', customRender: (text, record, index) => { return record.year + ' 年度 ' } },
// {
// title: '', key: 'status', dataIndex: 'status',
// customRender: (text, record, index) => {
// // 1- 2- 3- 4-
// if (text == 1) {
// return ''
// }
// if (text == 2) {
// return ''
// }
// if (text == 3) {
// return ''
// }
// if (text == 4) {
// return ''
// }
// },
// },
{ title: '创建人员', key: 'createName', dataIndex: 'createName' },
{ title: '创建时间', key: 'createTime', dataIndex: 'createTime' },
{ title: '操作', width: 200, key: 'action', align: 'center', scopedSlots: { customRender: 'action' }, },
@ -102,7 +89,7 @@ export default {
//
methods: {
//
handledCreate(record) {
handledCreate(record,showDetail) {
console.log(this.queryParam)
this.$router.push({
path: '/project/trainPlan/TrainPlanForm',
@ -110,9 +97,21 @@ export default {
t: this.queryParam.type, //
trainPlanId: record.id, //id
trainPlanPageNum: this.$refs.table.localPagination.current, //
showDetail: showDetail || false, //使bool truefalse
},
})
},
//
handledDelete(record) {
trainPlanDel({ id: record.id }).then(res => {
if (res.code == 200) {
this.$notification['success']({
message: '培训计划《'+ record.name +'删除成功!',
});
this.$refs.table.refresh(true);
}
})
},
//
changeType(path) {
console.log('变更路由:', path)