1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<template>
<div>
<a-form layout="inline" class="search_form">
<a-button type="primary" class="search_input" style="margin-right: 10px;" v-if="isButten" @click="createYear">添加</a-button>
<span :style="{color:'#DC143C'}">{{description}}</span>
</a-form>
<a-table :dataSource="tableData" :columns="columns" rowKey="id" :pagination="false" :loading="loading">
<template slot="option" slot-scope="record">
<a-button type="primary" size="small" @click="editYear(record)">修改</a-button>
<a-button type="danger" size="small" @click="deleteYear(record)">删除</a-button>
</template>
</a-table>
<a-pagination v-if="pagination.total > 0" :total="pagination.total" show-size-changer show-quick-jumper v-model="pagination.pageIndex" :page-size="pagination.pageSize" :page-size-options="pagination.pageSizeOptions" @showSizeChange="showSizeChange" @change="change" :showTotal="() => `共 ${pagination.total} 条`" />
<a-modal :visible="visibleEdit" :title="'添加/修改'" @cancel="close" @ok="submit" :maskClosable="false" :width="800" destroyOnClose>
<a-form-model ref="formRef" :model="formData" :rules="formRules" :label-col="{span: 6}" :wrapper-col="{span: 17}">
<a-form-model-item label="申报年度" prop="reportYear">
<a-input v-model="formData.reportYear" placeholder="申报年度" :disabled="disabled" style="width: 120px"></a-input>
</a-form-model-item>
<a-form-model-item label="申报时间" prop="startTime">
<a-form-model-item prop="startTime" style="flex-basis:30%;">
<a-date-picker format="YYYY-MM-DD HH:mm:ss" valueFormat="YYYY-MM-DD HH:mm:ss" v-model="formData.startTime" style="width: 180px" @change="dateChange" />
<span>~</span>
<a-date-picker format="YYYY-MM-DD HH:mm:ss" valueFormat="YYYY-MM-DD HH:mm:ss" v-model="formData.endTime" style="width: 180px" @change="dateChange" />
</a-form-model-item>
</a-form-model-item>
<a-form-model-item label="中期考核年度" prop="checkYear" v-if="display">
<a-input v-model="formData.checkYear" placeholder="中期考核年度"></a-input>
</a-form-model-item>
<a-form-model-item label="备注" prop="remark">
<a-textarea placeholder="" v-model="formData.remark" :rows="3" />
</a-form-model-item>
</a-form-model>
</a-modal>
</div>
</template>
<script>
import { isEmptyParams } from "@/views/utils/common";
import moment from 'moment';
export default {
name: 'projectTimeSet',
data () {
return {
formData: {
id: undefined,
reportYear: moment().format('YYYY'),
unitCode: '',
yearType: 1, //1项目 2任务书 3中期考核
startTime: '',
endTime: '',
remark: '',
checkYear: '',
created: '',
updated: ''
},
tableData: [],
columns: [],
pagination: {
pageIndex: 1,
pageSize: this.$defaultPageSize,
total: 0,
pageSizeOptions: this.$defaultPageSizeOptions,
},
// 弹窗标志
visibleEdit: false,
loading: false,
isButten: false,
disabled: true,
display: false,
description: '',
formRules: {
id: [{ required: false }],
reportYear: [{ required: true, message: '请输入申报年度' }],
unitCode: [{ required: true, message: '请输入单位编码' }],
yearType: [{ required: true, message: '请选择年度类型' }],
startTime: { required: true, message: '请选择开始时间' },
endTime: { required: true, message: '请选择结束时间' },
remark: [{ required: false }],
checkYear: [{ required: true, message: '请填写中期审核年度' }],
created: [{ required: false }],
updated: [{ required: false }]
}
}
},
created () {
this.InitApplyData()
},
computed: {
},
methods: {
moment,
InitApplyData () {
this.columns = [
{ title: '年度', dataIndex: 'reportYear' },
{ title: '开始时间', dataIndex: 'startTime' },
{ title: '结束时间', dataIndex: 'endTime' },
{ title: '备注', dataIndex: 'remark' },
]
this.getYearInfo()
},
getYearInfo () {
let len = this.$defaultLength
let pars = { type: 3 }
this.$api.year.getYearInfo(pars).then(({ data = {} }) => {
if (data) {
this.getListByPage()
this.isButten = data.disabled
this.description = data.description
}
}).catch(() => {
})
},
getListByPage () {
this.loading = true
let pars = { yearType: 3 }
let par = {
...pars,
pageIndex: this.pagination.pageIndex,
pageSize: this.pagination.pageSize
}
this.$api.batch.getListByPage(par).then(({ data = {} }) => {
if (data) {
const { dataList = [], total = 0 } = data
this.tableData = dataList
this.pagination.total = total
this.loading = false
}
}).catch(() => {
this.loading = false
})
},
searchList () {
this.pagination.pageIndex = 1
this.getListByPage()
},
change () {
this.getListByPage()
},
showSizeChange (current, pageSize) {
this.pagination.pageIndex = current
this.pagination.pageSize = pageSize
this.getListByPage()
},
// 起止日期选择处理
dateChange (value) {
let statr = this.formData.startTime
let end = this.formData.endTime
if (!statr || !end) {
return
}
if (statr > end) {
this.formData.startTime = end
this.formData.endTime = statr
}
},
createYear () {
let pars = { type: 3 }
this.$api.year.getYearInfo(pars).then(({ data = {} }) => {
if (data) {
this.formData.reportYear = data.reportYear
this.formData.unitCode = data.unitCode
this.formData.yearType = data.yearType
this.formData.startTime = data.startTime
this.formData.endTime = data.endTime
this.formData.checkYear = ''
this.formData.remark = ''
}
}).catch(() => {
})
this.visibleEdit = true
},
editYear (record) {
Object.assign(this.formData, record);
this.visibleEdit = true
},
close () {
this.visibleEdit = false
},
submit () {
this.$refs.formRef.validate(valid => {
if (valid) {
let pars = isEmptyParams(this.formData)
let par = {
...pars
}
this.$api.batch.addOrUpdateYearInfo(par).then(({ data = {} }) => {
if (data) {
this.$message.success('成功!')
this.visibleEdit = false
this.getYearInfo()
this.getListByPage()
}
})
}
})
},
deleteYear (record) {
this.$confirm({
title: '删除',
content: '确定要删除该申报年度?',
okText: '确定',
okType: 'danger',
cancelText: '取消',
onOk () {
let pars = isEmptyParams(record)
let par = {
...pars
}
this.$api.batch.deleteApplyYearInfo(par).then(({ data = {} }) => {
if (data) {
this.getYearInfo()
this.getListByPage()
this.$message.success('删除成功!')
}
})
},
onCancel () {
},
})
}
},
watch: {
$route () {
this.InitApplyData()
}
}
}
</script>