Skip to content

Commit 60eb9da

Browse files
authored
Merge pull request #3381 from Daryl0819/3.2.x_dev
UI: 添加sideslider关闭提示
2 parents ed8cc3a + 34ec53a commit 60eb9da

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

src/ui/src/views/model-association/_detail.vue

+13-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128
src_des: '',
129129
dest_des: '',
130130
direction: 'src_to_dest' // none, src_to_dest, bidirectional
131-
}
131+
},
132+
originRelationInfo: {}
132133
}
133134
},
134135
computed: {
@@ -141,14 +142,25 @@
141142
const updateParams = {...this.relationInfo}
142143
delete updateParams['bk_asst_id']
143144
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
144154
}
155+
145156
},
146157
created () {
147158
if (this.isEdit) {
148159
for (let key in this.relationInfo) {
149160
this.relationInfo[key] = this.$tools.clone(this.relation[key])
150161
}
151162
}
163+
this.originRelationInfo = this.$tools.clone(this.relationInfo)
152164
},
153165
methods: {
154166
...mapActions('objectAssociation', [

src/ui/src/views/model-association/index.vue

+23-2
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,16 @@
4545
class="relation-slider"
4646
:width="450"
4747
:title="slider.title"
48-
:isShow.sync="slider.isShow">
48+
:isShow.sync="slider.isShow"
49+
:beforeClose="handleSliderBeforeClose">
4950
<the-relation
51+
ref="relationForm"
5052
slot="content"
5153
class="slider-content"
5254
:isEdit="slider.isEdit"
5355
:relation="slider.relation"
5456
@saved="saveRelation"
55-
@cancel="slider.isShow = false"
57+
@cancel="handleSliderBeforeClose"
5658
></the-relation>
5759
</cmdb-slider>
5860
</div>
@@ -227,6 +229,25 @@
227229
handleSortChange (sort) {
228230
this.table.sort = sort
229231
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
230251
}
231252
}
232253
}

src/ui/src/views/model-manage/children/verification.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
:width="450"
4747
:title="slider.title"
4848
:isShow.sync="slider.isShow"
49-
:beforeClose="handleSliderBeforeClose">>
49+
:beforeClose="handleSliderBeforeClose">
5050
<the-verification-detail
5151
ref="verificationForm"
5252
class="slider-content"

0 commit comments

Comments
 (0)