完善预警中心功能迁移
This commit is contained in:
@@ -57,3 +57,11 @@ export function getWorkstationSearch (data) {
|
||||
params: apiParams('planning_production_produce_pincheck_search', data)
|
||||
})
|
||||
}
|
||||
|
||||
export function devicePinCheckExport (data) {
|
||||
return request({
|
||||
url: BASE + 'check',
|
||||
method: 'get',
|
||||
params: apiParams('planning_production_produce_pincheck_check', data)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,10 +1,66 @@
|
||||
<template>
|
||||
<d2-container>
|
||||
<template #header>
|
||||
<div class="toolbar">
|
||||
<el-button size="mini" type="primary" icon="el-icon-refresh" :disabled="loading" @click="fetchData">
|
||||
{{ $t(key('refresh')) }}
|
||||
</el-button>
|
||||
<div class="search-bar">
|
||||
<el-form ref="form" :inline="true" :model="form" size="mini">
|
||||
<el-form-item :label="$t(key('select_time'))" prop="time">
|
||||
<el-date-picker
|
||||
v-model="form.time"
|
||||
:default-time="['00:00:00', '23:59:59']"
|
||||
type="datetimerange"
|
||||
value-format="yyyy-MM-dd HH:mm:ss"
|
||||
format="yyyy-MM-dd HH:mm:ss"
|
||||
range-separator="~"
|
||||
:start-placeholder="$t(key('start_date'))"
|
||||
:end-placeholder="$t(key('end_date'))"
|
||||
style="width:360px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t(key('workstation'))" prop="workstation_id">
|
||||
<el-select
|
||||
v-model="form.workstation_id"
|
||||
filterable
|
||||
clearable
|
||||
:placeholder="$t(key('select_workstation'))"
|
||||
style="width:180px"
|
||||
@change="changeWorkstation"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in workstationOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item prop="device_code">
|
||||
<el-select
|
||||
v-model="form.device_code"
|
||||
filterable
|
||||
clearable
|
||||
:placeholder="$t(key('select_device'))"
|
||||
style="width:180px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in deviceOptions"
|
||||
:key="item.id || item.code"
|
||||
:label="item.name"
|
||||
:value="item.code"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button size="mini" type="primary" icon="el-icon-search" :disabled="loading" @click="onSearch">
|
||||
{{ $t(key('query')) }}
|
||||
</el-button>
|
||||
<el-button size="mini" icon="el-icon-refresh" :disabled="loading" @click="onReset">
|
||||
{{ $t(key('reset')) }}
|
||||
</el-button>
|
||||
<el-button size="mini" type="primary" icon="el-icon-download" :disabled="exportLoading" :loading="exportLoading" @click="handleExport">
|
||||
{{ $t(key('export')) }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -143,7 +199,9 @@ import {
|
||||
getDevicePinCheckList,
|
||||
getPinCheckDetail,
|
||||
setPinCheckClean,
|
||||
setPinCheckCleanSingle
|
||||
setPinCheckCleanSingle,
|
||||
getWorkstationSearch,
|
||||
devicePinCheckExport
|
||||
} from '@/api/planning-production/alert-center'
|
||||
|
||||
export default {
|
||||
@@ -154,6 +212,14 @@ export default {
|
||||
loading: false,
|
||||
detailLoading: false,
|
||||
detailTableLoading: false,
|
||||
exportLoading: false,
|
||||
form: {
|
||||
time: '',
|
||||
workstation_id: '',
|
||||
device_code: ''
|
||||
},
|
||||
workstationOptions: [],
|
||||
deviceOptions: [],
|
||||
workstations: [],
|
||||
currentWorkstation: null,
|
||||
workstationDialogVisible: false,
|
||||
@@ -166,6 +232,7 @@ export default {
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.loadWorkstationOptions()
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
@@ -173,16 +240,88 @@ export default {
|
||||
const data = res && res.data !== undefined ? res.data : res
|
||||
return data || []
|
||||
},
|
||||
normalizeList (res) {
|
||||
const data = this.normalizeData(res)
|
||||
if (Array.isArray(data)) return data
|
||||
if (Array.isArray(data.data)) return data.data
|
||||
if (Array.isArray(data.list)) return data.list
|
||||
if (Array.isArray(data.rows)) return data.rows
|
||||
return []
|
||||
},
|
||||
buildQueryParams () {
|
||||
return {
|
||||
...this.form,
|
||||
page_no: 1,
|
||||
page_size: 1000
|
||||
}
|
||||
},
|
||||
loadWorkstationOptions () {
|
||||
getWorkstationSearch({ pin_check: 'pin_check' })
|
||||
.then(res => {
|
||||
this.workstationOptions = this.normalizeList(res)
|
||||
})
|
||||
.catch(() => {
|
||||
this.workstationOptions = []
|
||||
})
|
||||
},
|
||||
fetchData () {
|
||||
this.loading = true
|
||||
getPincheckWorkstation({})
|
||||
getPincheckWorkstation(this.buildQueryParams())
|
||||
.then(res => {
|
||||
this.workstations = this.normalizeData(res)
|
||||
this.workstations = this.normalizeList(res)
|
||||
})
|
||||
.finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
onSearch () {
|
||||
this.fetchData()
|
||||
},
|
||||
onReset () {
|
||||
this.$refs.form.resetFields()
|
||||
this.deviceOptions = []
|
||||
this.fetchData()
|
||||
},
|
||||
changeWorkstation (workstationId) {
|
||||
this.form.device_code = ''
|
||||
const workstation = this.workstationOptions.find(item => String(item.id) === String(workstationId))
|
||||
this.deviceOptions = workstation && Array.isArray(workstation.devices) ? workstation.devices : []
|
||||
},
|
||||
isEmptyTime () {
|
||||
return !this.form.time || (Array.isArray(this.form.time) && !this.form.time.length)
|
||||
},
|
||||
async handleExport () {
|
||||
if (this.isEmptyTime()) {
|
||||
this.$message.error(this.$t(this.key('please_select_time')))
|
||||
return
|
||||
}
|
||||
if (!this.form.workstation_id) {
|
||||
this.$message.error(this.$t(this.key('please_select_workstation')))
|
||||
return
|
||||
}
|
||||
const confirmed = await this.$confirm(this.$t(this.key('export_confirm_message')), this.$t(this.key('prompt')), {
|
||||
confirmButtonText: this.$t(this.key('confirm')),
|
||||
cancelButtonText: this.$t(this.key('cancel')),
|
||||
type: 'warning',
|
||||
center: true
|
||||
}).catch(() => {
|
||||
this.$message.info(this.$t(this.key('clear_cancel')))
|
||||
return false
|
||||
})
|
||||
if (confirmed === false) return
|
||||
|
||||
this.exportLoading = true
|
||||
try {
|
||||
await devicePinCheckExport({
|
||||
...this.form,
|
||||
action: 'download'
|
||||
})
|
||||
this.$message.success(this.$t(this.key('create_download_task_success')))
|
||||
this.$router.push({ name: 'task' }).catch(() => {})
|
||||
} finally {
|
||||
this.exportLoading = false
|
||||
}
|
||||
},
|
||||
openWorkstation (item) {
|
||||
this.currentWorkstation = item
|
||||
this.workstationDialogTitle = this.$t(this.key('workstation_detail'), { device_name: item.name })
|
||||
@@ -191,7 +330,7 @@ export default {
|
||||
},
|
||||
fetchDeviceDetails (item) {
|
||||
this.detailLoading = true
|
||||
getDevicePinCheckList({ device_category_id: item.workstation_id })
|
||||
getDevicePinCheckList({ device_category_id: item.workstation_id || item.id })
|
||||
.then(res => {
|
||||
const data = this.normalizeData(res)
|
||||
this.consecutiveData = data.consecutive_data || []
|
||||
@@ -212,7 +351,7 @@ export default {
|
||||
device_code: row.device_code
|
||||
})
|
||||
getPinCheckDetail({
|
||||
device_category_id: row.workstation_id,
|
||||
device_category_id: row.workstation_id || (this.currentWorkstation && this.currentWorkstation.workstation_id) || (this.currentWorkstation && this.currentWorkstation.id),
|
||||
device_code: row.device_code,
|
||||
type
|
||||
})
|
||||
@@ -260,7 +399,7 @@ export default {
|
||||
this.$message.success(this.$t(this.key('clear_success')))
|
||||
this.fetchData()
|
||||
this.fetchDeviceDetails({
|
||||
workstation_id: row.workstation_id,
|
||||
workstation_id: row.workstation_id || (this.currentWorkstation && this.currentWorkstation.workstation_id) || (this.currentWorkstation && this.currentWorkstation.id),
|
||||
name: row.device_name
|
||||
})
|
||||
}
|
||||
@@ -269,7 +408,7 @@ export default {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.toolbar {
|
||||
.search-bar {
|
||||
margin-bottom: -18px;
|
||||
}
|
||||
.alert-center {
|
||||
|
||||
Reference in New Issue
Block a user