|
@@ -2,9 +2,9 @@
|
|
|
import {
|
|
import {
|
|
|
IotProjectTaskPlanApi,
|
|
IotProjectTaskPlanApi,
|
|
|
type IotProjectTaskPlanCreateData,
|
|
type IotProjectTaskPlanCreateData,
|
|
|
- type IotProjectTaskPlanExtProperty,
|
|
|
|
|
type IotProjectTaskPlanPageParams,
|
|
type IotProjectTaskPlanPageParams,
|
|
|
type IotProjectTaskPlanPageVO,
|
|
type IotProjectTaskPlanPageVO,
|
|
|
|
|
+ type IotProjectTaskPlanTeamProjectBiz,
|
|
|
type IotProjectTaskPlanUpdateData
|
|
type IotProjectTaskPlanUpdateData
|
|
|
} from '@/api/pms/iotprojecttaskplan'
|
|
} from '@/api/pms/iotprojecttaskplan'
|
|
|
import * as DeptApi from '@/api/system/dept'
|
|
import * as DeptApi from '@/api/system/dept'
|
|
@@ -71,12 +71,15 @@ const BUSINESS_PLAN_CONFIG: Record<string, BusinessPlanConfig> = {
|
|
|
井下: { field: 'planWellTrips', unit: '井' }
|
|
井下: { field: 'planWellTrips', unit: '井' }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const businessOptions = getStrDictOptions(DICT_TYPE.RQ_IOT_WORKLOAD_PLAN_BIZ)
|
|
|
|
|
|
|
+const businessDictOptions = getStrDictOptions(DICT_TYPE.RQ_IOT_WORKLOAD_PLAN_BIZ)
|
|
|
const deptTreeProps = { ...defaultProps, disabled: 'disabled' }
|
|
const deptTreeProps = { ...defaultProps, disabled: 'disabled' }
|
|
|
|
|
+const teamProjectBizOptions = ref<IotProjectTaskPlanTeamProjectBiz[]>([])
|
|
|
|
|
|
|
|
const getBusinessPlanConfig = (business: string) => {
|
|
const getBusinessPlanConfig = (business: string) => {
|
|
|
const businessValue = String(business || '').trim()
|
|
const businessValue = String(business || '').trim()
|
|
|
- const businessLabel = businessOptions.find((option) => option.value === businessValue)?.label
|
|
|
|
|
|
|
+ const businessLabel =
|
|
|
|
|
+ teamProjectBizOptions.value.find((option) => option.business === businessValue)?.businessName ||
|
|
|
|
|
+ businessDictOptions.find((option) => option.value === businessValue)?.label
|
|
|
return BUSINESS_PLAN_CONFIG[businessValue] || BUSINESS_PLAN_CONFIG[businessLabel || '']
|
|
return BUSINESS_PLAN_CONFIG[businessValue] || BUSINESS_PLAN_CONFIG[businessLabel || '']
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -92,10 +95,9 @@ const createDialogVisible = ref(false)
|
|
|
const createLoading = ref(false)
|
|
const createLoading = ref(false)
|
|
|
const formMode = ref<FormMode>('create')
|
|
const formMode = ref<FormMode>('create')
|
|
|
const deptOptionsLoading = ref(false)
|
|
const deptOptionsLoading = ref(false)
|
|
|
-const extPropertiesLoading = ref(false)
|
|
|
|
|
|
|
+const businessOptionsLoading = ref(false)
|
|
|
const deptOptions = ref<DeptOption[]>([])
|
|
const deptOptions = ref<DeptOption[]>([])
|
|
|
const flatDeptOptions = ref<DeptOption[]>([])
|
|
const flatDeptOptions = ref<DeptOption[]>([])
|
|
|
-const planExtProperties = ref<IotProjectTaskPlanExtProperty[]>([])
|
|
|
|
|
const createFormRef = ref<FormInstance>()
|
|
const createFormRef = ref<FormInstance>()
|
|
|
|
|
|
|
|
const isReadonly = computed(() => formMode.value === 'view')
|
|
const isReadonly = computed(() => formMode.value === 'view')
|
|
@@ -108,15 +110,6 @@ const dialogDescription = computed(() =>
|
|
|
isReadonly.value ? '查看部门项目业务计划工作量详情' : '维护部门各月份的项目业务计划工作量'
|
|
isReadonly.value ? '查看部门项目业务计划工作量详情' : '维护部门各月份的项目业务计划工作量'
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-const selectableBusinessOptions = computed(() => {
|
|
|
|
|
- const identifiers = new Set(planExtProperties.value.map((property) => property.identifier))
|
|
|
|
|
-
|
|
|
|
|
- return businessOptions.filter((option) => {
|
|
|
|
|
- const config = getBusinessPlanConfig(option.value)
|
|
|
|
|
- return config ? identifiers.has(config.field) : false
|
|
|
|
|
- })
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
const createInitialForm = (): CreatePlanForm => ({
|
|
const createInitialForm = (): CreatePlanForm => ({
|
|
|
id: undefined,
|
|
id: undefined,
|
|
|
deptId: undefined,
|
|
deptId: undefined,
|
|
@@ -166,16 +159,16 @@ const findCompanyId = (selectedDeptId: number) => {
|
|
|
return undefined
|
|
return undefined
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const loadPlanExtProperties = async (selectedDeptId?: number) => {
|
|
|
|
|
- planExtProperties.value = []
|
|
|
|
|
|
|
+const loadTeamProjectBizOptions = async (selectedDeptId?: number) => {
|
|
|
|
|
+ teamProjectBizOptions.value = []
|
|
|
if (!selectedDeptId) return
|
|
if (!selectedDeptId) return
|
|
|
|
|
|
|
|
- extPropertiesLoading.value = true
|
|
|
|
|
|
|
+ businessOptionsLoading.value = true
|
|
|
try {
|
|
try {
|
|
|
- const data = await IotProjectTaskPlanApi.getPlanExtProperties(selectedDeptId)
|
|
|
|
|
- planExtProperties.value = Array.isArray(data) ? data : []
|
|
|
|
|
|
|
+ const data = await IotProjectTaskPlanApi.getTeamProjectBiz(selectedDeptId)
|
|
|
|
|
+ teamProjectBizOptions.value = Array.isArray(data) ? data : []
|
|
|
} finally {
|
|
} finally {
|
|
|
- extPropertiesLoading.value = false
|
|
|
|
|
|
|
+ businessOptionsLoading.value = false
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -184,7 +177,7 @@ const handleDeptChange = async (selectedDeptId?: number) => {
|
|
|
createFormData.value.business = ''
|
|
createFormData.value.business = ''
|
|
|
createFormData.value.workloadUnit = ''
|
|
createFormData.value.workloadUnit = ''
|
|
|
createFormData.value.planWorkload = undefined
|
|
createFormData.value.planWorkload = undefined
|
|
|
- await loadPlanExtProperties(selectedDeptId)
|
|
|
|
|
|
|
+ await loadTeamProjectBizOptions(selectedDeptId)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const normalizeStartTime = (value: unknown) => {
|
|
const normalizeStartTime = (value: unknown) => {
|
|
@@ -206,7 +199,11 @@ const handleOpenForm = async (mode: FormMode, id?: number) => {
|
|
|
if (id) {
|
|
if (id) {
|
|
|
const data = await IotProjectTaskPlanApi.get(id)
|
|
const data = await IotProjectTaskPlanApi.get(id)
|
|
|
const business = String(data.business || '')
|
|
const business = String(data.business || '')
|
|
|
|
|
+ await loadTeamProjectBizOptions(data.deptId)
|
|
|
const config = getBusinessPlanConfig(business)
|
|
const config = getBusinessPlanConfig(business)
|
|
|
|
|
+ const businessOption = teamProjectBizOptions.value.find(
|
|
|
|
|
+ (option) => option.business === business
|
|
|
|
|
+ )
|
|
|
const workloadValue = config ? data[config.field] : undefined
|
|
const workloadValue = config ? data[config.field] : undefined
|
|
|
|
|
|
|
|
createFormData.value = {
|
|
createFormData.value = {
|
|
@@ -215,11 +212,10 @@ const handleOpenForm = async (mode: FormMode, id?: number) => {
|
|
|
companyId: data.companyId || findCompanyId(data.deptId),
|
|
companyId: data.companyId || findCompanyId(data.deptId),
|
|
|
startTime: normalizeStartTime(data.startTime),
|
|
startTime: normalizeStartTime(data.startTime),
|
|
|
business,
|
|
business,
|
|
|
- workloadUnit: data.workloadUnit || config?.unit || '',
|
|
|
|
|
|
|
+ workloadUnit: data.workloadUnit || businessOption?.unit || config?.unit || '',
|
|
|
planWorkload:
|
|
planWorkload:
|
|
|
workloadValue === null || workloadValue === undefined ? undefined : Number(workloadValue)
|
|
workloadValue === null || workloadValue === undefined ? undefined : Number(workloadValue)
|
|
|
}
|
|
}
|
|
|
- await loadPlanExtProperties(data.deptId)
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
await nextTick()
|
|
await nextTick()
|
|
@@ -232,8 +228,11 @@ const handleOpenForm = async (mode: FormMode, id?: number) => {
|
|
|
const handleOpenCreate = () => handleOpenForm('create')
|
|
const handleOpenCreate = () => handleOpenForm('create')
|
|
|
|
|
|
|
|
const handleBusinessChange = () => {
|
|
const handleBusinessChange = () => {
|
|
|
|
|
+ const businessOption = teamProjectBizOptions.value.find(
|
|
|
|
|
+ (option) => option.business === createFormData.value.business
|
|
|
|
|
+ )
|
|
|
const config = getBusinessPlanConfig(createFormData.value.business)
|
|
const config = getBusinessPlanConfig(createFormData.value.business)
|
|
|
- createFormData.value.workloadUnit = config?.unit || ''
|
|
|
|
|
|
|
+ createFormData.value.workloadUnit = businessOption?.unit || config?.unit || ''
|
|
|
createFormData.value.planWorkload = undefined
|
|
createFormData.value.planWorkload = undefined
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -495,16 +494,16 @@ watch(
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="createFormData.business"
|
|
v-model="createFormData.business"
|
|
|
:placeholder="createFormData.deptId ? '请选择项目业务' : '请先选择部门'"
|
|
:placeholder="createFormData.deptId ? '请选择项目业务' : '请先选择部门'"
|
|
|
- :loading="extPropertiesLoading"
|
|
|
|
|
|
|
+ :loading="businessOptionsLoading"
|
|
|
:disabled="isReadonly || !createFormData.deptId"
|
|
:disabled="isReadonly || !createFormData.deptId"
|
|
|
clearable
|
|
clearable
|
|
|
class="w-full"
|
|
class="w-full"
|
|
|
@change="handleBusinessChange">
|
|
@change="handleBusinessChange">
|
|
|
<el-option
|
|
<el-option
|
|
|
- v-for="option in selectableBusinessOptions"
|
|
|
|
|
- :key="option.value"
|
|
|
|
|
- :label="option.label"
|
|
|
|
|
- :value="option.value" />
|
|
|
|
|
|
|
+ v-for="option in teamProjectBizOptions"
|
|
|
|
|
+ :key="option.business"
|
|
|
|
|
+ :label="option.businessName"
|
|
|
|
|
+ :value="option.business" />
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-col>
|
|
</el-col>
|