495 lines
15 KiB
Vue
495 lines
15 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>
|
|
<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="#626aef" icon="Download" @click="handleImport"> 导入
|
|
</el-button>
|
|
<el-button class="tool-box" color="#00aa00" icon="Upload" @click="handleDownload"> 导出
|
|
</el-button>
|
|
<el-button class="tool-box" color="#ff0000" icon="Delete" @click="handleDeletes"> 删除
|
|
</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" @selection-change="handleSelectionChange"
|
|
highlight-current-row @sort-change="sortChange">
|
|
<el-table-column type="selection" width="55">
|
|
</el-table-column>
|
|
<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="lineName" label="产线名称" align="center" :show-overflow-tooltip="true" />
|
|
<el-table-column prop="lineCode" label="产线号" align="center" :show-overflow-tooltip="true" />
|
|
<el-table-column prop="createTime" label="创建时间" align="center" />
|
|
<el-table-column prop="updateTime" label="更新时间" align="center" />
|
|
<!-- <el-table-column prop="delflag" label="delflag" align="center" :show-overflow-tooltip="true" /> -->
|
|
<el-table-column label="操作" width="160">
|
|
<template #default="scope">
|
|
<el-button type="primary" size="small" icon="view" title="查看"
|
|
@click="handleView(scope.row)"></el-button>
|
|
<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 :title="title" :lock-scroll="false" v-model="open" width="800">
|
|
<el-form ref="formRef" :model="form" :rules="rules" label-width="80px">
|
|
<el-row :gutter="20">
|
|
<el-col :lg="12">
|
|
<el-form-item label="工艺名称" prop="processName">
|
|
<el-input v-model="form.processName" placeholder="请输入工艺名称" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="12">
|
|
<el-form-item label="工艺编码" prop="processCode">
|
|
<el-input v-model="form.processCode" placeholder="请输入工艺编码" />
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="12">
|
|
<el-form-item label="产线名称" prop="lineName">
|
|
<el-select v-model="form.lineName" placeholder="请选择">
|
|
<el-option v-for="item in productionLine" :key="item.value" :label="item.label"
|
|
:value="item.value" />
|
|
</el-select>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :lg="12">
|
|
<el-form-item label="产线号" prop="lineCode">
|
|
<el-input v-model="form.lineCode" placeholder="请输入产线号" />
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
</el-form>
|
|
<template #footer v-if="opertype != 3">
|
|
<el-button text @click="cancel">{{ $t('btn.cancel') }}</el-button>
|
|
<el-button type="primary" @click="submitForm">{{ $t('btn.submit') }}</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
<!-- 导入对话框 -->
|
|
<el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body draggable
|
|
:close-on-click-modal="false"> <span v-if="show">数据正在导入中请稍等……</span>
|
|
<el-upload name="file" ref="uploadRef" :limit="1" accept=".xlsx,.xls" :headers="upload.headers"
|
|
:action="`${upload.url}`" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress"
|
|
:on-success="handleFileSuccess" :on-error="handleFileError" :auto-upload="false" drag>
|
|
<el-icon class="el-icon--upload">
|
|
<upload-filled />
|
|
</el-icon>
|
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
<template #tip>
|
|
<div class="el-upload__tip text-center">
|
|
<span>仅允许导入xls、xlsx格式文件。</span>
|
|
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline"
|
|
@click="importTemplate">下载模板</el-link>
|
|
</div>
|
|
</template>
|
|
</el-upload>
|
|
<template #footer>
|
|
<el-button @click="upload.open = false">{{ $t('btn.cancel') }}</el-button>
|
|
<el-button type="primary" @click="submitFileForm">{{ $t('btn.submit') }}</el-button>
|
|
</template>
|
|
</el-dialog>
|
|
|
|
<!-- 查看详情 -->
|
|
<el-dialog v-model="dialogTableVisible" title="详情" width="800">
|
|
<el-table :data="gridData">
|
|
<el-table-column property="operationName" label="工艺名称" width="150" />
|
|
<el-table-column property="operationCode" label="工艺编号" width="200" />
|
|
<el-table-column property="processCode" label="工艺路线编码" />
|
|
<el-table-column property="createTime" label="创建时间" />
|
|
</el-table>
|
|
<pagination :total="detailTotail" v-model:page="queryParamsDetail.pageNum"
|
|
v-model:limit="queryParamsDetail.pageSize" @pagination="handleView" />
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup name="processInformationManagement">
|
|
import { ElMessageBox, ElMessage } from 'element-plus'
|
|
import { getProcessInfoList, getProcessInfoById, addProcessInfo, updateProcessInfo, delProcessInfo, getLineName } from "@/api/processRouteManagement/processInformationManagement/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 } 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 queryParams = reactive({
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
processCode: '',
|
|
processName: '',
|
|
})
|
|
//详情请求参数
|
|
const queryParamsDetail = reactive({
|
|
pageNum: 1,
|
|
pageSize: 20,
|
|
id: null
|
|
})
|
|
const productionLine = ref([])
|
|
const gridData = ref([])
|
|
//导入参数
|
|
const upload = reactive({
|
|
open: false,
|
|
title: '导入数据',
|
|
isUploading: false,
|
|
// updateSupport: 0,
|
|
// uploadType: 1,
|
|
headers: { Authorization: 'Bearer ' + getToken() },
|
|
url: import.meta.env.VITE_APP_BASE_API + `/business/ProcessInfo/ImportProcessInfo?userId=${userStore.userId}&userName=${userStore.userName}`
|
|
})
|
|
//文件上传中
|
|
const handleFileUploadProgress = (event, file, fileList) => {
|
|
upload.isUploading = true,
|
|
show.value = true
|
|
console.log(upload.url, '上传地址');
|
|
}
|
|
// 多选下拉
|
|
function handleSelectionChange(val) {
|
|
const selectedIds = val.map(item => item.processCode);
|
|
ids.value = selectedIds;
|
|
console.log(ids.value, 'ids.value多选下拉数据');
|
|
}
|
|
function getList() {
|
|
getProcessInfoList(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 handleFileSuccess = (response, file, fileList) => {
|
|
|
|
const { code, msg, data } = response
|
|
if (code === 500) {
|
|
proxy.$message.error('模板存在异常!')
|
|
upload.isUploading = false
|
|
proxy.$refs['uploadRef'].clearFiles()
|
|
return
|
|
}
|
|
if (data === -1) {
|
|
proxy.$message.error('模板不匹配!')
|
|
upload.isUploading = false
|
|
proxy.$refs['uploadRef'].clearFiles()
|
|
return
|
|
}
|
|
|
|
upload.open = false
|
|
show.value = false
|
|
upload.isUploading = false
|
|
proxy.$refs['uploadRef'].clearFiles()
|
|
// dialogVisibleActualAssembly.value = true
|
|
// proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + `导入成功:${data}条` + '</div>', '导入结果', {
|
|
// dangerouslyUseHTMLString: true
|
|
// })
|
|
if (code == 200) {
|
|
ElMessage({
|
|
message: '导入成功',
|
|
type: 'success',
|
|
})
|
|
getList()
|
|
}
|
|
}
|
|
/** 文件上传异常处理 */
|
|
const handleFileError = (error, file, fileList) => {
|
|
const { code, msg, data } = error.response || {}
|
|
if (error) {
|
|
proxy.$message.error('模板导入异常!')
|
|
return
|
|
}
|
|
}
|
|
//文件上传按钮
|
|
function submitFileForm() {
|
|
proxy.$refs['uploadRef'].submit()
|
|
}
|
|
// 列配置
|
|
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 handleImport() {
|
|
upload.open = true
|
|
}
|
|
//导入下载模版
|
|
/** 下载模板操作 */
|
|
function importTemplate() {
|
|
proxy.download('/mes/ProcessInfo/importTemplate', '导入模板')
|
|
}
|
|
//导出
|
|
function handleDownload() {
|
|
proxy
|
|
.$confirm('是否确定要导出数据吗?', '警告', {
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
})
|
|
.then(async () => {
|
|
await proxy.downFile('/business/ProcessInfo/export', { ...queryParams })
|
|
})
|
|
}
|
|
|
|
|
|
|
|
// 查询
|
|
function handleQuery() {
|
|
queryParams.pageNum = 1
|
|
getList()
|
|
}
|
|
|
|
// 重置查询
|
|
function resetQuery() {
|
|
proxy.resetForm('queryRef')
|
|
queryParams.processCode = null
|
|
queryParams.processName = null
|
|
queryParams.pageSize = 10
|
|
handleQuery()
|
|
}
|
|
|
|
// 自定义排序
|
|
function sortChange(column) {
|
|
// 在实际应用中实现排序逻辑
|
|
console.log('排序字段:', column.prop, '排序方式:', column.order)
|
|
}
|
|
|
|
// 表单相关
|
|
const formRef = ref()
|
|
const title = ref('')
|
|
const opertype = ref(0)
|
|
const open = ref(false)
|
|
|
|
const state = reactive({
|
|
form: {
|
|
id: null,
|
|
RoutingCode: '',
|
|
processCode: '',
|
|
processName: '',
|
|
operationSeq: null,
|
|
workCenter: '',
|
|
standardTime: null,
|
|
description: ''
|
|
},
|
|
rules: {
|
|
processCode: [{ required: true, message: '工艺编码不能为空', trigger: 'blur' }],
|
|
processName: [{ required: true, message: '工艺名称不能为空', trigger: 'blur' }],
|
|
lineName: [{ required: true, message: '产线名称不能为空', trigger: 'blur' }],
|
|
lineCode: [{ required: true, message: '产线号不能为空', trigger: 'blur' }],
|
|
operationSeq: [
|
|
{ required: true, message: '工艺顺序号不能为空', trigger: 'blur' },
|
|
{ type: 'number', message: '工艺顺序号必须为数字', trigger: 'blur' }
|
|
],
|
|
standardTime: [
|
|
{ required: true, message: '标准工时不能为空', trigger: 'blur' },
|
|
{ type: 'number', message: '标准工时必须为数字', trigger: 'blur' }
|
|
]
|
|
}
|
|
})
|
|
|
|
const { form, rules } = toRefs(state)
|
|
|
|
// 关闭弹窗
|
|
function cancel() {
|
|
open.value = false
|
|
reset()
|
|
}
|
|
|
|
// 重置表单
|
|
function reset() {
|
|
form.value = {
|
|
id: null,
|
|
RoutingCode: '',
|
|
processCode: '',
|
|
processName: '',
|
|
operationSeq: null,
|
|
workCenter: '',
|
|
standardTime: null,
|
|
description: ''
|
|
}
|
|
proxy.resetForm('formRef')
|
|
}
|
|
|
|
// 添加工艺
|
|
function handleAdd() {
|
|
getLineName().then(res => {
|
|
if (res.code == 200) {
|
|
productionLine.value = res.data
|
|
}
|
|
})
|
|
reset()
|
|
open.value = true
|
|
title.value = '添加工艺'
|
|
opertype.value = 1
|
|
}
|
|
//查看详情
|
|
function handleView(val) {
|
|
dialogTableVisible.value = true
|
|
let data = {
|
|
processCode: val.processCode,
|
|
pageNum: queryParamsDetail.pageNum,
|
|
pageSize: queryParamsDetail.pageSize
|
|
}
|
|
getProcessInfoById(data).then(res => {
|
|
if (res.code == 200) {
|
|
gridData.value = res.data.result,
|
|
detailTotail.value = res.data.totalNum
|
|
}
|
|
})
|
|
}
|
|
// 修改工艺
|
|
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) {
|
|
updateProcessInfo(data).then(res => {
|
|
if (res.code == 200) {
|
|
ElMessage({
|
|
message: '修改成功',
|
|
type: 'success',
|
|
})
|
|
getList()
|
|
}
|
|
})
|
|
} else {
|
|
addProcessInfo(data).then(res => {
|
|
if (res.code == 200) {
|
|
ElMessage({
|
|
message: '新增成功',
|
|
type: 'success',
|
|
})
|
|
}
|
|
getList()
|
|
})
|
|
}
|
|
open.value = false
|
|
|
|
}
|
|
})
|
|
}
|
|
|
|
function handleDeletes() {
|
|
if (ids.value.length === 0) {
|
|
ElMessage({
|
|
message: '请至少选择一条记录进行删除',
|
|
type: 'warning',
|
|
});
|
|
return;
|
|
}
|
|
delProcessInfo(ids.value).then(res => {
|
|
if (res.code == 200) {
|
|
ElMessage({
|
|
message: '删除成功',
|
|
type: 'success',
|
|
})
|
|
getList()
|
|
}
|
|
})
|
|
}
|
|
// 删除工艺
|
|
function handleDelete(row) {
|
|
proxy.$confirm(
|
|
'确认删除该条数据吗?',
|
|
'提示',
|
|
{ confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }
|
|
).then(() => {
|
|
delProcessInfo([row.processCode]).then(res => {
|
|
if (res.code === 200) {
|
|
ElMessage({ message: '删除成功', type: 'success' });
|
|
getList();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
// 树节点选择
|
|
function handlerTreeSelected(id) {
|
|
queryParams.RoutingCode = id
|
|
handleQuery()
|
|
}
|
|
|
|
// 初始化加载数据
|
|
getList()
|
|
</script> |