任务日志页面更换组合式api写法

This commit is contained in:
不做码农 2022-04-18 13:34:12 +08:00
parent 2e97971c81
commit 6dbeaa9223

View File

@ -26,12 +26,10 @@
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="danger" plain icon="delete" :disabled="multiple" @click="handleDelete"
v-hasPermi="['PRIV_JOBLOG_DELETE']">删除</el-button>
<el-button type="danger" plain icon="delete" :disabled="multiple" @click="handleDelete" v-hasPermi="['PRIV_JOBLOG_DELETE']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="delete" @click="handleClean" :disabled="total <= 0"
v-hasPermi="['PRIV_JOBLOG_REMOVE']">清空</el-button>
<el-button type="danger" plain icon="delete" @click="handleClean" :disabled="total <= 0" v-hasPermi="['PRIV_JOBLOG_REMOVE']">清空</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="download" @click="handleExport" v-hasPermi="['PRIV_JOBLOG_EXPORT']">导出</el-button>
@ -106,41 +104,31 @@
</div>
</template>
<script>
<script setup name="job/log">
import {
listJobLog,
delJobLog,
exportJobLog,
cleanJobLog,
} from '@/api/monitor/jobLog'
import { useRoute } from 'vue-router'
import { getCurrentInstance, reactive, toRefs } from 'vue-demi'
const { proxy } = getCurrentInstance()
const route = useRoute()
export default {
name: 'job/log',
data() {
return {
//
loading: true,
//
ids: [],
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
jobLogList: [],
//
open: false,
//
dateRange: [],
//
const loading = ref(true)
const ids = ref([])
const multiple = ref(true)
const showSearch = ref(true)
const total = ref(0)
const jobLogList = ref([])
const open = ref(false)
const dateRange = ref([])
const statusOptions = ref([])
const jobGroupOptions = ref([])
const data = reactive({
form: {},
//
statusOptions: [],
//
jobGroupOptions: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
@ -149,63 +137,66 @@ export default {
status: undefined,
jobId: undefined,
},
}
},
created() {
this.queryParams.jobId = this.$route.query.jobId
this.getList()
this.getDicts('sys_job_status').then((response) => {
this.statusOptions = response.data
})
this.getDicts('sys_job_group').then((response) => {
this.jobGroupOptions = response.data
const { form, queryParams } = toRefs(data)
queryParams.value.jobId = route.query.jobId
proxy.getDicts('sys_job_status').then((response) => {
statusOptions.value = response.data
})
},
methods: {
proxy.getDicts('sys_job_group').then((response) => {
jobGroupOptions.value = response.data
})
/** 查询调度日志列表 */
getList() {
this.loading = true
listJobLog(this.addDateRange(this.queryParams, this.dateRange)).then(
function getList() {
loading.value = true
listJobLog(proxy.addDateRange(queryParams.value, dateRange.value)).then(
(response) => {
this.jobLogList = response.data.result
this.total = response.data.totalNum
this.loading = false
jobLogList.value = response.data.result
total.value = response.data.totalNum
loading.value = false
}
)
},
}
//
statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status)
},
function statusFormat(row, column) {
return proxy.selectDictLabel(statusOptions.value, row.status)
}
//
jobGroupFormat(row, column) {
return this.selectDictLabel(this.jobGroupOptions, row.jobGroup)
},
function jobGroupFormat(row, column) {
return proxy.selectDictLabel(jobGroupOptions.value, row.jobGroup)
}
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
function handleQuery() {
queryParams.value.pageNum = 1
getList()
}
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm('queryForm')
this.handleQuery()
},
function resetQuery() {
dateRange.value = []
resetForm('queryForm')
handleQuery()
}
//
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.jobLogId)
this.multiple = !selection.length
},
function handleSelectionChange(selection) {
ids.value = selection.map((item) => item.jobLogId)
multiple.value = !selection.length
}
/** 详细按钮操作 */
handleView(row) {
this.open = true
this.form = row
},
function handleView(row) {
open.value = true
form.value = row
}
/** 删除按钮操作 */
handleDelete(row) {
const jobLogIds = this.ids
this.$confirm(
function handleDelete(row) {
const jobLogIds = ids.value
proxy
.$confirm(
'是否确认删除调度日志编号为"' + jobLogIds + '"的数据项?',
'警告',
{
@ -218,13 +209,14 @@ export default {
return delJobLog(jobLogIds)
})
.then(() => {
this.getList()
this.$modal.msgSuccess('删除成功')
getList()
proxy.$modal.msgSuccess('删除成功')
})
},
}
/** 清空按钮操作 */
handleClean() {
this.$confirm('是否确认清空所有调度日志数据项?', '警告', {
function handleClean() {
proxy
.$confirm('是否确认清空所有调度日志数据项?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
@ -233,25 +225,24 @@ export default {
return cleanJobLog()
})
.then(() => {
this.getList()
this.$modal.msgSuccess('清空成功')
getList()
proxy.$modal.msgSuccess('清空成功')
})
},
}
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams
this.$confirm('是否确认导出所有调度日志数据项?', '警告', {
function handleExport() {
proxy
.$confirm('是否确认导出所有调度日志数据项?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(function () {
return exportJobLog(queryParams)
return exportJobLog(queryParams.value)
})
.then((response) => {
this.download(response.data.path)
proxy.download(response.data.path)
})
},
},
}
handleQuery()
</script>