编写工段 工位 设备 派工页面

This commit is contained in:
shaoleiliu-netizen123 2026-07-08 10:43:59 +08:00
parent 96bc1b4e9d
commit 826d22e358
13 changed files with 1760 additions and 25 deletions

81
src/api/device.ts Normal file
View File

@ -0,0 +1,81 @@
import { request} from '@/utils/request'
import { update } from 'three/examples/jsm/libs/tween.module.js'
export interface Device{
id:number,
deviceCode:string,
deviceName:string,
deviceTypeId:number,
deviceType:string,
sectionId:number,
spec:string,
manufacturer:string,
manufactureDate:string,
workshopId:number,
remark:string,
status:number,
createTime:string,
updateTime:string
}
export const deviceApi = {
page(params:{
page:number,
pageSize:number,
deviceCode:any
}) {
return request({
url:"/biz/device/page",
method:"get",
params
})
},
create(data:Device) {
return request({
url:"/biz/device",
method:"post",
data
})
},
update(data:Device) {
return request({
url:"/biz/device",
method:"put",
data
})
},
list(sectionId:number) {
return request({
url:`/biz/device/list/${sectionId}`,
method:"get"
})
},
delete(ids:any) {
return request({
url:`/biz/device/${ids.join(",")}`,
method:"delete"
})
},
export(
params?:{
ids?:string[],
deviceCode:any
}){
const p:Record<string,any> = {}
if(params?.ids?.length) p.ids = params.ids.join(',')
if(params?.deviceCode != undefined && params?.deviceCode !== null) p.sectionCode = params.deviceCode
return request({
url:`/biz/device/report`,
method:"get",
params:p,
responseType:"blob"
})
}
}

View File

@ -45,7 +45,7 @@ export const plmModelApi = {
url: '/biz/plm/model/preview', url: '/biz/plm/model/preview',
method: 'get', method: 'get',
params, params,
timeout: 360000, timeout: 600000,
}) })
}, },
} }

78
src/api/section.ts Normal file
View File

@ -0,0 +1,78 @@
import { request } from '@/utils/request'
import { st } from 'vue-router/dist/router-CWoNjPRp.mjs'
export interface Section{
id?: number,
sectionCode?: string,
sectionName?: string,
workshopId?: number,
createTime?:string,
updateTime?:string,
status?:number,
remark?:string
}
export const sectionApi = {
page(params:{
page:number,
pageSize:number,
sectionName:any,
sectionCode:any
}){
return request({
url:"biz/section/page",
method:"get",
params
})
},
create(data:Section){
return request({
url:"biz/section/add",
method:"post",
data
})
},
update(data:Section) {
return request({
url:"biz/section/update",
method:"put",
data
})
},
delete(ids:any) {
return request({
url:`/biz/section/${ids.join(",")}`,
method:"delete"
})
},
export(params?:{
ids?: string[],
sectionCode:any,
sectionName:any
}) {
const p:Record<string,any> = {}
if(params?.ids?.length) p.ids = params.ids.join(',')
if(params?.sectionCode != undefined && params?.sectionCode !== null) p.sectionCode = params.sectionCode
if(params?.sectionName != undefined && params?.sectionName !== null) p.sectionName = params.sectionName
return request({
url:`/biz/section/export`,
method:"get",
params:p,
responseType:'blob'
})
},
list() {
return request({
url:"/biz/section/list",
method:"get"
})
}
}

69
src/api/station.ts Normal file
View File

@ -0,0 +1,69 @@
import { request } from "@/utils/request";
import { update } from "three/examples/jsm/libs/tween.module.js";
export interface Station{
id?: number,
stationCode?:string,
stationName?:string,
workshopId?:number,
sectionId?:number,
remark?:string,
status?:number,
createTime?:string,
updateTime?:string
}
export const stationApi = {
page(params:{
page:number,
pageSize:number,
stationCode:any
}){
return request({
url:"biz/station/page",
method:"get",
params
})
},
create(data:Station){
return request({
url:"biz/station/add",
method:"post",
data
})
},
update(data:Station) {
return request({
url:"biz/station/update",
method:"put",
data
})
},
delete(ids:any) {
return request({
url:`/biz/station/${ids.join(",")}`,
method:"delete"
})
},
export(params?:{
ids?:string[],
stationCode:any
}){
const p:Record<string,any> = {}
if(params?.ids?.length) p.ids = params.ids.join(",")
if(params?.stationCode != undefined && params?.stationCode !== null)
console.log(params);
console.log(1111);
return request({
url:`/biz/station/export`,
method:"get",
params:p,
responseType:"blob"
})
}
}

View File

@ -8,6 +8,13 @@
<div class="cad-model-viewer__toolbar"> <div class="cad-model-viewer__toolbar">
<n-button size="tiny" quaternary @click="resetView">复位</n-button> <n-button size="tiny" quaternary @click="resetView">复位</n-button>
<n-button size="tiny" quaternary v-if="glbDownloadUrl" @click="openSelectFolderDownload(glbDownloadUrl)">
下载GLB文件
</n-button>
<n-button size="tiny" quaternary v-if="stpDownloadUrl" @click="openSelectFolderDownload(stpDownloadUrl)">
下载源文件
</n-button>
</div> </div>
</div> </div>
</template> </template>
@ -24,6 +31,12 @@ const props = defineProps({
modelUrl: { modelUrl: {
type: String, type: String,
}, },
glbDownloadUrl:{
type: String
},
stpDownloadUrl:{
type: String
},
width: { width: {
type: String, type: String,
default: '100%' default: '100%'
@ -197,6 +210,21 @@ const loadModel = () => {
console.log('✅ 成功进入解析回调,开始处理模型') console.log('✅ 成功进入解析回调,开始处理模型')
loading.value = false loading.value = false
const model = gltf.scene const model = gltf.scene
// model.traverse((obj) => {
// if (obj.isMesh) {
// //
// if(obj.name.includes("platform")){
// obj.material = new THREE.MeshStandardMaterial({color:0xaaaaaa, metalness:0.2, roughness:0.7})
// }else if(obj.name.includes("scissor")){
// obj.material = new THREE.MeshStandardMaterial({color:0x666666, metalness:0.3, roughness:0.6})
// }else if(obj.name.includes("motor")){
// obj.material = new THREE.MeshStandardMaterial({color:0x333333, metalness:0.5, roughness:0.4})
// }else{
// obj.material = new THREE.MeshStandardMaterial({color:0x888888})
// }
// obj.material.needsUpdate = true
// }
// })
currentModel = model currentModel = model
fitModelToView(model) fitModelToView(model)
scene.add(model) scene.add(model)
@ -241,6 +269,33 @@ function resetView() {
} }
async function openSelectFolderDownload(url) {
if(!url) return alert('暂无可下载的文件,请先完成模型转换')
try{
const dirHandle = await window.showDirectoryPicker()
const res = await fetch(url)
const blob = await res.blob()
const urlParams = new URLSearchParams(url.split("?")[1])
const materialCode = urlParams.get('materialCode')
const suffix = urlParams.get("suffix")
const fileName = `${materialCode}.${suffix}`
const fileHandle = await dirHandle.getFileHandle(fileName,{create:true})
const writable = await fileHandle.createWritable()
await writable.write(blob)
await writable.close()
alert(`保存成功!文件已写入你选中的文件夹:${fileName}`)
}catch(err) {
console.log('文件夹选择取消/浏览器不支持,降级普通下载', err)
window.open(url, '_blank')
}
}
watch(() => props.modelUrl, (newVal) => newVal && loadModel(), { immediate: true }) watch(() => props.modelUrl, (newVal) => newVal && loadModel(), { immediate: true })
onMounted(() => { onMounted(() => {

View File

@ -14,7 +14,11 @@
<n-text depth="3">首次查看可能需要 30 数分钟</n-text> <n-text depth="3">首次查看可能需要 30 数分钟</n-text>
</div> </div>
<CadModelViewer v-else-if="previewUrl" :modelUrl="previewUrl" class="plm-model-drawer__viewer" /> <CadModelViewer v-else-if="previewUrl"
:modelUrl="previewUrl"
:glbDownloadUrl ="glbDownloadUrl"
:stpDownloadUrl = "stpDownloadUrl"
class="plm-model-drawer__viewer" />
<n-result <n-result
v-else-if="error" v-else-if="error"
@ -44,6 +48,8 @@ const visible = ref(false)
const loading = ref(false) const loading = ref(false)
const converting = ref(false) const converting = ref(false)
const previewUrl = ref('') const previewUrl = ref('')
const glbDownloadUrl = ref('')
const stpDownloadUrl = ref('')
const error = ref('') const error = ref('')
const context = ref<PlmModelOpenContext>({}) const context = ref<PlmModelOpenContext>({})
const resultMeta = ref<PlmModelPreviewResult | null>(null) const resultMeta = ref<PlmModelPreviewResult | null>(null)
@ -105,6 +111,8 @@ async function open(ctx: PlmModelOpenContext) {
if (res.status === 'ready' && res.previewUrl) { if (res.status === 'ready' && res.previewUrl) {
previewUrl.value = res.previewUrl previewUrl.value = res.previewUrl
glbDownloadUrl.value = res.glbDownloadUrl
stpDownloadUrl.value = res.stpDownloadUrl
} else { } else {
error.value = res.message || (res.status === 'not_found' ? '未找到该物料的三维模型' : '模型预览失败') error.value = res.message || (res.status === 'not_found' ? '未找到该物料的三维模型' : '模型预览失败')
} }

View File

@ -0,0 +1,459 @@
<template>
<div class="page-container">
<n-card>
<!-- 搜索表单 -->
<div class="search-form">
<n-form inline :model="searchForm" label-placement="left">
<n-form-item label="主键ID">
<n-input v-model:value="searchForm.deviceCode" placeholder="请输入设备编码" clearable />
</n-form-item>
<n-form-item>
<n-space>
<n-button type="primary" @click="handleSearch">
<template #icon><n-icon><SearchOutline /></n-icon></template>
搜索
</n-button>
<n-button @click="handleReset">
<template #icon><n-icon><RefreshOutline /></n-icon></template>
重置
</n-button>
</n-space>
</n-form-item>
</n-form>
</div>
<!-- 工具栏 -->
<div class="table-toolbar">
<n-space>
<n-button type="primary" @click="handleAdd">
<template #icon><n-icon><AddOutline /></n-icon></template>
新增设备
</n-button>
<!-- <n-button @click="importModalVisible = true">
<template #icon><n-icon><CloudUploadOutline /></n-icon></template>
导入
</n-button> -->
<n-button @click="handleExport">
<template #icon><n-icon><DownloadOutline /></n-icon></template>
导出{{ selectedIds.length > 0 ? `(${selectedIds.length})` : '' }}
</n-button>
<n-button type="error" :disabled="selectedIds.length === 0" @click="handleBatchDelete">
<template #icon><n-icon><TrashOutline /></n-icon></template>
删除
</n-button>
</n-space>
</div>
<!-- 表格 -->
<n-data-table
:columns="columns"
:data="tableData"
:loading="loading"
:pagination="pagination"
:row-key="(row) => row.id"
:scroll-x="1200"
@update:page="handlePageChange"
@update:page-size="handlePageSizeChange"
@update:checked-row-keys="handleCheck"
/>
</n-card>
<!-- 新增/编辑弹窗 -->
<n-modal v-model:show="modalVisible" preset="card" :title="modalTitle" style="width: 600px">
<n-form ref="formRef" :model="formData" :rules="formRules" label-placement="left" label-width="100px">
<n-form-item label="设备名称" path="deviceName">
<n-input v-model:value="formData.deviceName" placeholder="请输入设备名称" />
</n-form-item>
<n-form-item label="设备类型" path="deviceTypeId">
<n-select
v-model:value="formData.deviceTypeId"
:options="deviceTypeList"
placeholder="请选择设备类型"
clearable
style="width: 200px"
/>
</n-form-item>
<n-form-item label="所属工段" path="sectionId">
<n-select
v-model:value="formData.sectionId"
:options="sectionList"
placeholder="请选择所属工段"
clearable
style="width: 200px"
/>
</n-form-item>
<n-form-item label="设备规格型号" path="spec">
<n-input v-model:value="formData.spec" placeholder="请输入设备规格型号" />
</n-form-item>
<n-form-item label="生产厂家" path="manufacturer">
<n-input v-model:value="formData.manufacturer" placeholder="请输入生产厂家" />
</n-form-item>
<n-form-item label="出厂日期" path="manufactureDate">
<n-date-picker v-model:value="formData.manufactureDate" type="datetime" clearable style="width: 100%" />
</n-form-item>
<n-form-item label="备注" path="remark">
<n-input v-model:value="formData.remark" type="textarea" placeholder="请输入备注" />
</n-form-item>
<n-form-item label="状态" path="status">
<n-switch v-model:value="formData.status" :checked-value="1" :unchecked-value="0">
<template #checked>启用</template>
<template #unchecked>禁用</template>
</n-switch>
</n-form-item>
</n-form>
<template #footer>
<n-space justify="end">
<n-button @click="modalVisible = false">取消</n-button>
<n-button type="primary" @click="handleSubmit">确定</n-button>
</n-space>
</template>
</n-modal>
<!-- 导入弹窗 -->
<n-modal v-model:show="importModalVisible" preset="card" title="导入设备表" style="width: 500px">
<n-space vertical>
<n-alert type="info">
<template #header>导入说明</template>
<ul style="margin: 0; padding-left: 16px; line-height: 1.8">
<li>请先下载导入模板按模板格式填写数据</li>
<li>支持 .xlsx .xls 格式</li>
</ul>
</n-alert>
<n-space>
<n-button type="primary" @click="handleDownloadTemplate">
<template #icon><n-icon><DownloadOutline /></n-icon></template>
下载模板
</n-button>
</n-space>
<n-upload :max="1" accept=".xlsx,.xls" :show-file-list="true" :custom-request="handleImportUpload">
<n-upload-dragger>
<div style="margin-bottom: 12px">
<n-icon size="48" :depth="3"><CloudUploadOutline /></n-icon>
</div>
<n-text style="font-size: 16px">点击或拖拽文件到此处上传</n-text>
<n-p depth="3" style="margin: 8px 0 0 0">支持 .xlsx .xls 格式</n-p>
</n-upload-dragger>
</n-upload>
</n-space>
<template #footer>
<n-button @click="importModalVisible = false">关闭</n-button>
</template>
</n-modal>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, h, onMounted } from 'vue'
import { NButton, NSpace,NTag, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions } from 'naive-ui'
import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5'
import { deviceApi, type Device } from '@/api/device'
import { stationApi, type Station } from '@/api/station'
import { dictDataApi } from '@/api/org'
import {sectionApi, type Section} from '@/api/section'
const message = useMessage()
const dialog = useDialog()
let sectionList = reactive<{label:string,value:any}[]>([])
//
const searchForm = reactive({
deviceCode: null as number | null,
})
//
const tableData = ref<Device[]>([])
const loading = ref(false)
const selectedIds = ref<number[]>([])
const pagination = reactive({
page: 1,
pageSize: 10,
itemCount: 0,
showSizePicker: true,
pageSizes: [10, 20, 50]
})
//
const modalVisible = ref(false)
const modalTitle = ref('')
const importModalVisible = ref(false)
const formRef = ref()
const defaultFormData: Device = {
id:"",
deviceCode: '',
deviceName: '',
deviceTypeId: undefined,
deviceType:"",
sectionId: "",
sectionName:"",
spec: '',
manufacturer: '',
manufactureDate: undefined,
workshopId: '',
remark: '',
status:''
}
const formData = reactive<Device>({ ...defaultFormData })
// //使
const deviceTypeList = ref<{ label: string; value: any ;class:any}[]>([])
const statusList = ref<{ label: string; value: any ;class:any}[]>([])
//
const formRules = {
}
//
const columns: DataTableColumns<Device> = [
{ type: 'selection' },
{ title: '设备编码', key: 'deviceCode' },
{ title: '设备名称', key: 'deviceName' },
{ title: '设备类型', key: 'deviceType' },
{ title: '所属工段', key: 'sectionName' },
{ title: '设备型号', key: 'spec' },
{ title: '生产厂家', key: 'manufacturer' },
{ title: '出厂日期', key: 'manufactureDate' },
{ title: '状态', key: 'status',
render:(row) =>{
const val = row.status
const opt = statusList.value.find(o => o.value === val || String(o.value) === String(val))
if (!opt) return val ?? '-'
return h(NTag, { type: opt.class, size: 'small' }, { default: () => opt.label })
}
},
{
title: '操作',
key: 'actions',
width: 140,
fixed: 'right',
render(row) {
return h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'nowrap' } }, [
h(NButton, { size: 'small', quaternary: true, onClick: () => handleEdit(row) }, {
default: () => [h(NIcon, null, { default: () => h(CreateOutline) }), ' 编辑']
}),
h(NButton, { size: 'small', quaternary: true, type: 'error', onClick: () => handleDelete(row) }, {
default: () => [h(NIcon, null, { default: () => h(TrashOutline) }), ' 删除']
})
])
}
}
]
//
async function loadData() {
loading.value = true
try {
const res = await deviceApi.page({
page: pagination.page,
pageSize: pagination.pageSize,
deviceCode:searchForm.deviceCode
})
tableData.value = res.list
pagination.itemCount = res.total
} finally {
loading.value = false
}
}
//
function handleSearch() {
pagination.page = 1
loadData()
}
//
function handleReset() {
searchForm.deviceCode = null
handleSearch()
}
//
function handlePageChange(page: number) {
pagination.page = page
loadData()
}
function handlePageSizeChange(pageSize: number) {
pagination.pageSize = pageSize
pagination.page = 1
loadData()
}
//
function handleCheck(keys: Array<string | number>) {
selectedIds.value = keys as number[]
}
//
function handleAdd() {
modalTitle.value = '新增设备表'
Object.assign(formData, defaultFormData)
modalVisible.value = true
}
//
function handleEdit(row: Device) {
modalTitle.value = '编辑设备表'
console.log(row);
Object.assign(formData, row)
if (formData.manufactureDate && typeof formData.manufactureDate === 'string') {
formData.manufactureDate = new Date(formData.manufactureDate.replace(' ', 'T')).getTime()
}
modalVisible.value = true
}
//
async function handleSubmit() {
await formRef.value?.validate()
try {
const submitData = { ...formData } as Device
if (typeof submitData.manufactureDate === 'number') {
submitData.manufactureDate = new Date(submitData.manufactureDate).toISOString().slice(0, 19).replace('T', ' ')
}
if (submitData.id) {
await deviceApi.update(submitData)
message.success('修改成功')
} else {
await deviceApi.create(submitData)
message.success('新增成功')
}
modalVisible.value = false
loadData()
} catch (error) {
//
}
}
//
function handleDelete(row: Device) {
dialog.warning({
title: '提示',
content: '确定要删除该记录吗?',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
try {
await deviceApi.delete([row.id!])
message.success('删除成功')
loadData()
} catch (error) {
//
}
}
})
}
//
function handleBatchDelete() {
dialog.warning({
title: '提示',
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
try {
await deviceApi.delete(selectedIds.value)
message.success('删除成功')
selectedIds.value = []
loadData()
} catch (error) {
//
}
}
})
}
//
async function handleExport() {
try {
const params: Record<string, any> = {}
if (selectedIds.value.length > 0) params.ids = selectedIds.value
if (searchForm.deviceCode != null) params.deviceCode = searchForm.deviceCode
const blob = await deviceApi.export(params)
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '设备表数据.xlsx'
link.click()
window.URL.revokeObjectURL(url)
} catch (error) {
//
}
}
//
async function handleDownloadTemplate() {
try {
const blob = await deviceApi.downloadTemplate()
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '设备表导入模板.xlsx'
link.click()
window.URL.revokeObjectURL(url)
} catch (error) {
//
}
}
//
async function handleImportUpload({ file }: UploadCustomRequestOptions) {
if (!file.file) return
try {
const result = await deviceApi.importData(file.file)
if (result.fail > 0) {
dialog.warning({
title: '导入结果',
content: `成功: ${result.success} 条,失败: ${result.fail}\n错误信息: ${(result.errors || []).join('\n') || '无'}`,
positiveText: '确定'
})
} else {
message.success(`导入成功,共 ${result.success} 条数据`)
importModalVisible.value = false
}
loadData()
} catch (error) {
//
}
}
//
async function loadDictOptions() {
try {
const data = await dictDataApi.listByType("device_type")
deviceTypeList.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue),class:d.listClass }))
}catch {}
try {
const data = await dictDataApi.listByType("sys_status")
statusList.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue),class:d.listClass }))
}catch {}
}
//
async function loadSection() {
const data = await sectionApi.list()
sectionList = data.map((d:any)=> ({ label: d.sectionName, value: (Number(d.id) || d.id) }))
}
onMounted(() => {
loadData()
loadSection()
loadDictOptions()
})
</script>
<style scoped>
.search-form {
margin-bottom: 16px;
}
.table-toolbar {
margin-bottom: 16px;
}
</style>

View File

@ -265,29 +265,36 @@
</n-modal> </n-modal>
<!-- 派工 --> <!-- 派工 -->
<n-modal v-model:show="dispatchmodal" title="派工" preset="card" style="width: 800px" :mask-closable="false"> <n-modal v-model:show="dispatchmodal" title="工序派工" preset="card" style="width: 800px" :mask-closable="false">
<n-form ref="dispatchformRef" :model="dispatchform" label-placement="left" :rules="dispatchrules" label-width="80"> <n-divider />
<n-card>
<n-grid :cols="2"> <n-grid :cols="2">
<n-gi> <n-gi>
<n-form-item label="工序名称"> <span class="pgClass">当前工序</span>
<n-input v-model:value="dispatchform.name" disabled /> <span>{{dispatchform.name}}</span>
</n-form-item>
</n-gi> </n-gi>
<n-gi>
<span class="pgClass">计划数量</span>
<span>{{dispatchform.quantity}}</span>
</n-gi>
</n-grid>
<n-grid :cols="2">
<n-gi> <n-gi>
<n-form-item label="生产数量"> <span class="pgClass">开始时间</span>
<n-input v-model:value="dispatchform.quantity" disabled /> <span>{{dispatchform.beginTime}}</span>
</n-form-item>
</n-gi> </n-gi>
<n-gi> <n-gi>
<n-form-item label="开始时间"> <span class="pgClass">结束时间</span>
<n-input v-model:value="dispatchform.beginTime" disabled /> <span>{{dispatchform.endTime}}</span>
</n-form-item>
</n-gi>
<n-gi>
<n-form-item label="结束时间">
<n-input v-model:value="dispatchform.endTime" disabled />
</n-form-item>
</n-gi> </n-gi>
</n-grid>
</n-card>
<n-form ref="dispatchformRef" :model="dispatchform"
label-placement="left"
:rules="dispatchrules"
style="margin-top: 10px;"
label-width="80">
<n-grid :cols="2">
<n-gi :span="24"> <n-gi :span="24">
<Pgitem <Pgitem
v-for="(n, i) in dispatchform.list" v-for="(n, i) in dispatchform.list"
@ -395,7 +402,7 @@ const dispatchLoading = ref(false)
const dispatchformRef = ref() const dispatchformRef = ref()
const dispatchform = reactive<any>({ const dispatchform = reactive<any>({
id: '', name: '', beginTime: '', endTime: '', quantity: '', id: '', name: '', beginTime: '', endTime: '', quantity: '',
list: [{ userId: '', quantity: '' }], list: [{ sectionId:'',deviceId:'',userId: '', quantity: '' }],
}) })
const dispatchrules = {} const dispatchrules = {}
@ -599,11 +606,11 @@ function disphand(process: ProcessPlanItemVO, order?: OrderProcessPlanVO) {
dispatchform.beginTime = entity.beginTime dispatchform.beginTime = entity.beginTime
dispatchform.endTime = entity.endTime dispatchform.endTime = entity.endTime
dispatchform.quantity = entity.quantity dispatchform.quantity = entity.quantity
dispatchform.list = [{ userId: '', quantity: '' }] dispatchform.list = [{ sectionId:'',deviceId:'',userId: '', quantity: '' }]
} }
function addpgnum() { function addpgnum() {
dispatchform.list.push({ userId: '', quantity: '' }) dispatchform.list.push({ sectionId:'',deviceId:'',userId: '', quantity: '' })
} }
function deletenum(index: number) { function deletenum(index: number) {
@ -866,4 +873,7 @@ onMounted(loadData)
background: #fff; background: #fff;
border-radius: 0 0 8px 8px; border-radius: 0 0 8px 8px;
} }
.pgClass {
font-weight: bold;
}
</style> </style>

View File

@ -1,8 +1,58 @@
<template> <template>
<n-grid> <div>
<n-grid>
<n-gi :span="10">
<n-form-item
label="指派工段"
:path="`${listname}[${index}].sectionId`"
:rule="{
required:true,
message:`请选择工段`,
trigger: 'blur'
}"
>
<n-select
v-model:value="obj.sectionId"
filterable
placeholder="请选择工段"
:options="sectionList"
:loading="loadingRef"
clearable
remote
:clear-filter-after-select="false"
@change="searchSection"
/>
</n-form-item>
</n-gi>
<n-gi :span="10">
<n-form-item
label="指派工位"
:path="`${listname}[${index}].deviceId`"
:rule="{
required:true,
message:`请选择工位`,
trigger: 'blur'
}"
>
<n-select
v-model:value="obj.deviceId"
filterable
placeholder="请选择工位"
:options="deviceList"
:loading="loadingRef"
clearable
remote
:clear-filter-after-select="false"
/>
</n-form-item>
</n-gi>
</n-grid>
<n-grid>
<n-gi :span="10"> <n-gi :span="10">
<n-form-item <n-form-item
label="指派员工" label="分配人员"
:path="`${listname}[${index}].userId`" :path="`${listname}[${index}].userId`"
:rule="{ :rule="{
required: true, required: true,
@ -57,15 +107,23 @@
</n-icon> </n-icon>
</n-gi> </n-gi>
</n-grid> </n-grid>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { ref,reactive, watch } from 'vue'
import { userApi } from '@/api/system' import { userApi } from '@/api/system'
import {deviceApi} from '@/api/device'
import {sectionApi, type Section} from '@/api/section'
import { import {
AddOutline, AddOutline,
TrashOutline, TrashOutline,
} from '@vicons/ionicons5' } from '@vicons/ionicons5'
import { any, label } from 'three/tsl';
import { Value } from 'three/examples/jsm/inspector/ui/Values.js';
import { bind } from 'echarts/types/src/export/api/util.js'
import { number } from 'echarts'
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
listname:any listname:any
obj:any, obj:any,
@ -79,6 +137,8 @@
update: [index:any,obj:any] update: [index:any,obj:any]
}>() }>()
// function updatehand() { // function updatehand() {
// emit('update') // emit('update')
// } // }
@ -90,10 +150,14 @@
emit('delehand',index) emit('delehand',index)
} }
let sectionList = reactive<{label:string,value:any}[]>([])
let yglist = ref<any>([]) let yglist = ref<any>([])
let loadingRef = ref(false) let loadingRef = ref(false)
let deviceList = ref<any>([])
function slehand(v?:any) { function slehand(v?:any) {
loadingRef.value = true loadingRef.value = true
yglist.value.splice(0) yglist.value.splice(0)
@ -121,5 +185,33 @@
}) })
} }
//
async function loadSection() {
const data = await sectionApi.list()
sectionList =data.map((d:any)=>{
return {
label:d.sectionName,
value:d.id+''
}
})
}
function searchSection(sectionId?:number){
if(!sectionId) return
props.obj.deviceId = ''
deviceList.value = []
deviceApi.list(sectionId).then(res=>{
deviceList.value = res.map((n:any)=>{
return {
label:n.name,
value:n.id+''
}
})
})
}
loadSection()
slehand() slehand()
// handleDevice()
</script> </script>

View File

@ -0,0 +1,431 @@
<template>
<div class="page-container">
<n-card>
<!-- 搜索表单 -->
<div class="search-form">
<n-form inline :model="searchForm" label-placement="left">
<n-form-item label="工段编号">
<n-input v-model:value="searchForm.sectionCode" placeholder="请输入工段编号" clearable />
</n-form-item>
<n-form-item label="工段名称">
<n-input v-model:value="searchForm.sectionName" placeholder="请输入工段名称" clearable />
</n-form-item>
<n-form-item>
<n-space>
<n-button type="primary" @click="handleSearch">
<template #icon><n-icon><SearchOutline /></n-icon></template>
搜索
</n-button>
<n-button @click="handleReset">
<template #icon><n-icon><RefreshOutline /></n-icon></template>
重置
</n-button>
</n-space>
</n-form-item>
</n-form>
</div>
<!-- 工具栏 -->
<div class="table-toolbar">
<n-space>
<n-button type="primary" @click="handleAdd">
<template #icon><n-icon><AddOutline /></n-icon></template>
新增
</n-button>
<!-- <n-button @click="importModalVisible = true">
<template #icon><n-icon><CloudUploadOutline /></n-icon></template>
导入
</n-button> -->
<n-button @click="handleExport">
<template #icon><n-icon><DownloadOutline /></n-icon></template>
导出{{ selectedIds.length > 0 ? `(${selectedIds.length})` : '' }}
</n-button>
<n-button type="error" :disabled="selectedIds.length === 0" @click="handleBatchDelete">
<template #icon><n-icon><TrashOutline /></n-icon></template>
删除
</n-button>
</n-space>
</div>
<!-- 表格 -->
<n-data-table
:columns="columns"
:data="tableData"
:loading="loading"
:pagination="pagination"
:row-key="(row) => row.id"
:scroll-x="1200"
@update:page="handlePageChange"
@update:page-size="handlePageSizeChange"
@update:checked-row-keys="handleCheck"
/>
</n-card>
<!-- 新增/编辑弹窗 -->
<n-modal v-model:show="modalVisible" preset="card" :title="modalTitle" style="width: 600px">
<n-form ref="formRef" :model="formData" :rules="formRules" label-placement="left" label-width="100px">
<n-form-item label="工段名称" path="sectionName">
<n-input v-model:value="formData.sectionName" placeholder="请输入工段名称" />
</n-form-item>
<n-form-item label="所属车间" path="workshopId">
<n-select
v-model:value="formData.workshopId"
:options="workshopList"
placeholder="请选择所属车间"
clearable
style="width: 200px"
/>
</n-form-item>
<n-form-item label="备注" path="remark">
<n-input v-model:value="formData.remark" type="textarea" placeholder="请输入备注" />
</n-form-item>
<n-form-item label="状态" path="status">
<n-switch v-model:value="formData.status" :checked-value="1" :unchecked-value="0">
<template #checked>启用</template>
<template #unchecked>禁用</template>
</n-switch>
</n-form-item>
</n-form>
<template #footer>
<n-space justify="end">
<n-button @click="modalVisible = false">取消</n-button>
<n-button type="primary" @click="handleSubmit">确定</n-button>
</n-space>
</template>
</n-modal>
<!-- 导入弹窗 -->
<n-modal v-model:show="importModalVisible" preset="card" title="导入工段表" style="width: 500px">
<n-space vertical>
<n-alert type="info">
<template #header>导入说明</template>
<ul style="margin: 0; padding-left: 16px; line-height: 1.8">
<li>请先下载导入模板按模板格式填写数据</li>
<li>支持 .xlsx .xls 格式</li>
</ul>
</n-alert>
<n-space>
<n-button type="primary" @click="handleDownloadTemplate">
<template #icon><n-icon><DownloadOutline /></n-icon></template>
下载模板
</n-button>
</n-space>
<n-upload :max="1" accept=".xlsx,.xls" :show-file-list="true" :custom-request="handleImportUpload">
<n-upload-dragger>
<div style="margin-bottom: 12px">
<n-icon size="48" :depth="3"><CloudUploadOutline /></n-icon>
</div>
<n-text style="font-size: 16px">点击或拖拽文件到此处上传</n-text>
<n-p depth="3" style="margin: 8px 0 0 0">支持 .xlsx .xls 格式</n-p>
</n-upload-dragger>
</n-upload>
</n-space>
<template #footer>
<n-button @click="importModalVisible = false">关闭</n-button>
</template>
</n-modal>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, h, onMounted } from 'vue'
import { NButton, NSpace,NTag, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions } from 'naive-ui'
import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5'
import { sectionApi, type Section } from '@/api/section'
import { dictDataApi } from '@/api/org'
const message = useMessage()
const dialog = useDialog()
//
const searchForm = reactive({
sectionCode: null as string | null,
sectionName: null as string | null
})
//
const tableData = ref<Section[]>([])
const loading = ref(false)
const selectedIds = ref<number[]>([])
const pagination = reactive({
page: 1,
pageSize: 10,
itemCount: 0,
showSizePicker: true,
pageSizes: [10, 20, 50]
})
//
const modalVisible = ref(false)
const modalTitle = ref('')
const importModalVisible = ref(false)
const formRef = ref()
const defaultFormData: Section = {
id:'',
remark:'',
sectionCode: '',
sectionName: '',
workshopId: undefined,
status:''
}
const formData = reactive<Section>({ ...defaultFormData })
// //使
const workshopList = ref<{ label: string; value: any ;class:any}[]>([])
const statusList = ref<{ label: string; value: any ;class:any}[]>([])
//
const formRules = {
}
//
const columns: DataTableColumns<Section> = [
{ type: 'selection' },
{ title: '工段编码', key: 'sectionCode',width:180 },
{ title: '工段名称', key: 'sectionName',minWidth:150 },
{ title: '所属车间', key: 'workshopId',
render: (row) => {
const val = row.workshopId
const opt = workshopList.value.find(o => o.value === val || String(o.value) === String(val))
if (!opt) return val ?? '-'
return h(NTag, { type: opt.class, size: 'small' }, { default: () => opt.label })
}
},
{ title: '备注', key: 'remark',
render:(row)=>{
const val = row.remark
return val
}
},
{ title: '状态', key: 'status',
render:(row) =>{
const val = row.status
const opt = statusList.value.find(o => o.value === val || String(o.value) === String(val))
if (!opt) return val ?? '-'
return h(NTag, { type: opt.class, size: 'small' }, { default: () => opt.label })
}
},
{title:"创建时间",key:"createTime"},
{
title: '操作',
key: 'actions',
width: 140,
fixed: 'right',
render(row) {
return h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'nowrap' } }, [
h(NButton, { size: 'small', quaternary: true, onClick: () => handleEdit(row) }, {
default: () => [h(NIcon, null, { default: () => h(CreateOutline) }), ' 编辑']
}),
h(NButton, { size: 'small', quaternary: true, type: 'error', onClick: () => handleDelete(row) }, {
default: () => [h(NIcon, null, { default: () => h(TrashOutline) }), ' 删除']
})
])
}
}
]
//
async function loadData() {
loading.value = true
try {
const res = await sectionApi.page({
page: pagination.page,
pageSize: pagination.pageSize,
sectionName:searchForm.sectionName,
sectionCode:searchForm.sectionCode
})
tableData.value = res.list
pagination.itemCount = res.total
} finally {
loading.value = false
}
}
//
function handleSearch() {
pagination.page = 1
loadData()
}
//
function handleReset() {
searchForm.sectionCode = null
searchForm.sectionName = null
handleSearch()
}
//
function handlePageChange(page: number) {
pagination.page = page
loadData()
}
function handlePageSizeChange(pageSize: number) {
pagination.pageSize = pageSize
pagination.page = 1
loadData()
}
//
function handleCheck(keys: Array<string | number>) {
selectedIds.value = keys as number[]
}
//
function handleAdd() {
modalTitle.value = '新增工段表'
Object.assign(formData, defaultFormData)
modalVisible.value = true
}
//
function handleEdit(row: Section) {
modalTitle.value = '编辑工段表'
Object.assign(formData, row)
modalVisible.value = true
}
//
async function handleSubmit() {
await formRef.value?.validate()
try {
const submitData = { ...formData } as Section
if (submitData.id) {
await sectionApi.update(submitData)
message.success('修改成功')
} else {
await sectionApi.create(submitData)
message.success('新增成功')
}
modalVisible.value = false
loadData()
} catch (error) {
//
}
}
//
function handleDelete(row: Section) {
dialog.warning({
title: '提示',
content: '确定要删除该记录吗?',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
try {
await sectionApi.delete([row.id!])
message.success('删除成功')
loadData()
} catch (error) {
//
}
}
})
}
//
function handleBatchDelete() {
dialog.warning({
title: '提示',
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
try {
await sectionApi.delete(selectedIds.value)
message.success('删除成功')
selectedIds.value = []
loadData()
} catch (error) {
//
}
}
})
}
//
async function handleExport() {
try {
const params: Record<string, any> = {}
if (selectedIds.value.length > 0) params.ids = selectedIds.value
if (searchForm.sectionCode != null) params.sectionCode = searchForm.sectionCode
if (searchForm.sectionName != null) params.sectionName = searchForm.sectionName
const blob = await sectionApi.export(params)
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '工段表数据.xlsx'
link.click()
window.URL.revokeObjectURL(url)
} catch (error) {
//
}
}
//
async function handleDownloadTemplate() {
try {
const blob = await sectionApi.downloadTemplate()
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '工段表导入模板.xlsx'
link.click()
window.URL.revokeObjectURL(url)
} catch (error) {
//
}
}
//
async function handleImportUpload({ file }: UploadCustomRequestOptions) {
if (!file.file) return
try {
const result = await sectionApi.importData(file.file)
if (result.fail > 0) {
dialog.warning({
title: '导入结果',
content: `成功: ${result.success} 条,失败: ${result.fail}\n错误信息: ${(result.errors || []).join('\n') || '无'}`,
positiveText: '确定'
})
} else {
message.success(`导入成功,共 ${result.success} 条数据`)
importModalVisible.value = false
}
loadData()
} catch (error) {
//
}
}
//
async function loadDictOptions() {
try {
const data = await dictDataApi.listByType('work_shop')
workshopList.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue),class:d.listClass }))
}catch {}
try {
const data = await dictDataApi.listByType("sys_status")
statusList.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue),class:d.listClass }))
}catch {}
}
onMounted(() => {
loadData()
loadDictOptions()
})
</script>
<style scoped>
.search-form {
margin-bottom: 16px;
}
.table-toolbar {
margin-bottom: 16px;
}
</style>

View File

@ -0,0 +1,416 @@
<template>
<div class="page-container">
<n-card>
<!-- 搜索表单 -->
<div class="search-form">
<n-form inline :model="searchForm" label-placement="left">
<n-form-item label="工位编码">
<n-input v-model:value="searchForm.stationCode" placeholder="请输入工位编码" clearable />
</n-form-item>
<n-form-item>
<n-space>
<n-button type="primary" @click="handleSearch">
<template #icon><n-icon><SearchOutline /></n-icon></template>
搜索
</n-button>
<n-button @click="handleReset">
<template #icon><n-icon><RefreshOutline /></n-icon></template>
重置
</n-button>
</n-space>
</n-form-item>
</n-form>
</div>
<!-- 工具栏 -->
<div class="table-toolbar">
<n-space>
<n-button type="primary" @click="handleAdd">
<template #icon><n-icon><AddOutline /></n-icon></template>
新增工位
</n-button>
<!-- <n-button @click="importModalVisible = true">
<template #icon><n-icon><CloudUploadOutline /></n-icon></template>
导入
</n-button> -->
<n-button @click="handleExport">
<template #icon><n-icon><DownloadOutline /></n-icon></template>
导出{{ selectedIds.length > 0 ? `(${selectedIds.length})` : '' }}
</n-button>
<n-button type="error" :disabled="selectedIds.length === 0" @click="handleBatchDelete">
<template #icon><n-icon><TrashOutline /></n-icon></template>
删除
</n-button>
</n-space>
</div>
<!-- 表格 -->
<n-data-table
:columns="columns"
:data="tableData"
:loading="loading"
:pagination="pagination"
:row-key="(row) => row.id"
:scroll-x="1200"
@update:page="handlePageChange"
@update:page-size="handlePageSizeChange"
@update:checked-row-keys="handleCheck"
/>
</n-card>
<!-- 新增/编辑弹窗 -->
<n-modal v-model:show="modalVisible" preset="card" :title="modalTitle" style="width: 600px">
<n-form ref="formRef" :model="formData" :rules="formRules" label-placement="left" label-width="100px">
<n-form-item label="工位名称" path="stationName">
<n-input v-model:value="formData.stationName" placeholder="请输入工位名称" />
</n-form-item>
<n-form-item label="所属工段" path="sectionId">
<n-select
v-model:value="formData.sectionId"
:options="sectionList"
placeholder="请选择所属工段"
clearable
style="width: 200px"
/>
</n-form-item>
<n-form-item label="备注" path="remark">
<n-input v-model:value="formData.remark" type="textarea" placeholder="请输入备注" />
</n-form-item>
<n-form-item label="状态" path="status">
<n-switch v-model:value="formData.status" :checked-value="1" :unchecked-value="0">
<template #checked>启用</template>
<template #unchecked>禁用</template>
</n-switch>
</n-form-item>
</n-form>
<template #footer>
<n-space justify="end">
<n-button @click="modalVisible = false">取消</n-button>
<n-button type="primary" @click="handleSubmit">确定</n-button>
</n-space>
</template>
</n-modal>
<!-- 导入弹窗 -->
<n-modal v-model:show="importModalVisible" preset="card" title="导入工位表" style="width: 500px">
<n-space vertical>
<n-alert type="info">
<template #header>导入说明</template>
<ul style="margin: 0; padding-left: 16px; line-height: 1.8">
<li>请先下载导入模板按模板格式填写数据</li>
<li>支持 .xlsx .xls 格式</li>
</ul>
</n-alert>
<n-space>
<n-button type="primary" @click="handleDownloadTemplate">
<template #icon><n-icon><DownloadOutline /></n-icon></template>
下载模板
</n-button>
</n-space>
<n-upload :max="1" accept=".xlsx,.xls" :show-file-list="true" :custom-request="handleImportUpload">
<n-upload-dragger>
<div style="margin-bottom: 12px">
<n-icon size="48" :depth="3"><CloudUploadOutline /></n-icon>
</div>
<n-text style="font-size: 16px">点击或拖拽文件到此处上传</n-text>
<n-p depth="3" style="margin: 8px 0 0 0">支持 .xlsx .xls 格式</n-p>
</n-upload-dragger>
</n-upload>
</n-space>
<template #footer>
<n-button @click="importModalVisible = false">关闭</n-button>
</template>
</n-modal>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, h, onMounted } from 'vue'
import { NButton, NSpace,NTag, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions } from 'naive-ui'
import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5'
import { stationApi, type Station } from '@/api/station'
import { dictDataApi } from '@/api/org'
import {sectionApi, type Section} from '@/api/section'
const message = useMessage()
const dialog = useDialog()
//
const searchForm = reactive({
stationCode: null as string | null,
})
//
const tableData = ref<Station[]>([])
const loading = ref(false)
const selectedIds = ref<number[]>([])
const pagination = reactive({
page: 1,
pageSize: 10,
itemCount: 0,
showSizePicker: true,
pageSizes: [10, 20, 50]
})
//
const modalVisible = ref(false)
const modalTitle = ref('')
const importModalVisible = ref(false)
const formRef = ref()
const defaultFormData: Station = {
id:'',
stationCode: '',
stationName: '',
sectionId: undefined,
status:undefined,
remark:undefined
}
const formData = reactive<Station>({ ...defaultFormData })
let sectionList = reactive<{label:string,value:any}[]>([])
// //使
const statusList = ref<{ label: string; value: any ;class:any}[]>([])
//
const formRules = {
}
//
const columns: DataTableColumns<Station> = [
{ type: 'selection' },
{ title: '工位编码', key: 'stationCode' },
{ title: '工位名称', key: 'stationName' },
{ title: '所属工段', key: 'sectionName' },
{ title: '备注', key: 'remark' },
{ title: '启用状态', key: 'status',
render:(row) =>{
const val = row.status
const opt = statusList.value.find(o => o.value === val || String(o.value) === String(val))
if (!opt) return val ?? '-'
return h(NTag, { type: opt.class, size: 'small' }, { default: () => opt.label })
}
},
{ title: '创建时间', key: 'createTime' },
{
title: '操作',
key: 'actions',
width: 140,
fixed: 'right',
render(row) {
return h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'nowrap' } }, [
h(NButton, { size: 'small', quaternary: true, onClick: () => handleEdit(row) }, {
default: () => [h(NIcon, null, { default: () => h(CreateOutline) }), ' 编辑']
}),
h(NButton, { size: 'small', quaternary: true, type: 'error', onClick: () => handleDelete(row) }, {
default: () => [h(NIcon, null, { default: () => h(TrashOutline) }), ' 删除']
})
])
}
}
]
//
async function loadData() {
loading.value = true
try {
const res = await stationApi.page({
page: pagination.page,
pageSize: pagination.pageSize,
stationCode: searchForm.stationCode || undefined,
})
tableData.value = res.list
pagination.itemCount = res.total
} finally {
loading.value = false
}
}
//
function handleSearch() {
pagination.page = 1
loadData()
}
//
function handleReset() {
searchForm.stationCode = null
handleSearch()
}
//
function handlePageChange(page: number) {
pagination.page = page
loadData()
}
function handlePageSizeChange(pageSize: number) {
pagination.pageSize = pageSize
pagination.page = 1
loadData()
}
//
function handleCheck(keys: Array<string | number>) {
selectedIds.value = keys as number[]
}
//
function handleAdd() {
modalTitle.value = '新增工位表'
Object.assign(formData, defaultFormData)
modalVisible.value = true
}
//
function handleEdit(row: Station) {
modalTitle.value = '编辑工位表'
Object.assign(formData, row)
modalVisible.value = true
}
//
async function handleSubmit() {
await formRef.value?.validate()
try {
const submitData = { ...formData } as Station
if (submitData.id) {
await stationApi.update(submitData)
message.success('修改成功')
} else {
await stationApi.create(submitData)
message.success('新增成功')
}
modalVisible.value = false
loadData()
} catch (error) {
//
}
}
//
function handleDelete(row: Station) {
dialog.warning({
title: '提示',
content: '确定要删除该记录吗?',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
try {
await stationApi.delete([row.id!])
message.success('删除成功')
loadData()
} catch (error) {
//
}
}
})
}
//
function handleBatchDelete() {
dialog.warning({
title: '提示',
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
try {
await stationApi.delete(selectedIds.value)
message.success('删除成功')
selectedIds.value = []
loadData()
} catch (error) {
//
}
}
})
}
//
async function handleExport() {
try {
const params: Record<string, any> = {}
if (selectedIds.value.length > 0) params.ids = selectedIds.value
if (searchForm.stationCode != null) params.stationCode = searchForm.stationCode
const blob = await stationApi.export(params)
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '工位表数据.xlsx'
link.click()
window.URL.revokeObjectURL(url)
} catch (error) {
//
}
}
//
async function handleDownloadTemplate() {
try {
const blob = await stationApi.downloadTemplate()
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '工位表导入模板.xlsx'
link.click()
window.URL.revokeObjectURL(url)
} catch (error) {
//
}
}
//
async function handleImportUpload({ file }: UploadCustomRequestOptions) {
if (!file.file) return
try {
const result = await stationApi.importData(file.file)
if (result.fail > 0) {
dialog.warning({
title: '导入结果',
content: `成功: ${result.success} 条,失败: ${result.fail}\n错误信息: ${(result.errors || []).join('\n') || '无'}`,
positiveText: '确定'
})
} else {
message.success(`导入成功,共 ${result.success} 条数据`)
importModalVisible.value = false
}
loadData()
} catch (error) {
//
}
}
//
async function loadDictOptions() {
try {
const data = await dictDataApi.listByType("sys_status")
statusList.value = data.map(d => ({ label: d.dictLabel, value: (Number(d.dictValue) || d.dictValue),class:d.listClass }))
}catch {}
}
//
async function loadSection() {
const data = await sectionApi.list()
sectionList = data.map((d:any)=> ({ label: d.sectionName, value: (Number(d.id) || d.id) }))
}
onMounted(() => {
loadData()
loadSection()
loadDictOptions()
})
</script>
<style scoped>
.search-form {
margin-bottom: 16px;
}
.table-toolbar {
margin-bottom: 16px;
}
</style>

View File

@ -511,6 +511,24 @@ const columns = [
} }
}, },
{
align:'center',
title: '车间名称',
key: 'workshopName',
minWidth: 200
},
{
align:'center',
title: '工段名称',
key: 'sectionName',
minWidth: 200
},
{
align:'center',
title: '工位名称',
key: 'deviceName',
minWidth: 200
},
{ {
align:'center', align:'center',
title: '工人名称', title: '工人名称',

View File

@ -295,6 +295,24 @@ const columns = [
} }
//0 1 2+34 //0 1 2+34
},
{
align:'center',
title: '车间名称',
key: 'workshopName',
minWidth: 200
},
{
align:'center',
title: '工段名称',
key: 'sectionName',
minWidth: 200
},
{
align:'center',
title: '工位名称',
key: 'deviceName',
minWidth: 200
}, },
{ {
align:'center', align:'center',