|
@@ -98,25 +98,26 @@ import {CommonStatusEnum} from '@/utils/constants'
|
|
import {FormRules} from 'element-plus'
|
|
import {FormRules} from 'element-plus'
|
|
import {IotTreeApi} from '@/api/system/tree'
|
|
import {IotTreeApi} from '@/api/system/tree'
|
|
import * as SapOrgApi from "@/api/system/saporg";
|
|
import * as SapOrgApi from "@/api/system/saporg";
|
|
-import {ImageVO} from "@/api/ai/image";
|
|
|
|
-import {SelectedReqVO, selectedReqVO} from "@/api/system/saporg";
|
|
|
|
import { toRaw } from "vue";
|
|
import { toRaw } from "vue";
|
|
|
|
+import { useTableStore } from '@/store/modules/tableStore'
|
|
|
|
|
|
defineOptions({ name: 'SystemDeptForm' })
|
|
defineOptions({ name: 'SystemDeptForm' })
|
|
|
|
|
|
const { t } = useI18n() // 国际化
|
|
const { t } = useI18n() // 国际化
|
|
const message = useMessage() // 消息弹窗
|
|
const message = useMessage() // 消息弹窗
|
|
-
|
|
|
|
|
|
+const tableStore = useTableStore();
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
|
+const selectedDeptId = ref(null); // 通过 tableStore 存储的 table 行记录 id 由父组件传递过来
|
|
|
|
+
|
|
const formData = ref({
|
|
const formData = ref({
|
|
id: undefined,
|
|
id: undefined,
|
|
title: '',
|
|
title: '',
|
|
- parentId: undefined,
|
|
|
|
|
|
+ parentId: selectedDeptId.value,
|
|
name: undefined,
|
|
name: undefined,
|
|
- sort: undefined,
|
|
|
|
|
|
+ sort: 0,
|
|
leaderUserId: undefined,
|
|
leaderUserId: undefined,
|
|
phone: undefined,
|
|
phone: undefined,
|
|
email: undefined,
|
|
email: undefined,
|
|
@@ -153,6 +154,8 @@ const selectedFactoryCodes = ref([]) // 选择的SAP工厂 code 列表
|
|
/** 打开弹窗 */
|
|
/** 打开弹窗 */
|
|
const open = async (type: string, id?: number) => {
|
|
const open = async (type: string, id?: number) => {
|
|
dialogVisible.value = true
|
|
dialogVisible.value = true
|
|
|
|
+ // 获取 tableStore 中的 已经选中的 行记录id
|
|
|
|
+ selectedDeptId.value = tableStore.selectedId;
|
|
dialogTitle.value = t('action.' + type)
|
|
dialogTitle.value = t('action.' + type)
|
|
formType.value = type
|
|
formType.value = type
|
|
resetForm()
|
|
resetForm()
|
|
@@ -171,22 +174,24 @@ const open = async (type: string, id?: number) => {
|
|
await getTree()
|
|
await getTree()
|
|
// 加载工厂(SAP)列表
|
|
// 加载工厂(SAP)列表
|
|
factoryList.value = await SapOrgApi.SapOrgApi.getSimpleSapOrgList(1)
|
|
factoryList.value = await SapOrgApi.SapOrgApi.getSimpleSapOrgList(1)
|
|
- costCenterList.value = await SapOrgApi.SapOrgApi.getSimpleSapOrgList(2)
|
|
|
|
- stockLocationList.value = await SapOrgApi.SapOrgApi.getSimpleSapOrgList(3)
|
|
|
|
|
|
+ // costCenterList.value = await SapOrgApi.SapOrgApi.getSimpleSapOrgList(2)
|
|
|
|
+ // stockLocationList.value = await SapOrgApi.SapOrgApi.getSimpleSapOrgList(3)
|
|
|
|
|
|
// 根据已有的SAP工厂值 获取 factoryCode数组
|
|
// 根据已有的SAP工厂值 获取 factoryCode数组
|
|
- /* selectedFactoryCodes.value = formData.value.factoryIds.map(id => {
|
|
|
|
|
|
+ selectedFactoryCodes.value = formData.value.factoryIds.map(id => {
|
|
const factory = factoryList.value.find(item => item.id === id)
|
|
const factory = factoryList.value.find(item => item.id === id)
|
|
return factory ? factory.factoryCode : null
|
|
return factory ? factory.factoryCode : null
|
|
}).filter(code => code !== null)
|
|
}).filter(code => code !== null)
|
|
|
|
+
|
|
|
|
+ // console.log(JSON.stringify(toRaw(selectedFactoryCodes.value)))
|
|
// 根据SAP工厂已有值 加载成本中心(SAP)列表
|
|
// 根据SAP工厂已有值 加载成本中心(SAP)列表
|
|
selectedFactoryReqVO.value.type = 2
|
|
selectedFactoryReqVO.value.type = 2
|
|
selectedFactoryReqVO.value.factoryCodes = toRaw(selectedFactoryCodes.value)
|
|
selectedFactoryReqVO.value.factoryCodes = toRaw(selectedFactoryCodes.value)
|
|
- costCenterList.value = await SapOrgApi.SapOrgApi.getSelectedList(selectedFactoryReqVO)
|
|
|
|
|
|
+ costCenterList.value = await SapOrgApi.SapOrgApi.getSelectedList(selectedFactoryReqVO.value)
|
|
// 根据SAP工厂已有值 加载库存地点(SAP)列表
|
|
// 根据SAP工厂已有值 加载库存地点(SAP)列表
|
|
selectedFactoryReqVO.value.type = 3
|
|
selectedFactoryReqVO.value.type = 3
|
|
- selectedFactoryReqVO.value.factoryCodes = selectedFactoryCodes.value
|
|
|
|
- stockLocationList.value = await SapOrgApi.SapOrgApi.getSelectedList(selectedFactoryReqVO) */
|
|
|
|
|
|
+ selectedFactoryReqVO.value.factoryCodes = toRaw(selectedFactoryCodes.value)
|
|
|
|
+ stockLocationList.value = await SapOrgApi.SapOrgApi.getSelectedList(selectedFactoryReqVO.value)
|
|
}
|
|
}
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
|
|
@@ -251,12 +256,15 @@ const resetForm = () => {
|
|
formData.value = {
|
|
formData.value = {
|
|
id: undefined,
|
|
id: undefined,
|
|
title: '',
|
|
title: '',
|
|
- parentId: undefined,
|
|
|
|
|
|
+ parentId: selectedDeptId.value,
|
|
name: undefined,
|
|
name: undefined,
|
|
- sort: undefined,
|
|
|
|
|
|
+ sort: 0,
|
|
leaderUserId: undefined,
|
|
leaderUserId: undefined,
|
|
phone: undefined,
|
|
phone: undefined,
|
|
email: undefined,
|
|
email: undefined,
|
|
|
|
+ factoryIds: [],
|
|
|
|
+ costCenterIds: [],
|
|
|
|
+ stockLocationIds: [],
|
|
status: CommonStatusEnum.ENABLE
|
|
status: CommonStatusEnum.ENABLE
|
|
}
|
|
}
|
|
formRef.value?.resetFields()
|
|
formRef.value?.resetFields()
|
|
@@ -270,4 +278,9 @@ const getTree = async () => {
|
|
dept.children = handleTree(data)
|
|
dept.children = handleTree(data)
|
|
deptTree.value.push(dept)
|
|
deptTree.value.push(dept)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/** 初始化 **/
|
|
|
|
+onMounted(() => {
|
|
|
|
+ formData.value.sort = 0
|
|
|
|
+})
|
|
</script>
|
|
</script>
|