<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="工件号">
|
<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-input v-model="queryParam.oP80NewCode" allow-clear placeholder="请输入成品码" />
|
</a-form-item>
|
</a-col>
|
<a-col :md="colMd" :sm="colSm">
|
<a-form-item label="来源" v-if="queryParam.selectModel == 2">
|
<a-input v-model="queryParam.createUserName" allow-clear placeholder="请输入来源" />
|
</a-form-item>
|
</a-col>
|
<a-col :md="colMd" :sm="colSm">
|
<a-form-item label="修改来源" v-if="queryParam.selectModel == 2">
|
<a-input v-model="queryParam.updatedUserName" 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>
|
<a-col :md="colMd2" :sm="colSm2">
|
<a-form-item :label="queryParam.selectModel == 1?'初始上线时间':'上线时间'">
|
<a-range-picker style="width:100%" :show-time="{format:'HH:mm'}" v-model="queryParam.dates" format="YYYY-MM-DD HH:mm" />
|
</a-form-item>
|
</a-col>
|
<template v-if="advanced">
|
<a-col :md="colMd" :sm="colSm">
|
<a-form-item label="工件状态" v-if="queryParam.selectModel == 1">
|
<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
|
allow-clear
|
style="width: 100%"
|
v-model="queryParam.IsHaveOP80Code"
|
placeholder="请选择是否有成品码"
|
>
|
<a-select-option v-for="(item, index) in IsHaveOP80Code" :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
|
allow-clear
|
style="width: 100%"
|
v-model="queryParam.qualityState"
|
placeholder="请选择质量状态"
|
>
|
<a-select-option v-for="(item, index) in QualityState" :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="操作类型" v-if="queryParam.selectModel == 2">
|
<a-input v-model="queryParam.operationType" allow-clear placeholder="请输入操作类型" />
|
</a-form-item>
|
|
<a-form-item label="设备名称" v-if="queryParam.selectModel == 1">
|
<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="getData(1)">查询</a-button>
|
<a-button style="margin-left: 8px" @click="resetQueryData">重置</a-button>
|
<a @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">
|
<div style="margin-bottom:10px">
|
<a-button type="info" icon="download" @click="exportExcel">导出Excel</a-button>
|
</div>
|
|
<a-spin :spinning="confirmLoading">
|
<a-table
|
:rowClassName="getRowBackGround"
|
:columns="columns"
|
:data-source="data"
|
:pagination="pages"
|
:rowKey="(record) => record.id"
|
>
|
<span slot="workPieceinitOnlineTime" slot-scope="text">
|
<span v-if="text">{{ moment(moment(text)).format('YYYY-MM-DD HH:mm:ss') }}</span>
|
<span v-else>{{ text }}</span>
|
</span>
|
<span slot="workPieceLastOfflineTime" slot-scope="text">
|
<span v-if="text">{{ moment(moment(text)).format('YYYY-MM-DD HH:mm:ss') }}</span>
|
<span v-else>{{ text }}</span>
|
</span>
|
<span slot="qualityDeatil" slot-scope="item, record">
|
<a :disabled="record.disabled" @click="$refs.qualityDetail.show(record)">质量详情</a>
|
</span>
|
</a-table>
|
</a-spin>
|
</a-card>
|
|
<qualityDetail ref="qualityDetail" />
|
</div>
|
</template>
|
<script>
|
// 工件加工追溯
|
import { STable, XCard } from '@/components'
|
import { downloadFile,getThisWeekRange } from '@/utils/util'
|
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,
|
colMd2: 10,
|
colSm2: 24,
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 7 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 17 }
|
},
|
advanced: false, // 高级搜索 展开/关闭
|
confirmLoading: false,
|
currentSelModel:1,//当前选择的维护
|
queryParam: {
|
selectModel: 1,
|
dates:[]
|
},
|
pages: {
|
current: 1,
|
pageSize: 10,
|
total: 0,
|
showSizeChanger: true,
|
showTotal: (total, range) => `${range[0]}-${range[1]}共${total}条`,
|
pageSizeOptions: ['10', '20', '30', '40','50','100','200','300','400','500'],
|
onChange: this.getData,
|
onShowSizeChange: this.pageSizeChange
|
},
|
columns: [
|
{
|
title: '序号',
|
dataIndex: 'index',
|
key: 'index',
|
align: 'center',
|
customRender: (text, record, index) => `${index + 1}`
|
},
|
{
|
title: '工件号',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceID'
|
},
|
{
|
title: '当前工序',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workingProcedureCurrent'
|
},
|
{
|
title: '质量状态',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'qualityStateName'
|
},
|
{
|
title: '不合格原因',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'qualityNoOkReason'
|
},
|
{
|
title: '成品码',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'oP80NewCode'
|
},
|
{
|
title: '质量详情',
|
align: 'center',
|
sorter: true,
|
scopedSlots: { customRender: 'qualityDeatil' }
|
}
|
],
|
columns1: [
|
{
|
title: '工件状态',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceStateName'
|
},
|
{
|
title: '设备名称',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'equipmentName'
|
// scopedSlots: {customRender: 'equipmentName'}
|
},
|
{
|
title: '初始上线时间',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceinitOnlineTime',
|
scopedSlots: {
|
customRender: 'workPieceinitOnlineTime'
|
}
|
},
|
{
|
title: '最终下线时间',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceLastOfflineTime',
|
scopedSlots: {
|
customRender: 'workPieceLastOfflineTime'
|
}
|
},
|
{
|
title: '加工时长',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'workPieceCurr'
|
}
|
],
|
columns2: [
|
{
|
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: 'jiaJuGongWei'
|
},
|
{
|
title: '来源',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'createUserName'
|
},
|
{
|
title: '来源描述',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'dataCapturePointCname'
|
},
|
{
|
title: '修改来源',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'updatedUserName'
|
},
|
{
|
title: '修改来源描述',
|
align: 'center',
|
sorter: true,
|
dataIndex: 'updateDataCapturePointCname'
|
}
|
],
|
data: [],
|
tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' },
|
// 加载数据方法 必须为 Promise 对象
|
// 设备下拉框数据
|
equitypeData: [],
|
// 工序下拉框数据
|
WorkPieceSelectData: [],
|
selectedRowKeys: [],
|
selectedRows: [],
|
QualityState: []
|
}
|
},
|
watch: {
|
'queryParam.selectModel': {
|
handler(val, oldVal) {
|
var old_dates=this.queryParam.dates;
|
this.queryParam = { selectModel: val,dates:[] }
|
this.queryParam.dates = old_dates;
|
this.currentSelModel=val;
|
if (val == 1) {
|
if (oldVal) {
|
this.columns.splice(3, this.columns2.length)
|
}
|
this.columns.splice(3, 0, ...this.columns1)
|
} else if (val == 2) {
|
this.columns.splice(3, this.columns1.length)
|
this.columns.splice(3, 0, ...this.columns2)
|
}
|
},
|
immediate: true
|
}
|
},
|
created() {
|
this.getEquipmentName()
|
this.ProcessSelectData = this.$options.filters['dictData']('process_type')
|
this.IsHaveOP80Code = this.$options.filters['dictData']('yes_or_no')
|
this.WorkPieceSelectData = this.$options.filters['dictData']('workpiece_state')
|
|
this.modelEnums = [
|
{ name: '工件', code: 1 },
|
{ name: '工件+工序', code: 2 }
|
]
|
this.QualityState = this.$options.filters['dictData']('quality_state')
|
this.initData();
|
this.getData()
|
},
|
methods: {
|
initData(){
|
this.queryParam.dates = [];
|
this.queryParam.dates = getThisWeekRange();
|
},
|
//重置
|
resetQueryData(){
|
this.queryParam = { selectModel: this.currentSelModel,dates:[] }
|
this.initData();
|
},
|
setDisabled() {
|
this.data.forEach((item) => {
|
if (item.operationTypeHand == 'SPC') {
|
item.disabled =
|
item.workingProcedureCurrent == 'OP05' ||
|
//去掉OP70的不显示质量数据 【Editby shaocx,2024-08-18】
|
//item.workingProcedureCurrent == 'OP70' ||
|
item.workingProcedureCurrent == 'OP80'
|
} else {
|
item.disabled = item.workingProcedureCurrent == 'OP05' || item.workingProcedureCurrent == 'OP50'
|
//去掉OP70的不显示质量数据 【Editby shaocx,2024-08-18】
|
//|| item.workingProcedureCurrent == 'OP70'
|
}
|
})
|
},
|
moment,
|
// 查询列表数据
|
async getData(pageNo) {
|
if (pageNo) this.pages.current = pageNo
|
const { current, pageSize } = this.pages
|
this.queryParam.pageNo = current
|
this.queryParam.pageSize = pageSize
|
this.confirmLoading = true
|
try {
|
if (this.queryParam.selectModel == 1) {
|
const { data } = await workPieceInfoMachiningPage(this.switchingDate())
|
this.data = data.rows
|
this.pages.total = data.totalRows
|
} else {
|
const { data } = await workPieceProcessMachiningPage(this.switchingDate())
|
this.data = data.rows
|
this.pages.total = data.totalRows
|
}
|
} catch (error) {
|
console.log(error)
|
}
|
this.confirmLoading = false
|
|
this.setDisabled()
|
},
|
getRowBackGround(record) {
|
if (this.queryParam.selectModel == 1) {
|
switch (
|
record.cololType // 这里根据条件改变表格背景色
|
) {
|
case 1:
|
return 'table-color-yellow'
|
case 2:
|
return 'table-color-green'
|
case 3:
|
return 'table-color-red'
|
case 4:
|
return 'table-color-blue'
|
case 5:
|
return 'table-color-gray'
|
}
|
}
|
},
|
// 导出
|
exportExcel() {
|
if (this.queryParam.selectModel == 1) {
|
WorkPieceInfoToExcel(this.queryParam)
|
.then((res) => {
|
downloadFile(res)
|
})
|
.catch((err) => {
|
console.info(err)
|
this.$message.error('下载错误:获取文件流错误' + err)
|
})
|
} else {
|
workPieceProcessToExcel(this.queryParam)
|
.then((res) => {
|
downloadFile(res)
|
})
|
.catch((err) => {
|
console.info(err)
|
this.$message.error('下载错误:获取文件流错误' + err)
|
})
|
}
|
},
|
/**
|
* 查询参数组装
|
*/
|
switchingDate() {
|
const dates = this.queryParam.dates
|
if (dates != null) {
|
this.queryParam.startTimeBeginTime = moment(dates[0]).format('YYYY-MM-DD HH:mm')
|
this.queryParam.startTimeEndTime = moment(dates[1]).format('YYYY-MM-DD HH:mm')
|
if (dates.length < 1) {
|
delete this.queryParam.startTimeBeginTime
|
delete this.queryParam.startTimeEndTime
|
}
|
}
|
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
|
},
|
// pageSize 变化的回调
|
pageSizeChange(current, size) {
|
this.pages.pageSize = size
|
this.getData(1)
|
},
|
changeModel() {
|
this.data = []
|
}
|
}
|
}
|
</script>
|
<style lang="less">
|
.table-operator {
|
margin-bottom: 18px;
|
}
|
button {
|
margin-right: 8px;
|
}
|
|
.table-color-yellow{
|
background-color: rgb(202, 202, 86);
|
}
|
|
.table-color-green{
|
background-color: rgb(147, 228, 147);
|
}
|
|
.table-color-red{
|
background-color: rgb(236, 157, 157);
|
}
|
|
.table-color-blue{
|
background-color: rgb(156, 156, 231);
|
}
|
|
.table-color-gray{
|
background-color: rgb(181, 172, 172);
|
}
|
</style>
|