<template> <a-page-header style="padding: 10px; font-size: 20px" @back="handleBack"> <template #extra> <a-button v-if="route.query.type !== 'SEARCH'" key="1" type="primary" @click="onSubmit">保存</a-button> </template> </a-page-header> <a-card :bordered="false" title="仓库"> <DynamicForm :allDisabled="route.query.type === 'SEARCH'" :formItems="officialAccountFormItems" :model="formData" :rules="formRules" ref="formRef1" /> </a-card> <a-card :bordered="false" class="mt-4"> <a-tabs v-model:activeKey="activeKey"> <a-tab-pane key="1" tab="基本信息"> <DynamicForm :allDisabled="route.query.type === 'SEARCH'" :formItems="baseFormItems" :model="formData" :rules="formRules" ref="formRef1" /> </a-tab-pane> <a-tab-pane key="2" tab="单位信息" force-render> <DynamicForm :allDisabled="route.query.type === 'SEARCH'" :formItems="unitFormItems" :model="formData" :rules="formRules" ref="formRef1" /> </a-tab-pane> <a-tab-pane key="3" tab="包装关系" force-render> <DynamicTable :initialData="data" :columns="columns" rowKey="id"></DynamicTable> </a-tab-pane> <a-tab-pane key="4" tab="商品推广" force-render> </a-tab-pane> </a-tabs> </a-card> </template> <script setup> import { required } from '@/utils/formRules' import officialAccountApi from '@/api/base/wx/officialAccountApi' import useFormHandler from '@/hook/useFormHandler' import tool from '@/utils/tool' import { useRoute } from 'vue-router' const route = useRoute() import DynamicTable from '@/components/DynamicTable/index.vue' const formRules = { name: [required('请输入名称')], type: [required('请输入类型')], appid: [required('请输入AppID')], secret: [required('请输入AppSecret')] } const officialAccountFormItems = [ { label: '编码:', name: 'number', type: 'a-select', span: 6, attrs: { placeholder: '请选择类型', options: tool.dictList('OFFICIAL_ACCOUNT_TYPE') } }, { label: '名称:', name: 'name', type: 'a-input', span: 6, rules: [required('请输入名称')], attrs: { placeholder: '请输入名称', allowClear: true } }, { label: '仓库条码:', name: 'name', type: 'a-input', span: 6, rules: [required('请输入名称')], attrs: { placeholder: '请输入名称', allowClear: true } }, { label: '可用状态:', name: 'enabledState', type: 'a-select', span: 6, attrs: { placeholder: '请选择可用状态', options: tool.dictList('COMMON_STATUS') }, defaultValue: 'ENABLE' }, { label: '库存管理方式:', name: 'name', type: 'a-input', span: 6, rules: [required('请输入名称')], attrs: { placeholder: '请输入名称', allowClear: true } }, { label: '备注:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } } ] const baseFormItems = [ { label: '物料类型:', name: 'number', type: 'a-select', span: 6, attrs: { placeholder: '请选择类型', options: tool.dictList('OFFICIAL_ACCOUNT_TYPE') } }, { label: '品牌:', name: 'number', type: 'a-select', span: 6, attrs: { placeholder: '请选择类型', options: tool.dictList('OFFICIAL_ACCOUNT_TYPE') } }, { label: '最高库存:', name: 'number', type: 'a-select', span: 6, attrs: { placeholder: '请选择类型', options: tool.dictList('OFFICIAL_ACCOUNT_TYPE') } }, { label: '最低库存:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } }, { label: '保质期:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } }, { label: '统一零售价:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } }, { label: '商品条形码:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } }, { label: '保质期单位:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } }, { label: '最大包装数量:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } }, { label: '批次管理:', name: 'number', type: 'a-select', span: 6, attrs: { placeholder: '请选择类型', options: tool.dictList('OFFICIAL_ACCOUNT_TYPE') } }, ] const unitFormItems = [ { label: '单位组:', name: 'number', type: 'a-select', span: 6, attrs: { placeholder: '请选择类型', options: tool.dictList('OFFICIAL_ACCOUNT_TYPE') } }, { label: '基本单位:', name: 'number', type: 'a-select', span: 6, attrs: { placeholder: '请选择类型', options: tool.dictList('OFFICIAL_ACCOUNT_TYPE') } }, { label: '采购单位:', name: 'number', type: 'a-select', span: 6, attrs: { placeholder: '请选择类型', options: tool.dictList('OFFICIAL_ACCOUNT_TYPE') } }, { label: '分销单位:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } }, { label: '生产单位:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } }, { label: '销售单位:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } }, { label: '库存单位:', name: 'remarks', type: 'a-textarea', span: 24, attrs: { placeholder: '请输入备注', allowClear: true } } ] const formRef1 = ref(null) const formRef2 = ref(null) const { state, formData, submitLoading, formRefs, onSubmit, handleBack, fetchData } = useFormHandler( [...officialAccountFormItems, ...baseFormItems], { submitForm: officialAccountApi.officialAccountSubmitForm, getDetail: officialAccountApi.officialAccountDetail } ) onMounted(() => { formRefs.value = [formRef1.value, formRef2.value] fetchData(route.query.type) }) let activeKey = ref('1') const data = ref([ { id: '1', name: 'John', age: 28 }, { id: '2', name: 'Jane', age: 22 } ]) const columns = [ { title: '上游仓库代码', dataIndex: 'name', editable: true, dataType: 'text' // 或 'number', 'select' }, { title: '上游仓库名称', dataIndex: 'age', editable: true, dataType: 'number' } ] </script>