378 lines
11 KiB
Vue
378 lines
11 KiB
Vue
<template>
|
|
<div>
|
|
<div>
|
|
<el-form :model="queryParams" label-position="right" inline ref="queryRef" v-show="showSearch"
|
|
@submit.prevent>
|
|
<el-form-item label="工艺路线名称" prop="processName">
|
|
<el-input v-model.trim="queryParams.processName" placeholder="请输入工艺路线名称" clearable />
|
|
</el-form-item>
|
|
<el-form-item label="工艺路线编码" prop="processCode">
|
|
<el-input v-model.trim="queryParams.processCode" placeholder="请输入工艺路线编码" clearable />
|
|
</el-form-item>
|
|
<el-form-item label="是否首检" prop="processCode">
|
|
<el-select v-model="queryParams.firstInspection" placeholder="请选择">
|
|
<el-option v-for="item in firstInspectionOptions" :key="item.value" :label="item.label"
|
|
:value="item.value" />
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item>
|
|
<el-button icon="search" type="primary" @click="handleQuery">{{ $t('btn.search')
|
|
}}</el-button>
|
|
<el-button icon="refresh" @click="resetQuery">{{ $t('btn.reset') }}</el-button>
|
|
</el-form-item>
|
|
<el-row :gutter="15" class="mb10">
|
|
<el-col :span="1.5">
|
|
<!-- <el-button type="primary" v-hasPermi="['business:processmodeloperation:add']" plain icon="plus"
|
|
@click="handleAdd">
|
|
{{ $t('btn.add') }}
|
|
</el-button> -->
|
|
<el-button class="tool-box" color="#00aa00" icon="Upload" @click="handleDownload"> 导出
|
|
</el-button>
|
|
</el-col>
|
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"
|
|
:columns="columns"></right-toolbar>
|
|
</el-row>
|
|
</el-form>
|
|
|
|
<!-- 工具区域 -->
|
|
<el-row :gutter="15" class="mb10">
|
|
</el-row>
|
|
<el-table :data="dataList" v-loading="loading" ref="table" border
|
|
header-cell-class-name="el-table-header-cell" highlight-current-row @sort-change="sortChange">
|
|
<el-table-column prop="processName" label="工艺路线名称" align="center" :show-overflow-tooltip="true" />
|
|
<el-table-column prop="processCode" label="工艺路线编码" align="center" :show-overflow-tooltip="true" />
|
|
<el-table-column prop="operationName" label="工艺名称" align="center" />
|
|
<el-table-column prop="operationCode" label="工艺编码" align="center" />
|
|
<el-table-column prop="firstInspection" label="是否首检" align="center">
|
|
<template #default="scope">
|
|
<el-tag type="success" v-if="scope.row.firstInspection == 1">是</el-tag>
|
|
<el-tag type="info" v-if="scope.row.firstInspection == 0">否</el-tag>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column prop="plcCode" label="产品标识" align="center" />
|
|
<el-table-column prop="workStation" label="工位号" align="center" />
|
|
<el-table-column prop="temperature" label="温度" align="center" />
|
|
<el-table-column prop="pressure" label="压力" align="center" />
|
|
<el-table-column prop="collectionTime" label="数据采集时间" align="center" />
|
|
<el-table-column prop="createBy" label="创建人" align="center" />
|
|
<el-table-column prop="createTime" label="创建时间" align="center" />
|
|
<el-table-column prop="updateBy" label="更新人" align="center" />
|
|
<el-table-column prop="updateTime" label="更新时间" align="center" />
|
|
<!-- <el-table-column label="操作" width="160">
|
|
<template #default="scope">
|
|
<el-button type="success" size="small" icon="edit" title="编辑"
|
|
v-hasPermi="['business:processmodeloperation:edit']"
|
|
@click="handleUpdate(scope.row)"></el-button>
|
|
<el-button type="danger" size="small" icon="delete" title="删除"
|
|
v-hasPermi="['business:processmodeloperation:delete']"
|
|
@click="handleDelete(scope.row)"></el-button>
|
|
</template>
|
|
</el-table-column> -->
|
|
</el-table>
|
|
<pagination :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize"
|
|
@pagination="getList" />
|
|
</div>
|
|
|
|
<div>
|
|
</div>
|
|
<!-- 导出 -->
|
|
<el-dialog v-model="exportDialog.open" title="导出" @close="handleCloseWorkOrder" width="500" draggable
|
|
:close-on-click-modal="false">
|
|
<el-form>
|
|
<el-form-item label="选择日期" prop="createWorkOrderDate">
|
|
<el-date-picker v-model="dateRange" type="daterange" range-separator="至" start-placeholder="开始日期"
|
|
end-placeholder="结束日期" />
|
|
</el-form-item>
|
|
</el-form>
|
|
<template #footer>
|
|
<el-button text @click="handleCloseWorkOrder">{{ $t('btn.cancel') }}</el-button>
|
|
<el-button type="primary" @click="submitExport">{{ $t('btn.submit') }}</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup name="processInformationManagement">
|
|
import { ElMessageBox, ElMessage } from 'element-plus'
|
|
import { getCache, addCache, delCache } from "@/api/processParameterTraceability/index"
|
|
import useUserStore from '@/store/modules/user'
|
|
import { getToken } from '@/utils/auth'
|
|
const dialogTableVisible = ref(false)
|
|
const userStore = useUserStore()
|
|
const userId = userStore.userId
|
|
const userName = userStore.userName
|
|
console.log(userStore.userId, 'userStore.userId') //
|
|
import { ref, reactive, getCurrentInstance, toRefs } from 'vue';
|
|
// 使用ref和reactive初始化响应式数据
|
|
const { proxy } = getCurrentInstance()
|
|
const ids = ref([])
|
|
const loading = ref(false)
|
|
const showSearch = ref(true)
|
|
const show = ref(false)
|
|
const dataList = ref([])
|
|
const open = ref(false)
|
|
|
|
// 查询参数
|
|
const queryParams = reactive({
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
})
|
|
|
|
const firstInspectionOptions = [
|
|
{
|
|
value: '1',
|
|
label: '是',
|
|
},
|
|
{
|
|
value: '0',
|
|
label: '否',
|
|
},
|
|
|
|
]
|
|
function getList() {
|
|
getCache(queryParams).then(res => {
|
|
if (res.code == 200) {
|
|
dataList.value = res.data.result
|
|
total.value = res.data.totalNum
|
|
console.log(dataList.value, 'dataList.value表格数据');
|
|
console.log(res, 'res表格数据');
|
|
}
|
|
})
|
|
}
|
|
//导出参数
|
|
const exportDialog = reactive({
|
|
open: false,
|
|
title: '',
|
|
url: '/mes/ProcessParameter/export'
|
|
})
|
|
//导出
|
|
function handleDownload() {
|
|
exportDialog.open = true
|
|
const today = new Date();
|
|
dateRange.value = [today, today];
|
|
}
|
|
function handleCloseWorkOrder() {
|
|
exportDialog.open = false
|
|
|
|
const today = new Date();
|
|
dateRange.value = [today, today];
|
|
}
|
|
// 初始化日期格式化函数
|
|
function formatDate(date) {
|
|
const year = date.getFullYear();
|
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
const day = String(date.getDate()).padStart(2, '0');
|
|
return `${year}-${month}-${day}`;
|
|
}
|
|
|
|
function submitExport() {
|
|
if (!dateRange.value || dateRange.value.length !== 2) {
|
|
ElMessage.warning('请选择完整的日期范围')
|
|
return
|
|
}
|
|
const [startDate, endDate] = dateRange.value
|
|
const startTime = formatDate(startDate)
|
|
const endTime = formatDate(endDate)
|
|
console.log(import.meta.env.VITE_APP_BASE_API, '请求地址');
|
|
const exportUrl = `${exportDialog.url}?pageNum=${queryParams.pageNum}&pageSize=${queryParams.pageSize}&startTime=${startTime}&endTime=${endTime}`
|
|
proxy.download(exportUrl, '工单数据.xlsx')
|
|
handleCloseWorkOrder()
|
|
}
|
|
// 列配置
|
|
const columns = ref([
|
|
{ visible: true, prop: 'processCode', label: '物料工艺路线编码' },
|
|
{ visible: true, prop: 'processName', label: '物料名称' },
|
|
{ visible: true, prop: 'operationSeq', label: '工艺顺序号' },
|
|
{ visible: true, prop: 'workCenter', label: '工作中心/设备/车间' },
|
|
{ visible: true, prop: 'standardTime', label: '标准工时(分钟)' },
|
|
{ visible: true, prop: 'description', label: '工艺描述' }
|
|
])
|
|
|
|
const total = ref(0)
|
|
const detailTotail = ref(0)
|
|
const queryRef = ref()
|
|
|
|
// 模拟工艺路线选项数据
|
|
const options = ref([
|
|
{ routingCode: 'ROUTING_001', routingName: '电子产品组装工艺' },
|
|
{ routingCode: 'ROUTING_002', routingName: '机械零件加工工艺' },
|
|
{ routingCode: 'ROUTING_003', routingName: '塑料制品成型工艺' }
|
|
])
|
|
|
|
// 模拟工艺数据
|
|
const mockProcessData = []
|
|
|
|
// 查询
|
|
function handleQuery() {
|
|
queryParams.pageNum = 1
|
|
getList()
|
|
}
|
|
|
|
// 重置查询
|
|
function resetQuery() {
|
|
proxy.resetForm('queryRef')
|
|
queryParams.processCode = null
|
|
queryParams.processName = null
|
|
queryParams.firstInspection = null
|
|
queryParams.pageSize = 10
|
|
handleQuery()
|
|
}
|
|
// 初始化日期范围为当天
|
|
const dateRange = ref([
|
|
new Date(),
|
|
new Date()
|
|
])
|
|
|
|
// 页面加载时初始化日期范围
|
|
onMounted(() => {
|
|
const today = new Date();
|
|
dateRange.value = [today, today];
|
|
})
|
|
// 自定义排序
|
|
function sortChange(column) {
|
|
// 在实际应用中实现排序逻辑
|
|
console.log('排序字段:', column.prop, '排序方式:', column.order)
|
|
}
|
|
|
|
// 表单相关
|
|
const formRef = ref()
|
|
const title = ref('')
|
|
|
|
const state = reactive({
|
|
form: {
|
|
id: null,
|
|
processName: '',
|
|
processCode: '',
|
|
operationName: '',
|
|
operationCode: '',
|
|
firstInspection: 0,
|
|
plcCode: '',
|
|
workStation: '',
|
|
temperature: null,
|
|
pressure: null,
|
|
collectionTime: ''
|
|
},
|
|
rules: {
|
|
processName: [{ required: true, message: '工艺路线名称不能为空', trigger: 'blur' }],
|
|
processCode: [{ required: true, message: '工艺路线编码不能为空', trigger: 'blur' }],
|
|
operationName: [{ required: true, message: '工艺名称不能为空', trigger: 'blur' }],
|
|
operationCode: [{ required: true, message: '工艺编码不能为空', trigger: 'blur' }],
|
|
firstInspection: [{ required: true, message: '请选择是否首检', trigger: 'change' }],
|
|
plcCode: [{ required: true, message: '产品标识不能为空', trigger: 'blur' }],
|
|
workStation: [{ required: true, message: '工位号不能为空', trigger: 'blur' }],
|
|
temperature: [
|
|
{ required: true, message: '温度不能为空', trigger: 'blur' },
|
|
{ type: 'number', message: '温度必须为数字', trigger: 'blur' }
|
|
],
|
|
pressure: [
|
|
{ required: true, message: '压力不能为空', trigger: 'blur' },
|
|
{ type: 'number', message: '压力必须为数字', trigger: 'blur' }
|
|
],
|
|
collectionTime: [{ required: true, message: '数据采集时间不能为空', trigger: 'change' }]
|
|
}
|
|
})
|
|
|
|
const { form, rules } = toRefs(state)
|
|
|
|
// 关闭弹窗
|
|
function cancel() {
|
|
open.value = false
|
|
reset()
|
|
}
|
|
|
|
// 重置表单
|
|
function reset() {
|
|
form.value = {
|
|
id: null,
|
|
processName: '',
|
|
processCode: '',
|
|
operationName: '',
|
|
operationCode: '',
|
|
firstInspection: 0,
|
|
plcCode: '',
|
|
workStation: '',
|
|
temperature: null,
|
|
pressure: null,
|
|
collectionTime: ''
|
|
}
|
|
proxy.resetForm('formRef')
|
|
}
|
|
|
|
const opertype = ref(0)
|
|
// 添加工艺
|
|
function handleAdd() {
|
|
reset()
|
|
open.value = true
|
|
title.value = '添加'
|
|
opertype.value = 1
|
|
}
|
|
|
|
// 修改工艺
|
|
function handleUpdate(row) {
|
|
reset()
|
|
form.value = { ...row }
|
|
open.value = true
|
|
title.value = '修改'
|
|
opertype.value = 2
|
|
}
|
|
|
|
// 提交表单
|
|
function submitForm() {
|
|
let data = {
|
|
...form.value,
|
|
userId: userId,
|
|
userName: userName
|
|
}
|
|
proxy.$refs["formRef"].validate((valid) => {
|
|
if (valid) {
|
|
if (opertype.value === 2) {
|
|
updateCache(data).then(res => {
|
|
if (res.code == 200) {
|
|
ElMessage({
|
|
message: '修改成功',
|
|
type: 'success',
|
|
})
|
|
getList()
|
|
}
|
|
})
|
|
} else {
|
|
addCache(data).then(res => {
|
|
if (res.code == 200) {
|
|
ElMessage({
|
|
message: '新增成功',
|
|
type: 'success',
|
|
})
|
|
}
|
|
getList()
|
|
})
|
|
}
|
|
open.value = false
|
|
}
|
|
})
|
|
}
|
|
|
|
// 删除工艺
|
|
function handleDelete(row) {
|
|
proxy.$confirm(
|
|
'确认删除该条数据吗?',
|
|
'提示',
|
|
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
|
|
).then(() => {
|
|
delCache(row.id).then(res => {
|
|
if (res.code === 200) {
|
|
ElMessage({ message: '删除成功', type: 'success' });
|
|
getList();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
// 树节点选择
|
|
function handlerTreeSelected(id) {
|
|
queryParams.RoutingCode = id
|
|
handleQuery()
|
|
}
|
|
|
|
// 初始化加载数据
|
|
getList()
|
|
</script> |