From feff92f79ef2e78fe566010e9c8821f1300ad7c5 Mon Sep 17 00:00:00 2001 From: Yjhon Date: Mon, 14 Mar 2022 16:56:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E8=AE=A1=E5=88=92=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/trainplan/index.js | 20 ++++++++- src/views/project/trainPlan/TrainPlanForm.vue | 36 ++++++++++++---- src/views/project/trainPlan/TrainPlanList.vue | 43 +++++++++---------- 3 files changed, 68 insertions(+), 31 deletions(-) diff --git a/src/api/trainplan/index.js b/src/api/trainplan/index.js index 871b7c0..838fc55 100644 --- a/src/api/trainplan/index.js +++ b/src/api/trainplan/index.js @@ -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 + }) } \ No newline at end of file diff --git a/src/views/project/trainPlan/TrainPlanForm.vue b/src/views/project/trainPlan/TrainPlanForm.vue index 140c1bb..f95c9fe 100644 --- a/src/views/project/trainPlan/TrainPlanForm.vue +++ b/src/views/project/trainPlan/TrainPlanForm.vue @@ -2,20 +2,20 @@ - + - + {{ entity }}年度 - 选择项目 + 选择项目 - + - 保存 + 保存 关闭 @@ -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 => 关闭后当前未保存的数据将丢失! 确认关闭吗?, - 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 = '单位培训计划' } }, diff --git a/src/views/project/trainPlan/TrainPlanList.vue b/src/views/project/trainPlan/TrainPlanList.vue index e9a7cd2..7e45bcd 100644 --- a/src/views/project/trainPlan/TrainPlanList.vue +++ b/src/views/project/trainPlan/TrainPlanList.vue @@ -23,9 +23,13 @@ @@ -36,7 +40,7 @@ // 这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等) // 例如: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值 true是详情,false不是详情 }, }) }, + //删除 + 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)