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
const departmentDialog = {
data: function () {
return {
form: {
id: '',
name: '',
parentId: '',
parentName: '',
code: '',
areaId: '',
areaName: '',
level: '',
type: '',
sort: ''
},
conpanyControl: [],
props: [
{
label: '上级机构',
prop: 'parentName',
defaultProp: 'parentId',
inputType: 'inputTree',
defaultProps: {
children: 'children',
label: 'name'
},
visible: false
},
{
label: '名称',
prop: 'name',
inputType: 'input'
},
{
label: '所属行政区划',
prop: 'areaName',
defaultProp: 'areaId',
inputType: 'inputTree',
defaultProps: {
children: 'children',
label: 'name'
},
visible: false
},
{
label: '机构类别',
prop: 'type',
inputType: 'select',
options: []
},
{
label: '机构编码',
prop: 'code',
inputType: 'input'
},
{
label: '排序',
prop: 'sort',
inputType: 'input'
}
],
rules: {
parentName: [
{ required: true, message: '不能为空', trigger: 'change' }
],
name: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
areaName: [
{ required: true, message: '不能为空', trigger: 'change' }
],
type: [
{ required: true, message: '不能为空', trigger: 'change' }
],
code: [
{ required: true, message: '不能为空', trigger: 'blur' }
],
sort: [
{ required: true, message: '不能为空', trigger: 'blur' }
]
}
}
},
watch: {
parentIdOptions: {
handler: function (newVal) {
if (newVal && newVal.length > 0) {
this.setOptions('parentName', this.props, newVal)
}
},
immediate: true
}
},
created: function () {
this.getOrganizationType()
this.getCompartmentList()
},
methods: {
// 机构类别
getOrganizationType: function (data) {
var self = this
api({
url: '/sys/department/type',
type: 'get',
successFuc: function (res) {
if (res.code === CONFIG.SUCCESS) {
self.setOptions('type', self.props, res.data)
}
}
})
},
// 所属行政区划
getCompartmentList: function (data) {
var self = this
api({
url: '/sys/compartment/areaName',
type: 'get',
successFuc: function (res) {
if (res.code === CONFIG.SUCCESS) {
self.setOptions('areaName', self.props, res.data)
}
}
})
},
// Dialog 打开的回调
openDialogHandle: function () {
var self = this
this.$nextTick(function () {
if (self.title1 === CONFIG.EDIT || self.title1 === CONFIG.ADD) {
self.clearValidate('departmentForm')
}
if (self.title1 === CONFIG.EDIT) {
self.validate('departmentForm')
}
})
},
// Dialog 关闭的回调
closeDialogHandle: function () {
var self = this
this.$nextTick(function () {
if (self.title1 === CONFIG.EDIT || self.title1 === CONFIG.ADD) {
self.clearForm('departmentForm')
}
})
},
// 确定
confirmHandle: function () {
this.$refs.departmentForm.submitHandle()
},
submitHandle: function (data) {
this.close('departmentDialog')
},
cancelHandle: function () {
this.close('departmentDialog')
}
}
}