2021-06-11 10:00:22 +08:00
|
|
|
|
import { tableSort } from '@/utils/tools'
|
2023-06-27 10:54:36 +08:00
|
|
|
|
import { defaultPageSize, fromRoute, position, storageKey, dbTableColumnCustomizeConfigPre } from '@/utils/constants'
|
2023-08-24 17:15:41 +08:00
|
|
|
|
import _ from 'lodash'
|
2021-06-11 10:00:22 +08:00
|
|
|
|
import { ref } from 'vue'
|
2021-06-21 11:29:26 +08:00
|
|
|
|
import pagination from '@/components/common/Pagination'
|
2022-04-13 16:40:55 +08:00
|
|
|
|
import axios from 'axios'
|
2022-04-14 15:52:07 +08:00
|
|
|
|
import { api } from '@/utils/api'
|
2023-06-16 17:51:08 +08:00
|
|
|
|
import Loading from '@/components/common/Loading'
|
2023-06-27 10:54:36 +08:00
|
|
|
|
import indexedDBUtils from '@/indexedDB'
|
2022-04-14 15:52:07 +08:00
|
|
|
|
|
2021-06-11 10:00:22 +08:00
|
|
|
|
export default {
|
2021-06-17 16:56:50 +08:00
|
|
|
|
components: {
|
2023-06-16 17:51:08 +08:00
|
|
|
|
pagination,
|
|
|
|
|
|
Loading
|
2021-06-11 16:59:16 +08:00
|
|
|
|
},
|
2021-06-11 10:00:22 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
fromRoute: fromRoute,
|
|
|
|
|
|
// 侧滑
|
|
|
|
|
|
rightBox: {
|
|
|
|
|
|
show: false
|
|
|
|
|
|
},
|
|
|
|
|
|
pageObj: { // 分页对象
|
|
|
|
|
|
pageNo: 1,
|
2021-08-23 09:13:54 +08:00
|
|
|
|
pageSize: defaultPageSize,
|
2023-05-17 10:51:52 +08:00
|
|
|
|
total: null// total为0时,elment分页组件pagination,修改当前页无效。修改为null即可解决此问题
|
2021-06-11 10:00:22 +08:00
|
|
|
|
},
|
|
|
|
|
|
/* 工具参数 */
|
|
|
|
|
|
tools: {
|
2023-06-16 17:51:08 +08:00
|
|
|
|
// loading: true, // 是否显示table加载动画
|
2021-06-11 10:00:22 +08:00
|
|
|
|
customTableTitle: [] // 自定义列工具的数据
|
|
|
|
|
|
},
|
|
|
|
|
|
mainTableHeight: position.tableHeight.normal, // 主列表table高度
|
|
|
|
|
|
batchDeleteObjs: [],
|
|
|
|
|
|
object: {},
|
|
|
|
|
|
searchLabel: ref({}),
|
|
|
|
|
|
|
2022-12-08 16:36:27 +08:00
|
|
|
|
isFirstQuery: true,
|
|
|
|
|
|
|
2021-06-11 10:00:22 +08:00
|
|
|
|
tableData: [],
|
|
|
|
|
|
scrollbarWrap: null,
|
|
|
|
|
|
delFlag: false,
|
2023-06-12 11:13:26 +08:00
|
|
|
|
disableEdit: true, // 编辑按钮是否不可用,当选择多条记录的时候,编辑按钮不可用
|
2023-04-26 23:46:23 +08:00
|
|
|
|
disableDelete: true,
|
2023-06-16 17:51:08 +08:00
|
|
|
|
operationWidth: '165', // 操作列宽
|
|
|
|
|
|
loading: true,
|
|
|
|
|
|
isNoData: false
|
2021-06-11 10:00:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
sortableShow: tableSort.sortableShow,
|
|
|
|
|
|
propTitle: tableSort.propTitle,
|
|
|
|
|
|
asce: tableSort.asce,
|
|
|
|
|
|
desc: tableSort.desc,
|
|
|
|
|
|
strToDate: tableSort.strToDate,
|
2022-06-06 17:37:01 +08:00
|
|
|
|
tableOperation ([command, row]) {
|
2021-06-11 10:00:22 +08:00
|
|
|
|
switch (command) {
|
|
|
|
|
|
case 'edit': {
|
|
|
|
|
|
this.edit(row)
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
case 'delete': {
|
|
|
|
|
|
this.del(row)
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
case 'copy': {
|
|
|
|
|
|
this.copy(row)
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
2022-04-12 18:00:01 +08:00
|
|
|
|
case 'download': {
|
2022-06-06 17:37:01 +08:00
|
|
|
|
this.download(row)
|
2022-04-12 18:00:01 +08:00
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
case 'preview': {
|
|
|
|
|
|
this.preview(row)
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
2021-06-11 10:00:22 +08:00
|
|
|
|
default:
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2023-06-16 17:51:08 +08:00
|
|
|
|
toggleLoading (loading) {
|
|
|
|
|
|
this.loading = loading
|
|
|
|
|
|
},
|
2021-06-11 10:00:22 +08:00
|
|
|
|
selectionChange (objs) {
|
2023-04-26 23:46:23 +08:00
|
|
|
|
this.batchDeleteObjs = []
|
|
|
|
|
|
objs.forEach(obj => {
|
|
|
|
|
|
const delObj = this.batchDeleteObjs.find(item => item.id === obj.id)
|
|
|
|
|
|
if (delObj === undefined) {
|
|
|
|
|
|
this.batchDeleteObjs.push(obj)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-08-24 17:15:41 +08:00
|
|
|
|
this.disableEdit = this.batchDeleteObjs.length !== 1
|
|
|
|
|
|
this.disableDelete = this.batchDeleteObjs.length < 1
|
2021-06-11 10:00:22 +08:00
|
|
|
|
},
|
2023-04-26 23:46:23 +08:00
|
|
|
|
getTableData (params, isAll, isClearType) {
|
|
|
|
|
|
if (isAll) {
|
|
|
|
|
|
this.searchLabel = null
|
|
|
|
|
|
} else if (isClearType) {
|
2023-05-29 13:00:28 +08:00
|
|
|
|
this.searchLabel.type = ''// 换新接口需要修改的属性名称
|
2023-04-26 23:46:23 +08:00
|
|
|
|
}
|
2023-08-03 15:54:30 +08:00
|
|
|
|
this.searchLabel = { ...this.searchLabel, ...this.pageObj }
|
2021-06-11 10:00:22 +08:00
|
|
|
|
if (params) {
|
|
|
|
|
|
this.searchLabel = { ...this.searchLabel, ...params }
|
|
|
|
|
|
}
|
2023-06-16 17:51:08 +08:00
|
|
|
|
this.isNoData = false
|
|
|
|
|
|
this.toggleLoading(true)
|
2021-09-02 17:12:27 +08:00
|
|
|
|
delete this.searchLabel.total
|
2021-10-15 16:42:15 +08:00
|
|
|
|
let listUrl = this.url
|
|
|
|
|
|
if (this.listUrl) {
|
|
|
|
|
|
listUrl = this.listUrl
|
|
|
|
|
|
}
|
2023-10-16 17:53:46 +08:00
|
|
|
|
axios.get(listUrl, { params: this.searchLabel }).then(response => {
|
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
|
this.tableData = _.get(response, 'data.data.list', [])
|
|
|
|
|
|
this.pageObj.total = _.get(response, 'data.data.total', 0)
|
|
|
|
|
|
this.isNoData = !this.tableData || this.tableData.length === 0
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.error(response)
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
if (response.data.message) {
|
|
|
|
|
|
this.$message.error(response.data.message)
|
2023-03-14 19:39:40 +08:00
|
|
|
|
} else {
|
2023-10-16 17:53:46 +08:00
|
|
|
|
this.$message.error(this.$t('tip.somethingWentWrong'))
|
2023-03-14 19:39:40 +08:00
|
|
|
|
}
|
2021-06-11 10:00:22 +08:00
|
|
|
|
}
|
2023-10-16 17:53:46 +08:00
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
this.toggleLoading(false)
|
2023-08-03 18:47:18 +08:00
|
|
|
|
this.loading = false
|
2023-10-16 17:53:46 +08:00
|
|
|
|
})
|
2021-06-11 10:00:22 +08:00
|
|
|
|
},
|
|
|
|
|
|
del (row) {
|
|
|
|
|
|
this.$confirm(this.$t('tip.confirmDelete'), {
|
|
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
cancelButtonText: this.$t('tip.no'),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2023-08-24 17:15:41 +08:00
|
|
|
|
axios.delete(this.url + '?ids=' + row.id).then(response => {
|
|
|
|
|
|
if (response.status === 200) {
|
2021-06-11 10:00:22 +08:00
|
|
|
|
this.delFlag = true
|
|
|
|
|
|
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
} else {
|
2023-08-24 17:15:41 +08:00
|
|
|
|
this.$message.error(response.data.message)
|
2021-06-11 10:00:22 +08:00
|
|
|
|
}
|
2023-09-18 16:31:11 +08:00
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
// 表格内无删除,只是顶部工具栏有
|
|
|
|
|
|
this.$message.error(e.response.data.message)
|
2021-06-11 10:00:22 +08:00
|
|
|
|
})
|
2023-03-27 11:11:00 +08:00
|
|
|
|
}).catch(e => {})
|
2021-06-11 10:00:22 +08:00
|
|
|
|
},
|
2023-03-10 20:50:54 +08:00
|
|
|
|
delBatch () {
|
2023-03-24 18:44:02 +08:00
|
|
|
|
const ids = []
|
|
|
|
|
|
if (this.batchDeleteObjs && this.batchDeleteObjs.length > 0) {
|
|
|
|
|
|
this.batchDeleteObjs.forEach(item => {
|
2023-03-10 20:50:54 +08:00
|
|
|
|
ids.push(item.id)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2023-03-24 18:44:02 +08:00
|
|
|
|
if (ids.length === 0) {
|
|
|
|
|
|
this.$alert(this.$t('tip.pleaseSelect'), {
|
2023-03-10 20:50:54 +08:00
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
2023-03-24 18:44:02 +08:00
|
|
|
|
type: 'warning'
|
2023-03-27 11:11:00 +08:00
|
|
|
|
}).catch(() => {})
|
2023-03-24 18:44:02 +08:00
|
|
|
|
} else {
|
2023-03-10 20:50:54 +08:00
|
|
|
|
this.$confirm(this.$t('tip.confirmDelete'), {
|
|
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
cancelButtonText: this.$t('tip.no'),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2023-06-16 17:51:08 +08:00
|
|
|
|
this.toggleLoading(true)
|
2023-03-10 20:50:54 +08:00
|
|
|
|
axios.delete(this.url + '?ids=' + ids).then(response => {
|
2023-08-24 17:15:41 +08:00
|
|
|
|
if (response.status === 200) {
|
2023-03-10 20:50:54 +08:00
|
|
|
|
this.delFlag = true
|
|
|
|
|
|
this.$message({ duration: 2000, type: 'success', message: this.$t('tip.deleteSuccess') })
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.data.message)
|
|
|
|
|
|
}
|
2023-09-18 16:31:11 +08:00
|
|
|
|
}).catch(e => {
|
|
|
|
|
|
this.$message.error(e.response.data.message)
|
2023-03-10 20:50:54 +08:00
|
|
|
|
}).finally(() => {
|
2023-06-16 17:51:08 +08:00
|
|
|
|
this.toggleLoading(false)
|
2023-03-10 20:50:54 +08:00
|
|
|
|
})
|
2023-08-24 17:15:41 +08:00
|
|
|
|
}).finally(() => {
|
|
|
|
|
|
if (this.isSelectedStatus !== undefined) {
|
|
|
|
|
|
this.isSelectedStatus = false
|
|
|
|
|
|
this.disableDelete = true
|
|
|
|
|
|
this.batchDeleteObjs = []
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-03-10 20:50:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-06-11 10:00:22 +08:00
|
|
|
|
newObject () {
|
|
|
|
|
|
return JSON.parse(JSON.stringify(this.blankObject))
|
|
|
|
|
|
},
|
|
|
|
|
|
pageNo (val) {
|
|
|
|
|
|
this.pageObj.pageNo = val
|
2022-12-08 16:36:27 +08:00
|
|
|
|
if (this.isFirstQuery) {
|
|
|
|
|
|
this.isFirstQuery = false
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}, 300)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}
|
2021-06-11 10:00:22 +08:00
|
|
|
|
},
|
|
|
|
|
|
pageSize (val) {
|
|
|
|
|
|
this.pageObj.pageSize = val
|
2023-07-03 15:54:32 +08:00
|
|
|
|
this.pageObj.pageNo = 1
|
2022-04-14 15:52:07 +08:00
|
|
|
|
localStorage.setItem(storageKey.pageSize + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId, val)
|
2021-06-11 10:00:22 +08:00
|
|
|
|
this.getTableData()
|
|
|
|
|
|
},
|
|
|
|
|
|
add () {
|
|
|
|
|
|
this.object = this.newObject()
|
|
|
|
|
|
this.rightBox.show = true
|
|
|
|
|
|
},
|
|
|
|
|
|
closeRightBox (refresh) {
|
|
|
|
|
|
this.rightBox.show = false
|
|
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.delFlag = true
|
|
|
|
|
|
this.getTableData()
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
edit (u) {
|
2023-08-24 17:15:41 +08:00
|
|
|
|
axios.get(`${this.url}/${u.id}`).then(response => {
|
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
|
this.object = response.data.data
|
2021-06-11 10:00:22 +08:00
|
|
|
|
this.rightBox.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-03-24 18:44:02 +08:00
|
|
|
|
editSelectRecord () {
|
|
|
|
|
|
if (this.batchDeleteObjs.length === 0) {
|
|
|
|
|
|
this.$alert(this.$t('tip.pleaseSelectForEdit'), {
|
2023-03-10 20:50:54 +08:00
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
2023-03-24 18:44:02 +08:00
|
|
|
|
type: 'warning'
|
2023-03-27 11:11:00 +08:00
|
|
|
|
}).catch(() => {})
|
2023-03-24 18:44:02 +08:00
|
|
|
|
} else {
|
2023-08-24 17:15:41 +08:00
|
|
|
|
axios.get(`${this.url}/${this.batchDeleteObjs[0].id}`).then(response => {
|
|
|
|
|
|
if (response.status === 200) {
|
|
|
|
|
|
this.object = response.data.data
|
2023-03-10 20:50:54 +08:00
|
|
|
|
this.rightBox.show = true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-06-11 10:00:22 +08:00
|
|
|
|
copy (u) {
|
|
|
|
|
|
this.object = { ...u, name: 'Copy from ' + u.name, id: '' }
|
|
|
|
|
|
this.rightBox.show = true
|
|
|
|
|
|
},
|
2022-06-06 17:37:01 +08:00
|
|
|
|
download (u) {
|
|
|
|
|
|
if (this.$refs.dataTable.loadingTableId === u.id) { // 列表单个下载
|
2022-04-15 14:59:53 +08:00
|
|
|
|
return
|
|
|
|
|
|
}
|
2023-07-05 11:28:06 +08:00
|
|
|
|
if (localStorage.getItem(storageKey.s3Enable) == 1) {
|
|
|
|
|
|
if (u.state !== 1 || u.upload !== 1) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (u.state !== 1) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2023-01-05 13:59:15 +08:00
|
|
|
|
}
|
2022-04-13 18:31:13 +08:00
|
|
|
|
let fileName = ''
|
|
|
|
|
|
let url = ''
|
|
|
|
|
|
let params = {}
|
2022-06-06 17:37:01 +08:00
|
|
|
|
fileName = u.name + '.pdf' // 文件名称
|
|
|
|
|
|
url = api.reportDownloadPdf // 单个 pdf 下载
|
|
|
|
|
|
params = {
|
|
|
|
|
|
id: u.id
|
2022-04-13 16:40:55 +08:00
|
|
|
|
}
|
2022-06-06 17:37:01 +08:00
|
|
|
|
this.$refs.dataTable.loadingTableId = u.id // 列表单个下载
|
|
|
|
|
|
if (!u) { // 列表单个下载
|
2022-04-24 18:16:41 +08:00
|
|
|
|
this.$refs.dataTable.loadingTableId = u.id
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
// 判断是否成功登陆成功
|
2022-06-06 17:37:01 +08:00
|
|
|
|
if (!localStorage.getItem(storageKey.token)) {
|
2022-04-24 18:16:41 +08:00
|
|
|
|
return window.location.replace('/')
|
2022-04-15 14:59:53 +08:00
|
|
|
|
}
|
2023-08-24 17:15:41 +08:00
|
|
|
|
axios.get(api.reportTemp).then(res => {
|
|
|
|
|
|
if (res.status === 200) {
|
2022-05-10 18:20:44 +08:00
|
|
|
|
axios.get(url, { responseType: 'blob', params: params }).then(res => {
|
|
|
|
|
|
if (window.navigator.msSaveOrOpenBlob) {
|
|
|
|
|
|
// 兼容ie11
|
|
|
|
|
|
const blobObject = new Blob([res.data])
|
|
|
|
|
|
window.navigator.msSaveOrOpenBlob(blobObject, fileName)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
const url = URL.createObjectURL(new Blob([res.data]))
|
|
|
|
|
|
const a = document.createElement('a')
|
|
|
|
|
|
document.body.appendChild(a) // 此处增加了将创建的添加到body当中
|
|
|
|
|
|
a.href = url
|
|
|
|
|
|
a.download = fileName
|
|
|
|
|
|
a.target = '_blank'
|
|
|
|
|
|
a.click()
|
|
|
|
|
|
a.remove() // 将a标签移除
|
|
|
|
|
|
}
|
2022-06-06 17:37:01 +08:00
|
|
|
|
this.$refs.dataTable.loadingTableId = !u.id
|
2022-05-10 18:20:44 +08:00
|
|
|
|
}, error => {
|
|
|
|
|
|
const $self = this
|
|
|
|
|
|
const reader = new FileReader()
|
|
|
|
|
|
reader.onload = function (event) {
|
|
|
|
|
|
const responseText = reader.result
|
|
|
|
|
|
const exception = JSON.parse(responseText)
|
|
|
|
|
|
if (exception.message) {
|
|
|
|
|
|
$self.$message.error(exception.message)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
console.error(error)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
reader.readAsText(error.response.data)
|
2022-06-06 17:37:01 +08:00
|
|
|
|
this.$refs.dataTable.loadingTableId = !u.id
|
2022-05-10 18:20:44 +08:00
|
|
|
|
}).catch(() => {
|
2022-06-06 17:37:01 +08:00
|
|
|
|
this.$refs.dataTable.loadingTableId = !u.id
|
2022-05-10 18:20:44 +08:00
|
|
|
|
})
|
2022-04-15 14:59:53 +08:00
|
|
|
|
}
|
2022-04-12 18:00:01 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
preview (u) {
|
2022-04-15 14:59:53 +08:00
|
|
|
|
if (this.$refs.dataTable.loadingPreviewId === u.id) { // 列表单个下载
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2023-07-05 11:28:06 +08:00
|
|
|
|
if (localStorage.getItem(storageKey.s3Enable) == 1) {
|
|
|
|
|
|
if (u.state !== 1 || u.upload !== 1) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (u.state !== 1) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2023-01-05 13:59:15 +08:00
|
|
|
|
}
|
2022-04-13 16:40:55 +08:00
|
|
|
|
const params = {
|
|
|
|
|
|
id: u.id
|
|
|
|
|
|
}
|
2022-04-15 14:59:53 +08:00
|
|
|
|
this.$refs.dataTable.loadingPreviewId = u.id
|
2022-04-14 15:52:07 +08:00
|
|
|
|
axios.get(api.reportView, { params: params }).then(res => {
|
2022-04-24 18:16:41 +08:00
|
|
|
|
if (!localStorage.getItem(storageKey.token)) {
|
|
|
|
|
|
this.$refs.dataTable.loadingPreviewId = !u.id
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2022-04-13 16:40:55 +08:00
|
|
|
|
const prevWindow = window.open('', '')
|
|
|
|
|
|
prevWindow.document.write(res.data)
|
|
|
|
|
|
prevWindow.focus()
|
2022-04-15 14:59:53 +08:00
|
|
|
|
this.$refs.dataTable.loadingPreviewId = !u.id
|
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
|
this.$refs.dataTable.loadingPreviewId = !u.id
|
2022-04-12 18:00:01 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-06-11 10:00:22 +08:00
|
|
|
|
esc () {
|
|
|
|
|
|
this.rightBox.show = false
|
|
|
|
|
|
},
|
|
|
|
|
|
dragend () {
|
|
|
|
|
|
this.$nextTick(() => {
|
2023-05-29 13:00:28 +08:00
|
|
|
|
if (this.$refs.dataTable && this.$refs.dataTable.$refs.dataTable) {
|
2023-04-26 23:46:23 +08:00
|
|
|
|
this.$refs.dataTable.$refs.dataTable.doLayout()
|
|
|
|
|
|
}
|
2021-06-11 10:00:22 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
tableDataSort (orderBy) {
|
2022-01-26 19:14:40 +08:00
|
|
|
|
this.searchLabel.orderBy = orderBy
|
2021-06-11 10:00:22 +08:00
|
|
|
|
this.getTableData()
|
2021-07-27 09:19:44 +08:00
|
|
|
|
},
|
2023-10-16 17:53:46 +08:00
|
|
|
|
search (params, flag, list) {
|
2021-07-27 09:19:44 +08:00
|
|
|
|
this.pageObj.pageNo = 1
|
2023-10-16 17:53:46 +08:00
|
|
|
|
if (flag !== 'detection') {
|
|
|
|
|
|
delete this.searchLabel.category
|
|
|
|
|
|
delete this.searchLabel.source
|
|
|
|
|
|
}
|
|
|
|
|
|
if (list && list.length > 0) {
|
|
|
|
|
|
if (list.indexOf('status') > -1) {
|
|
|
|
|
|
delete this.searchLabel.status
|
|
|
|
|
|
}
|
|
|
|
|
|
if (list.indexOf('category') > -1) {
|
|
|
|
|
|
delete this.searchLabel.category
|
|
|
|
|
|
}
|
|
|
|
|
|
if (list.indexOf('eventType') > -1) {
|
|
|
|
|
|
delete this.searchLabel.eventType
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-04-12 18:00:01 +08:00
|
|
|
|
this.getTableData(params)
|
2022-04-13 16:40:55 +08:00
|
|
|
|
},
|
|
|
|
|
|
getTimeString () {
|
|
|
|
|
|
const split = '-'
|
|
|
|
|
|
const date = new Date()
|
|
|
|
|
|
const year = date.getFullYear()
|
|
|
|
|
|
const month = this.formatNum(date.getMonth() + 1)
|
|
|
|
|
|
const day = this.formatNum(date.getDate())
|
|
|
|
|
|
const hours = this.formatNum(date.getHours())
|
|
|
|
|
|
const minutes = this.formatNum(date.getMinutes())
|
|
|
|
|
|
const seconds = this.formatNum(date.getSeconds())
|
|
|
|
|
|
return year + split + month + split + day + ' ' + hours + split + minutes + split + seconds
|
|
|
|
|
|
},
|
|
|
|
|
|
formatNum (num) {
|
|
|
|
|
|
return num > 9 ? num : '0' + num
|
2021-06-11 10:00:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
tableData: {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler (n) {
|
2023-08-03 18:47:18 +08:00
|
|
|
|
if (n && n.length === 0 && this.pageObj.pageNo > 1) {
|
2021-06-11 10:00:22 +08:00
|
|
|
|
this.pageNo(this.pageObj.pageNo - 1)
|
|
|
|
|
|
}
|
|
|
|
|
|
// TODO 不是删除时回到顶部
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
'tools.customTableTitle': {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
this.dragend()
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2023-06-27 10:54:36 +08:00
|
|
|
|
async mounted () {
|
2022-04-14 15:52:07 +08:00
|
|
|
|
const pageSize = localStorage.getItem(storageKey.pageSize + '-' + localStorage.getItem(storageKey.username) + '-' + this.tableId)
|
2021-06-11 10:00:22 +08:00
|
|
|
|
if (pageSize && pageSize !== 'undefined') {
|
|
|
|
|
|
this.pageObj.pageSize = pageSize
|
|
|
|
|
|
}
|
2023-06-27 10:54:36 +08:00
|
|
|
|
const userId = localStorage.getItem(storageKey.userId)
|
2023-07-03 15:54:32 +08:00
|
|
|
|
const tableName = dbTableColumnCustomizeConfigPre + '-' + this.tableId
|
2023-06-28 11:23:29 +08:00
|
|
|
|
let localStorageTableTitle = []
|
2023-07-03 15:54:32 +08:00
|
|
|
|
if (indexedDBUtils.selectTable(tableName)) {
|
2023-06-28 11:23:29 +08:00
|
|
|
|
localStorageTableTitle = await indexedDBUtils.selectTable(tableName).get({ id: userId })
|
|
|
|
|
|
}
|
2023-06-27 10:54:36 +08:00
|
|
|
|
|
|
|
|
|
|
localStorageTableTitle = localStorageTableTitle && localStorageTableTitle.config
|
|
|
|
|
|
? localStorageTableTitle.config
|
|
|
|
|
|
: (this.$refs.dataTable && this.$refs.dataTable.tableTitle ? this.$refs.dataTable.tableTitle : [])
|
2023-05-25 18:31:26 +08:00
|
|
|
|
// this.tools.customTableTitle = this.$refs.dataTable.tableTitle.map((item, index) => { // 修复切换中英文的问题
|
|
|
|
|
|
// if (localStorageTableTitle[index]) {
|
|
|
|
|
|
// item.show = localStorageTableTitle[index].show
|
|
|
|
|
|
// }
|
|
|
|
|
|
// return item
|
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
// 不够优美,后续修改
|
|
|
|
|
|
// 为了避免缓存里的label在切换中英文时不一致,因为在拖拽后,键值不一致了,故根据prop匹配来修改label
|
|
|
|
|
|
for (let i = 0; i < localStorageTableTitle.length; i++) {
|
|
|
|
|
|
for (let j = 0; j < this.tools.customTableTitle.length; j++) {
|
|
|
|
|
|
if (localStorageTableTitle[i].prop === this.tools.customTableTitle.prop) {
|
|
|
|
|
|
localStorageTableTitle[i].label = this.tools.customTableTitle.label
|
|
|
|
|
|
break
|
|
|
|
|
|
}
|
2021-10-24 20:23:24 +08:00
|
|
|
|
}
|
2023-05-25 18:31:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.tools.customTableTitle = localStorageTableTitle
|
2023-08-03 15:54:30 +08:00
|
|
|
|
if (localStorageTableTitle && this.$refs.dataTable && this.$refs.dataTable.tableTitle && (localStorageTableTitle.length > this.$refs.dataTable.tableTitle.length)) {
|
2021-06-11 10:00:22 +08:00
|
|
|
|
const arr = localStorageTableTitle.splice(this.$refs.dataTable.tableTitle.length, localStorageTableTitle.length)
|
|
|
|
|
|
this.tools.customTableTitle = this.tools.customTableTitle.concat(arr)
|
|
|
|
|
|
}
|
2022-12-08 16:18:54 +08:00
|
|
|
|
// this.getTableData()
|
2023-06-16 17:51:08 +08:00
|
|
|
|
},
|
|
|
|
|
|
unmounted () {
|
|
|
|
|
|
this.isNoData = false
|
2021-06-11 10:00:22 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|