File tree 3 files changed +37
-4
lines changed
3 files changed +37
-4
lines changed Original file line number Diff line number Diff line change 128
128
src_des: ' ' ,
129
129
dest_des: ' ' ,
130
130
direction: ' src_to_dest' // none, src_to_dest, bidirectional
131
- }
131
+ },
132
+ originRelationInfo: {}
132
133
}
133
134
},
134
135
computed: {
141
142
const updateParams = {... this .relationInfo }
142
143
delete updateParams[' bk_asst_id' ]
143
144
return updateParams
145
+ },
146
+ changedValues () {
147
+ const values = {}
148
+ Object .keys (this .relationInfo ).forEach (key => {
149
+ if (this .relationInfo [key] !== this .originRelationInfo [key]) {
150
+ values[key] = this .relationInfo [key]
151
+ }
152
+ })
153
+ return values
144
154
}
155
+
145
156
},
146
157
created () {
147
158
if (this .isEdit ) {
148
159
for (let key in this .relationInfo ) {
149
160
this .relationInfo [key] = this .$tools .clone (this .relation [key])
150
161
}
151
162
}
163
+ this .originRelationInfo = this .$tools .clone (this .relationInfo )
152
164
},
153
165
methods: {
154
166
... mapActions (' objectAssociation' , [
Original file line number Diff line number Diff line change 45
45
class =" relation-slider"
46
46
:width =" 450"
47
47
:title =" slider.title"
48
- :isShow.sync =" slider.isShow" >
48
+ :isShow.sync =" slider.isShow"
49
+ :beforeClose =" handleSliderBeforeClose" >
49
50
<the-relation
51
+ ref =" relationForm"
50
52
slot =" content"
51
53
class =" slider-content"
52
54
:isEdit =" slider.isEdit"
53
55
:relation =" slider.relation"
54
56
@saved =" saveRelation"
55
- @cancel =" slider.isShow = false "
57
+ @cancel =" handleSliderBeforeClose "
56
58
></the-relation >
57
59
</cmdb-slider >
58
60
</div >
227
229
handleSortChange (sort ) {
228
230
this .table .sort = sort
229
231
this .searchRelation ()
232
+ },
233
+ handleSliderBeforeClose () {
234
+ const hasChanged = Object .keys (this .$refs .relationForm .changedValues ).length
235
+ if (hasChanged) {
236
+ return new Promise ((resolve , reject ) => {
237
+ this .$bkInfo ({
238
+ title: this .$t (' Common["退出会导致未保存信息丢失,是否确认?"]' ),
239
+ confirmFn : () => {
240
+ this .slider .isShow = false
241
+ resolve (true )
242
+ },
243
+ cancelFn : () => {
244
+ resolve (false )
245
+ }
246
+ })
247
+ })
248
+ }
249
+ this .slider .isShow = false
250
+ return true
230
251
}
231
252
}
232
253
}
Original file line number Diff line number Diff line change 46
46
:width =" 450"
47
47
:title =" slider.title"
48
48
:isShow.sync =" slider.isShow"
49
- :beforeClose =" handleSliderBeforeClose" >>
49
+ :beforeClose =" handleSliderBeforeClose" >
50
50
<the-verification-detail
51
51
ref =" verificationForm"
52
52
class =" slider-content"
You can’t perform that action at this time.
0 commit comments