<template>
|
<div>
|
<x-card :bordered="false" v-if="hasPerm('WorkPieceProcess:page')">
|
<div slot="content" class="table-page-search-wrapper">
|
<a-form :label-col="labelCol" :wrapper-col="wrapperCol">
|
<a-row :gutter="gutter">
|
<a-col :md="colMd" :sm="colSm">
|
<a-form-item label="查询维度">
|
<a-select @change="changeModel" style="width: 100%" v-model="queryParam.selectModel" placeholder="请选择查询维度">
|
<a-select-option v-for="(item, index) in modelEnums" :key="index" :value="item.code">
|
{{ item.name }}
|
</a-select-option>
|
</a-select>
|
</a-form-item>
|
</a-col>
|
<a-col :md="colMd" :sm="colSm">
|
<a-form-item label="工件ID">
|
<a-input v-model="queryParam.workPieceID" allow-clear placeholder="请输入工件号" />
|
</a-form-item>
|
</a-col>
|
<a-col :md="colMd" :sm="colSm">
|
<a-form-item label="工序">
|
<a-select
|
allow-clear
|
style="width: 100%"
|
v-model="queryParam.WorkingProcedureCurrent"
|
placeholder="请选择工序"
|
>
|
<a-select-option v-for="(item, index) in ProcessSelectData" :key="index" :value="item.code">
|
{{ item.name }}
|
</a-select-option>
|
</a-select>
|
</a-form-item>
|
</a-col>
|
<template v-if="advanced && queryParam.selectModel == 1">
|
<a-col :md="colMd" :sm="colSm">
|
<a-form-item label="工件状态">
|
<a-select
|
allow-clear
|
style="width: 100%"
|
v-model="queryParam.WorkPieceState"
|
placeholder="请选择工件状态"
|
>
|
<a-select-option v-for="(item, index) in WorkPieceSelectData" :key="index" :value="item.code">
|
{{ item.name }}
|
</a-select-option>
|
</a-select>
|
</a-form-item>
|
</a-col>
|
|
<a-col :md="colMd" :sm="colSm">
|
<a-form-item label="设备名称">
|
<a-select
|
show-search
|
option-filter-prop="children"
|
:filter-option="filterOption"
|
:allowClear="true"
|
style="width: 100%"
|
v-model="queryParam.equipmentName"
|
placeholder="请选择设备名称"
|
>
|
<a-select-option v-for="item in equitypeData" :key="item.id" :value="item.equipmentName">{{
|
item.equipmentName
|
}}</a-select-option>
|
</a-select>
|
</a-form-item>
|
</a-col>
|
</template>
|
<a-col :md="colMd" :sm="colSm">
|
<span class="table-page-search-submitButtons">
|
<a-button
|
type="primary"
|
@click="queryParam.selectModel == 1 ? $refs.table.refresh(true) : $refs.table2.refresh(true)"
|
>查询</a-button
|
>
|
<a-button style="margin-left: 8px" @click="() => (queryParam = { selectModel: 1 })">重置</a-button>
|
<a v-if="queryParam.selectModel == 1" @click="advanced = !advanced" style="margin-left: 8px">
|
{{ advanced ? '收起' : '展开' }}
|
<a-icon :type="advanced ? 'up' : 'down'" />
|
</a>
|
</span>
|
</a-col>
|
</a-row>
|
</a-form>
|
</div>
|
</x-card>
|
|
<a-card :bordered="false" >
|
<a-button type="primary" @click="exportExcel">导出</a-button>
|
<s-table
|
v-show="queryParam.selectModel == 1"
|
ref="table"
|
:columns="columns"
|
:data="loadData"
|
:alert="true"
|
:rowKey="(record) => record.id">
|
<span slot="qualityDeatil" slot-scope="item, record">
|
<a :disabled="record.workingProcedureCurrent=='OP05'||record.workingProcedureCurrent=='OP50'||record.workingProcedureCurrent=='OP70'||record.workingProcedureCurrent=='OP80'" @click="showQualityDeatil(record)">质量详情</a>
|
</span>
|
</s-table>
|
|
<s-table
|
v-show="queryParam.selectModel == 2"
|
ref="table2"
|
:columns="newcolumns"
|
:data="loadData2"
|
:alert="true"
|
:rowKey="(record) => record.id">
|
</s-table>
|
</a-card>
|
|
<!-- <a-card :bordered="false" v-if="queryParam.selectModel == 2">
|
<a-button type="primary" @click="exportExcel">导出</a-button>
|
<s-table ref="table2" :columns="newcolumns" :data="loadData2" :alert="true" :rowKey="(record) => record.id">
|
</s-table>
|
</a-card> -->
|
|
<qualityDetail ref="qualityDetail" />
|
</div>
|
</template>
|
<script>
|
// 工件加工追溯
|
import { STable, XCard } from '@/components'
|
import moment from 'moment'
|
import {
|
workPieceInfoMachiningPage,
|
workPieceProcessMachiningPage,
|
WorkPieceInfoToExcel,
|
workPieceProcessToExcel
|
} from '@/api/modular/main/WorkPieceInfoManage'
|
// 获取设备下拉框数据
|
import { getEquipmentName } from '@/api/modular/main/EquipmentBaseInfoManage'
|
import qualityDetail from './modules/qualityDetail.vue'
|
export default {
|
components: {
|
STable,
|
XCard,
|
qualityDetail
|
},
|
data() {
|
return {
|
gutter: 36,
|
colMd: 6,
|
colSm: 18,
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 8 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 15 }
|
},
|
advanced: false, // 高级搜索 展开/关闭
|
queryParam: { selectModel: 1 },
|
columns: [
|
{
|
title: '序号',
|
dataIndex: 'index',
|
key: 'index',
|
align: 'center',
|
customRender: (text, record, index) => `${index + 1}`
|
},
|
{
|
title: '工件ID',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceID'
|
},
|
{
|
title: '当前工序',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workingProcedureCurrent'
|
},
|
{
|
title: '工件状态',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceStateName'
|
},
|
{
|
title: '设备名称',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'equipmentName'
|
// scopedSlots: {customRender: 'equipmentName'}
|
},
|
{
|
title: '初始上线时间',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceinitOnlineTime'
|
},
|
{
|
title: '最终下线时间',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceLastOfflineTime'
|
},
|
{
|
title: '已加工时长',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceCurr'
|
},
|
{
|
title: '质量状态',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'qualityStateName'
|
},
|
{
|
title: '质量详情',
|
align: 'center',
|
sorter: true,
|
scopedSlots: { customRender: 'qualityDeatil' }
|
}
|
],
|
newcolumns: [
|
{
|
title: '序号',
|
dataIndex: 'index',
|
key: 'index',
|
align: 'center',
|
customRender: (text, record, index) => `${index + 1}`
|
},
|
{
|
title: '工件ID',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceID'
|
},
|
{
|
title: '当前工序',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workingProcedureCurrent'
|
},
|
// {
|
// title: '工件状态',
|
// align: 'center',
|
// sorter: true,
|
// dataIndex: 'workPieceStateName'
|
// },
|
{
|
title: '操作类型',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'operationTypeHand'
|
},
|
{
|
title: '设备名称',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'equipmentName'
|
},
|
{
|
title: '上线时间',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'startTime'
|
},
|
{
|
title: '下线时间',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'endTime'
|
},
|
{
|
title: '加工时长',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'timeSceonds'
|
},
|
{
|
title: '质量状态',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'qualityStateName'
|
}
|
],
|
tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' },
|
// 加载数据方法 必须为 Promise 对象
|
// 设备下拉框数据
|
equitypeData: [],
|
// 工序下拉框数据
|
WorkPieceSelectData: [],
|
selectedRowKeys: [],
|
selectedRows: []
|
}
|
},
|
// watch: {
|
// selectModel(val) {
|
// if (val == 1) {
|
// this.$nextTick(() => {
|
// this.$refs.table.refresh(true)
|
// })
|
// } else {
|
// this.$nextTick(() => {
|
// setTimeout(() => {
|
// this.$refs.table2.refresh(true)
|
// }, 500)
|
// })
|
// }
|
// }
|
// },
|
created() {
|
this.getEquipmentName()
|
this.ProcessSelectData = this.$options.filters['dictData']('process_type')
|
this.WorkPieceSelectData = this.$options.filters['dictData']('workpiece_state')
|
this.modelEnums = [
|
{ name: '工件', code: 1 },
|
{ name: '工件+工序', code: 2 }
|
]
|
},
|
methods: {
|
moment,
|
// 查询列表数据
|
loadData(parameter) {
|
return workPieceInfoMachiningPage(Object.assign(parameter, this.switchingDate())).then((res) => {
|
return res.data
|
})
|
},
|
loadData2(parameter) {
|
return workPieceProcessMachiningPage(Object.assign(parameter, this.switchingDate())).then((res) => {
|
return res.data
|
})
|
},
|
// 导出
|
exportExcel() {
|
const boldData = null
|
if (this.selectModel.selectModel == 1) {
|
WorkPieceInfoToExcel().then((res) => {
|
const link = document.createElement('a') // 创建a标签
|
const blob = new Blob([res], { type: 'application/vnd.ms-excel' }) // response就是接口返回的文件流
|
const objectUrl = URL.createObjectURL(blob)
|
link.href = objectUrl
|
link.download = `${this.selectModel.selectModel == 1 ? '产品加工历史表' : '工件加工追溯表'}${moment(
|
new Date().toString()
|
).format('YYYY-MM-DD hh:mm:ss')}` // 自定义文件名
|
link.click() // 下载文件
|
URL.revokeObjectURL(objectUrl) // 释放内存
|
})
|
} else {
|
workPieceProcessToExcel().then((res) => {
|
const link = document.createElement('a') // 创建a标签
|
const blob = new Blob([res], { type: 'application/vnd.ms-excel' }) // response就是接口返回的文件流
|
const objectUrl = URL.createObjectURL(blob)
|
link.href = objectUrl
|
link.download = `${this.selectModel == 1 ? '产品加工历史表' : '工件加工追溯表'}${moment(
|
new Date().toString()
|
).format('YYYY-MM-DD hh:mm:ss')}` // 自定义文件名
|
link.click() // 下载文件
|
URL.revokeObjectURL(objectUrl) // 释放内存
|
})
|
}
|
},
|
/**
|
* 查询参数组装
|
*/
|
switchingDate() {
|
const obj = JSON.parse(JSON.stringify(this.queryParam))
|
return obj
|
},
|
getEquipmentName() {
|
getEquipmentName().then((res) => {
|
this.equitypeData = res.data
|
})
|
},
|
onSelectChange(rows) {
|
console.log(rows)
|
},
|
// 设备查询框筛选
|
filterOption(input, option) {
|
return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
|
},
|
showQualityDeatil(record) {
|
this.$refs.qualityDetail.show(record)
|
}
|
}
|
}
|
</script>
|
<style lang="less">
|
.table-operator {
|
margin-bottom: 18px;
|
}
|
button {
|
margin-right: 8px;
|
}
|
</style>
|