zhang_li
7 months ago
5 changed files with 247 additions and 24 deletions
@ -0,0 +1,27 @@ |
|||
import request from '@/config/axios' |
|||
export interface InspectionRequestPackageVO { |
|||
number: string |
|||
packageCode: string |
|||
packageSpecificationCode: string |
|||
amount: string |
|||
measuringUnit: string |
|||
} |
|||
|
|||
//查询包装列表
|
|||
export const getInspectionRequestPackageList = async (id: number) => { |
|||
return await request.get({ url: `/qms/inspection-request-package/list?masterId=` + id }) |
|||
} |
|||
// 新增检验申请
|
|||
export const createInspectionRequestPackage = async (data: InspectionRequestPackageVO) => { |
|||
return await request.post({ url: `/qms/inspection-request-package/create`, data }) |
|||
} |
|||
|
|||
// 修改检验申请
|
|||
export const updateInspectionRequestPackage = async (data: InspectionRequestPackageVO) => { |
|||
return await request.put({ url: `/qms/inspection-request-package/update`, data }) |
|||
} |
|||
|
|||
// 删除检验申请
|
|||
export const deleteInspectionRequestPackage = async (id: number) => { |
|||
return await request.delete({ url: `/qms/inspection-request-package/delete?id=` + id }) |
|||
} |
@ -1,40 +1,202 @@ |
|||
<template> |
|||
<div> |
|||
<Dialog v-model="isPackageShow" :title="dialogTitle" :width="width?width:'900px'" v-loading="packageLoading"> |
|||
<Dialog |
|||
v-model="isPackageShow" |
|||
:title="dialogTitle" |
|||
:width="width ? width : '900px'" |
|||
v-loading="packageLoading" |
|||
> |
|||
<TableHead |
|||
:HeadButttondata="HeadButttondata" |
|||
:masterId="masterParmas.masterId" |
|||
@button-base-click="buttonBaseClick" |
|||
:allSchemas="detailAllSchemas" |
|||
/> |
|||
<Table |
|||
ref="searchTableRef" |
|||
:columns="columns" |
|||
:data="allList" |
|||
:reserveSelection="true" |
|||
row-key="id" |
|||
/> |
|||
> |
|||
<template #action="{ row }"> |
|||
<ButtonBase |
|||
:Butttondata="butttondata" |
|||
@button-base-click="buttonTableClick($event, row)" |
|||
/> |
|||
</template> |
|||
</Table> |
|||
</Dialog> |
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="formRef" |
|||
:rules="detailAllSchemasRules" |
|||
:formAllSchemas="detailAllSchemas" |
|||
:isBusiness="false" |
|||
:apiUpdate="apiUpdate" |
|||
:apiCreate="apiCreate" |
|||
:isDetail="true" |
|||
:detailData="detailData" |
|||
@success="submitForm" |
|||
/> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
|
|||
const isPackageShow = ref(false) |
|||
const packageLoading = ref(false) |
|||
const dialogTitle = ref() |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
const message = useMessage() // 消息弹窗 |
|||
const columns = ref() |
|||
const allList = ref() |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
// 接受父组件参数 |
|||
const props = defineProps({ |
|||
width: { |
|||
type: String, |
|||
required: false |
|||
}, |
|||
// 明细列表相关信息 |
|||
detailAllSchemas: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
}, |
|||
// 明细验证 |
|||
detailAllSchemasRules: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
}, |
|||
// 子表新增API |
|||
apiCreate: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 子表编辑API |
|||
apiUpdate: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 子表新增修改校验 |
|||
detailValidate: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 子列表 删除 展示与隐藏 ,默认展示 |
|||
detailButtonIsShowDelete: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: true |
|||
}, |
|||
// 列表 |
|||
list: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
} |
|||
}) |
|||
|
|||
const isPackageShow = ref(false) |
|||
const packageLoading = ref(false) |
|||
const dialogTitle = ref() |
|||
const columns = ref() |
|||
const allList = ref([]) |
|||
|
|||
//主表所需的参数 |
|||
const masterParmas = ref({ |
|||
masterId: '', //主表id |
|||
number: '' //主表单据号 |
|||
}) |
|||
const openPackage = async (row?: any, titleName?: any,tableColumns?: any,list?: any) => { |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = ref() |
|||
// 列表-操作按钮 |
|||
const butttondata = ref() |
|||
const detailData = ref({}) |
|||
const openPackage = async (row?: any, titleName?: any, tableColumns?: any, list?: any) => { |
|||
isPackageShow.value = true |
|||
detailData.value = row |
|||
masterParmas.value.masterId = row.masterId || row.id |
|||
masterParmas.value.number = row.number |
|||
if(detailData.value.status ==1){ |
|||
HeadButttondata.value = [ |
|||
defaultButtons.defaultAddBtn(null) // 新增 |
|||
] |
|||
butttondata.value =[ |
|||
defaultButtons.mainListEditBtn(null), // 编辑 |
|||
defaultButtons.mainListDeleteBtn(null) //删除 |
|||
] |
|||
columns.value = tableColumns |
|||
}else{ |
|||
columns.value = tableColumns.filter(item=>item.field != 'action') |
|||
|
|||
} |
|||
if (titleName) { |
|||
dialogTitle.value = titleName |
|||
} |
|||
columns.value = tableColumns.filter(item => (item.field !== 'action')) |
|||
allList.value = list |
|||
} |
|||
defineExpose({ openPackage }) // 提供 open 方法,用于打开弹窗 |
|||
|
|||
// 根据状态返回该按钮是否显示 |
|||
const isShowMainButton = (row, val) => { |
|||
if (val.indexOf(row.status) > -1) { |
|||
return false |
|||
} else { |
|||
return true |
|||
} |
|||
} |
|||
// 头部按钮事件 |
|||
const buttonBaseClick = (val, item) => { |
|||
if (val == 'add') { |
|||
// 新增 |
|||
openForm('create') |
|||
} |
|||
} |
|||
/** 添加/修改操作 */ |
|||
const formRef = ref() |
|||
const openForm = async (type: string, row?: number) => { |
|||
formRef.value.open(type, row, masterParmas.value) |
|||
} |
|||
const submitForm = async (formType, data) => { |
|||
try { |
|||
// 子表新增编辑校验 如果业务需要子表提交校验 需在主页详情组件添加 detailValidate 参数及方法 |
|||
const rs = (await props.detailValidate) ? await props.detailValidate(data) : true |
|||
if (!rs) return |
|||
emit('ListTableSubmit', formType, data) |
|||
// 刷新当前列表 |
|||
} finally { |
|||
formRef.value.formLoading = false |
|||
} |
|||
} |
|||
// 列表-操作按钮事件 |
|||
const buttonTableClick = async (val, row) => { |
|||
if (val == 'edit') { |
|||
// 编辑 |
|||
openForm('update', row) |
|||
} else if (val == 'delete') { |
|||
// 删除 |
|||
handleDelete(row) |
|||
} |
|||
} |
|||
const handleDelete = async (row: any) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
emit('ListTableSubmit', 'detele', row) |
|||
} catch {} |
|||
} |
|||
const emit = defineEmits(['ListTableSubmit']) // 定义 success 事件,用于操作成功后的回调 |
|||
defineExpose({ openPackage, formRef }) // 提供 open 方法,用于打开弹窗 |
|||
watch( |
|||
() => props.list, |
|||
(newValue) => { |
|||
allList.value = newValue |
|||
formRef.value.dialogVisible = false |
|||
}, |
|||
{ |
|||
deep: true |
|||
} |
|||
) |
|||
</script> |
|||
|
|||
|
Loading…
Reference in new issue