删除增加二次确认

This commit is contained in:
guoyue 2022-11-03 17:58:28 +08:00
parent 14f82809f6
commit 3e1ff71686
6 changed files with 138 additions and 76 deletions

View File

@ -2,7 +2,7 @@ import Cookies from 'js-cookie'
import qs from 'qs'
import { deepClone } from '@/utils/form-generator/index'
export default {
data () {
data() {
/* eslint-disable */
return {
// 设置属性
@ -38,19 +38,19 @@ export default {
}
/* eslint-enable */
},
created () {
created() {
if (this.mixinViewModuleOptions.createdIsNeed) {
this.query()
}
},
activated () {
activated() {
if (this.mixinViewModuleOptions.activatedIsNeed) {
this.query()
}
},
methods: {
// 获取数据列表
query () {
query() {
this.dataListLoading = true
this.$http.get(
this.mixinViewModuleOptions.getDataListURL + '?' + qs.stringify({
@ -126,11 +126,11 @@ export default {
})
},
// 多选
dataListSelectionChangeHandle (val) {
dataListSelectionChangeHandle(val) {
this.dataListSelections = val
},
// 排序
dataListSortChangeHandle (data) {
dataListSortChangeHandle(data) {
if (!data.order || !data.prop) {
this.order = ''
this.orderField = ''
@ -141,13 +141,13 @@ export default {
this.query()
},
// 分页, 每页条数
pageSizeChangeHandle (val) {
pageSizeChangeHandle(val) {
this.page = 1
this.limit = val
this.query()
},
// 分页, 当前页
pageCurrentChangeHandle (val) {
pageCurrentChangeHandle(val) {
this.page = val
this.query()
},
@ -156,7 +156,7 @@ export default {
this.query()
},
// 新增
addOrUpdateHandle (id) {
addOrUpdateHandle(id) {
this.addOrUpdateVisible = true
this.disabled = false
this.$nextTick(() => {
@ -167,7 +167,7 @@ export default {
},
// 组件服务新增
addOrUpdateHandleAI (id) {
addOrUpdateHandleAI(id) {
// const infoList = []
let showList = []
this.$http.get('category/getCategoryTree').then(({ data: res }) => {
@ -225,7 +225,7 @@ export default {
}, 100)
},
// 应用资源新增
addOrUpdateHandleServe (id) {
addOrUpdateHandleServe(id) {
// const infoList = []
let showList = []
this.$http.get('category/getCategoryTree').then(({ data: res }) => {
@ -283,7 +283,7 @@ export default {
}, 100)
},
// 修改
UpdateHandle (val) {
UpdateHandle(val) {
this.addOrUpdateVisible = true
this.disabled = false
const cloneVal = deepClone(val)
@ -308,7 +308,7 @@ export default {
})
},
// 关闭当前窗口
closeCurrentTab (data) {
closeCurrentTab(data) {
var tabName = this.$store.state.contentTabsActiveName
this.$store.state.contentTabs = this.$store.state.contentTabs.filter(item => item.name !== tabName)
if (this.$store.state.contentTabs.length <= 0) {
@ -320,7 +320,7 @@ export default {
}
},
// 删除
deleteHandle (id) {
deleteHandle(id) {
if (this.mixinViewModuleOptions.deleteIsBatch && !id && this.dataListSelections.length <= 0) {
return this.$message({
message: this.$t('prompt.deleteBatch'),
@ -354,8 +354,13 @@ export default {
}).catch(() => { })
},
deleteHandle2 (id) {
deleteHandle2(id) {
console.log('删除========================》', id, this.dataListSelections)
this.$confirm('确认是否删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const ids = []
if (id) {
ids.push(id)
@ -368,11 +373,21 @@ export default {
}
this.$http.post('/resource/delete', { ids: ids }).then(res => {
console.log('删除成功', res)
this.$message({
type: 'success',
message: '删除成功!'
});
this.getDataList()
})
}).catch(() => {
// this.$message({
// type: 'info',
// message: '已取消删除'
// });
});
},
// 导出
exportHandle () {
exportHandle() {
var params = qs.stringify({
token: Cookies.get('ucsToken'),
...this.dataForm

View File

@ -70,7 +70,7 @@ export default {
mixinViewModuleOptions: {
getDataListURL: "/fuse/page",
exportURL: "/ability/bsabilityai/export",
deleteURL: "/fuse",
deleteURL: "/fuse/delete",
getDataListIsPage: true,
deleteIsBatch: false,
},
@ -93,6 +93,11 @@ export default {
},
methods: {
deleteRow(id) {
this.$confirm('确认是否删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http.delete('/fuse/delete', {
data: [id]
}).then(res => {
@ -111,6 +116,8 @@ export default {
}).catch(err => {
this.$message.error(err);
})
}).catch(() => {
});
},
//
searchData() {

View File

@ -12,8 +12,8 @@
v-if="dataInfo.length > 1">删除
</el-button>
</el-form-item>
<el-button class="add-btn" size="small" v-if="index == dataInfo.length - 1" @click="addItem"
type="primary">添加
<el-button class="add-btn" size="small" v-if="index == dataInfo.length - 1" @click="addItem" type="primary">
添加
</el-button>
</div>
</div>
@ -97,8 +97,19 @@ export default {
})
},
//
deleteItem(list, index) {
deleteItem(index) {
this.$confirm('确认是否删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '删除成功!'
});
this.dataInfo.splice(index, 1)
}).catch(() => {
});
}
}
}

View File

@ -16,8 +16,8 @@
v-if="!disabledType && dataInfo.length > 1">删除
</el-button>
</el-form-item>
<el-button class="add-btn" size="small"
v-if="!disabledType && index == dataInfo.length - 1" @click="addItem" type="primary">添加
<el-button class="add-btn" size="small" v-if="!disabledType && index == dataInfo.length - 1"
@click="addItem" type="primary">添加
</el-button>
</div>
@ -100,8 +100,19 @@ export default {
})
},
//
deleteItem(list, index) {
deleteItem(index) {
this.$confirm('确认是否删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '删除成功!'
});
this.dataInfo.splice(index, 1)
}).catch(() => {
});
}
}
}

View File

@ -84,6 +84,11 @@ export default {
},
methods: {
deleteRow(id) {
this.$confirm('确认是否删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$http.delete('/fuse/delete', {
data: [id]
}).then(res => {
@ -102,6 +107,8 @@ export default {
}).catch(err => {
this.$message.error(err);
})
}).catch(() => {
});
},
//
searchData() {

View File

@ -110,8 +110,19 @@ export default {
})
},
//
deleteItem(list, index) {
deleteItem(index) {
this.$confirm('确认是否删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$message({
type: 'success',
message: '删除成功!'
});
this.dataInfo.splice(index, 1)
}).catch(() => {
});
}
}
}