mt-qj-wms-ui/src/views/report/task-history.vue
2022-11-21 15:38:44 +08:00

365 lines
9.5 KiB
Vue

<template>
<div class="mod-config">
<el-form
style="display: flex; align-items: center; justify-content: right;"
:inline="true"
:model="dataForm"
>
<!-- <el-form-item>
<el-select
size="small"
v-model="dataForm.vehicleId"
filterable
placeholder="车辆名称"
>
<el-option
v-for="item in options2"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item> -->
<el-form-item prop="stoveCode">
<el-input
v-model="dataForm.stoveCode"
placeholder="炉号"
clearable
></el-input>
</el-form-item>
<el-form-item prop="kilnId">
<el-select
size="small"
v-model="dataForm.kilnId"
clearable
filterable
placeholder="加工炉"
>
<el-option
v-for="item in options"
:key="item.id"
:label="item.code"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-date-picker
size="small"
v-model="dataForm.time"
type="daterange"
range-separator="至"
start-placeholder="开始日期"
end-placeholder="结束日期"
>
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button size="small" @click="getDataList(1)">查询</el-button>
</el-form-item>
</el-form>
<el-table
:data="dataList"
ref="dataTable"
:stripe="true"
:header-cell-style="{
background: '#eef1f6',
color: '#606266',
height: '56px'
}"
v-loading="dataListLoading"
@selection-change="selectionChangeHandle"
:row-key="
row => {
return row.id;
}
"
style="width: 100%;"
>
<el-table-column
type="selection"
header-align="center"
reserve-selection
align="center"
width="50"
>
</el-table-column>
<el-table-column
type="index"
header-align="center"
align="center"
label="序号"
width="50"
>
</el-table-column>
<!-- <el-table-column
prop="taskCode"
label="任务编码"
>
</el-table-column> -->
<el-table-column align="center" width="180" prop="stoveCode" label="炉号">
</el-table-column>
<el-table-column align="center" prop="sheetNo" label="生产单号">
</el-table-column>
<el-table-column align="center" prop="targetPosition" label="加工炉">
</el-table-column>
<el-table-column align="center" prop="plcValue" label="工艺号">
</el-table-column>
<el-table-column align="center" prop="beginTime" label="进炉时间">
<template slot-scope="scope">
{{
scope.row.beginTime ? scope.row.beginTime.replace("T", " ") : ""
}}
</template>
</el-table-column>
<!-- <el-table-column
align="center"
prop="taskSource"
label="任务来源"
>
</el-table-column> -->
<el-table-column align="center" prop="status" label="任务状态">
<template slot-scope="scope">
{{ scope.row.status >= 0 ? statusList[scope.row.status] : "" }}
</template>
</el-table-column>
<el-table-column align="center" prop="taskType" label="任务类型">
<template slot-scope="scope">
<span>{{
scope.row.taskType === 0
? "入库到工业炉"
: scope.row.taskType === 1
? "入库到缓存"
: scope.row.taskType === 2
? "工业炉出库到缓存区"
: "缓存区出库"
}}</span>
</template>
</el-table-column>
<el-table-column align="center" prop="startPosition" label="开始位置">
</el-table-column>
<!-- <el-table-column
prop="vehicleName"
label="车辆名称"
>
</el-table-column> -->
<el-table-column
fixed="right"
header-align="center"
align="center"
width="100"
label="检验"
>
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click="checkResult(scope.row.sheetNo)"
>检验结果</el-button
>
</template>
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="100"
label="能耗情况"
>
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click="eleHandle(scope.row.taskId, scope.row.targetPosition)"
>详情</el-button
>
</template>
</el-table-column>
<el-table-column
fixed="right"
header-align="center"
align="center"
width="100"
label="生产单详情"
>
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click="LocationBtn(scope.row.taskId)"
>生产单详情</el-button
>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[10, 20, 50, 100]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper"
>
</el-pagination>
<task-history-result
v-if="taskHistoryResultVisible"
ref="addOrUpdate"
></task-history-result>
</div>
</template>
<script>
import taskHistoryResult from './components/task-history-result'
// 任务状态列表
const statusList = {
0: '等待执行',
1: '执行中',
2: '执行完成',
3: '追加后完成'
}
export default {
data () {
return {
dataForm: {
vehicleId: '',
stoveCode: '',
kilnId: '',
time: []
},
taskHistoryResultVisible: false,
dataList: [],
options2: [],
options: [],
dataListSelections: [],
pageIndex: 1,
pageSize: 10,
totalPage: 0,
dataListLoading: false,
orderDetailVisible: false,
statusList
}
},
components: {
taskHistoryResult
},
activated () {
this.$http({
url: this.$http.adornUrl('/kilnInfo/page'),
method: 'post',
data: this.$http.adornData({
current: 1,
size: 500
// paramKey: this.dataForm.paramKey
})
}).then(({ data }) => {
if (data && data.code === 0) {
this.options = data.data.records
} else {
this.options = []
}
})
this.getDataList(1)
},
methods: {
// 获取数据列表
getDataList (val) {
this.dataListLoading = true
if (val) {
this.$refs.dataTable.clearSelection()
}
this.$http({
url: this.$http.adornUrl('/taskHis/taskHis'),
method: 'post',
data: this.$http.adornData({
current: this.pageIndex,
size: this.pageSize,
vehicleId: this.dataForm.vehicleId,
stoveCode: this.dataForm.stoveCode,
kilnId: this.dataForm.kilnId,
startTime:
this.dataForm.time && this.dataForm.time.length > 0
? this.dataForm.time[0]
: '',
endTime:
this.dataForm.time && this.dataForm.time.length > 0
? this.dataForm.time[1]
: ''
})
}).then(({ data }) => {
if (data && data.code === 0) {
this.dataList = data.data.records
this.totalPage = data.data.total
} else {
this.dataList = []
this.totalPage = 0
}
this.dataListLoading = false
})
},
// 每页数
sizeChangeHandle (val) {
this.pageSize = val
this.pageIndex = 1
this.getDataList()
},
// 当前页
currentChangeHandle (val) {
this.pageIndex = val
this.getDataList()
},
LocationBtn (id) {
this.$router.push({ name: 'report-task-history-detail', query: { id } })
},
eleHandle (taskId, targetPosition) {
const a = this.dataListSelections.findIndex(
item => item.targetPosition !== targetPosition
)
if (a !== 0) {
const taskIdArr = this.dataListSelections.map(item => {
return item.taskId
})
const taskIds = [...new Set([...taskIdArr, taskId])]
this.$router.push({
name: 'report-task-ele',
query: { taskIds }
})
} else {
this.$message({
message: '加工炉必须一致',
type: 'info',
duration: 1500
})
}
},
checkResult (sheetNo) {
this.taskHistoryResultVisible = true
this.$nextTick(() => {
this.$refs.addOrUpdate.init(sheetNo)
})
},
// 多选
selectionChangeHandle (val) {
let targetPosition = val[0] ? val[0].targetPosition : ''
let arr = []
val.forEach(item => {
if (targetPosition === item.targetPosition) {
arr.push(item)
} else {
this.$message({
message: '加工炉必须一致',
type: 'info',
duration: 1500
})
this.$refs.dataTable.toggleRowSelection(item, false)
}
})
this.dataListSelections = arr
}
}
}
</script>