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
| <template>
| <a-modal
| :title="title"
| :width="1200"
| :visible="visible"
| :confirmLoading="confirmLoading"
| @ok="handleOk"
| @cancel="handleCancel"
| >
| <a-spin :spinning="confirmLoading">
| <a-form-model ref="form" :label-col="labelCol" :wrapper-col="wrapperCol" :model="model" :rules="validatorRules">
| <!-- 主表单区域 -->
| <a-row class="form-row" :gutter="16">
| <a-col :lg="8">
| <a-form-model-item label="开始日期" prop="ksrq">
| <a-date-picker v-model="model.ksrq" valueFormat="YYYY-MM-DD" style="width: 100%" placeholder="请选择开始日期" />
| </a-form-model-item>
| </a-col>
| <a-col :lg="8">
| <a-form-model-item label="结束日期" prop="jsrq">
| <a-date-picker v-model="model.jsrq" valueFormat="YYYY-MM-DD" style="width: 100%" placeholder="请选择结束日期" />
| </a-form-model-item>
| </a-col>
| </a-row>
| </a-form-model>
| </a-spin>
|
| <!-- 选择用户 -->
| </a-modal>
| </template>
|
| <script>
| import { putAction } from '@/api/manage'
| import moment from 'moment'
| export default {
| name: 'ProjectModal3',
| data() {
| return {
| title: '修改时间计划',
| visible: false,
| form: this.$form.createForm(this),
| userIds: 'admin',
| model: {},
| labelCol: {
| xs: { span: 24 },
| sm: { span: 5 },
| },
| wrapperCol: {
| xs: { span: 24 },
| sm: { span: 16 },
| },
| confirmLoading: false,
| validatorRules: {
| ksrq: [{ required: true, message: '开始日期不能为空', trigger: 'blur' }],
| jsrq: [{ required: true, message: '结束日期不能为空', trigger: 'blur' }],
| },
| url: {
| edit: '/pro/project/edit',
| },
| }
| },
| created() {},
| watch: {
| /* model(newName, oldName) {
| if(newName.projectManager_dictText){
| let that = this;
| setTimeout(() => {
| that.userIds = newName.projectManager_dictText;
|
| }, 1000)
|
| }
|
| }*/
| },
| methods: {
| edit(record) {
| this.form.resetFields()
| this.visible = true
| this.model = Object.assign({}, record)
| },
| getNumberOfDays(date1, date2) {
| //获得天数
| //date1:开始日期,date2结束日期
| var a1 = Date.parse(new Date(date1))
| var a2 = Date.parse(new Date(date2))
| var day = parseInt((a2 - a1) / (1000 * 60 * 60 * 24)) //核心:时间戳相减,然后除以天数
| return day
| },
|
| handleCancel() {
| this.close()
| },
| moment,
| handleOk() {
| let that = this
| this.$refs.form.validate((valid) => {
| if (valid) {
| console.info(this.model)
| //计算开始结束时间 start
| const zq = that.getNumberOfDays(that.model.ksrq, that.model.jsrq)
| console.info(zq)
| if (zq < 0) {
| that.$message.warning('日期不合法')
| return false
| }
|
|
| //计算开始结束时间 end
| that.confirmLoading = true
| //add
| putAction(this.url.edit, that.model)
| .then((res) => {
| that.confirmLoading = false
| if (res.success) {
| that.close()
| that.$message.success(res.message)
| that.$emit('ok', res.result)
| that.close()
| } else {
| that.$message.warning(res.message)
| }
| })
| .finally(() => {
| that.confirmLoading = false
| })
| }
| })
| },
| close() {
| this.$emit('close')
| this.visible = false
| },
| handleAddUser() {},
| handleChangeUserCommon(v) {},
| },
| }
| </script>
|
| <style scoped>
| </style>
|
|