Browse Source

feat(s0): 物料计划周期订单类型改字典下拉+配置面板

MaterialPlanCycleList 订单类型查询栏与新增/编辑表单 el-input 改 el-select
(复用现有字典 s0_order_type,存 value 码、表格经 code→label 映射显示,
allow-create 兼容历史手填),列表加配置字典入口复用 DictDataMaintainPanel。
纯前端,字典值 s0_order_type 已在库无需 SQL。

bump version Web 2.4.269
YY968XX 1 week ago
parent
commit
90e8924939
2 changed files with 56 additions and 5 deletions
  1. 1 1
      Web/package.json
  2. 55 4
      Web/src/views/aidop/s0/supply/MaterialPlanCycleList.vue

+ 1 - 1
Web/package.json

@@ -1,7 +1,7 @@
 {
   "name": "admin.net",
   "type": "module",
-  "version": "2.4.268",
+  "version": "2.4.269",
   "packageManager": "pnpm@10.32.1",
   "lastBuildTime": "2026.03.15",
   "description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",

+ 55 - 4
Web/src/views/aidop/s0/supply/MaterialPlanCycleList.vue

@@ -2,7 +2,9 @@
 	<AidopDemoShell :title="pageTitle" subtitle="S0 / Supply / 物料计划周期标准">
 		<el-form :inline="true" :model="query" class="mb12" @submit.prevent>
 			<el-form-item label="订单类型">
-				<el-input v-model="query.orderType" clearable placeholder="全部" style="width: 140px" />
+				<el-select v-model="query.orderType" filterable clearable allow-create default-first-option placeholder="全部" style="width: 160px">
+					<el-option v-for="opt in orderTypeOptions" :key="opt.value" :label="opt.label" :value="String(opt.value)" />
+				</el-select>
 			</el-form-item>
 			<el-form-item label="启用">
 				<el-select v-model="query.isActive" clearable placeholder="全部" style="width: 120px">
@@ -14,6 +16,7 @@
 				<el-button type="primary" @click="loadList">查询</el-button>
 				<el-button @click="resetQuery">重置</el-button>
 				<el-button type="success" @click="openCreate">新增</el-button>
+				<el-button @click="openDictConfig">配置字典</el-button>
 			</el-form-item>
 		</el-form>
 
@@ -21,7 +24,9 @@
 
 		<el-table :data="rows" v-loading="loading" border stripe style="width: 100%" max-height="calc(100vh - 260px)">
 			<el-table-column prop="domainCode" label="工厂域" width="120" show-overflow-tooltip />
-			<el-table-column prop="orderType" label="订单类型" width="120" show-overflow-tooltip />
+			<el-table-column prop="orderType" label="订单类型" width="120" show-overflow-tooltip>
+				<template #default="{ row }">{{ orderTypeLabel(row.orderType) }}</template>
+			</el-table-column>
 			<el-table-column prop="stdHours" label="标准物料计划时长(h)" width="170" align="right" />
 			<el-table-column prop="remarks" label="备注" min-width="160" show-overflow-tooltip />
 			<el-table-column label="启用" width="80" align="center">
@@ -66,7 +71,11 @@
 							<el-option v-for="item in formFactoryOptions" :key="item.id" :label="item.name || item.code || `${item.id}`" :value="item.id" />
 						</el-select>
 					</el-form-item></el-col>
-					<el-col :span="12"><el-form-item label="订单类型"><el-input v-model="form.orderType" placeholder="留空表示默认/不限" /></el-form-item></el-col>
+					<el-col :span="12"><el-form-item label="订单类型">
+						<el-select v-model="form.orderType" filterable clearable allow-create default-first-option placeholder="留空表示默认/不限" style="width: 100%">
+							<el-option v-for="opt in orderTypeOptions" :key="opt.value" :label="opt.label" :value="String(opt.value)" />
+						</el-select>
+					</el-form-item></el-col>
 					<el-col :span="12"><el-form-item label="工厂域"><el-input v-model="form.domainCode" /></el-form-item></el-col>
 					<el-col :span="12"><el-form-item label="标准时长(h)" prop="stdHours"><el-input-number v-model="form.stdHours" :min="0" style="width: 100%" /></el-form-item></el-col>
 					<el-col :span="12"><el-form-item label="启用"><el-switch v-model="form.isActive" /></el-form-item></el-col>
@@ -78,6 +87,17 @@
 				<el-button type="primary" :loading="saving" @click="submitForm">保存</el-button>
 			</template>
 		</el-dialog>
+
+		<el-dialog v-model="dictDialogVisible" title="配置订单类型字典" width="620px" destroy-on-close>
+			<DictDataMaintainPanel
+				:dict-code="ORDER_TYPE_DICT_CODE"
+				title="订单类型选项(MTS / MTO / ETO / 计划 / 非量产工单,可自行增删;与「订单优先级规则」页共用)"
+				@changed="onDictChanged"
+			/>
+			<template #footer>
+				<el-button type="primary" @click="dictDialogVisible = false">关闭</el-button>
+			</template>
+		</el-dialog>
 	</AidopDemoShell>
 </template>
 
@@ -86,15 +106,21 @@ import { computed, onMounted, reactive, ref, watch } from 'vue';
 import { useRoute } from 'vue-router';
 import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
 import AidopDemoShell from '../../components/AidopDemoShell.vue';
+import DictDataMaintainPanel from '../sales/components/DictDataMaintainPanel.vue';
 import {
+	loadDictOptions,
 	loadOrgList,
 	s0MaterialPlanCyclesApi,
+	type OptionItem,
 	type OrgOption,
 	type S0MaterialPlanCycleRow,
 	type S0MaterialPlanCycleUpsert,
 } from '../api/s0SupplyApi';
 import { applyDefaultOrgScopeForCreate, normalizeOrgScopeForSubmit, preserveOrgScopeForEdit, shouldClearFactoryOnCompanyChange } from '../composables/useS0MfgOrgScope';
 
+// 订单类型字典编码(复用「订单优先级规则」页同一字典,存 value 码、显示 label)
+const ORDER_TYPE_DICT_CODE = 's0_order_type';
+
 const route = useRoute();
 const pageTitle = computed(() => (route.meta?.title as string) || '物料计划周期');
 
@@ -117,6 +143,31 @@ const formRef = ref<FormInstance>();
 const companyOptions = ref<OrgOption[]>([]);
 const factoryOptions = ref<OrgOption[]>([]);
 
+// 订单类型下拉选项(来自可后台维护的字典 s0_order_type)
+const orderTypeOptions = ref<OptionItem[]>([]);
+// 配置字典弹窗
+const dictDialogVisible = ref(false);
+
+// code → label 映射,表格把存的 value 码显示为中文/英文 label(无映射则回落原值,兼容历史手填)
+const orderTypeMap = computed(() => new Map(orderTypeOptions.value.map((o) => [String(o.value), o.label])));
+function orderTypeLabel(code?: string | null): string {
+	if (!code) return '';
+	return orderTypeMap.value.get(String(code)) ?? code;
+}
+
+async function loadOrderTypeOptions() {
+	orderTypeOptions.value = await loadDictOptions(ORDER_TYPE_DICT_CODE);
+}
+
+function openDictConfig() {
+	dictDialogVisible.value = true;
+}
+
+// 字典项在配置面板里增改停用后,重载下拉,保证选项即时同步
+function onDictChanged() {
+	void loadOrderTypeOptions();
+}
+
 const filteredFactoryOptions = computed(() => {
 	if (!query.companyRefId) return factoryOptions.value;
 	return factoryOptions.value.filter((item) => item.pid === query.companyRefId);
@@ -264,7 +315,7 @@ function toggleActive(row: S0MaterialPlanCycleRow) {
 }
 
 onMounted(async () => {
-	await loadOptions();
+	await Promise.all([loadOptions(), loadOrderTypeOptions()]);
 	await loadList();
 });
 </script>