|
@@ -34,14 +34,16 @@
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+ <!--
|
|
|
<el-form-item label="联系电话" prop="phone">
|
|
|
<el-input v-model="formData.phone" maxlength="11" placeholder="请输入联系电话" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="邮箱" prop="email">
|
|
|
<el-input v-model="formData.email" maxlength="50" placeholder="请输入邮箱" />
|
|
|
</el-form-item>
|
|
|
+ -->
|
|
|
<el-form-item label="SAP工厂">
|
|
|
- <el-select v-model="formData.factoryIds" multiple placeholder="请选择">
|
|
|
+ <el-select v-model="formData.factoryIds" multiple placeholder="请选择" @change="selectedFactoryChange">
|
|
|
<el-option
|
|
|
v-for="item in factoryList"
|
|
|
:key="item.id"
|
|
@@ -96,6 +98,9 @@ import {CommonStatusEnum} from '@/utils/constants'
|
|
|
import {FormRules} from 'element-plus'
|
|
|
import {IotTreeApi} from '@/api/system/tree'
|
|
|
import * as SapOrgApi from "@/api/system/saporg";
|
|
|
+import {ImageVO} from "@/api/ai/image";
|
|
|
+import {SelectedReqVO, selectedReqVO} from "@/api/system/saporg";
|
|
|
+import { toRaw } from "vue";
|
|
|
|
|
|
defineOptions({ name: 'SystemDeptForm' })
|
|
|
|
|
@@ -120,11 +125,17 @@ const formData = ref({
|
|
|
stockLocationIds: [],
|
|
|
status: CommonStatusEnum.ENABLE
|
|
|
})
|
|
|
+
|
|
|
+const selectedFactoryReqVO = ref({
|
|
|
+ type: 0, // 类型(1工厂 2成本中心 3库位)
|
|
|
+ factoryCodes: [] // 已经选择的SAP工厂code 列表
|
|
|
+})
|
|
|
+
|
|
|
const formRules = reactive<FormRules>({
|
|
|
parentId: [{ required: true, message: '上级部门不能为空', trigger: 'blur' }],
|
|
|
name: [{ required: true, message: '部门名称不能为空', trigger: 'blur' }],
|
|
|
sort: [{ required: true, message: '显示排序不能为空', trigger: 'blur' }],
|
|
|
- email: [{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }],
|
|
|
+ // email: [{ type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }],
|
|
|
phone: [
|
|
|
{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请输入正确的手机号码', trigger: 'blur' }
|
|
|
],
|
|
@@ -137,6 +148,8 @@ const factoryList = ref([] as SapOrgApi.SapOrgVO[]) // SAP工厂列表
|
|
|
const costCenterList = ref([] as SapOrgApi.SapOrgVO[]) // SAP成本中心列表
|
|
|
const stockLocationList = ref([] as SapOrgApi.SapOrgVO[]) // SAP库存地点列表
|
|
|
|
|
|
+const selectedFactoryCodes = ref([]) // 选择的SAP工厂 code 列表
|
|
|
+
|
|
|
/** 打开弹窗 */
|
|
|
const open = async (type: string, id?: number) => {
|
|
|
dialogVisible.value = true
|
|
@@ -158,10 +171,22 @@ const open = async (type: string, id?: number) => {
|
|
|
await getTree()
|
|
|
// 加载工厂(SAP)列表
|
|
|
factoryList.value = await SapOrgApi.SapOrgApi.getSimpleSapOrgList(1)
|
|
|
- // 加载成本中心(SAP)列表
|
|
|
costCenterList.value = await SapOrgApi.SapOrgApi.getSimpleSapOrgList(2)
|
|
|
- // 加载库存地点(SAP)列表
|
|
|
stockLocationList.value = await SapOrgApi.SapOrgApi.getSimpleSapOrgList(3)
|
|
|
+
|
|
|
+ // 根据已有的SAP工厂值 获取 factoryCode数组
|
|
|
+ /* selectedFactoryCodes.value = formData.value.factoryIds.map(id => {
|
|
|
+ const factory = factoryList.value.find(item => item.id === id)
|
|
|
+ return factory ? factory.factoryCode : null
|
|
|
+ }).filter(code => code !== null)
|
|
|
+ // 根据SAP工厂已有值 加载成本中心(SAP)列表
|
|
|
+ selectedFactoryReqVO.value.type = 2
|
|
|
+ selectedFactoryReqVO.value.factoryCodes = toRaw(selectedFactoryCodes.value)
|
|
|
+ costCenterList.value = await SapOrgApi.SapOrgApi.getSelectedList(selectedFactoryReqVO)
|
|
|
+ // 根据SAP工厂已有值 加载库存地点(SAP)列表
|
|
|
+ selectedFactoryReqVO.value.type = 3
|
|
|
+ selectedFactoryReqVO.value.factoryCodes = selectedFactoryCodes.value
|
|
|
+ stockLocationList.value = await SapOrgApi.SapOrgApi.getSelectedList(selectedFactoryReqVO) */
|
|
|
}
|
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
|
@@ -200,6 +225,27 @@ const submitForm = async () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/** 已经选择了 SAP工厂 */
|
|
|
+const selectedFactoryChange = async (selectedIds) => {
|
|
|
+ // 获取选中的factoryCode数组
|
|
|
+ const selectedFactoryCodes = selectedIds.map(id => {
|
|
|
+ const factory = factoryList.value.find(item => item.id === id)
|
|
|
+ return factory ? factory.factoryCode : null
|
|
|
+ }).filter(code => code !== null)
|
|
|
+
|
|
|
+ // 获得已经选择的 SAP 工厂 数组
|
|
|
+ // const factoryIds = formData.value.factoryIds
|
|
|
+ // 调用后台接口查询 SAP工厂下属的 成本中心列表
|
|
|
+ selectedFactoryReqVO.value.type = 2
|
|
|
+ selectedFactoryReqVO.value.factoryCodes = selectedFactoryCodes
|
|
|
+ costCenterList.value = await SapOrgApi.SapOrgApi.getSelectedList(selectedFactoryReqVO.value)
|
|
|
+
|
|
|
+ // 根据选择的 SAP工厂 调用后台接口查询 SAP工厂下属的 库存地点列表
|
|
|
+ selectedFactoryReqVO.value.type = 3
|
|
|
+ selectedFactoryReqVO.value.factoryCodes = selectedFactoryCodes
|
|
|
+ stockLocationList.value = await SapOrgApi.SapOrgApi.getSelectedList(selectedFactoryReqVO.value)
|
|
|
+}
|
|
|
+
|
|
|
/** 重置表单 */
|
|
|
const resetForm = () => {
|
|
|
formData.value = {
|