NEZ-2134 feat: Task asset批量删除 页面开发

This commit is contained in:
wenzhijie
2022-08-19 14:22:01 +08:00
parent fcce0fd743
commit 1b093f05f5
3 changed files with 234 additions and 306 deletions

View File

@@ -14,6 +14,14 @@ export default {
},
data () {
return {
dialogFooterShow: true,
idShow: true,
showOne: true,
showTwo: false,
showThree: false,
isDisabled: true,
ForceDeleteShow: false,
dialogVisible: false,
fromRoute: fromRoute,
// 侧滑
rightBox: {
@@ -42,7 +50,10 @@ export default {
delFlag: false,
fromBottom: false,
operationWidth: '165', // 操作列宽
searchCheckBox: {}
searchCheckBox: {},
dialogData: [],
multipleSelection: [],
idStr: []
}
},
methods: {
@@ -72,8 +83,30 @@ export default {
isBuildIn (row) {
return (row.buildIn && row.buildIn == 1) || (row.builtIn && row.builtIn == 1)
},
batchDeleteselectionChange (obj) {
this.batchDeleteObjs = obj
const ids = []
this.batchDeleteObjs.forEach(function (value, index, obj) {
ids.push(obj[index].id)
})
this.idStr = ids.toString()
console.log(this.idStr, 1)
},
selectionChange (objs) {
this.batchDeleteObjs = objs
if (this.batchDeleteObjs.length > 0) {
this.isDisabled = false
console.log('批量删除按钮可用')
} else {
this.isDisabled = true
console.log('批量删除按钮不可用')
}
// const ids = []
// this.batchDeleteObjs.forEach(function (value, index, obj) {
// ids.push(obj[index].id)
// })
// this.idStr = ids.toString()
// console.log(this.idStr, 1)
},
getTableData (params) {
if (params && Object.keys(params).length > 0) {
@@ -149,6 +182,76 @@ export default {
}
})
},
// 批量删除
BatchDelete () {
this.dialogVisible = true
this.$nextTick(() => {
// console.log(this.$refs.batchDeleteData, 2)
console.log(this.batchDeleteObjs, 3)
this.batchDeleteObjs.forEach((row) => {
this.$refs.batchDeleteData.toggleRowSelection(row, true)
})
})
},
// 批量删除-确定按钮
BatchDeleteYes (obj) {
if (this.ForceDeleteShow) {
this.showThree = true
this.showOne = false
this.showTwo = false
this.dialogFooterShow = false
// this.$delete(this.url + '?ids=' + this.idStr).then(response => {
// if (response.code === 200) {
// this.showThree = true
// this.showOne = false
// this.showTwo = false
// this.dialogFooterShow = false
// this.batchDeleteObjs = []
// this.idStr = []
// this.getTableData()
// } else {
// this.$message.error(response.msg)
// }
// })
} else {
this.showThree = false
this.showOne = false
this.showTwo = true
this.dialogFooterShow = true
}
},
BatchDeleteToggleSelection (val) {
this.multipleSelection = val
},
// 强制删除按钮
ForceDeleteFun () {
this.ForceDeleteShow = true
},
// Dialog 关闭的回调
handleClose () {
// this.dialogVisible = false
// this.showOne = true
// this.showTwo = false
// this.showThree = false
// this.dialogFooterShow = true
// this.ForceDeleteShow = false
if (this.showThree) {
this.$delete(this.url + '?ids=' + this.idStr).then(response => {
if (response.code === 200) {
this.showThree = false
this.showOne = true
this.showTwo = false
this.dialogFooterShow = true
this.ForceDeleteShow = false
this.batchDeleteObjs = []
this.idStr = []
this.getTableData()
} else {
this.$message.error(response.msg)
}
})
}
},
del (row) {
const self = this
this.$confirm(this.$t('tip.confirmDelete'), {
@@ -326,6 +429,20 @@ export default {
}
},
watch: {
batchDeleteObjs: {
deep: true,
handler (n) {
if (n.length === 0 && this.pageObj.pageNo > 1) {
this.pageNo(this.pageObj.pageNo - 1)
}
/* if (!this.delFlag) { // 不是删除时回到顶部
this.$refs.dataTable.bodyWrapper.scrollTop = 0
} else {
this.delFlag = false
} */
}
},
tableData: {
deep: true,
handler (n) {
@@ -898,21 +1015,6 @@ export default {
},
jsonKey: 'val'
},
state: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'state',
type: 'string',
defaultJson: {
disabled: false,
label: 'ipamState',
name: 'State',
readonly: true,
type: 'select',
val: ''
},
jsonKey: 'val'
},
name: {
target: this.searchLabel,
isSearchInput: true,
@@ -1002,298 +1104,12 @@ export default {
jsonKey: 'valnum'
}
}
} else if (path === 'recordRule') {
searchKeys = {
// key: path 键
// value: vue set 参数
pageNo: { target: this.pageObj, propertyName: 'pageNo', type: 'number' },
pageSize: { target: this.pageObj, propertyName: 'pageSize', type: 'number' },
orderBy: { target: this.$data, propertyName: 'orderBy', type: 'string' },
ids: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'ids',
type: 'string',
defaultJson: {
disabled: false,
label: 'ids',
name: 'ID',
type: 'input',
val: ''
},
jsonKey: 'val'
},
state: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'state',
type: 'Number',
defaultJson: {
disabled: false,
label: 'recordState',
name: 'State',
readonly: true,
type: 'select',
val: ''
},
jsonKey: 'val'
},
name: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'name',
type: 'string',
defaultJson: {
disabled: false,
id: 'name',
label: 'name',
name: 'Name',
type: 'input',
val: ''
},
jsonKey: 'val'
},
type: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'type',
type: 'Number',
defaultJson: {
disabled: false,
label: 'recordType',
name: 'Type',
readonly: true,
type: 'select',
val: ''
},
jsonKey: 'val'
},
expr: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'expr',
type: 'string',
defaultJson: {
disabled: false,
label: 'expr',
name: 'Expression',
type: 'input',
val: ''
},
jsonKey: 'val'
},
starrd: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'starrd',
type: 'Number',
defaultJson: {
disabled: false,
label: 'starrd',
name: 'Starrd',
type: 'select',
val: ''
},
jsonKey: 'val'
},
buildIn: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'buildIn',
type: 'Number',
defaultJson: {
disabled: false,
label: 'buildIn',
name: 'buildIn',
type: 'select',
val: ''
},
jsonKey: 'val'
}
}
} else if (path === 'issue') {
searchKeys = {
// key: path 键
// value: vue set 参数
pageNo: { target: this.pageObj, propertyName: 'pageNo', type: 'number' },
pageSize: { target: this.pageObj, propertyName: 'pageSize', type: 'number' },
orderBy: { target: this.$data, propertyName: 'orderBy', type: 'string' },
ids: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'ids',
type: 'string',
defaultJson: {
disabled: false,
label: 'ids',
name: 'ID',
type: 'input',
val: ''
},
jsonKey: 'val'
},
name: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'name',
type: 'string',
defaultJson: {
disabled: false,
id: 'name',
label: 'name',
name: 'Name',
type: 'input',
val: ''
},
jsonKey: 'val'
},
type: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'type',
type: 'string',
defaultJson: {
disabled: false,
label: 'issueType',
name: 'Type',
readonly: true,
type: 'issueType',
val: ''
},
jsonKey: 'val'
},
state: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'state',
type: 'Number',
defaultJson: {
disabled: false,
label: 'issueState',
name: 'State',
readonly: true,
type: 'select',
val: ''
},
jsonKey: 'val'
},
priority: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'priority',
type: 'Number',
defaultJson: {
disabled: false,
label: 'priority',
name: 'Priority',
type: 'select',
val: ''
},
jsonKey: 'val'
},
assetsId: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'assetsId',
type: 'Number',
defaultJson: {
disabled: false,
label: 'assetsId',
name: 'Assets id',
type: 'input',
val: ''
},
jsonKey: 'val'
},
assetName: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'assetName',
type: 'string',
defaultJson: {
disabled: false,
label: 'assetName',
name: 'Assets name',
type: 'input',
val: ''
},
jsonKey: 'val'
},
cid: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'cid',
type: 'string',
defaultJson: {
disabled: false,
label: 'cid',
name: 'Create user',
type: 'issue',
val: ''
},
jsonKey: 'val'
},
uid: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'uid',
type: 'string',
defaultJson: {
disabled: false,
label: 'uid',
name: 'Update user',
type: 'issue',
val: ''
},
jsonKey: 'val'
},
rid: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'rid',
type: 'string',
defaultJson: {
disabled: false,
label: 'rid',
name: 'Reporter',
type: 'issue',
val: ''
},
jsonKey: 'val'
},
aid: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'aid',
type: 'string',
defaultJson: {
disabled: false,
label: 'aid',
name: 'Assignee',
type: 'issue',
val: ''
},
jsonKey: 'val'
},
starrd: {
target: this.searchLabel,
isSearchInput: true,
propertyName: 'starrd',
type: 'Number',
defaultJson: {
disabled: false,
label: 'starrd',
name: 'Starrd',
type: 'select',
val: ''
},
jsonKey: 'val'
}
}
}
this.initQueryFromPath(searchKeys)
},
mounted () {
this.$nextTick((row) => {
})
const pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId)
if (pageSize && pageSize !== 'undefined') {
this.pageObj.pageSize = pageSize