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
<template>
<div style="height: 200px;">
<a-spin :spinning="loading" style="width: 100%;height: 100%;">
<a-form-model ref="form" :model="formData" :rules="rules" class="from-table">
<a-row>
<a-col :span="4" class="bg-gray">
<div class="required">单位</div>
</a-col>
<a-col :span="20">
<a-form-model-item ref="appUnitId" prop="appUnitId">
<unit-select v-model="formData.appUnitId" />
<span style="color: rgb(56, 188, 213);margin-left:5px">※ 请输入单位名称查找到单位</span>
</a-form-model-item>
</a-col>
</a-row>
<a-row>
<a-col :span="24" style="text-align:center;">
<a-button type="primary" @click="submit">保存</a-button>
</a-col>
</a-row>
</a-form-model>
</a-spin>
</div>
</template>
<script>
import { isEmptyParams, getCardInfo } from "@/views/utils/common"
import moment from 'moment'
import unitSelect from '@/views/components/common/unitSelect'
export default {
name: "unitEdit",
components: {
unitSelect
},
data () {
return {
formData: {
id: null, appUnitId: null
},
rules: {
appUnitId: [{ required: true, message: '请选择单位', trigger: 'change' }],
},
loading: false,
}
},
props: {
value: {
type: String,
default: () => {
return null
}
},
appUnitId: {
type: String,
default: () => {
return null;
},
},
},
created () {
this.getById()
},
methods: {
moment,
getById () {
this.formData.id = this.value
this.formData.appUnitId = this.appUnitId
},
submit () {
this.$refs.form.validate(valid => {
if (valid) {
this.loading = true
let pars = isEmptyParams(this.formData)
let par = { ...pars }
this.$api.project.updateUnit(par).then(({ data = {} }) => {
if (data) {
this.$message.success('成功!')
this.$emit('close', 'unitEdit')
}
this.loading = false
}).catch(() => { this.loading = false })
} else {
return false
}
})
}
}
}
</script>