zhang_li
10 months ago
12 changed files with 1030 additions and 218 deletions
@ -1,51 +1,51 @@ |
|||
import request from '@/config/axios' |
|||
|
|||
export interface DeviceMaintenanceDetailVO { |
|||
describes: string |
|||
describes1: string |
|||
workOut: string |
|||
maintenances: string |
|||
describes: string |
|||
describes1: string |
|||
workOut: string |
|||
maintenances: string |
|||
} |
|||
|
|||
// 查询维修工单子列表
|
|||
export const getDeviceMaintenanceDetailPage = async (params) => { |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = {...params} |
|||
return await request.post({ url: '/wms/purchasereceipt-request-detail/senior', data }) |
|||
} else { |
|||
return await request.get({ url: `/admin-api/eam/device-maintenance-detail/page`, params }) |
|||
} |
|||
if (params.isSearch) { |
|||
delete params.isSearch |
|||
const data = {...params} |
|||
return await request.post({ url: '/wms/purchasereceipt-request-detail/senior', data }) |
|||
} else { |
|||
return await request.get({ url: `/eam/device-maintenance-detail/page`, params }) |
|||
} |
|||
} |
|||
|
|||
// 查询维修工单子详情
|
|||
export const getPurchasereceiptRequestDetail = async (id: number) => { |
|||
return await request.get({ url: `/eam/device-maintenance-detail/get?id=` + id }) |
|||
export const getPurchasereceiptRequestDetail = async (id) => { |
|||
return await request.get({ url: `/eam/device-maintenance-detail/selectListByNumber?id=` + id }) |
|||
} |
|||
|
|||
// 新增维修工单子
|
|||
export const createDeviceMaintenanceDetail = async (data: DeviceMaintenanceDetailVO) => { |
|||
return await request.post({ url: `/eam/device-maintenance-detail/create`, data }) |
|||
return await request.post({ url: `/eam/device-maintenance-detail/create`, data }) |
|||
} |
|||
|
|||
// 修改维修工单子
|
|||
export const updateDeviceMaintenanceDetail = async (data: DeviceMaintenanceDetailVO) => { |
|||
return await request.put({ url: `/eam/device-maintenance-detail/update`, data }) |
|||
return await request.put({ url: `/eam/device-maintenance-detail/update`, data }) |
|||
} |
|||
|
|||
// 删除维修工单子
|
|||
export const deleteDeviceMaintenanceDetail = async (id: number) => { |
|||
return await request.delete({ url: `/eam/device-maintenance-detail/delete?id=` + id }) |
|||
return await request.delete({ url: `/eam/device-maintenance-detail/delete?id=` + id }) |
|||
} |
|||
|
|||
|
|||
|
|||
// 导出维修工单子 Excel
|
|||
export const exportPurchasereceiptRequestDetail = async (params) => { |
|||
return await request.download({ url: `/wms/purchasereceipt-request-detail/export-excel`, params }) |
|||
return await request.download({ url: `/wms/purchasereceipt-request-detail/export-excel`, params }) |
|||
} |
|||
|
|||
// 下载用户导入模板
|
|||
export const importTemplate = () => { |
|||
return request.download({ url: '/wms/purchasereceipt-request-detail/get-import-template' }) |
|||
} |
|||
return request.download({ url: '/wms/purchasereceipt-request-detail/get-import-template' }) |
|||
} |
|||
|
@ -0,0 +1,557 @@ |
|||
<template> |
|||
<div> |
|||
<el-drawer |
|||
v-model="isShowDrawer" |
|||
title="详情" |
|||
direction="rtl" |
|||
size="80%" |
|||
v-loading="detailLoading" |
|||
> |
|||
<template #header> |
|||
<div class="font-size-18px"> |
|||
{{ titleValueRef }} <span class="ml-20px font-size-16px">{{ titleNameRef }}</span> |
|||
</div> |
|||
</template> |
|||
<ContentWrap> |
|||
<Descriptions |
|||
:data="detailData" |
|||
labelClassName="label-class-name" |
|||
label-align="left" |
|||
direction="vertical" |
|||
:column="8" |
|||
:schema="allSchemas.detailSchema" |
|||
:columns="2" |
|||
width="200px" |
|||
/> |
|||
</ContentWrap> |
|||
|
|||
<Tabs :tabsList="tabsList" :current="current" @change="change" /> |
|||
<div class="flex"> |
|||
<!-- 详情 --> |
|||
<ContentWrap class="w-[100%]"> |
|||
<!-- 列表头部 --> |
|||
<TableHead |
|||
v-if="!isBasic" |
|||
:HeadButttondata="HeadButttondata" |
|||
:number="masterParmas.number" |
|||
@button-base-click="buttonBaseClick" |
|||
:routeName="routeName" |
|||
@searchFormClick="searchFormClick" |
|||
:allSchemas="detailAllSchemas" |
|||
/> |
|||
<!-- 默认单表展现 --> |
|||
<Descriptions |
|||
v-if="isBasic && !tabsExtend" |
|||
:data="detailData" |
|||
:schema="allSchemas.detailSchema" |
|||
:columns="2" |
|||
/> |
|||
<!-- 单表切换tabs 展现table --> |
|||
<Table |
|||
v-if="isBasic && tabsExtend" |
|||
:columns="detailAllSchemasRef.tableColumns" |
|||
:data="tableObjectRef.tableList" |
|||
:loading="tableObjectRef.loading" |
|||
:pagination="{ total: tableObjectRef.total }" |
|||
v-model:pageSize="tableObjectRef.pageSize" |
|||
v-model:currentPage="tableObjectRef.currentPage" |
|||
> |
|||
<!-- <template #action="{ row }"> |
|||
<ButtonBase |
|||
:Butttondata="buttondata" |
|||
@button-base-click="buttonTableClick($event, row)" |
|||
/> |
|||
</template> --> |
|||
</Table> |
|||
<Table |
|||
v-if="!isBasic && fromeWhere != 'countPlan'" |
|||
:columns="detailAllSchemasRef.tableColumns" |
|||
:data="tableObjectRef.tableList" |
|||
:loading="tableObjectRef.loading" |
|||
:pagination="{ total: tableObjectRef.total }" |
|||
v-model:pageSize="tableObjectRef.pageSize" |
|||
v-model:currentPage="tableObjectRef.currentPage" |
|||
> |
|||
<template #photos="{ row }"> |
|||
<div v-for="(item,index) in row.photos.split(',')" :key="index" style="color:#409eff ; cursor: pointer;" @click="openImage(item)">{{ item }}</div> |
|||
</template> |
|||
<template #action="{ row }"> |
|||
<ButtonBase |
|||
:Butttondata="buttondata" |
|||
@button-base-click="buttonTableClick($event, row)" |
|||
/> |
|||
</template> |
|||
</Table> |
|||
<DetailTable |
|||
v-if="!isBasic && fromeWhere == 'countPlan' && isShowDrawer" |
|||
:columns="detailAllSchemasRef.tableColumns" |
|||
:data="tableObjectRef.tableList" |
|||
:allList="allList" |
|||
:countScopeType="countScopeType" |
|||
:key="updateKey" |
|||
> |
|||
<template #action="{ row }"> |
|||
<ButtonBase |
|||
:Butttondata="buttondata" |
|||
@button-base-click="buttonTableClick($event, row)" |
|||
/> |
|||
</template> |
|||
</DetailTable> |
|||
</ContentWrap> |
|||
</div> |
|||
</el-drawer> |
|||
<!-- 表单弹窗:添加/修改 --> |
|||
<BasicForm |
|||
ref="formRef" |
|||
@success="submitForm" |
|||
:rules="detailAllSchemasRules" |
|||
:formAllSchemas="detailAllSchemas" |
|||
:isBusiness="false" |
|||
:apiUpdate="apiUpdate" |
|||
:apiCreate="apiCreate" |
|||
:fromeWhere="fromeWhere" |
|||
:isDetail="true" |
|||
@searchTableSuccess="searchTableSuccess" |
|||
:detailData="detailData" |
|||
@submitForm="submitForm" |
|||
@selectChangeDetail="selectChangeDetail" |
|||
:formTypeDetail="formTypeDetail" |
|||
:countPlanAllList="countPlanAllList" |
|||
/> |
|||
</div> |
|||
</template> |
|||
|
|||
<script lang="ts" setup> |
|||
import Tabs from '@/components/Tabs/src/Tabs.vue' |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
import BasicForm from '@/components/BasicForm/src/BasicForm.vue' |
|||
import TableHead from '@/components/TableHead/src/TableHead.vue' |
|||
import DetailTable from '@/components/DetailTable/src/DetailTable.vue' |
|||
|
|||
defineOptions({ name: 'Detail' }) |
|||
|
|||
const message = useMessage() // 消息弹窗 |
|||
const { t } = useI18n() // 国际化 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
routeName.value = routeName.value.substring(0, routeName.value.length - 4) + 'Detail' |
|||
const updateKey = ref(0) |
|||
|
|||
const props = defineProps({ |
|||
// 标签参数 |
|||
tabs: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
}, |
|||
// 是否是基础数据 展现详情顶部表单 |
|||
isBasic: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
// 表单,列表 相关信息 |
|||
allSchemas: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
}, |
|||
// 明细列表相关信息 |
|||
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 |
|||
}, |
|||
// 子表分页列表API |
|||
apiPage: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 子表删除API |
|||
apiDelete: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 子表新增修改校验 |
|||
detailValidate: { |
|||
type: Function, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 来源 countPlan盘点计划进入 |
|||
fromeWhere: { |
|||
type: String, |
|||
required: false, |
|||
default: '' |
|||
}, |
|||
// 获取接口列表集合 |
|||
allList: { |
|||
type: Object, |
|||
required: true, |
|||
default: null |
|||
}, |
|||
// 盘点范围类型 |
|||
countScopeType: { |
|||
type: Array, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
//盘点详情子表新增的时候判断盘点范围值显示输入框还是下拉框 |
|||
formTypeDetail: { |
|||
type: String, |
|||
required: false, |
|||
default: 'InputString' |
|||
}, |
|||
//盘点详情子表新增的时候判断盘点范围值的下拉列表 |
|||
countPlanAllList: { |
|||
type: Array, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 详情列表扩展操作按钮 |
|||
buttondataTable: { |
|||
type: Array, |
|||
required: false, |
|||
default: ()=>{ |
|||
return [] |
|||
} |
|||
}, |
|||
// 针对基础数据tabs扩展 显示table列表 默认false |
|||
tabsExtend: { |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
}, |
|||
// tableObject 数据过滤条件 针对 详情扩展标签页 传入不同条件 |
|||
tableObjectExtend: { |
|||
type: Array, |
|||
required: false, |
|||
default: null |
|||
}, |
|||
// 子列表 新增 编辑 删除的展示与隐藏,默认展示 |
|||
detailButtonIsShow:{ |
|||
type: Boolean, |
|||
required: false, |
|||
default: false |
|||
} |
|||
}) |
|||
const isShowDrawer = ref(false) |
|||
const detailLoading = ref(false) |
|||
const tabsList = ref(JSON.parse(JSON.stringify(props.tabs ? props.tabs : ''))) |
|||
|
|||
|
|||
|
|||
// Tabs当前选择 |
|||
const current = ref(0) |
|||
const change = (item, index) => { |
|||
current.value = index |
|||
emit('changeTabs', item) |
|||
} |
|||
|
|||
//主表所需的参数 |
|||
const masterParmas = ref({ |
|||
number: '', //主表id |
|||
// number: '', //主表单据号 |
|||
// status: '' //主表状态 用于控制子表新增编辑按钮显示情况 |
|||
}) |
|||
|
|||
// 列表头部按钮 |
|||
const HeadButttondata = ref() |
|||
// 列表-操作按钮 |
|||
const buttondata = ref() |
|||
|
|||
/** 打开弹窗 */ |
|||
const detailData = ref() |
|||
const titleNameRef = ref() |
|||
const titleValueRef = ref() |
|||
const openDetail = async (row: any, titleName: any, titleValue: any, tableName: any) => { |
|||
titleNameRef.value = titleName |
|||
titleValueRef.value = titleValue |
|||
// 加载明细列表 |
|||
if (!props.isBasic) { |
|||
// 设置主表id |
|||
masterParmas.value.number = row.number |
|||
// masterParmas.value.number = row.number |
|||
// masterParmas.value.status = row.status |
|||
tableObjectRef.value.params = { |
|||
number: row.number |
|||
} |
|||
await getList() |
|||
} |
|||
isShowDrawer.value = true |
|||
if (row) { |
|||
detailLoading.value = true |
|||
try { |
|||
detailData.value = row |
|||
// 判断详情新增按钮是否显示 |
|||
if (routeName.value.indexOf('Job') > -1) { |
|||
HeadButttondata.value = [ |
|||
defaultButtons.defaultFilterBtn(null) // 筛选 |
|||
] |
|||
} else { |
|||
if(!props.detailButtonIsShow){ |
|||
HeadButttondata.value = [ |
|||
defaultButtons.defaultAddBtn({ |
|||
hide: isShowMainButton(row, ['1']) |
|||
}), // 新增 |
|||
defaultButtons.defaultFilterBtn(null) // 筛选 |
|||
] |
|||
} |
|||
//盘点计划详情筛选 |
|||
if (props.fromeWhere == 'countPlan') { |
|||
HeadButttondata.value = [ |
|||
defaultButtons.defaultAddBtn({ |
|||
hide: isShowMainButton(row, ['1']) |
|||
}) // 新增 |
|||
] |
|||
} |
|||
//盘点计划详情筛选 |
|||
if (props.fromeWhere == 'putawayRequest') { |
|||
HeadButttondata.value = [ |
|||
defaultButtons.defaultFilterBtn(null) // 筛选 |
|||
] |
|||
} |
|||
//盘点调整申请筛选 |
|||
if (props.fromeWhere == 'countadjustRequest') { |
|||
HeadButttondata.value = [ |
|||
defaultButtons.defaultFilterBtn(null) // 筛选 |
|||
] |
|||
} |
|||
//采购收货详情筛选 |
|||
if (props.fromeWhere == 'purchasereceipt') { |
|||
HeadButttondata.value = [ |
|||
defaultButtons.defaultFilterBtn(null) // 筛选 |
|||
] |
|||
} |
|||
//客户收货详情筛选 |
|||
if (props.fromeWhere == 'customerreceipt') { |
|||
HeadButttondata.value = [ |
|||
defaultButtons.defaultFilterBtn(null) // 筛选 |
|||
] |
|||
} |
|||
} |
|||
|
|||
// 动态显示操作列按钮 |
|||
if(!props.detailButtonIsShow){ |
|||
buttondata.value = [...[ |
|||
defaultButtons.mainListEditBtn({ |
|||
hide: isShowMainButton(row, ['1']) |
|||
}), // 编辑 |
|||
defaultButtons.mainListDeleteBtn({ |
|||
hide: isShowMainButton(row, ['1']) |
|||
})], // 删除 |
|||
...props.buttondataTable |
|||
] |
|||
} |
|||
} finally { |
|||
detailLoading.value = false |
|||
} |
|||
} |
|||
} |
|||
defineExpose({ openDetail }) // 提供 open 方法,用于打开弹窗 |
|||
|
|||
|
|||
const tableObjectRef = ref() |
|||
const tableMethodsRef = ref() |
|||
const detailAllSchemasRef = ref() |
|||
|
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: props.apiPage // 分页接口 |
|||
}) |
|||
|
|||
tableObjectRef.value = tableObject |
|||
tableMethodsRef.value = tableMethods |
|||
detailAllSchemasRef.value = props.detailAllSchemas |
|||
|
|||
// 根据状态返回该按钮是否显示 |
|||
const isShowMainButton = (row, val) => { |
|||
if (val.indexOf(row.status) > -1) { |
|||
return false |
|||
} else { |
|||
return true |
|||
} |
|||
} |
|||
|
|||
// 获得表格的各种操作 |
|||
const { getList } = tableMethodsRef.value |
|||
|
|||
// 头部按钮事件 |
|||
const buttonBaseClick = (val, item) => { |
|||
if (val == 'add') { |
|||
// 新增 |
|||
openForm('create') |
|||
} else if (val == 'import') { |
|||
// 导入 |
|||
handleImport() |
|||
} else if (val == 'export') { |
|||
// 导出 |
|||
handleExport() |
|||
} else if (val == 'refresh') { |
|||
// 刷新 |
|||
getList() |
|||
} else if (val == 'filtrate') { |
|||
// 筛选 |
|||
} else { |
|||
// 其他按钮 |
|||
console.log('其他按钮', item) |
|||
} |
|||
} |
|||
|
|||
// 字段设置 更新主列表字段 |
|||
// const updataTableColumns = (val) => { |
|||
// detailAllSchemas.tableColumns.value = val |
|||
// } |
|||
|
|||
// 列表-操作按钮事件 |
|||
const buttonTableClick = async (val, row) => { |
|||
if (val == 'edit') { |
|||
// 编辑 |
|||
openForm('update', row) |
|||
emit('detailOpenForm', row) |
|||
} else if (val == 'delete') { |
|||
// 删除 |
|||
handleDelete(row.id) |
|||
} else { |
|||
emit('tableFormButton',val, row) |
|||
} |
|||
} |
|||
/** 添加/修改操作 */ |
|||
const formRef = ref() |
|||
const openForm = async (type: string, row?: number) => { |
|||
formRef.value.open(type, row, masterParmas.value) |
|||
} |
|||
// form 提交 |
|||
const submitForm = async (formType, data) => { |
|||
try { |
|||
// 子表新增编辑校验 如果业务需要子表提交校验 需在主页详情组件添加 detailValidate 参数及方法 |
|||
const rs = (await props.detailValidate) ? props.detailValidate(data) : true |
|||
if (!rs) return |
|||
if (formType === 'create') { |
|||
await props.apiCreate(data) |
|||
message.success(t('common.createSuccess')) |
|||
} else { |
|||
await props.apiUpdate(data) |
|||
message.success(t('common.updateSuccess')) |
|||
} |
|||
formRef.value.dialogVisible = false |
|||
// 刷新当前列表 |
|||
await getList() |
|||
updateKey.value += 1 |
|||
} finally { |
|||
formRef.value.formLoading = false |
|||
} |
|||
} |
|||
|
|||
// 查询页面返回 |
|||
const searchTableSuccess = (formField, searchField, val, formRef) => { |
|||
emit('searchTableSuccessDetail', formField, searchField, val, formRef) |
|||
} |
|||
// 传递给父类 |
|||
const emit = defineEmits([ |
|||
'searchTableSuccessDetail', |
|||
'changeTabs', |
|||
'selectChangeDetail', |
|||
'detailOpenForm', |
|||
'tableFormButton', |
|||
'openImage' |
|||
]) |
|||
/** 删除按钮操作 */ |
|||
const handleDelete = async (id: number) => { |
|||
try { |
|||
// 删除的二次确认 |
|||
await message.delConfirm() |
|||
// 发起删除 |
|||
await props.apiDelete(id) |
|||
message.success(t('common.delSuccess')) |
|||
// 刷新列表 |
|||
await getList() |
|||
updateKey.value += 1 |
|||
} catch {} |
|||
} |
|||
// 筛选提交 |
|||
const searchFormClick = async (searchData) => { |
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: props.apiPage // 分页接口 |
|||
}) |
|||
tableObject.params = { |
|||
isSearch: true, |
|||
filters: searchData.filters |
|||
? searchData.filters |
|||
: [{ column: 'number', action: '==', value: masterParmas.value.number }] |
|||
} |
|||
detailAllSchemasRef.value = props.detailAllSchemas |
|||
tableObjectRef.value = tableObject |
|||
tableMethodsRef.value = tableMethods |
|||
tableObjectRef.value.tableList = [] |
|||
const { getList } = tableMethods |
|||
await getList() |
|||
updateKey.value += 1 |
|||
// tableObjectRef.value.params = { |
|||
// isSearch: true, |
|||
// filters: searchData.filters |
|||
// ? searchData.filters |
|||
// : [{ column: 'masterId', action: '==', value: masterParmas.value.masterId }] |
|||
// } |
|||
// getList() // 刷新当前列表 |
|||
} |
|||
// 选择盘点类型的时候针对限值的操作 |
|||
const selectChangeDetail = (field, val) => { |
|||
emit('selectChangeDetail', field, val) |
|||
} |
|||
// 打开图片 |
|||
const openImage=(item)=>{ |
|||
emit('openImage', item) |
|||
} |
|||
//监视属性 |
|||
watch( |
|||
() => props.apiPage, |
|||
() => { |
|||
const { tableObject, tableMethods } = useTable({ |
|||
getListApi: props.apiPage // 分页接口 |
|||
}) |
|||
tableObject.params.number = masterParmas.value.number |
|||
detailAllSchemasRef.value = props.detailAllSchemas |
|||
if (props.tableObjectExtend) { |
|||
props.tableObjectExtend.forEach(item => { |
|||
tableObject.params[item.key] = item.value |
|||
}) |
|||
} |
|||
tableObjectRef.value = tableObject |
|||
tableMethodsRef.value = tableMethods |
|||
const { getList } = tableMethods |
|||
getList() |
|||
} |
|||
) |
|||
</script> |
|||
<style lang="scss"> |
|||
.el-drawer__body { |
|||
background: #f5f5f5 !important; |
|||
} |
|||
|
|||
::v-deep(.label-class-name) { |
|||
color: #dedede; |
|||
} |
|||
</style> |
|||
<style scoped lang="scss"></style> |
@ -0,0 +1,3 @@ |
|||
import SearchTableItem from './src/SearchTableItem.vue' |
|||
|
|||
export { SearchTableItem } |
@ -0,0 +1,144 @@ |
|||
<template> |
|||
<Dialog :title="dialogTitle" v-model="searchDialogVisible" :width="'80%'"> |
|||
<ContentWrap> |
|||
<Table |
|||
ref="searchTableRef" |
|||
:columns="tableColumns" |
|||
:data="tableObjectRef.tableList" |
|||
:loading="tableObjectRef.loading" |
|||
:selection="true" |
|||
:reserveSelection="true" |
|||
row-key="number" |
|||
> |
|||
<template #qty="{ row }"> |
|||
<el-input v-model="row.qty" type="number" placeholder="请输入数量" /> |
|||
</template> |
|||
</Table> |
|||
</ContentWrap> |
|||
<template #footer> |
|||
<div class="flex items-center"> |
|||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button> |
|||
<el-button @click="searchDialogVisible = false">取 消</el-button> |
|||
</div> |
|||
</template> |
|||
</Dialog> |
|||
</template> |
|||
<script setup lang="ts"> |
|||
import * as defaultButtons from '@/utils/disposition/defaultButtons' |
|||
|
|||
// const { t } = useI18n() // 国际化 |
|||
const message = useMessage() // 消息弹窗 |
|||
|
|||
const route = useRoute() // 路由信息 |
|||
const routeName = ref() |
|||
routeName.value = route.name |
|||
|
|||
const searchDialogVisible = ref(false) // 弹窗的是否展示 |
|||
const dialogTitle = ref('') // 弹窗的标题 |
|||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 |
|||
|
|||
/** 打开弹窗 */ |
|||
const getListRef = ref() |
|||
const setSearchParamsRef = ref() |
|||
const tableObjectRef = ref({ |
|||
tableList: '', |
|||
loading: false, |
|||
params: {} |
|||
}) |
|||
const getPage: any = ref() |
|||
const searchSchema = ref() |
|||
const tableColumns = ref() |
|||
const formFieldRef = ref() |
|||
const searchFieldRef = ref() |
|||
const typeRef = ref() |
|||
const rowRef = ref() |
|||
const allSchemasRef = ref() |
|||
const multipleBol = ref(false) |
|||
const searchConditionRef = ref() |
|||
const open = ( |
|||
titleName: any, |
|||
allSchemas: any, |
|||
getApiPage: any, |
|||
formField: any, |
|||
searchField: any, |
|||
multiple: any, |
|||
type: any, |
|||
row: any, |
|||
searchCondition: any, |
|||
isCountRequestRe: any |
|||
) => { |
|||
searchDialogVisible.value = true |
|||
formFieldRef.value = formField |
|||
searchFieldRef.value = searchField |
|||
|
|||
allSchemasRef.value = allSchemas |
|||
searchSchema.value = allSchemas.searchSchema |
|||
tableColumns.value = allSchemas.tableColumns.filter((item) => item.field !== 'action') |
|||
getPage.value = getApiPage |
|||
typeRef.value = type |
|||
rowRef.value = row |
|||
multipleBol.value = multiple |
|||
dialogTitle.value = titleName |
|||
const getList = async () => { |
|||
await getPage.value(searchCondition).then((res) => { |
|||
tableObjectRef.value.tableList = res |
|||
}) |
|||
} |
|||
console.log(tableObjectRef.value) |
|||
|
|||
getList() |
|||
} |
|||
|
|||
|
|||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗 |
|||
|
|||
|
|||
// Table 组件 ref |
|||
const searchTableRef = ref() |
|||
|
|||
/** 提交表单 */ |
|||
const emit = defineEmits(['searchTableSuccess']) // 定义 searchTableSuccess 事件,用于操作成功后的回调 |
|||
const submitForm = async () => { |
|||
// 提交请求 |
|||
formLoading.value = true |
|||
const selections = searchTableRef.value.selections |
|||
// 如果不是多选的 |
|||
if (!multipleBol.value) { |
|||
if (selections.length > 1 || selections.length == 0) { |
|||
message.warning('请选择一条数据!') |
|||
formLoading.value = false |
|||
return |
|||
} |
|||
// 多选 |
|||
} else { |
|||
if (selections.length == 0) { |
|||
message.warning('至少选择一条数据!') |
|||
formLoading.value = false |
|||
return |
|||
} |
|||
} |
|||
let isQtyNone = selections.filter((item) => !item.qty) |
|||
if (isQtyNone && isQtyNone.length > 0) { |
|||
message.warning('请填写数量') |
|||
formLoading.value = false |
|||
return |
|||
} |
|||
try { |
|||
searchDialogVisible.value = false |
|||
console.log(selections) |
|||
// 发送操作成功的事件 |
|||
emit( |
|||
'searchTableSuccess', |
|||
formFieldRef.value, |
|||
searchFieldRef.value, |
|||
selections, |
|||
typeRef.value, |
|||
rowRef.value |
|||
) |
|||
} finally { |
|||
formLoading.value = false |
|||
} |
|||
} |
|||
</script> |
|||
<style scoped lang="scss"> |
|||
</style> |
Loading…
Reference in new issue