| | |
| | | getRouteProcess, |
| | | updateRouteProcess, |
| | | } from '#/api/mes/pro/route/process'; |
| | | import { getRouteProductListByRoute } from '#/api/mes/pro/route/product'; |
| | | import { $t } from '#/locales'; |
| | | |
| | | import { useRouteProcessFormSchema } from '../data'; |
| | |
| | | }); |
| | | |
| | | /** 加载工序选项后再生成 schema(避免下拉空选项) */ |
| | | async function loadSchema(): Promise<VbenFormSchema[]> { |
| | | async function loadSchema(routeId: number): Promise<VbenFormSchema[]> { |
| | | const list = await getProcessSimpleList(); |
| | | const options = (list || []).map((item) => ({ |
| | | label: item.name ?? '', |
| | | value: item.id!, |
| | | })); |
| | | return useRouteProcessFormSchema(options); |
| | | const products = routeId ? await getRouteProductListByRoute(routeId) : []; |
| | | return useRouteProcessFormSchema( |
| | | options, |
| | | products.map((item) => item.itemId!).filter(Boolean), |
| | | ); |
| | | } |
| | | |
| | | const [Modal, modalApi] = useVbenModal({ |
| | |
| | | formData.value = undefined; |
| | | return; |
| | | } |
| | | modalApi.lock(); |
| | | try { |
| | | // 工序下拉依赖远程数据,schema 在弹窗打开时再生成 |
| | | const schema = await loadSchema(); |
| | | formApi.setState({ schema }); |
| | | } finally { |
| | | modalApi.unlock(); |
| | | } |
| | | // 加载数据 |
| | | const data = modalApi.getData<{ |
| | | id?: number; |
| | | maxSort?: number; |
| | |
| | | if (!data) { |
| | | return; |
| | | } |
| | | modalApi.lock(); |
| | | try { |
| | | // 工序下拉依赖远程数据,schema 在弹窗打开时再生成 |
| | | const schema = await loadSchema(data.routeId); |
| | | formApi.setState({ schema }); |
| | | } finally { |
| | | modalApi.unlock(); |
| | | } |
| | | // 加载数据 |
| | | if (!data.id) { |
| | | // 新增时,默认序号 = maxSort + 1,并给一个默认甘特图颜色 |
| | | await formApi.setValues({ |