This commit is contained in:
zc
2026-03-17 10:47:57 +08:00
parent 5554cf1548
commit 722fbd988c
16 changed files with 700 additions and 27 deletions

1
package-lock.json generated
View File

@@ -766,6 +766,7 @@
}, },
"node_modules/@clack/prompts/node_modules/is-unicode-supported": { "node_modules/@clack/prompts/node_modules/is-unicode-supported": {
"version": "1.3.0", "version": "1.3.0",
"extraneous": true,
"inBundle": true, "inBundle": true,
"license": "MIT", "license": "MIT",
"engines": { "engines": {

View File

@@ -3,6 +3,7 @@ import http from '@/utils/http'
const BASE_URL = '/admin/materialInfo' const BASE_URL = '/admin/materialInfo'
export interface MaterialInfoResp { export interface MaterialInfoResp {
id: string
materialName: string materialName: string
encoding: string encoding: string
unitWeight: string unitWeight: string
@@ -13,6 +14,7 @@ export interface MaterialInfoResp {
createUserString: string createUserString: string
updateUserString: string updateUserString: string
disabled: boolean disabled: boolean
photoLoadError: boolean
} }
export interface MaterialInfoQuery { export interface MaterialInfoQuery {
materialName: string | undefined materialName: string | undefined

View File

@@ -0,0 +1,53 @@
import http from '@/utils/http'
import type {LabelValueState} from "@/types/global";
const BASE_URL = '/materialProcess/materialProcess'
export interface MaterialProcessResp {
id: string
processName: string
processCode: string
createTime: string
updateTime: string
createUser: string
updateUser: string
createUserString: string
updateUserString: string
disabled: boolean
}
export interface MaterialProcessQuery {
processName: string | undefined
processCode: string | undefined
sort: Array<string>
}
export interface MaterialProcessPageQuery extends MaterialProcessQuery, PageQuery {}
/** @desc 查询海康物料流程列表 */
export function listMaterialProcess(query: MaterialProcessPageQuery) {
return http.get<PageRes<MaterialProcessResp[]>>(`${BASE_URL}`, query)
}
/** @desc 查询海康物料流程详情 */
export function selectList() {
return http.get(`${BASE_URL}/selectList`)
}
/** @desc 新增海康物料流程 */
export function addMaterialProcess(data: any) {
return http.post(`${BASE_URL}`, data)
}
/** @desc 修改海康物料流程 */
export function updateMaterialProcess(data: any, id: string) {
return http.put(`${BASE_URL}/${id}`, data)
}
/** @desc 删除海康物料流程 */
export function deleteMaterialProcess(id: string) {
return http.del(`${BASE_URL}/${id}`)
}
/** @desc 导出海康物料流程 */
export function exportMaterialProcess(query: MaterialProcessQuery) {
return http.download(`${BASE_URL}/export`, query)
}

View File

@@ -0,0 +1,46 @@
import http from '@/utils/http'
const BASE_URL = '/materialType/materialType'
export interface MaterialTypeResp {
id: string
typeName: string
floatRatio: string
createTime: string
updateTime: string
createUser: string
updateUser: string
createUserString: string
updateUserString: string
disabled: boolean
}
export interface MaterialTypeQuery {
typeName: string | undefined
sort: Array<string>
}
export interface MaterialTypePageQuery extends MaterialTypeQuery, PageQuery {}
/** @desc 查询物料品类列表 */
export function listMaterialType(query: MaterialTypePageQuery) {
return http.get<PageRes<MaterialTypeResp[]>>(`${BASE_URL}`, query)
}
/** @desc 新增物料品类 */
export function selectList() {
return http.get(`${BASE_URL}/selectList`)
}
/** @desc 修改物料品类 */
export function updateMaterialType(data: any, id: string) {
return http.put(`${BASE_URL}/${id}`, data)
}
/** @desc 删除物料品类 */
export function deleteMaterialType(id: string) {
return http.del(`${BASE_URL}/${id}`)
}
/** @desc 导出物料品类 */
export function exportMaterialType(query: MaterialTypeQuery) {
return http.download(`${BASE_URL}/export`, query)
}

View File

@@ -0,0 +1,22 @@
import { ref } from 'vue'
import { selectList } from '@/apis/materialProcess/materialProcess'
import type { LabelValueState } from '@/types/global'
/** 物料品类模块 */
export function materialProcess(options?: { onSuccess?: () => void }) {
const loading = ref(false)
const materialProcessList = ref<LabelValueState[]>([])
const getMaterialProcessSelect = async () => {
try {
loading.value = true
const res = await selectList()
materialProcessList.value = res.data
// eslint-disable-next-line ts/no-unused-expressions
options?.onSuccess && options.onSuccess()
} finally {
loading.value = false
}
}
return { materialProcessList, getMaterialProcessSelect, loading }
}

View File

@@ -0,0 +1,22 @@
import { ref } from 'vue'
import { selectList } from '@/apis/materialType/materialType'
import type { LabelValueState } from '@/types/global'
/** 物料品类模块 */
export function materialType(options?: { onSuccess?: () => void }) {
const loading = ref(false)
const materialTypeList = ref<LabelValueState[]>([])
const getMaterialTypeSelect = async () => {
try {
loading.value = true
const res = await selectList()
materialTypeList.value = res.data
// eslint-disable-next-line ts/no-unused-expressions
options?.onSuccess && options.onSuccess()
} finally {
loading.value = false
}
}
return { materialTypeList, getMaterialTypeSelect, loading }
}

View File

@@ -13,8 +13,10 @@ declare module 'vue' {
ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb'] ABreadcrumb: typeof import('@arco-design/web-vue')['Breadcrumb']
ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem'] ABreadcrumbItem: typeof import('@arco-design/web-vue')['BreadcrumbItem']
AButton: typeof import('@arco-design/web-vue')['Button'] AButton: typeof import('@arco-design/web-vue')['Button']
ACard: typeof import('@arco-design/web-vue')['Card']
ACheckbox: typeof import('@arco-design/web-vue')['Checkbox'] ACheckbox: typeof import('@arco-design/web-vue')['Checkbox']
ACol: typeof import('@arco-design/web-vue')['Col'] ACol: typeof import('@arco-design/web-vue')['Col']
AColorPicker: typeof import('@arco-design/web-vue')['ColorPicker']
AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider'] AConfigProvider: typeof import('@arco-design/web-vue')['ConfigProvider']
ADatePicker: typeof import('@arco-design/web-vue')['DatePicker'] ADatePicker: typeof import('@arco-design/web-vue')['DatePicker']
ADescriptions: typeof import('@arco-design/web-vue')['Descriptions'] ADescriptions: typeof import('@arco-design/web-vue')['Descriptions']
@@ -35,14 +37,17 @@ declare module 'vue' {
AInputPassword: typeof import('@arco-design/web-vue')['InputPassword'] AInputPassword: typeof import('@arco-design/web-vue')['InputPassword']
AInputSearch: typeof import('@arco-design/web-vue')['InputSearch'] AInputSearch: typeof import('@arco-design/web-vue')['InputSearch']
ALayout: typeof import('@arco-design/web-vue')['Layout'] ALayout: typeof import('@arco-design/web-vue')['Layout']
ALayoutContent: typeof import('@arco-design/web-vue')['LayoutContent']
ALayoutHeader: typeof import('@arco-design/web-vue')['LayoutHeader'] ALayoutHeader: typeof import('@arco-design/web-vue')['LayoutHeader']
ALayoutSider: typeof import('@arco-design/web-vue')['LayoutSider'] ALayoutSider: typeof import('@arco-design/web-vue')['LayoutSider']
ALink: typeof import('@arco-design/web-vue')['Link'] ALink: typeof import('@arco-design/web-vue')['Link']
AMenu: typeof import('@arco-design/web-vue')['Menu'] AMenu: typeof import('@arco-design/web-vue')['Menu']
AMenuItem: typeof import('@arco-design/web-vue')['MenuItem'] AMenuItem: typeof import('@arco-design/web-vue')['MenuItem']
AModal: typeof import('@arco-design/web-vue')['Modal'] AModal: typeof import('@arco-design/web-vue')['Modal']
AOption: typeof import('@arco-design/web-vue')['Option']
AOverflowList: typeof import('@arco-design/web-vue')['OverflowList'] AOverflowList: typeof import('@arco-design/web-vue')['OverflowList']
APagination: typeof import('@arco-design/web-vue')['Pagination'] APagination: typeof import('@arco-design/web-vue')['Pagination']
APopconfirm: typeof import('@arco-design/web-vue')['Popconfirm']
APopover: typeof import('@arco-design/web-vue')['Popover'] APopover: typeof import('@arco-design/web-vue')['Popover']
AProgress: typeof import('@arco-design/web-vue')['Progress'] AProgress: typeof import('@arco-design/web-vue')['Progress']
ARadio: typeof import('@arco-design/web-vue')['Radio'] ARadio: typeof import('@arco-design/web-vue')['Radio']
@@ -51,6 +56,8 @@ declare module 'vue' {
ARow: typeof import('@arco-design/web-vue')['Row'] ARow: typeof import('@arco-design/web-vue')['Row']
AScrollbar: typeof import('@arco-design/web-vue')['Scrollbar'] AScrollbar: typeof import('@arco-design/web-vue')['Scrollbar']
ASelect: typeof import('@arco-design/web-vue')['Select'] ASelect: typeof import('@arco-design/web-vue')['Select']
ASkeleton: typeof import('@arco-design/web-vue')['Skeleton']
ASkeletonLine: typeof import('@arco-design/web-vue')['SkeletonLine']
ASpace: typeof import('@arco-design/web-vue')['Space'] ASpace: typeof import('@arco-design/web-vue')['Space']
ASpin: typeof import('@arco-design/web-vue')['Spin'] ASpin: typeof import('@arco-design/web-vue')['Spin']
AStatistic: typeof import('@arco-design/web-vue')['Statistic'] AStatistic: typeof import('@arco-design/web-vue')['Statistic']
@@ -61,8 +68,11 @@ declare module 'vue' {
ATabs: typeof import('@arco-design/web-vue')['Tabs'] ATabs: typeof import('@arco-design/web-vue')['Tabs']
ATag: typeof import('@arco-design/web-vue')['Tag'] ATag: typeof import('@arco-design/web-vue')['Tag']
ATooltip: typeof import('@arco-design/web-vue')['Tooltip'] ATooltip: typeof import('@arco-design/web-vue')['Tooltip']
ATree: typeof import('@arco-design/web-vue')['Tree']
ATreeSelect: typeof import('@arco-design/web-vue')['TreeSelect'] ATreeSelect: typeof import('@arco-design/web-vue')['TreeSelect']
ATrigger: typeof import('@arco-design/web-vue')['Trigger']
ATypographyParagraph: typeof import('@arco-design/web-vue')['TypographyParagraph'] ATypographyParagraph: typeof import('@arco-design/web-vue')['TypographyParagraph']
ATypographyTitle: typeof import('@arco-design/web-vue')['TypographyTitle']
AUpload: typeof import('@arco-design/web-vue')['Upload'] AUpload: typeof import('@arco-design/web-vue')['Upload']
Avatar: typeof import('./../components/Avatar/index.vue')['default'] Avatar: typeof import('./../components/Avatar/index.vue')['default']
AWatermark: typeof import('@arco-design/web-vue')['Watermark'] AWatermark: typeof import('@arco-design/web-vue')['Watermark']

View File

@@ -77,7 +77,7 @@
<tr> <tr>
<td class="label-cell"> <td class="label-cell">
<div class="label-row"> <div class="label-row">
<div class="label-field">标重(kg)</div> <div class="label-field">标重(g)</div>
<div class="label-value">{{ labelData.totalCalculatedWeight }}</div> <div class="label-value">{{ labelData.totalCalculatedWeight }}</div>
</div> </div>
</td> </td>
@@ -91,7 +91,7 @@
<tr> <tr>
<td class="label-cell"> <td class="label-cell">
<div class="label-row"> <div class="label-row">
<div class="label-field">实重(kg)</div> <div class="label-field">实重(g)</div>
<div class="label-value">{{ labelData.totalWeight || '' }}</div> <div class="label-value">{{ labelData.totalWeight || '' }}</div>
</div> </div>
</td> </td>
@@ -147,19 +147,6 @@ const labelData = reactive({
qrCodeData: '', qrCodeData: '',
}) })
// 标签数据
// const labelData = reactive({
// partName: '物料3',
// partNumber: '1',
// totalCalculatedWeight: '100',
// totalWeight: '100',
// productionDate: '202401010000',
// totalCount: '100',
// packingSignature: '',
// inspectionSignature: '',
// qrCodeData: '10#$$DY',
// })
// 标签容器引用 // 标签容器引用
const labelContainer = ref<HTMLElement | null>(null) const labelContainer = ref<HTMLElement | null>(null)

View File

@@ -19,6 +19,8 @@ import { useWindowSize } from '@vueuse/core'
import { addMaterialInfo, getMaterialInfo, updateMaterialInfo } from '@/apis/material/materialInfo' import { addMaterialInfo, getMaterialInfo, updateMaterialInfo } from '@/apis/material/materialInfo'
import { type ColumnItem, GiForm } from '@/components/GiForm' import { type ColumnItem, GiForm } from '@/components/GiForm'
import { useResetReactive } from '@/hooks' import { useResetReactive } from '@/hooks'
import { materialType } from "@/hooks/app/materialType";
import {materialProcess} from "@/hooks/app/materialProcess";
const emit = defineEmits<{ const emit = defineEmits<{
(e: 'save-success'): void (e: 'save-success'): void
@@ -32,6 +34,11 @@ const isUpdate = computed(() => !!dataId.value)
const title = computed(() => (isUpdate.value ? '修改物料管理' : '新增物料管理')) const title = computed(() => (isUpdate.value ? '修改物料管理' : '新增物料管理'))
const formRef = ref<InstanceType<typeof GiForm>>() const formRef = ref<InstanceType<typeof GiForm>>()
const { materialTypeList, getMaterialTypeSelect } = materialType()
const { materialProcessList, getMaterialProcessSelect } = materialProcess()
const [form, resetForm] = useResetReactive({ const [form, resetForm] = useResetReactive({
// todo 待补充 // todo 待补充
}) })
@@ -56,6 +63,31 @@ const columns: ColumnItem[] = reactive([
field: 'unitWeight', field: 'unitWeight',
type: 'input-number', type: 'input-number',
span: 24, span: 24,
required: true,
},
{
label: '物料品类',
field: 'materialTypeId',
type: 'select',
span: 24,
required: true,
props: {
options: materialTypeList,
allowClear: true,
allowSearch: true,
},
},
{
label: '物料流程编码',
field: 'materialProcessId',
type: 'select',
span: 24,
required: true,
props: {
options: materialProcessList,
allowClear: true,
allowSearch: true,
},
}, },
{ {
label: '物料规格', label: '物料规格',
@@ -69,6 +101,7 @@ const columns: ColumnItem[] = reactive([
type: 'image', type: 'image',
savePath: 'material/', savePath: 'material/',
span: 24, span: 24,
required: true,
}, },
]) ])
@@ -101,6 +134,12 @@ const save = async () => {
const onAdd = async () => { const onAdd = async () => {
reset() reset()
dataId.value = '' dataId.value = ''
if (!materialTypeList.value.length) {
await getMaterialTypeSelect()
}
if (!materialProcessList.value.length) {
await getMaterialProcessSelect();
}
visible.value = true visible.value = true
} }
@@ -109,6 +148,12 @@ const onUpdate = async (id: string) => {
reset() reset()
dataId.value = id dataId.value = id
const { data } = await getMaterialInfo(id) const { data } = await getMaterialInfo(id)
if (!materialTypeList.value.length) {
await getMaterialTypeSelect()
}
if (!materialProcessList.value.length) {
await getMaterialProcessSelect();
}
Object.assign(form, data) Object.assign(form, data)
visible.value = true visible.value = true
} }

View File

@@ -99,8 +99,6 @@ import has from '@/utils/has'
defineOptions({ name: 'MaterialInfo' }) defineOptions({ name: 'MaterialInfo' })
// 扩展类型定义,允许动态添加 photoLoadError 属性
// 如果 TS 报错,可以在 MaterialInfoResp 接口定义中添加 photoLoadError?: boolean;
interface MaterialInfoRespWithStatus extends MaterialInfoResp { interface MaterialInfoRespWithStatus extends MaterialInfoResp {
photoLoadError?: boolean; photoLoadError?: boolean;
} }
@@ -108,7 +106,7 @@ interface MaterialInfoRespWithStatus extends MaterialInfoResp {
const queryForm = reactive<MaterialInfoQuery>({ const queryForm = reactive<MaterialInfoQuery>({
materialName: undefined, materialName: undefined,
encoding: undefined, encoding: undefined,
sort: ['id,desc'], sort: ['mi.id,desc'],
}) })
const { const {
@@ -123,6 +121,7 @@ const columns = ref<TableInstanceColumns[]>([
{ title: '物料名称', dataIndex: 'materialName', slotName: 'materialName' }, { title: '物料名称', dataIndex: 'materialName', slotName: 'materialName' },
{ title: '物料编码', dataIndex: 'encoding', slotName: 'encoding' }, { title: '物料编码', dataIndex: 'encoding', slotName: 'encoding' },
{ title: '物料单位重量(g)', dataIndex: 'unitWeight', slotName: 'unitWeight' }, { title: '物料单位重量(g)', dataIndex: 'unitWeight', slotName: 'unitWeight' },
{ title: '物料品类', dataIndex: 'typeName' },
{ title: '物料规格', dataIndex: 'materialSpec', slotName: 'materialSpec' }, { title: '物料规格', dataIndex: 'materialSpec', slotName: 'materialSpec' },
{ title: '物料照片', dataIndex: 'photoUrl', slotName: 'photoUrl', width: 120, align: 'center' }, { title: '物料照片', dataIndex: 'photoUrl', slotName: 'photoUrl', width: 120, align: 'center' },
{ title: '创建人', dataIndex: 'createUserString', slotName: 'createUser' }, { title: '创建人', dataIndex: 'createUserString', slotName: 'createUser' },

View File

@@ -0,0 +1,104 @@
<template>
<a-modal
v-model:visible="visible"
:title="title"
:mask-closable="false"
:esc-to-close="false"
:width="width >= 600 ? 600 : '100%'"
draggable
@before-ok="save"
@close="reset"
>
<GiForm ref="formRef" v-model="form" :columns="columns" />
</a-modal>
</template>
<script setup lang="ts">
import { Message } from '@arco-design/web-vue'
import { useWindowSize } from '@vueuse/core'
import {
getMaterialProcess,
addMaterialProcess,
updateMaterialProcess,
type MaterialProcessResp
} from '@/apis/materialProcess/materialProcess'
import { type ColumnItem, GiForm } from '@/components/GiForm'
import { useResetReactive } from '@/hooks'
const emit = defineEmits<{
(e: 'save-success'): void
}>()
const { width } = useWindowSize()
const dataId = ref('')
const visible = ref(false)
const isUpdate = computed(() => !!dataId.value)
const title = computed(() => (isUpdate.value ? '修改海康物料流程' : '新增海康物料流程'))
const formRef = ref<InstanceType<typeof GiForm>>()
const [form, resetForm] = useResetReactive({
// todo 待补充
})
const columns: ColumnItem[] = reactive([
{
label: '流程名称',
field: 'processName',
type: 'input',
span: 24,
required: true,
},
{
label: '流程编码',
field: 'processCode',
type: 'input',
span: 24,
required: true,
},
])
// 重置
const reset = () => {
formRef.value?.formRef?.resetFields()
resetForm()
}
// 保存
const save = async () => {
try {
const isInvalid = await formRef.value?.formRef?.validate()
if (isInvalid) return false
if (isUpdate.value) {
await updateMaterialProcess(form, dataId.value)
Message.success('修改成功')
} else {
await addMaterialProcess(form)
Message.success('新增成功')
}
emit('save-success')
return true
} catch (error) {
return false
}
}
// 新增
const onAdd = async () => {
reset()
dataId.value = ''
visible.value = true
}
// 修改
const onUpdate = async (record: MaterialProcessResp) => {
reset()
dataId.value = record.id
Object.assign(form, record)
visible.value = true
}
defineExpose({ onAdd, onUpdate })
</script>
<style scoped lang="scss"></style>

View File

@@ -0,0 +1,130 @@
<template>
<div class="gi_table_page">
<GiTable
title="海康物料流程管理"
row-key="id"
:data="dataList"
:columns="columns"
:loading="loading"
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
:pagination="pagination"
:disabled-tools="['size']"
:disabled-column-keys="['name']"
@refresh="search"
>
<template #toolbar-left>
<a-input-search v-model="queryForm.processName" placeholder="请输入流程名称" allow-clear @search="search" />
<a-input-search v-model="queryForm.processCode" placeholder="请输入流程编码" allow-clear @search="search" />
<a-button @click="reset">
<template #icon><icon-refresh /></template>
<template #default>重置</template>
</a-button>
</template>
<template #toolbar-right>
<a-button v-permission="['materialProcess:materialProcess:add']" type="primary" @click="onAdd">
<template #icon><icon-plus /></template>
<template #default>新增</template>
</a-button>
<a-button v-permission="['materialProcess:materialProcess:export']" @click="onExport">
<template #icon><icon-download /></template>
<template #default>导出</template>
</a-button>
</template>
<template #action="{ record }">
<a-space>
<a-link v-permission="['materialProcess:materialProcess:update']" title="修改" @click="onUpdate(record)">修改</a-link>
<a-link
v-permission="['materialProcess:materialProcess:delete']"
status="danger"
:disabled="record.disabled"
:title="record.disabled ? '不可删除' : '删除'"
@click="onDelete(record)"
>
删除
</a-link>
</a-space>
</template>
</GiTable>
<MaterialProcessAddModal ref="MaterialProcessAddModalRef" @save-success="search" />
</div>
</template>
<script setup lang="ts">
import MaterialProcessAddModal from './MaterialProcessAddModal.vue'
import { type MaterialProcessResp, type MaterialProcessQuery, deleteMaterialProcess, exportMaterialProcess, listMaterialProcess } from '@/apis/materialProcess/materialProcess'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useDownload, useTable } from '@/hooks'
import { isMobile } from '@/utils'
import has from '@/utils/has'
defineOptions({ name: 'MaterialProcess' })
const queryForm = reactive<MaterialProcessQuery>({
processName: undefined,
processCode: undefined,
sort: ['id,desc']
})
const {
tableData: dataList,
loading,
pagination,
search,
handleDelete
} = useTable((page) => listMaterialProcess({ ...queryForm, ...page }), { immediate: true })
const columns = ref<TableInstanceColumns[]>([
{ title: '主键ID', dataIndex: 'id', slotName: 'id' },
{ title: '流程名称', dataIndex: 'processName', slotName: 'processName' },
{ title: '流程编码', dataIndex: 'processCode', slotName: 'processCode' },
{ title: '创建时间', dataIndex: 'createTime', slotName: 'createTime' },
{ title: '更新时间', dataIndex: 'updateTime', slotName: 'updateTime', show: false },
{ title: '创建人', dataIndex: 'createUserString', slotName: 'createUser' },
{ title: '更新人', dataIndex: 'updateUserString', slotName: 'updateUser', show: false },
{
title: '操作',
dataIndex: 'action',
slotName: 'action',
width: 160,
align: 'center',
fixed: !isMobile() ? 'right' : undefined,
show: has.hasPermOr(['materialProcess:materialProcess:detail', 'materialProcess:materialProcess:update', 'materialProcess:materialProcess:delete'])
}
]);
// 重置
const reset = () => {
queryForm.processName = undefined
queryForm.processCode = undefined
search()
}
// 删除
const onDelete = (record: MaterialProcessResp) => {
return handleDelete(() => deleteMaterialProcess(record.id), {
content: `是否确定删除该条数据?`,
showModal: true
})
}
// 导出
const onExport = () => {
useDownload(() => exportMaterialProcess(queryForm))
}
const MaterialProcessAddModalRef = ref<InstanceType<typeof MaterialProcessAddModal>>()
// 新增
const onAdd = () => {
MaterialProcessAddModalRef.value?.onAdd()
}
// 修改
const onUpdate = (record: MaterialProcessResp) => {
MaterialProcessAddModalRef.value?.onUpdate(record)
}
</script>
<style scoped lang="scss"></style>

View File

@@ -0,0 +1,99 @@
<template>
<a-modal
v-model:visible="visible"
:title="title"
:mask-closable="false"
:esc-to-close="false"
:width="width >= 600 ? 600 : '100%'"
draggable
@before-ok="save"
@close="reset"
>
<GiForm ref="formRef" v-model="form" :columns="columns" />
</a-modal>
</template>
<script setup lang="ts">
import { Message } from '@arco-design/web-vue'
import { useWindowSize } from '@vueuse/core'
import {addMaterialType, type MaterialTypeResp, updateMaterialType} from '@/apis/materialType/materialType'
import { type ColumnItem, GiForm } from '@/components/GiForm'
import { useResetReactive } from '@/hooks'
const emit = defineEmits<{
(e: 'save-success'): void
}>()
const { width } = useWindowSize()
const dataId = ref('')
const visible = ref(false)
const isUpdate = computed(() => !!dataId.value)
const title = computed(() => (isUpdate.value ? '修改物料品类' : '新增物料品类'))
const formRef = ref<InstanceType<typeof GiForm>>()
const [form, resetForm] = useResetReactive({
})
const columns: ColumnItem[] = reactive([
{
label: '品类名称',
field: 'typeName',
type: 'input',
span: 24,
required: true,
},
{
label: '品类浮动比',
field: 'floatRatio',
type: 'input-number',
span: 24,
required: true,
},
])
// 重置
const reset = () => {
formRef.value?.formRef?.resetFields()
resetForm()
}
// 保存
const save = async () => {
try {
const isInvalid = await formRef.value?.formRef?.validate()
if (isInvalid) return false
if (isUpdate.value) {
await updateMaterialType(form, dataId.value)
Message.success('修改成功')
} else {
await addMaterialType(form)
Message.success('新增成功')
}
emit('save-success')
return true
} catch (error) {
return false
}
}
// 新增
const onAdd = async () => {
reset()
dataId.value = ''
visible.value = true
}
// 修改
const onUpdate = async (data: MaterialTypeResp) => {
reset()
dataId.value = data.id
Object.assign(form, data)
visible.value = true
}
defineExpose({ onAdd, onUpdate })
</script>
<style scoped lang="scss"></style>

View File

@@ -0,0 +1,149 @@
<template>
<div class="gi_table_page">
<GiTable
title="物料品类管理"
row-key="id"
:data="dataList"
:columns="columns"
:loading="loading"
:scroll="{ x: '100%', y: '100%', minWidth: 1000 }"
:pagination="pagination"
:disabled-tools="['size']"
:disabled-column-keys="['name']"
:selected-keys="selectedKeys"
:row-selection="{ type: 'checkbox', showCheckedAll: true }"
@select-all="selectAll"
@select="select"
@refresh="search"
>
<template #toolbar-left>
<a-input-search v-model="queryForm.typeName" placeholder="请输入品类名称" allow-clear @search="search" />
<a-button @click="reset">
<template #icon><icon-refresh /></template>
<template #default>重置</template>
</a-button>
</template>
<template #toolbar-right>
<a-button v-permission="['materialType:materialType:add']" type="primary" @click="onAdd">
<template #icon><icon-plus /></template>
<template #default>新增</template>
</a-button>
<a-button v-permission="['materialType:materialType:export']" @click="onExport">
<template #icon><icon-download /></template>
<template #default>导出</template>
</a-button>
</template>
<template #action="{ record }">
<a-space>
<a-link v-permission="['materialType:materialType:update']" title="修改" @click="onUpdate(record)">修改</a-link>
<a-link
v-permission="['materialType:materialType:delete']"
status="danger"
@click="onDelete(record.id)"
>
删除
</a-link>
</a-space>
</template>
</GiTable>
<MaterialTypeAddModal ref="MaterialTypeAddModalRef" @save-success="search" />
</div>
</template>
<script setup lang="ts">
import { h } from 'vue'
import MaterialTypeAddModal from './MaterialTypeAddModal.vue'
import { type MaterialTypeResp, type MaterialTypeQuery, deleteMaterialType, exportMaterialType, listMaterialType } from '@/apis/materialType/materialType'
import type { TableInstanceColumns } from '@/components/GiTable/type'
import { useDownload, useTable } from '@/hooks'
import { isMobile } from '@/utils'
import has from '@/utils/has'
defineOptions({ name: 'MaterialType' })
const queryForm = reactive<MaterialTypeQuery>({
typeName: undefined,
sort: ['id,desc']
})
const {
tableData: dataList,
loading,
pagination,
selectedKeys,
select,
selectAll,
search,
handleDelete
} = useTable((page) => listMaterialType({ ...queryForm, ...page }), { immediate: true })
const columns = ref<TableInstanceColumns[]>([
{ title: '主键ID', dataIndex: 'id', slotName: 'id' },
{ title: '品类名称', dataIndex: 'typeName', slotName: 'typeName' },
{
title: h('span', null, [
'品类浮动比',
h('a-tooltip', {
title: '计算公式:电子称称重重量/(物料单位克重*物料数量)- 1'
}, [
h('span', {
style: {
marginLeft: '4px',
cursor: 'help',
color: '#1890ff'
}
}, '?')
])
]),
dataIndex: 'floatRatio',
slotName: 'floatRatio'
},
{ title: '创建时间', dataIndex: 'createTime', slotName: 'createTime' },
{ title: '更新时间', dataIndex: 'updateTime', slotName: 'updateTime', show: false },
{ title: '创建人', dataIndex: 'createUserString', slotName: 'createUser' },
{ title: '更新人', dataIndex: 'updateUserString', slotName: 'updateUser', show: false },
{
title: '操作',
dataIndex: 'action',
slotName: 'action',
width: 160,
align: 'center',
fixed: !isMobile() ? 'right' : undefined,
show: has.hasPermOr(['materialType:materialType:detail', 'materialType:materialType:update', 'materialType:materialType:delete'])
}
]);
// 重置
const reset = () => {
queryForm.typeName = undefined
search()
}
// 删除
const onDelete = (id) => {
return handleDelete(() => deleteMaterialType(id), {
content: `是否确定删除该条数据?`,
showModal: true
})
}
// 导出
const onExport = () => {
useDownload(() => exportMaterialType(queryForm))
}
const MaterialTypeAddModalRef = ref<InstanceType<typeof MaterialTypeAddModal>>()
// 新增
const onAdd = () => {
MaterialTypeAddModalRef.value?.onAdd()
}
// 修改
const onUpdate = (record: MaterialTypeResp) => {
MaterialTypeAddModalRef.value?.onUpdate(record)
}
</script>
<style scoped lang="scss"></style>

View File

@@ -74,7 +74,7 @@
<!-- 图片展示 --> <!-- 图片展示 -->
<div class="image-placeholder square-image"> <div class="image-placeholder square-image">
<img <img
src="@/assets/images/001.bmp" :src="imgData.imgUrl"
alt="图片展示" alt="图片展示"
style="width: 100%; height: 100%; object-fit: cover; border-radius: 4px;" style="width: 100%; height: 100%; object-fit: cover; border-radius: 4px;"
/> />
@@ -230,16 +230,16 @@
<span class="label">物料编码:</span> <span class="label">物料编码:</span>
<span class="value">{{ formData.encoding }}</span> <span class="value">{{ formData.encoding }}</span>
</div> </div>
<div class="info-item">
<span class="label">物料规格:</span>
<span class="value">{{ formData.materialSpec }}</span>
</div>
<div class="info-item"> <div class="info-item">
<span class="label">物料总个数:</span> <span class="label">物料总个数:</span>
<span class="value">{{ workOrderResp.totalCount }}</span> <span class="value">{{ workOrderResp.totalCount }}</span>
</div> </div>
<div class="info-item"> <div class="info-item">
<span class="label">物料总重量(g):</span> <span class="label">标准总重量(g):</span>
<span class="value">{{ workOrderResp.totalCalculatedWeight }}</span>
</div>
<div class="info-item">
<span class="label">实际总重量(g):</span>
<span class="value">{{ workOrderResp.totalWeight }}</span> <span class="value">{{ workOrderResp.totalWeight }}</span>
</div> </div>
</div> </div>
@@ -556,7 +556,7 @@ watch(activeStep, (newVal) => {
// 组件挂载时 // 组件挂载时
onMounted(async () => { onMounted(async () => {
await loadFlvJs() await loadFlvJs()
pollingInterval = setInterval(getImage, 1000) // pollingInterval = setInterval(getImage, 1000)
}) })
// 组件卸载时 // 组件卸载时
@@ -741,7 +741,6 @@ const handleNext = async () => {
// 准备工作订单数据 // 准备工作订单数据
const workOrderData = { const workOrderData = {
materialId: formData.id, materialId: formData.id,
materialName: formData.materialName,
workOrderInfos: weighingList.value, workOrderInfos: weighingList.value,
} }
// 调用后端接口 // 调用后端接口
@@ -755,6 +754,7 @@ const handleNext = async () => {
workOrderResp.value.title = res.data?.title || '' workOrderResp.value.title = res.data?.title || ''
workOrderResp.value.orderNo = res.data?.orderNo || '' workOrderResp.value.orderNo = res.data?.orderNo || ''
workOrderResp.value.totalWeight = res.data?.totalWeight || '' workOrderResp.value.totalWeight = res.data?.totalWeight || ''
workOrderResp.value.totalCalculatedWeight = res.data?.totalCalculatedWeight || ''
workOrderResp.value.totalCount = res.data?.totalCount || '' workOrderResp.value.totalCount = res.data?.totalCount || ''
// 关闭WebSocket连接 // 关闭WebSocket连接

View File

@@ -63,6 +63,9 @@
<template #totalWeight="{ record }"> <template #totalWeight="{ record }">
{{ record.totalWeight + 'g' }} {{ record.totalWeight + 'g' }}
</template> </template>
<template #totalCalculatedWeight="{ record }">
{{ record.totalCalculatedWeight + 'g' }}
</template>
<template #action="{ record }"> <template #action="{ record }">
<a-space> <a-space>
@@ -171,8 +174,9 @@ const columns = ref<TableInstanceColumns[]>(processColumns([
{ title: '物料名称', dataIndex: 'materialName' }, { title: '物料名称', dataIndex: 'materialName' },
{ title: '物料编码', dataIndex: 'encoding' }, { title: '物料编码', dataIndex: 'encoding' },
{ title: '单位克重', dataIndex: 'unitWeight' ,slotName: 'unitWeight'}, { title: '单位克重', dataIndex: 'unitWeight' ,slotName: 'unitWeight'},
{ title: '总重量', dataIndex: 'totalWeight' ,slotName: 'totalWeight'},
{ title: '总数量', dataIndex: 'totalCount' }, { title: '总数量', dataIndex: 'totalCount' },
{ title: '标准总重量', dataIndex: 'totalCalculatedWeight' ,slotName: 'totalCalculatedWeight'},
{ title: '实际总重量', dataIndex: 'totalWeight' ,slotName: 'totalWeight'},
{ title: '创建时间', dataIndex: 'createTime', width: 180 }, { title: '创建时间', dataIndex: 'createTime', width: 180 },
{ {
title: '操作', title: '操作',