This commit is contained in:
andy 2026-08-14 14:21:14 +08:00
commit ef2463ec68
17 changed files with 2504 additions and 643 deletions

View File

@ -79,6 +79,14 @@ export interface DeviceRealtimeVO {
} }
export interface DocumentEntity {
id?:number,
name?:string,
code?:string,
fileId?:number,
}
export const deviceApi = { export const deviceApi = {
page(params:{ page(params:{
@ -169,5 +177,13 @@ export const deviceApi = {
url:"/biz/device/list", url:"/biz/device/list",
method:"get" method:"get"
}) })
},
getDeviceByNcId(params:{ncId:number,page:number,pageSize:number}){
return request({
url:"biz/device/getDeviceByNcId",
method:"get",
params
})
} }
} }

View File

@ -0,0 +1,92 @@
import { request } from '@/utils/request'
// 设备和nc/图纸关联表 类型定义
export interface DeviceDocumentConnection {
id?: number
deviceId?: number
sourceId?: number
devcieIds?:[],
sourceIds?:[]
}
// 设备和nc/图纸关联表 API
export const deviceDocumentConnectionApi = {
// 分页查询
page(params: { page: number; pageSize: number; id?: number }) {
return request({ url: '/biz/deviceDocumentConnection/page', method: 'get', params })
},
// 获取详情
detail(id: number) {
return request({ url: `/biz/deviceDocumentConnection/${id}`, method: 'get' })
},
// 新增
create(data: DeviceDocumentConnection) {
return request({ url: '/biz/deviceDocumentConnection', method: 'post', data })
},
createDevice(data:DeviceDocumentConnection) {
return request({
url:"biz/deviceDocumentConnection/createDevice",
method:"post",
data
})
},
createDeviceDraw(data:DeviceDocumentConnection) {
return request({
url:"biz/deviceDocumentConnection/createDeviceDraw",
method:"post",
data
})
},
// 修改
update(data: DeviceDocumentConnection) {
return request({ url: '/biz/deviceDocumentConnection', method: 'put', data })
},
// 删除
delete(ids: number[]) {
return request({ url: `/biz/deviceDocumentConnection/${ids.join(',')}`, method: 'delete' })
},
// 导出
export(params?: { ids?: number[]; id?: number }) {
const p: Record<string, any> = {}
if (params?.ids?.length) p.ids = params.ids.join(',')
if (params?.id !== undefined && params?.id !== null) p.id = params.id
return request({ url: `/biz/deviceDocumentConnection/export`, method: 'get', params: p, responseType: 'blob' })
},
// 导入
importData(file: File) {
const formData = new FormData()
formData.append('file', file)
return request<{ success: number; fail: number; errors: string[] }>({
url: `/biz/deviceDocumentConnection/import`,
method: 'post',
data: formData,
headers: { 'Content-Type': 'multipart/form-data' }
})
},
// 下载导入模板
downloadTemplate() {
return request({ url: `/biz/deviceDocumentConnection/template`, method: 'get', responseType: 'blob' })
},
list(params:{page:number,pageSize:number}) {
return request({
url:"biz/deviceDocumentConnection/list",
method:"get",
params
})
}
}

View File

@ -87,3 +87,12 @@ export function multifilelist(fileId:any) {
method: 'get' method: 'get'
}) })
} }
export function getDeviceByDrawingId(params:{drawId?:number,page:number,pageSize:number}) {
return request({
url:"/biz/device/getDeviceByDrawingId",
method:"get",
params
})
}

92
src/api/stockIn.ts Normal file
View File

@ -0,0 +1,92 @@
import { request } from '@/utils/request'
/** 入库申请单 */
export interface StockIn {
id?: number
inboundCode?: string
subjectName?: string
/** 1生产入库 2委外收货 3采购入库 */
inboundType?: number
sourceOrderNo?: string
orderItemId?: number
workOrderCode?: string
processPlanId?: number
qcId?: number
materialCode?: string
materialName?: string
quantity?: number | string
progress?: number
warehouseId?: number
warehouseName?: string
/** 0草稿 1待确认 2上架入库 3已撤回 */
status?: number
/** 金蝶入库单编码 */
kingdeeInboundNo?: string
remark?: string
createTime?: string
createBy?: string
updateTime?: string
updateBy?: string
}
export type StockInSave = Omit<StockIn, 'inboundCode' | 'status' | 'progress' | 'createTime' | 'updateTime'>
export const STOCK_IN_TYPE_MAP: Record<number, { label: string; type: 'default' | 'info' | 'success' | 'warning' | 'error' }> = {
1: { label: '生产入库', type: 'success' },
2: { label: '委外收货', type: 'warning' },
3: { label: '采购入库', type: 'info' },
}
export const STOCK_IN_STATUS_MAP: Record<number, { label: string; type: 'default' | 'info' | 'success' | 'warning' | 'error' }> = {
0: { label: '草稿', type: 'default' },
1: { label: '待确认', type: 'info' },
2: { label: '上架入库', type: 'success' },
3: { label: '已撤回', type: 'warning' },
}
export const stockInApi = {
page(params: {
page: number
pageSize: number
inboundCode?: string
sourceOrderNo?: string
inboundType?: number
status?: number
warehouseName?: string
kingdeeInboundNo?: string
}) {
return request<{ list: StockIn[]; total: number; page: number; pageSize: number }>({
url: '/biz/stockIn/page',
method: 'get',
params,
})
},
detail(id: number | string) {
return request<StockIn>({ url: `/biz/stockIn/${id}`, method: 'get' })
},
create(data: StockInSave) {
return request<number>({ url: '/biz/stockIn', method: 'post', data })
},
update(data: StockInSave) {
return request({ url: '/biz/stockIn', method: 'put', data })
},
delete(ids: number[]) {
return request({ url: `/biz/stockIn/${ids.join(',')}`, method: 'delete' })
},
confirm(id: number, kingdeeInboundNo?: string | null) {
return request({
url: `/biz/stockIn/confirm/${id}`,
method: 'post',
data: kingdeeInboundNo ? { kingdeeInboundNo } : {},
})
},
revoke(id: number) {
return request({ url: `/biz/stockIn/revoke/${id}`, method: 'post' })
},
}

View File

@ -563,7 +563,7 @@ body.dark-theme {
// 页面容器 // 页面容器
.page-container { .page-container {
padding: 20px; padding: 20px;
min-height: calc(100vh - 60px); //min-height: calc(100vh - 60px);
} }
// 搜索表单 // 搜索表单

View File

@ -284,31 +284,78 @@
</template> </template>
</n-modal> </n-modal>
<!--工艺文档抽屉-->
<n-drawer v-model:show="deviceDocumentConnectionVisible" width="1000">
<n-drawer-content :title="title">
<n-space justify="space-between" class="mb-3">
<n-checkbox v-model:checked="isAllCheck" @update:checked="handleAllCheck">
全选当前筛选文档
</n-checkbox>
<n-tag type="info">已勾选 {{ selectedDeviceIds.length }} 道文档</n-tag>
</n-space>
<!-- 工序表格带复选框 -->
<n-data-table
:columns="deviceColumns"
:data="deviceList"
max-height="700"
v-model:checked-row-keys="selectedDeviceIds"
:row-key="rowKey"
:scroll-x="1200"
:loading="connectionLoading"
@update:checked-row-keys="handleUpateCheck"
/>
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
<n-pagination
v-model:page="connectionPagination.page"
v-model:page-size="connectionPagination.pageSize"
:item-count="connectionPagination.itemCount"
:page-sizes="[10, 20, 50, 100]"
show-size-picker
show-quick-jumper
@update:page="handleRelatePageChange"
@update:page-size="handleRelatePageSizeChange"
>
<template #prefix>
{{ connectionPagination.itemCount }}
</template>
</n-pagination>
</div>
<template #footer>
<n-button @click="deviceDocumentConnectionVisible = false">
取消
</n-button>
</template>
</n-drawer-content>
</n-drawer>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { import {
ref, ref,
reactive, reactive,
h, h,
onMounted, onMounted, computed,
} from 'vue' } from 'vue'
import { import {
NTree, NTree,
NButton, NButton,
NIcon, NIcon,
NSpace, NSpace,
NPagination, NPagination,
NGrid, NGrid,
useMessage, useMessage,
useDialog, useDialog,
NDropdown, NDropdown, NTag, type DataTableColumns,
} from 'naive-ui' } from 'naive-ui'
import { import {
@ -338,6 +385,9 @@ import
{ {
multifilelist multifilelist
} from '@/api/illustrated' } from '@/api/illustrated'
import {DeviceDocumentConnection, deviceDocumentConnectionApi} from "@/api/deviceDocumentConnection.ts";
import {Device, deviceApi} from "@/api/device.ts";
import {RowData} from "naive-ui/es/data-table/src/interface";
const dialog = useDialog() const dialog = useDialog()
@ -475,7 +525,7 @@ const columns = [
align:'center', align:'center',
title: '操作', title: '操作',
key: 'actions', key: 'actions',
width: 260, width: 360,
fixed: 'right', fixed: 'right',
render(row:any) { render(row:any) {
const buttons:any = [] const buttons:any = []
@ -544,7 +594,15 @@ const columns = [
{ default: () => '删除'} { default: () => '删除'}
)) ))
} }
buttons.push(h(NButton, {
size: 'small',
type:'primary',
ghost:true,
onClick: () => {
handlerConnectionDevice(row)
} },
{ default: () => '关联设备'}
))
return buttons.length > 0 ? h(NSpace, {justify:'center'}, { default: () => buttons }) : '-' return buttons.length > 0 ? h(NSpace, {justify:'center'}, { default: () => buttons }) : '-'
} }
@ -896,15 +954,125 @@ function handleExport() {
}) })
} }
const deviceDocumentConnectionVisible = ref<Boolean>(false)
const title = ref<String>("")
const deviceDocumentConnection = reactive<any>({})
const connectionLoading = ref<boolean>(false)
const connectionPagination = reactive({
page: 1,
pageSize: 2,
itemCount: 0,
showSizePicker: true,
pageSizes: [10, 20, 50]
})
const deviceList = ref<Device[]>([])
const selectedDeviceIds = ref<any>([])
function handlerConnectionDevice(row:any) {
deviceDocumentConnectionVisible.value = true
title.value = row.deviceName + "设备工艺文档关联"
deviceDocumentConnection.sourceId = row.id
getDeviceList(deviceDocumentConnection.sourceId)
}
//|
const isAllCheck = computed({
get() {
return deviceList.value.length > 0 && selectedDeviceIds.value.length === deviceList.value.length
},
set(val) {
if (val) {
selectedDeviceIds.value = deviceList.value.map(item => item.id)
}else {
selectedDeviceIds.value = []
}
loadCreateApi()
}
})
const handleAllCheck = (val:boolean) => {
isAllCheck.value = val
}
// function rowKey(row:RowData){
// return row.id
// }
const handleUpateCheck = async (keys:Array<string | number>,)=>{
selectedDeviceIds.value = keys
loadCreateApi()
}
const loadCreateApi = async ()=>{
deviceDocumentConnection.deviceIds = selectedDeviceIds.value
deviceDocumentConnection.page = connectionPagination.page
deviceDocumentConnection.pageSize = connectionPagination.pageSize
try {
await deviceDocumentConnectionApi.createDevice(deviceDocumentConnection)
message.success("关联成功")
getDeviceList(deviceDocumentConnection.sourceId)
}catch (error) {
message.error("关联失败")
}
}
async function getDeviceList(id:any) {
try {
const res = await deviceApi.getDeviceByNcId({
ncId:id,
page:connectionPagination.page,
pageSize:connectionPagination.pageSize
})
deviceList.value = res.list
connectionPagination.itemCount = res.total
//
selectedDeviceIds.value = deviceList.value.filter((item:any) =>item.isBind).map(item=>item.id)
connectionLoading.value = false
}catch (error) {
message.error("获取关联异常")
connectionLoading.value = false
}
}
//
function handleRelatePageChange(page: number) {
connectionPagination.page = page
getDeviceList(deviceDocumentConnection.sourceId)
}
function handleRelatePageSizeChange(pageSize: number) {
connectionPagination.pageSize = pageSize
connectionPagination.page = 1
getDeviceList(deviceDocumentConnection.sourceId)
}
const deviceColumns:DataTableColumns<Device> = [
{ type: 'selection' },
{title: '设备名称', key: 'deviceName',width:80},
{ title: "关联状态",key:"isBind",width:80,
render(row:any) {
const val = row.isBind;
if (val) {
return h(NTag, { type: "success" }, { default: () => "已关联" });
} else {
return h(NTag, { type: "default" }, { default: () => "未关联" });
}
}
}
]
getlist() getlist()
//
// async function handleDispatchRecord(row:ncCode){
// const ncId = row.id
// // ncDispatchRecords.value = await
// }
onMounted(() => { onMounted(() => {
@ -933,8 +1101,6 @@ onMounted(() => {
} }
}) })
//loadDictOptions()
}) })
</script> </script>

View File

@ -113,9 +113,10 @@
</n-form-item> </n-form-item>
<n-form-item label="所属工段" path="sectionId"> <n-form-item label="所属工段" path="sectionId">
<n-tree-select <n-tree-select
v-model:value="formData.sectionId" v-model:value="formData.sectionId"
cascade cascade
checkable checkable
default-expand-all
:options="sectionList" :options="sectionList"
/> />
</n-form-item> </n-form-item>
@ -243,11 +244,57 @@
</template> </template>
</n-drawer-content> </n-drawer-content>
</n-drawer> </n-drawer>
<!--工艺文档抽屉-->
<n-drawer v-model:show="deviceDocumentConnectionVisible" width="1200">
<n-drawer-content :title="title">
<n-space justify="space-between" class="mb-3">
<n-checkbox v-model:checked="isAllCheck" @update:checked="handleAllCheck">
全选当前筛选文档
</n-checkbox>
<n-tag type="info">已勾选 {{ selectedDocumentIds.length }} 道文档</n-tag>
</n-space>
<!-- 工序表格带复选框 -->
<n-data-table
:columns="documentColumns"
:data="documentList"
max-height="700"
v-model:checked-row-keys="selectedDocumentIds"
:row-key="rowKey"
:scroll-x="1200"
:loading="connectionLoading"
@update:checked-row-keys="handleUpateCheck"
/>
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
<n-pagination
v-model:page="connectionPagination.page"
v-model:page-size="connectionPagination.pageSize"
:item-count="connectionPagination.itemCount"
:page-sizes="[10, 20, 50, 100]"
show-size-picker
show-quick-jumper
@update:page="handleRelatePageChange"
@update:page-size="handleRelatePageSizeChange"
>
<template #prefix>
{{ connectionPagination.itemCount }}
</template>
</n-pagination>
</div>
<template #footer>
<n-button @click="doShowInner">
取消
</n-button>
</template>
</n-drawer-content>
</n-drawer>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {ref, reactive, h, onMounted} from 'vue' import {ref, reactive, h, onMounted, computed} from 'vue'
import {useRouter} from 'vue-router' import {useRouter} from 'vue-router'
import { import {
NButton, NSpace, NTag, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions, NButton, NSpace, NTag, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions,
@ -262,17 +309,17 @@ import {
CloudUploadOutline, CloudUploadOutline,
DownloadOutline, EllipsisHorizontalOutline DownloadOutline, EllipsisHorizontalOutline
} from '@vicons/ionicons5' } from '@vicons/ionicons5'
import {deviceApi, type Device} from '@/api/device' import {deviceApi, type Device, DocumentEntity} from '@/api/device'
import {dictDataApi} from '@/api/org' import {dictDataApi} from '@/api/org'
import {sectionApi} from '@/api/section' import {deptApi , userApi} from '@/api/system'
import {deptApi, type SysDept , userApi} from '@/api/system' import {DeviceAbnormalRecord} from "@/api/deviceAbnormalRecord.ts";
import {DeviceAbnormalRecord, deviceAbnormalRecordApi} from "@/api/deviceAbnormalRecord.ts";
import DeviceAbnormalRecordPage from '@/views/biz/device/DeviceAbnomarlRecord.vue' import DeviceAbnormalRecordPage from '@/views/biz/device/DeviceAbnomarlRecord.vue'
import DeviceOperationLogPage from "@/views/biz/device/DeviceOperationLog.vue"; import DeviceOperationLogPage from "@/views/biz/device/DeviceOperationLog.vue";
import DeviceDispatchLogPage from "@/views/biz/device/DeviceDispatchLog.vue"; import DeviceDispatchLogPage from "@/views/biz/device/DeviceDispatchLog.vue";
import { S } from 'vue-router/dist/router-CWoNjPRp.mjs' import {DeviceDocumentConnection, deviceDocumentConnectionApi} from "@/api/deviceDocumentConnection.ts";
import {RowData} from "naive-ui/es/data-table/src/interface";
const message = useMessage() const message = useMessage()
const dialog = useDialog() const dialog = useDialog()
@ -305,6 +352,66 @@ const deviceDispatchLogDrawerVisible = ref<Boolean>(false)
// //
const deviceOperationLogDrawerVisible = ref<Boolean>(false) const deviceOperationLogDrawerVisible = ref<Boolean>(false)
//
const deviceDocumentConnectionVisible = ref<Boolean>(false)
const documentList = ref<DocumentEntity[]>([])
const selectedDocumentIds = ref<number[]>([])
const deviceDocumentConnection = ref<DeviceDocumentConnection>({})
const connectionLoading = ref<boolean>(false)
const connectionPagination = reactive({
page: 1,
pageSize: 2,
itemCount: 0,
showSizePicker: true,
pageSizes: [10, 20, 50]
})
//|
const isAllCheck = computed({
get() {
return documentList.value.length > 0 && selectedDocumentIds.value.length === documentList.value.length
},
set(val) {
if (val) {
selectedDocumentIds.value = documentList.value.map(item => item.id)
}else {
selectedDocumentIds.value = []
}
loadCreateApi()
}
})
const handleAllCheck = (val:boolean) => {
isAllCheck.value = val
}
function rowKey(row:RowData){
return row.id
}
const handleUpateCheck = async (keys:Array<string | number>,)=>{
selectedDocumentIds.value = keys
loadCreateApi()
}
const loadCreateApi = async ()=>{
deviceDocumentConnection.sourceIds = selectedDocumentIds.value
deviceDocumentConnection.page = connectionPagination.page
deviceDocumentConnection.pageSize = connectionPagination.pageSize
try {
await deviceDocumentConnectionApi.create(deviceDocumentConnection)
message.success("关联成功")
getDocumentList(deviceDocumentConnection.deviceId);
}catch (error){
message.error("关联失败")
}
}
// //
const searchForm = reactive({ const searchForm = reactive({
deviceCode: null as number | null, deviceCode: null as number | null,
@ -427,6 +534,10 @@ const columns: DataTableColumns<Device> = [
{ {
label: '设备操作日志', label: '设备操作日志',
key: 'deviceOperationLog', key: 'deviceOperationLog',
},
{
label: '设备工艺文档关联',
key: 'deviceDocumentConnection'
} }
], onSelect: (key: string) => { ], onSelect: (key: string) => {
switch (key) { switch (key) {
@ -439,6 +550,8 @@ const columns: DataTableColumns<Device> = [
case "deviceOperationLog": case "deviceOperationLog":
deviceOperationLog(row) deviceOperationLog(row)
break break
case "deviceDocumentConnection":
handleDeviceDocumentConnection(row)
} }
} }
}, { }, {
@ -454,6 +567,31 @@ const columns: DataTableColumns<Device> = [
} }
] ]
const documentColumns:DataTableColumns<Document> = [
{ type: 'selection' },
{title: '文档名称', key: 'name',width:80},
{title: '文档类型', key: 'type',width:80,
render: (row) => {
var opt = row.type;
if (opt == 1) return "图纸"
if (opt == 2) return "文件"
if (opt == 3) return "NC代码"
return "-"
}
},
{ title: "关联状态",key:"isBind",width:80,
render(row) {
const val = row.isBind;
if (val) {
return h(NTag, { type: "success" }, { default: () => "已关联" });
} else {
return h(NTag, { type: "default" }, { default: () => "未关联" });
}
}
}
]
// //
async function loadData() { async function loadData() {
loading.value = true loading.value = true
@ -731,13 +869,55 @@ async function deviceOperationLog(row: Device) {
deviceId.value = row.id deviceId.value = row.id
deviceOperationLogDrawerVisible.value = true deviceOperationLogDrawerVisible.value = true
title.value = row.deviceName + "操作记录"; title.value = row.deviceName + "操作记录";
}
async function handleDeviceDocumentConnection(row:Device) {
deviceDocumentConnectionVisible.value = true
title.value = row.deviceName + "设备工艺文档关联"
deviceDocumentConnection.deviceId = row.id
getDocumentList(row.id)
}
async function getDocumentList(id) {
try {
const res = await deviceDocumentConnectionApi.list({
deviceId:id,
page:connectionPagination.page,
pageSize:connectionPagination.pageSize
});
documentList.value = res.list
connectionPagination.itemCount = res.total
//
selectedDocumentIds.value = documentList.value.filter(item=> item.isBind).map(item=>item.id)
connectionLoading.value = false
}catch (error) {
console.log("异常信息:"+error);
message.error("获取关联异常")
connectionLoading.value = false
}
} }
//
function handleRelatePageChange(page: number) {
connectionPagination.page = page
getDocumentList(deviceDocumentConnection.deviceId)
}
function handleRelatePageSizeChange(pageSize: number) {
connectionPagination.pageSize = pageSize
connectionPagination.page = 1
getDocumentList(deviceDocumentConnection.deviceId)
}
function doShowInner() { function doShowInner() {
deviceAbnormalRecordDrawerVisible.value = false deviceAbnormalRecordDrawerVisible.value = false
deviceOperationLogDrawerVisible.value = false deviceOperationLogDrawerVisible.value = false
deviceDispatchLogDrawerVisible.value = false deviceDispatchLogDrawerVisible.value = false
deviceDocumentConnectionVisible.value = false
} }
onMounted(() => { onMounted(() => {

View File

@ -0,0 +1,369 @@
<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.id" placeholder="请输入主键ID" 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="设备ID" path="deviceId">
<n-input v-model:value="formData.deviceId" placeholder="请输入设备ID" />
</n-form-item>
<n-form-item label="NC/图纸ID" path="sourceId">
<n-input v-model:value="formData.sourceId" placeholder="请输入NC/图纸ID" />
</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="导入设备和nc/图纸关联表" 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, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions } from 'naive-ui'
import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5'
import { deviceDocumentConnectionApi, type DeviceDocumentConnection } from '@/api/deviceDocumentConnection'
const message = useMessage()
const dialog = useDialog()
//
const searchForm = reactive({
id: null as number | null,
})
//
const tableData = ref<DeviceDocumentConnection[]>([])
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: DeviceDocumentConnection = {
deviceId: undefined,
sourceId: undefined,
}
const formData = reactive<DeviceDocumentConnection>({ ...defaultFormData })
// //使
//
const formRules = {
}
//
const columns: DataTableColumns<DeviceDocumentConnection> = [
{ type: 'selection' },
{ title: '主键ID', key: 'id' },
{ title: '设备ID', key: 'deviceId' },
{ title: 'NC/图纸ID', key: 'sourceId' },
{
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 deviceDocumentConnectionApi.page({
page: pagination.page,
pageSize: pagination.pageSize,
id: searchForm.id || undefined,
})
tableData.value = res.list
pagination.itemCount = res.total
} finally {
loading.value = false
}
}
//
function handleSearch() {
pagination.page = 1
loadData()
}
//
function handleReset() {
searchForm.id = 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 = '新增设备和nc/图纸关联表'
Object.assign(formData, defaultFormData)
modalVisible.value = true
}
//
function handleEdit(row: DeviceDocumentConnection) {
modalTitle.value = '编辑设备和nc/图纸关联表'
Object.assign(formData, row)
modalVisible.value = true
}
//
async function handleSubmit() {
await formRef.value?.validate()
try {
const submitData = { ...formData } as DeviceDocumentConnection
if (submitData.id) {
await deviceDocumentConnectionApi.update(submitData)
message.success('修改成功')
} else {
await deviceDocumentConnectionApi.create(submitData)
message.success('新增成功')
}
modalVisible.value = false
loadData()
} catch (error) {
//
}
}
//
function handleDelete(row: DeviceDocumentConnection) {
dialog.warning({
title: '提示',
content: '确定要删除该记录吗?',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
try {
await deviceDocumentConnectionApi.delete([row.id!])
message.success('删除成功')
loadData()
} catch (error) {
//
}
}
})
}
//
function handleBatchDelete() {
dialog.warning({
title: '提示',
content: `确定要删除选中的 ${selectedIds.value.length} 条记录吗?`,
positiveText: '确定',
negativeText: '取消',
onPositiveClick: async () => {
try {
await deviceDocumentConnectionApi.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.id != null) params.id = searchForm.id
const blob = await deviceDocumentConnectionApi.export(params)
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '设备和nc/图纸关联表数据.xlsx'
link.click()
window.URL.revokeObjectURL(url)
} catch (error) {
//
}
}
//
async function handleDownloadTemplate() {
try {
const blob = await deviceDocumentConnectionApi.downloadTemplate()
const url = window.URL.createObjectURL(blob)
const link = document.createElement('a')
link.href = url
link.download = '设备和nc/图纸关联表导入模板.xlsx'
link.click()
window.URL.revokeObjectURL(url)
} catch (error) {
//
}
}
//
async function handleImportUpload({ file }: UploadCustomRequestOptions) {
if (!file.file) return
try {
const result = await deviceDocumentConnectionApi.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() {
}
onMounted(() => {
loadData()
loadDictOptions()
})
</script>
<style scoped>
.search-form {
margin-bottom: 16px;
}
.table-toolbar {
margin-bottom: 16px;
}
</style>

View File

@ -240,14 +240,14 @@ const modalTitle = ref('')
const importModalVisible = ref(false) const importModalVisible = ref(false)
const formRef = ref() const formRef = ref()
const defaultFormData = { const defaultFormData = {
subscriptionKey: '', subscriptionKey: undefined,
title: '', title: '',
subscriptionDeviceIds: '', subscriptionDeviceIds: '',
subscriptionDiscoverField: '', subscriptionDiscoverField: undefined,
notifierMethod:1, notifierMethod:1,
sendingMethod: [], sendingMethod: [],
discoverValue: '', discoverValue: '',
detectionMethod: '', detectionMethod: undefined,
notifier: '', notifier: '',
notifierContent: '', notifierContent: '',
abnormalReporting: undefined, abnormalReporting: undefined,
@ -306,10 +306,18 @@ userApi.getPathList().then(rps => {
}) })
// const itemOptions = computed(() => {
// if (!selectedCategory.value) {
// return [] //
// }
// return allItems[selectedCategory.value] || []
// })
function keyupdate(v:any,n:any) { function keyupdate(v:any,n:any) {
formData.subscriptionDiscoverField = '' formData.subscriptionDiscoverField = null
yiczdopt.value = n.childList yiczdopt.value = n.childList
console.log(v) console.log(v)
console.log(n) console.log(n)
} }

View File

@ -393,9 +393,10 @@
</n-gi> </n-gi>
</n-grid> </n-grid>
</n-card> </n-card>
<!--:rules="dispatchrules"-->
<n-form ref="dispatchformRef" :model="dispatchform" <n-form ref="dispatchformRef" :model="dispatchform"
label-placement="left" label-placement="left"
:rules="dispatchrules"
style="margin-top: 10px;" style="margin-top: 10px;"
label-width="80"> label-width="80">
<n-grid :cols="2"> <n-grid :cols="2">
@ -1244,7 +1245,7 @@ function disphand(process: ProcessPlanItemVO, order?: OrderProcessPlanVO) {
dispatchform.sort = entity.sort dispatchform.sort = entity.sort
dispatchform.sectionId = entity.sectionId ?? process.sectionId ?? null dispatchform.sectionId = entity.sectionId ?? process.sectionId ?? null
dispatchform.workshopId = entity.workshopId ?? process.workshopId ?? order?.workshopId ?? null dispatchform.workshopId = entity.workshopId ?? process.workshopId ?? order?.workshopId ?? null
dispatchform.list = [{ sectionId: '', deviceId: '', quantity: remainQty || '',ncId:'' }] dispatchform.list = [{ sectionId: '', deviceId: '', quantity: remainQty+'' || '',ncId:'' }]
} }
function addpgnum() { function addpgnum() {

View File

@ -67,12 +67,23 @@
<n-form ref="formRef" :model="formData" :rules="formRules" label-placement="left" label-width="100px"> <n-form ref="formRef" :model="formData" :rules="formRules" label-placement="left" label-width="100px">
<n-grid :cols="2" :x-gap="24"> <n-grid :cols="2" :x-gap="24">
<n-form-item-gi label="mapper" path="mapperKey"> <n-form-item-gi label="mapper" path="mapperKey">
<n-select v-model:value="formData.mapperKey" placeholder="请选择mapper" :options="mapperOptions" @update:value="mapperUpdate" /> <n-select v-model:value="formData.mapperKey" filterable placeholder="请选择mapper" :options="mapperOptions" />
</n-form-item-gi>
<n-form-item-gi label="控制方法" path="controlMethod">
<n-select v-model:value="formData.controlMethod" multiple placeholder="请选择控制方法" :options="methodOptions" />
</n-form-item-gi> </n-form-item-gi>
<!-- <n-form-item-gi label="控制方法" path="controlMethod">
<n-select v-model:value="selectedMethod" filterable multiple placeholder="请选择控制方法" :options="methodOptions" />
</n-form-item-gi> -->
</n-grid> </n-grid>
<n-grid :cols="1" :x-gap="24">
<n-form-item-gi label="控制方法" path="controlMethod">
<n-checkbox-group v-model:value="selectedMethod">
<n-space item-style="display: flex;">
<n-checkbox :value="item.value" :label="item.label" v-for="(item) in methodOptions" :key="item.value"/>
</n-space>
</n-checkbox-group>
</n-form-item-gi>
</n-grid>
<n-grid :cols="1" :x-gap="24"> <n-grid :cols="1" :x-gap="24">
<n-form-item-gi label="权限控制方案" path="permissionControl"> <n-form-item-gi label="权限控制方案" path="permissionControl">
<n-dynamic-input <n-dynamic-input
@ -86,13 +97,14 @@
<template #default="{ value,index }"> <template #default="{ value,index }">
<n-space> <n-space>
<n-select <n-select
v-model:value="value.key" v-model:value="value.roleId"
:options="roleOptions" :options="roleOptions"
placeholder="请选择角色" placeholder="请选择角色"
style="width: 150px" style="width: 150px"
@update:value="handleRoleClick"
/> />
<n-input <n-input
v-model:value="value.value" v-model:value="value.rule"
placeholder="请输入权限内容" placeholder="请输入权限内容"
readonly readonly
style="width: 400px" style="width: 400px"
@ -123,11 +135,12 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, h, onMounted } from 'vue' import { ref, reactive, h, onMounted, watch } from 'vue'
import { NButton, NSpace, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions } from 'naive-ui' import { NButton, NSpace, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions } from 'naive-ui'
import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5' import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5'
import { permissionConfigApi, type PermissionConfig } from '@/api/permissionConfig' import { permissionConfigApi, type PermissionConfig } from '@/api/permissionConfig'
import { roleApi, SysRole } from '@/api/system' import { roleApi, SysRole } from '@/api/system'
import { any, select } from 'three/tsl'
const message = useMessage() const message = useMessage()
const dialog = useDialog() const dialog = useDialog()
@ -141,8 +154,8 @@ const searchForm = reactive({
const permissionControl = ref([ const permissionControl = ref([
{ {
sole:Date.now(), sole:Date.now(),
key: '', roleId: '',
value: '123' rule: ''
} }
]) ])
@ -152,8 +165,8 @@ const roleOptions = ref<Array<{ label: string; value: number; disabled:false }>>
const handleCreate = () => { const handleCreate = () => {
return { return {
sole: Date.now() + Math.random(), // keyfield使 sole: Date.now() + Math.random(), // keyfield使
key:"", roleId:"",
value: null // selectkey rule: null // selectkey
} }
} }
@ -182,6 +195,7 @@ const defaultFormData: PermissionConfig = {
permissionControl: '', permissionControl: '',
} }
const formData = reactive<PermissionConfig>({ ...defaultFormData }) const formData = reactive<PermissionConfig>({ ...defaultFormData })
const selectedMethod = ref([])
// //使 // //使
@ -220,11 +234,11 @@ const updatePermissionModal = ref(false)
function clickPermission(index:number){ function clickPermission(index:number){
updatePermissionIndex.value = index updatePermissionIndex.value = index
updatePermissionContent.value = permissionControl.value[index].value; updatePermissionContent.value = permissionControl.value[index].rule;
updatePermissionModal.value = true updatePermissionModal.value = true
} }
function closePermission(){ function closePermission(){
permissionControl.value[updatePermissionIndex.value].value = updatePermissionContent.value; permissionControl.value[updatePermissionIndex.value].rule = updatePermissionContent.value;
} }
// //
@ -280,13 +294,25 @@ function handleCheck(keys: Array<string | number>) {
function handleAdd() { function handleAdd() {
modalTitle.value = '新增数据权限配置' modalTitle.value = '新增数据权限配置'
Object.assign(formData, defaultFormData) Object.assign(formData, defaultFormData)
selectedMethod.value = []
permissionControl.value = [{
sole:Date.now(),
roleId: '',
rule: ''
}]
modalVisible.value = true modalVisible.value = true
} }
const isMonitor = ref(false);
// //
function handleEdit(row: PermissionConfig) { function handleEdit(row: PermissionConfig) {
modalTitle.value = '编辑数据权限配置' modalTitle.value = '编辑数据权限配置'
isMonitor.value = false;
Object.assign(formData, row) Object.assign(formData, row)
handleMapperClick();
permissionControl.value = JSON.parse(formData.permissionControl)
selectedMethod.value = JSON.parse(row.controlMethod)
console.log('页面打开')
modalVisible.value = true modalVisible.value = true
} }
@ -295,6 +321,8 @@ async function handleSubmit() {
await formRef.value?.validate() await formRef.value?.validate()
try { try {
const submitData = { ...formData } as PermissionConfig const submitData = { ...formData } as PermissionConfig
submitData.permissionControl = JSON.stringify(permissionControl.value)
submitData.controlMethod = JSON.stringify(selectedMethod.value)
if (submitData.id) { if (submitData.id) {
await permissionConfigApi.update(submitData) await permissionConfigApi.update(submitData)
message.success('修改成功') message.success('修改成功')
@ -406,16 +434,51 @@ async function handleImportUpload({ file }: UploadCustomRequestOptions) {
const mapperOptions = ref<{ label: string; value: any }[]>([]) const mapperOptions = ref<{ label: string; value: any }[]>([])
const methodSearchOptions = ref<{ label: string; value: any }[]>([]) const methodSearchOptions = ref<{ label: string; value: any }[]>([])
const methodOptions = ref<{ label: string; value: any }[]>([]) const methodOptions = ref<{ label: string; value: any }[]>([])
function mapperUpdate(v:any,opt:any) {
formData.controlMethod='' watch(() => formData.mapperKey, () => {
methodOptions.value = opt.childList;
if(isMonitor.value){
handleMapperClick()
}else{
isMonitor.value = true;
}
})
function handleMapperClick(){
selectedMethod.value=[]
mapperOptions.value.forEach((data:any) =>{
if(data.value === formData.mapperKey){
methodOptions.value = data.childList;
}
})
console.log('数据更新')
} }
watch(() => permissionControl.value, () => handleRoleClick())
function mapperSearchUpdate(v:any,opt:any) { function mapperSearchUpdate(v:any,opt:any) {
searchForm.controlMethod='' searchForm.controlMethod=''
methodSearchOptions.value = opt.childList; methodSearchOptions.value = opt.childList;
} }
function handleRoleClick() {
const selectedRoleList : string[] = [];
permissionControl.value.forEach((selectedRole:any) =>{
selectedRoleList.push(selectedRole.roleId);
})
roleOptions.value.forEach((data:any) =>{
if(selectedRoleList.includes(data.value)){
data.disabled = true
}else{
data.disabled = false
}
})
}
// //
async function loadDictOptions() { async function loadDictOptions() {
try { try {

View File

@ -499,16 +499,15 @@ async function handleSubmit() {
if (typeof submitData.updateTime === 'number') { if (typeof submitData.updateTime === 'number') {
submitData.updateTime = new Date(submitData.updateTime).toISOString().slice(0, 19).replace('T', ' ') submitData.updateTime = new Date(submitData.updateTime).toISOString().slice(0, 19).replace('T', ' ')
} }
console.log(submitData) if (submitData.id) {
// if (submitData.id) { await qcItemApi.update(submitData)
// await qcItemApi.update(submitData) message.success('修改成功')
// message.success('') } else {
// } else { await qcItemApi.create(submitData)
// await qcItemApi.create(submitData) message.success('新增成功')
// message.success('') }
// } modalVisible.value = false
// modalVisible.value = false loadData()
// loadData()
} catch (error) { } catch (error) {
// //
} }

View File

@ -225,8 +225,9 @@
</n-modal> </n-modal>
<!-- 提交判定明细抽屉 --> <!-- 提交判定明细抽屉 -->
<n-drawer v-model:show="showSubmitOuter" :width="800"> <n-drawer v-model:show="showSubmitOuter" :width="900">
<SumbitDetailCard <SumbitDetailCard1
:mask-closable="false"
:showOkTab="true" :showOkTab="true"
:showScrapTab="true" :showScrapTab="true"
:showReworkTab = true :showReworkTab = true
@ -237,7 +238,8 @@
/> />
<n-space justify="center" style="width: 100%; margin-top: 16px;"> <n-space justify="center" style="width: 100%; margin-top: 16px;">
<n-button size="small" @click="handleReset">重置</n-button> <!-- <n-button size="small" @click="handleReset">重置</n-button> -->
<n-button size="small" @click="showSubmitOuter = false">取消</n-button>
<n-button type="primary" size="small" @click="handleSubmitResultDetail">提交</n-button> <n-button type="primary" size="small" @click="handleSubmitResultDetail">提交</n-button>
</n-space> </n-space>
</n-drawer> </n-drawer>
@ -262,7 +264,7 @@ import {assingReworkApi} from '@/api/assingRework'
import { dictDataApi } from '@/api/org' import { dictDataApi } from '@/api/org'
import {qcResultDetailApi, type QcResultDetail} from "@/api/qcResultDetail.ts"; import {qcResultDetailApi, type QcResultDetail} from "@/api/qcResultDetail.ts";
import SumbitDetailCard from '@/components/SumbitDetailCard.vue' import SumbitDetailCard1 from '@/components/SumbitDetailCard1.vue'
import router from "@/router"; import router from "@/router";

View File

@ -15,23 +15,31 @@
/> />
</n-form-item> </n-form-item>
<n-form-item label="设备/工位"> <n-form-item label="设备/工位">
<n-select <n-select
v-model:value="searchForm.deviceIds" v-model:value="searchForm.deviceIds"
placeholder="请指定工段" placeholder="请指定工段"
clearable clearable
multiple multiple
style="width: 200px" style="width: 200px"
:options="deviceList" :options="deviceList"
/> />
</n-form-item> </n-form-item>
<n-form-item> <n-form-item>
<n-space> <n-space>
<n-button type="primary" @click="handleSearch"> <n-button type="primary" @click="handleSearch">
<template #icon><n-icon><SearchOutline /></n-icon></template> <template #icon>
<n-icon>
<SearchOutline/>
</n-icon>
</template>
搜索 搜索
</n-button> </n-button>
<n-button @click="handleReset"> <n-button @click="handleReset">
<template #icon><n-icon><RefreshOutline /></n-icon></template> <template #icon>
<n-icon>
<RefreshOutline/>
</n-icon>
</template>
重置 重置
</n-button> </n-button>
</n-space> </n-space>
@ -43,7 +51,11 @@
<div class="table-toolbar"> <div class="table-toolbar">
<n-space> <n-space>
<n-button type="primary" @click="handleAdd"> <n-button type="primary" @click="handleAdd">
<template #icon><n-icon><AddOutline /></n-icon></template> <template #icon>
<n-icon>
<AddOutline/>
</n-icon>
</template>
新增 新增
</n-button> </n-button>
</n-space> </n-space>
@ -51,11 +63,11 @@
<!-- 表格 --> <!-- 表格 -->
<n-data-table <n-data-table
:columns="columns" :columns="columns"
:data="tableData" :data="tableData"
:loading="loading" :loading="loading"
:row-key="(row) => row.id" :row-key="(row) => row.id"
:scroll-x="1200" :scroll-x="1200"
/> />
<div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px"> <div class="pagination-container" style="display: flex; justify-content: flex-end; margin-top: 12px">
<n-pagination <n-pagination
@ -80,26 +92,26 @@
<n-modal v-model:show="modalVisible" preset="card" :title="modalTitle" style="width: 600px"> <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 ref="formRef" :model="formData" :rules="formRules" label-placement="left" label-width="100px">
<n-form-item label="设备/工位" path="deviceId"> <n-form-item label="设备/工位" path="deviceId">
<n-select <n-select
v-model:value="formData.deviceId" v-model:value="formData.deviceId"
placeholder="请指定工段" placeholder="请指定工段"
clearable clearable
style="width: 200px" style="width: 200px"
:options="deviceList" :options="deviceList"
/> />
</n-form-item> </n-form-item>
<n-form-item label="接收人" path="receiverPerson"> <n-form-item label="接收人" path="receiverPerson">
<n-select <n-select
v-model:value="formData.receiverPersonId" v-model:value="formData.receiverPersonId"
placeholder="请选择接收人" placeholder="请选择接收人"
clearable clearable
style="width: 200px" style="width: 200px"
:options="userList" :options="userList"
/> />
</n-form-item> </n-form-item>
<n-form-item label="备注" path="remark"> <n-form-item label="备注" path="remark">
<n-input v-model:value="formData.remark" type="textarea" placeholder="请输入备注" /> <n-input v-model:value="formData.remark" type="textarea" placeholder="请输入备注"/>
</n-form-item> </n-form-item>
</n-form> </n-form>
<template #footer> <template #footer>
@ -122,14 +134,20 @@
</n-alert> </n-alert>
<n-space> <n-space>
<n-button type="primary" @click="handleDownloadTemplate"> <n-button type="primary" @click="handleDownloadTemplate">
<template #icon><n-icon><DownloadOutline /></n-icon></template> <template #icon>
<n-icon>
<DownloadOutline/>
</n-icon>
</template>
下载模板 下载模板
</n-button> </n-button>
</n-space> </n-space>
<n-upload :max="1" accept=".xlsx,.xls" :show-file-list="true" :custom-request="handleImportUpload"> <n-upload :max="1" accept=".xlsx,.xls" :show-file-list="true" :custom-request="handleImportUpload">
<n-upload-dragger> <n-upload-dragger>
<div style="margin-bottom: 12px"> <div style="margin-bottom: 12px">
<n-icon size="48" :depth="3"><CloudUploadOutline /></n-icon> <n-icon size="48" :depth="3">
<CloudUploadOutline/>
</n-icon>
</div> </div>
<n-text style="font-size: 16px">点击或拖拽文件到此处上传</n-text> <n-text style="font-size: 16px">点击或拖拽文件到此处上传</n-text>
<n-p depth="3" style="margin: 8px 0 0 0">支持 .xlsx .xls 格式</n-p> <n-p depth="3" style="margin: 8px 0 0 0">支持 .xlsx .xls 格式</n-p>
@ -144,13 +162,29 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, h, onMounted } from 'vue' import {ref, reactive, h, onMounted} from 'vue'
import { NButton, NSpace, NIcon, NUpload, useMessage, useDialog, type DataTableColumns, type UploadCustomRequestOptions } from 'naive-ui' import {
import { SearchOutline, RefreshOutline, AddOutline, TrashOutline, CreateOutline, CloudUploadOutline, DownloadOutline } from '@vicons/ionicons5' NButton,
import { stationHandoverApi, type StationHandover } from '@/api/stationHandover' NSpace,
import { sectionApi,Section } from '@/api/section' NIcon,
import { deviceApi,Device} from '@/api/device' NUpload,
import { userApi,SysUser } from '@/api/system' useMessage,
useDialog,
type DataTableColumns,
type UploadCustomRequestOptions
} from 'naive-ui'
import {
SearchOutline,
RefreshOutline,
AddOutline,
CreateOutline,
CloudUploadOutline,
DownloadOutline
} from '@vicons/ionicons5'
import {stationHandoverApi, type StationHandover} from '@/api/stationHandover'
import { Section } from '@/api/section'
import {deviceApi, Device} from '@/api/device'
import {userApi, SysUser} from '@/api/system'
import {deptApi} from "@/api/org.ts"; import {deptApi} from "@/api/org.ts";
import {TreeNode} from "echarts/types/src/data/Tree"; import {TreeNode} from "echarts/types/src/data/Tree";
@ -191,34 +225,33 @@ const defaultFormData: StationHandover = {
stationId: undefined, stationId: undefined,
handoverPersonId: undefined, handoverPersonId: undefined,
receiverPersonId: undefined, receiverPersonId: undefined,
handoverTime: undefined, handoverTime: undefined,
} }
const formData = reactive<StationHandover>({ ...defaultFormData }) const formData = reactive<StationHandover>({...defaultFormData})
// //使 // //使
// //
const formRules = { const formRules = {}
}
// //
const columns: DataTableColumns<StationHandover> = [ const columns: DataTableColumns<StationHandover> = [
{ type: 'selection' }, {type: 'selection'},
{ title: '设备/工位', key: 'deviceName' }, {title: '设备/工位', key: 'deviceName'},
{ title: '上机人', key: 'handoverPerson' }, {title: '上机人', key: 'handoverPerson'},
{ title: '接收人', key: 'receiverPerson' }, {title: '接收人', key: 'receiverPerson'},
{ title: '交接时间', key: 'handoverTime' }, {title: '交接时间', key: 'handoverTime'},
{ title: '交接备注', key: 'remark' }, {title: '交接备注', key: 'remark'},
{ title: '创建时间', key: 'createTime', width: 180 }, {title: '创建时间', key: 'createTime', width: 180},
{ {
title: '操作', title: '操作',
key: 'actions', key: 'actions',
width: 140, width: 140,
fixed: 'right', fixed: 'right',
render(row) { render(row) {
return h('div', { style: { display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'nowrap' } }, [ return h('div', {style: {display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'nowrap'}}, [
h(NButton, { size: 'small', quaternary: true, onClick: () => handleEdit(row) }, { h(NButton, {size: 'small', quaternary: true, onClick: () => handleEdit(row)}, {
default: () => [h(NIcon, null, { default: () => h(CreateOutline) }), ' 编辑'] default: () => [h(NIcon, null, {default: () => h(CreateOutline)}), ' 编辑']
}) })
]) ])
} }
@ -229,7 +262,7 @@ const columns: DataTableColumns<StationHandover> = [
async function loadData() { async function loadData() {
loading.value = true loading.value = true
try { try {
const deviceIds = searchForm.deviceIds != null ?JSON.stringify(searchForm.deviceIds) :null const deviceIds = searchForm.deviceIds != null ? JSON.stringify(searchForm.deviceIds) : null
const res = await stationHandoverApi.page({ const res = await stationHandoverApi.page({
page: pagination.page, page: pagination.page,
pageSize: pagination.pageSize, pageSize: pagination.pageSize,
@ -250,7 +283,7 @@ function handleSearch() {
// //
function handleReset() { function handleReset() {
searchForm.deviceIds = null searchForm.deviceIds = null
handleSearch() handleSearch()
} }
@ -298,7 +331,7 @@ function handleEdit(row: StationHandover) {
async function handleSubmit() { async function handleSubmit() {
await formRef.value?.validate() await formRef.value?.validate()
try { try {
const submitData = { ...formData } as StationHandover const submitData = {...formData} as StationHandover
if (typeof submitData.handoverTime === 'number') { if (typeof submitData.handoverTime === 'number') {
submitData.handoverTime = new Date(submitData.handoverTime).toISOString().slice(0, 19).replace('T', ' ') submitData.handoverTime = new Date(submitData.handoverTime).toISOString().slice(0, 19).replace('T', ' ')
} }
@ -392,7 +425,7 @@ async function handleDownloadTemplate() {
} }
// //
async function handleImportUpload({ file }: UploadCustomRequestOptions) { async function handleImportUpload({file}: UploadCustomRequestOptions) {
if (!file.file) return if (!file.file) return
try { try {
const result = await stationHandoverApi.importData(file.file) const result = await stationHandoverApi.importData(file.file)
@ -422,10 +455,11 @@ async function loadSection() {
const data = await deptApi.tree() const data = await deptApi.tree()
sectionList.value = buildOptions(data); sectionList.value = buildOptions(data);
} }
function handleUpdateValue(key:any) {
function handleUpdateValue(key: any) {
console.log(key);
loadDevice(key) console.log(key);
loadDevice(key)
} }
@ -446,28 +480,28 @@ function buildOptions(d: any[]): TreeNode[] {
} }
/// ///
async function loadDevice(sectionIdList:number[]) { async function loadDevice(sectionIdList: number[]) {
const sectionIds = sectionIdList != null ?JSON.stringify(sectionIdList) :null const sectionIds = sectionIdList != null ? JSON.stringify(sectionIdList) : null
const res = await deviceApi.getDeviceList({ const res = await deviceApi.getDeviceList({
sectionIds sectionIds
}) })
deviceList.value = res.map((n:any)=>{ deviceList.value = res.map((n: any) => {
return { return {
label:n.deviceName, label: n.deviceName,
value:n.id value: n.id
} }
}) })
} }
// //
async function loadUserList() { async function loadUserList() {
const res = await userApi.getPathList(); const res = await userApi.getPathList();
userList.value = res.map((n:any)=>{ userList.value = res.map((n: any) => {
return { return {
label:n.username, label: n.username,
value:n.id value: n.id
} }
}) })
} }

View File

@ -0,0 +1,641 @@
<template>
<div class="page-container">
<n-card>
<div class="table-toolbar">
<n-space>
<n-button type="primary" @click="handleAdd">
<template #icon><n-icon><AddOutline /></n-icon></template>
新建入库单
</n-button>
<n-button type="error" :disabled="selectedIds.length === 0" @click="handleBatchDelete">
<template #icon><n-icon><TrashOutline /></n-icon></template>
批量删除
</n-button>
</n-space>
<n-space>
<n-button quaternary circle @click="loadData">
<template #icon><n-icon><RefreshOutline /></n-icon></template>
</n-button>
</n-space>
</div>
<div class="search-form">
<n-form inline :model="searchForm" label-placement="left" size="small">
<n-form-item label="入库单号">
<n-input v-model:value="searchForm.inboundCode" placeholder="OWR-" clearable style="width: 150px" />
</n-form-item>
<n-form-item label="来源单号">
<n-input v-model:value="searchForm.sourceOrderNo" placeholder="工单/订单号" clearable style="width: 150px" />
</n-form-item>
<n-form-item label="入库类型">
<n-select
v-model:value="searchForm.inboundType"
placeholder="全部"
clearable
style="width: 120px"
:options="typeOptions"
/>
</n-form-item>
<n-form-item label="当前阶段">
<n-select
v-model:value="searchForm.status"
placeholder="全部"
clearable
style="width: 120px"
:options="statusOptions"
/>
</n-form-item>
<n-form-item label="金蝶入库单">
<n-input v-model:value="searchForm.kingdeeInboundNo" placeholder="金蝶编码" clearable style="width: 140px" />
</n-form-item>
<n-form-item>
<n-space>
<n-button type="primary" size="small" @click="handleSearch">
<template #icon><n-icon><SearchOutline /></n-icon></template>
搜索
</n-button>
<n-button size="small" @click="handleReset">重置</n-button>
</n-space>
</n-form-item>
</n-form>
</div>
<n-data-table
:columns="columns"
:data="tableData"
:loading="loading"
:pagination="pagination"
:row-key="(row) => row.id!"
:scroll-x="1680"
@update:page="handlePageChange"
@update:page-size="handlePageSizeChange"
@update:checked-row-keys="handleCheck"
/>
</n-card>
<!-- 详情 -->
<n-modal v-model:show="detailVisible" preset="card" title="入库单详情" style="width: 720px">
<n-descriptions v-if="detailData" :column="2" bordered size="small" label-placement="left">
<n-descriptions-item label="入库单号">{{ detailData.inboundCode || '-' }}</n-descriptions-item>
<n-descriptions-item label="当前阶段">{{ statusLabel(detailData.status) }}</n-descriptions-item>
<n-descriptions-item label="入库类型">{{ typeLabel(detailData.inboundType) }}</n-descriptions-item>
<n-descriptions-item label="来源单号">{{ detailData.sourceOrderNo || '-' }}</n-descriptions-item>
<n-descriptions-item label="工单号">{{ detailData.workOrderCode || '-' }}</n-descriptions-item>
<n-descriptions-item label="金蝶入库单编码">{{ detailData.kingdeeInboundNo || '-' }}</n-descriptions-item>
<n-descriptions-item label="物料编码">{{ detailData.materialCode || '-' }}</n-descriptions-item>
<n-descriptions-item label="物料名称">{{ detailData.materialName || '-' }}</n-descriptions-item>
<n-descriptions-item label="入库数量">{{ formatQty(detailData.quantity) }}</n-descriptions-item>
<n-descriptions-item label="入库仓库">{{ detailData.warehouseName || '-' }}</n-descriptions-item>
<n-descriptions-item label="入库进度">{{ detailData.progress ?? 0 }}%</n-descriptions-item>
<n-descriptions-item label="创建时间">{{ detailData.createTime || '-' }}</n-descriptions-item>
<n-descriptions-item label="更新时间">{{ detailData.updateTime || '-' }}</n-descriptions-item>
<n-descriptions-item label="备注" :span="2">{{ detailData.remark || '-' }}</n-descriptions-item>
</n-descriptions>
</n-modal>
<!-- 新增/编辑 -->
<n-modal v-model:show="modalVisible" preset="card" :title="modalTitle" style="width: 720px">
<n-form ref="formRef" :model="formData" :rules="formRules" label-placement="left" label-width="110px">
<n-grid :cols="2" :x-gap="16">
<n-form-item-gi label="入库类型" path="inboundType">
<n-select v-model:value="formData.inboundType" :options="typeOptions" />
</n-form-item-gi>
<n-form-item-gi label="入库仓库" path="warehouseName">
<n-input v-model:value="formData.warehouseName" placeholder="如:成品仓" />
</n-form-item-gi>
<n-form-item-gi label="来源单号" path="sourceOrderNo">
<n-input v-model:value="formData.sourceOrderNo" placeholder="生产订单号/委外单号" />
</n-form-item-gi>
<n-form-item-gi label="工单号" path="workOrderCode">
<n-input
v-model:value="formData.workOrderCode"
placeholder="工序工单号(保存时后端可补物料/数量)"
@blur="onWorkOrderBlur"
/>
</n-form-item-gi>
<n-form-item-gi label="生产订单ID" path="orderItemId">
<n-input-number v-model:value="formData.orderItemId" :min="1" :precision="0" clearable style="width: 100%" placeholder="mes_order_item.id" />
</n-form-item-gi>
<n-form-item-gi label="入库数量" path="quantity">
<n-input-number v-model:value="formData.quantity" :min="0.0001" :precision="4" style="width: 100%" />
</n-form-item-gi>
<n-form-item-gi label="物料编码" path="materialCode">
<n-input v-model:value="formData.materialCode" placeholder="物料编码" />
</n-form-item-gi>
<n-form-item-gi label="物料名称" path="materialName">
<n-input v-model:value="formData.materialName" placeholder="物料名称" />
</n-form-item-gi>
<n-form-item-gi label="金蝶入库单" path="kingdeeInboundNo">
<n-input v-model:value="formData.kingdeeInboundNo" placeholder="确认入库时可填写" />
</n-form-item-gi>
<n-form-item-gi :span="2" label="备注" path="remark">
<n-input v-model:value="formData.remark" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" />
</n-form-item-gi>
</n-grid>
</n-form>
<template #footer>
<n-space justify="end">
<n-button @click="modalVisible = false">取消</n-button>
<n-button type="primary" :loading="submitLoading" @click="handleSubmit">保存</n-button>
</n-space>
</template>
</n-modal>
<!-- 确认入库 -->
<n-modal v-model:show="confirmVisible" preset="card" title="确认入库" style="width: 480px">
<n-form label-placement="left" label-width="120px">
<n-form-item label="入库单号">
<n-input :value="confirmRow?.inboundCode" disabled />
</n-form-item>
<n-form-item label="金蝶入库单编码">
<n-input v-model:value="confirmKingdeeNo" placeholder="推送金蝶成功后的单号(可后补)" clearable />
</n-form-item>
</n-form>
<template #footer>
<n-space justify="end">
<n-button @click="confirmVisible = false">取消</n-button>
<n-button type="primary" :loading="submitLoading" @click="doConfirm">确认入库</n-button>
</n-space>
</template>
</n-modal>
</div>
</template>
<script setup lang="ts">
import { ref, reactive, h, onMounted } from 'vue'
import {
NButton, NSpace, NIcon, NTag, NModal, NForm, NFormItem, NFormItemGi, NGrid,
NInput, NInputNumber, NSelect, NDescriptions, NDescriptionsItem, NProgress,
useMessage, useDialog, type DataTableColumns, type FormRules,
} from 'naive-ui'
import {
SearchOutline, RefreshOutline, AddOutline, TrashOutline,
CheckmarkCircleOutline, EllipseOutline, PlayOutline,
} from '@vicons/ionicons5'
import {
stockInApi,
STOCK_IN_TYPE_MAP,
STOCK_IN_STATUS_MAP,
type StockIn,
} from '@/api/stockIn'
const message = useMessage()
const dialog = useDialog()
const searchForm = reactive({
inboundCode: '',
sourceOrderNo: '',
inboundType: null as number | null,
status: null as number | null,
kingdeeInboundNo: '',
})
const typeOptions = Object.entries(STOCK_IN_TYPE_MAP).map(([value, item]) => ({
label: item.label,
value: Number(value),
}))
const statusOptions = Object.entries(STOCK_IN_STATUS_MAP).map(([value, item]) => ({
label: item.label,
value: Number(value),
}))
const tableData = ref<StockIn[]>([])
const loading = ref(false)
const submitLoading = ref(false)
const selectedIds = ref<number[]>([])
const pagination = reactive({
page: 1,
pageSize: 10,
itemCount: 0,
showSizePicker: true,
pageSizes: [10, 20, 50],
})
const detailVisible = ref(false)
const detailData = ref<StockIn | null>(null)
const modalVisible = ref(false)
const modalTitle = ref('')
const formRef = ref()
const confirmVisible = ref(false)
const confirmRow = ref<StockIn | null>(null)
const confirmKingdeeNo = ref('')
const defaultFormData = (): Record<string, any> => ({
id: undefined,
inboundType: 1,
sourceOrderNo: '',
orderItemId: null,
workOrderCode: '',
processPlanId: null,
materialCode: '',
materialName: '',
quantity: null,
warehouseName: '',
subjectName: '',
kingdeeInboundNo: '',
remark: '',
})
const formData = reactive<Record<string, any>>(defaultFormData())
const formRules: FormRules = {
inboundType: [{ required: true, type: 'number', message: '请选择入库类型', trigger: ['blur', 'change'] }],
warehouseName: [{ required: true, message: '请输入入库仓库', trigger: 'blur' }],
quantity: [{ required: true, type: 'number', message: '请输入入库数量', trigger: ['blur', 'change'] }],
}
function formatQty(val?: number | string | null) {
if (val == null || val === '') return '0'
return Number(val).toLocaleString()
}
function typeLabel(type?: number) {
if (type == null) return '-'
return STOCK_IN_TYPE_MAP[type]?.label ?? String(type)
}
function statusLabel(status?: number) {
if (status == null) return '-'
return STOCK_IN_STATUS_MAP[status]?.label ?? String(status)
}
const columns: DataTableColumns<StockIn> = [
{ type: 'selection', width: 48, align: 'center', fixed: 'left' },
{
title: '主体 / 单号',
key: 'inboundCode',
width: 200,
fixed: 'left',
render(row) {
return h('div', { class: 'subject-cell' }, [
h('div', { class: 'subject-name' }, row.subjectName || row.warehouseName || '-'),
h('div', { class: 'subject-code' }, row.inboundCode || '-'),
])
},
},
{
title: '入库类型',
key: 'inboundType',
width: 110,
align: 'center',
render(row) {
const item = STOCK_IN_TYPE_MAP[row.inboundType ?? 1] ?? STOCK_IN_TYPE_MAP[1]
return h(NTag, { type: item.type, size: 'small', round: true }, { default: () => item.label })
},
},
{
title: '来源单号',
key: 'sourceOrderNo',
width: 150,
ellipsis: { tooltip: true },
render: (row) => row.sourceOrderNo || row.workOrderCode || '-',
},
{
title: '入库数量',
key: 'quantity',
width: 100,
align: 'center',
render: (row) => formatQty(row.quantity),
},
{
title: '入库进度',
key: 'progress',
width: 140,
render(row) {
const p = row.progress ?? 0
return h(NProgress, {
type: 'line',
percentage: p,
indicatorPlacement: 'inside',
processing: p > 0 && p < 100,
status: p >= 100 ? 'success' : 'default',
height: 16,
})
},
},
{
title: '入库仓库',
key: 'warehouseName',
width: 110,
ellipsis: { tooltip: true },
render: (row) => row.warehouseName || '-',
},
{
title: '金蝶入库单编码',
key: 'kingdeeInboundNo',
width: 150,
ellipsis: { tooltip: true },
render: (row) => row.kingdeeInboundNo || '-',
},
{
title: '时间',
key: 'createTime',
width: 160,
render: (row) => row.createTime || '-',
},
{
title: '更新时间',
key: 'updateTime',
width: 180,
render(row) {
return h('div', [
h('div', row.updateTime || '-'),
h('div', { class: 'muted' }, row.updateBy ? `更新人 ${row.updateBy}` : ''),
])
},
},
{
title: '当前阶段',
key: 'status',
width: 110,
align: 'center',
render(row) {
const status = row.status ?? 0
const item = STOCK_IN_STATUS_MAP[status] ?? STOCK_IN_STATUS_MAP[0]
const done = status === 2
return h('div', { class: 'status-cell' }, [
h(NIcon, { color: done ? '#18a058' : '#bfbfbf', size: 16 }, {
default: () => h(done ? CheckmarkCircleOutline : EllipseOutline),
}),
h('span', item.label),
])
},
},
{
title: '操作',
key: 'actions',
width: 200,
align: 'center',
fixed: 'right',
render(row) {
const status = row.status ?? 0
const btns = [
h(NButton, { text: true, type: 'primary', size: 'small', onClick: () => openDetail(row) }, { default: () => '详情' }),
]
if (status === 0 || status === 1 || status === 3) {
btns.push(
h(NButton, {
text: true,
type: 'primary',
size: 'small',
onClick: () => openConfirm(row),
}, {
default: () => h('span', { class: 'action-with-icon' }, [
h(NIcon, { size: 14 }, { default: () => h(PlayOutline) }),
' 确认入库',
]),
}),
)
btns.push(
h(NButton, { text: true, type: 'primary', size: 'small', onClick: () => handleEdit(row) }, { default: () => '编辑' }),
)
btns.push(
h(NButton, {
text: true,
type: 'error',
size: 'small',
onClick: () => handleDelete([row.id!]),
}, {
default: () => h(NIcon, { size: 16 }, { default: () => h(TrashOutline) }),
}),
)
}
if (status === 2) {
btns.push(
h(NButton, { text: true, type: 'warning', size: 'small', onClick: () => handleRevoke(row) }, { default: () => '撤回入库' }),
)
}
return h(NSpace, { size: 4, justify: 'center' }, { default: () => btns })
},
},
]
async function loadData() {
loading.value = true
try {
const res = await stockInApi.page({
page: pagination.page,
pageSize: pagination.pageSize,
inboundCode: searchForm.inboundCode || undefined,
sourceOrderNo: searchForm.sourceOrderNo || undefined,
inboundType: searchForm.inboundType ?? undefined,
status: searchForm.status ?? undefined,
kingdeeInboundNo: searchForm.kingdeeInboundNo || undefined,
})
tableData.value = res.list ?? []
pagination.itemCount = res.total ?? 0
} catch (e: any) {
message.error(e?.message || '加载失败')
} finally {
loading.value = false
}
}
function handleSearch() {
pagination.page = 1
loadData()
}
function handleReset() {
searchForm.inboundCode = ''
searchForm.sourceOrderNo = ''
searchForm.inboundType = null
searchForm.status = null
searchForm.kingdeeInboundNo = ''
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 openDetail(row: StockIn) {
detailData.value = row
detailVisible.value = true
}
function handleAdd() {
Object.assign(formData, defaultFormData())
modalTitle.value = '新建入库单'
modalVisible.value = true
}
function handleEdit(row: StockIn) {
Object.assign(formData, defaultFormData(), {
id: row.id,
inboundType: row.inboundType ?? 1,
sourceOrderNo: row.sourceOrderNo || '',
orderItemId: row.orderItemId ?? null,
workOrderCode: row.workOrderCode || '',
processPlanId: row.processPlanId ?? null,
materialCode: row.materialCode || '',
materialName: row.materialName || '',
quantity: row.quantity != null ? Number(row.quantity) : null,
warehouseName: row.warehouseName || '',
subjectName: row.subjectName || '',
kingdeeInboundNo: row.kingdeeInboundNo || '',
remark: row.remark || '',
})
modalTitle.value = '编辑入库单'
modalVisible.value = true
}
function onWorkOrderBlur() {
const code = (formData.workOrderCode || '').trim()
if (code && !formData.sourceOrderNo) {
formData.sourceOrderNo = code
}
}
async function handleSubmit() {
try {
await formRef.value?.validate()
} catch {
return
}
submitLoading.value = true
try {
const payload = {
id: formData.id,
inboundType: formData.inboundType,
sourceOrderNo: formData.sourceOrderNo || undefined,
orderItemId: formData.orderItemId || undefined,
workOrderCode: formData.workOrderCode || undefined,
processPlanId: formData.processPlanId || undefined,
materialCode: formData.materialCode || undefined,
materialName: formData.materialName || undefined,
quantity: formData.quantity,
warehouseName: formData.warehouseName,
subjectName: formData.subjectName || formData.warehouseName,
kingdeeInboundNo: formData.kingdeeInboundNo || undefined,
remark: formData.remark || undefined,
}
if (formData.id) {
await stockInApi.update(payload)
message.success('保存成功')
} else {
await stockInApi.create(payload)
message.success('创建成功')
}
modalVisible.value = false
loadData()
} catch (e: any) {
message.error(e?.message || '保存失败')
} finally {
submitLoading.value = false
}
}
function openConfirm(row: StockIn) {
confirmRow.value = row
confirmKingdeeNo.value = row.kingdeeInboundNo || ''
confirmVisible.value = true
}
async function doConfirm() {
if (!confirmRow.value?.id) return
submitLoading.value = true
try {
await stockInApi.confirm(confirmRow.value.id, confirmKingdeeNo.value || null)
message.success('已确认入库')
confirmVisible.value = false
loadData()
} catch (e: any) {
message.error(e?.message || '确认失败')
} finally {
submitLoading.value = false
}
}
function handleRevoke(row: StockIn) {
dialog.warning({
title: '撤回入库',
content: `确认撤回入库单 ${row.inboundCode}`,
positiveText: '撤回',
negativeText: '取消',
onPositiveClick: async () => {
try {
await stockInApi.revoke(row.id!)
message.success('已撤回')
loadData()
} catch (e: any) {
message.error(e?.message || '撤回失败')
}
},
})
}
function handleDelete(ids: number[]) {
dialog.warning({
title: '删除确认',
content: `确认删除选中的 ${ids.length} 条入库单?`,
positiveText: '删除',
negativeText: '取消',
onPositiveClick: async () => {
try {
await stockInApi.delete(ids)
message.success('删除成功')
selectedIds.value = []
loadData()
} catch (e: any) {
message.error(e?.message || '删除失败')
}
},
})
}
function handleBatchDelete() {
if (!selectedIds.value.length) return
handleDelete([...selectedIds.value])
}
onMounted(() => {
loadData()
})
</script>
<style scoped>
.table-toolbar {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.search-form {
margin-bottom: 12px;
}
.subject-cell .subject-name {
font-weight: 600;
color: #1f2225;
}
.subject-cell .subject-code {
margin-top: 2px;
font-size: 12px;
color: #8b8f97;
}
.status-cell {
display: inline-flex;
align-items: center;
gap: 4px;
}
.muted {
font-size: 12px;
color: #8b8f97;
}
.action-with-icon {
display: inline-flex;
align-items: center;
gap: 2px;
}
</style>

File diff suppressed because it is too large Load Diff

View File

@ -319,8 +319,7 @@ const AssingWorkColumns :DataTableColumns<AssingWork> = [
const showQcReport = ref<boolean>(false) const showQcReport = ref<boolean>(false)
const reportTitle = ref<string>() const reportTitle = ref<string>()
//
const loadingRowIds = ref<Set<number>>(new Set())
const AssingWorkDetailColums:DataTableColumns<AssingWorkDetail> = [ const AssingWorkDetailColums:DataTableColumns<AssingWorkDetail> = [
{ {