培训计划调整

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 = { const trainPlanAPI = {
add: '/trainPlan/add', add: '/trainPlan/add',
list: '/trainPlan/list' list: '/trainPlan/list',
get: '/trainPlan/get',
del: '/trainPlan/del'
} }
export function trainPlanAdd(params) { export function trainPlanAdd(params) {
@ -19,4 +21,20 @@ export function trainPlanList(params) {
method: 'get', method: 'get',
params: params 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-card :bordered="false" :title="title">
<a-form-model ref="form" :rules="rules" :model="form" :layout="'horizontal'"> <a-form-model ref="form" :rules="rules" :model="form" :layout="'horizontal'">
<a-form-model-item label="培训计划名称" prop="name"> <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>
<a-form-model-item label="培训计划年度" prop="year"> <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-option v-for="entity in years" :key="entity"> {{ entity }}年度 </a-select-option>
</a-select> </a-select>
</a-form-model-item> </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-table v-if="selectedRows.length > 0" rowKey="id" :columns="columns" :data-source="selectedRows" :pagination="false"></a-table>
<a-form-model-item label="备注"> <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-form-model-item>
<a-col :span="24" style="text-align: center;"> <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-button type="danger" size="default" @click="showConfirm">关闭</a-button>
</a-col> </a-col>
</a-form-model> </a-form-model>
@ -32,7 +32,7 @@
// import from '' // import from ''
import { STable } from '@/components' import { STable } from '@/components'
import { getProjectList } from '@/api/project/project' import { getProjectList } from '@/api/project/project'
import { trainPlanAdd } from '@/api/trainplan'; import { trainPlanAdd, trainPlanGet } from '@/api/trainplan';
export default { export default {
// import使 // import使
@ -41,6 +41,7 @@ export default {
data() { data() {
// //
return { return {
disabled: false,
title: '年度培训计划', title: '年度培训计划',
queryParam: { queryParam: {
pageNum: 1, pageNum: 1,
@ -56,7 +57,6 @@ export default {
projectIds: [], projectIds: [],
status: 1, // status: 1, //
}, },
rowSelection: {},
selectedRows: [], selectedRows: [],
selectedRowKeys: [], selectedRowKeys: [],
rules: { rules: {
@ -120,10 +120,19 @@ export default {
/** 提示框 START */ /** 提示框 START */
showConfirm() { showConfirm() {
this.$confirm({ this.$confirm({
title: '提示', title: '提示',
content: h => <span style="color:red;font-size:15px;">关闭后当前未保存的数据将丢失! 确认关闭吗?</span>, 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'); }, onCancel() { console.log('Cancel'); },
class: 'test', class: 'test',
}); });
@ -183,9 +192,20 @@ export default {
}, },
// - 访this // - 访this
created() { created() {
let id = this.$route.query.trainPlanId;
this.initYears(); 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') { if (this.$route.query.t != 'year') {
this.queryParam.type = 3; // this.queryParam.type = 3; //
this.form.type = 3;
this.title = '单位培训计划' this.title = '单位培训计划'
} }
}, },

View File

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