From 9d89dedf542a7b9f8e2549c44723771133f79ef2 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期二, 19 五月 2026 18:04:10 +0800
Subject: [PATCH] 模板类型变更
---
src/pages/oa/ApproveManage/approve-template/edit.vue | 112 ++++++++++++++++++++++++++++++++++++++++---------------
1 files changed, 81 insertions(+), 31 deletions(-)
diff --git a/src/pages/oa/ApproveManage/approve-template/edit.vue b/src/pages/oa/ApproveManage/approve-template/edit.vue
index 3b50270..aba2103 100644
--- a/src/pages/oa/ApproveManage/approve-template/edit.vue
+++ b/src/pages/oa/ApproveManage/approve-template/edit.vue
@@ -28,19 +28,18 @@
maxlength="50"
clearable />
</up-form-item>
- <up-form-item label="妯℃澘绫诲瀷"
- prop="templateType"
+ <up-form-item label="瀹℃壒绫诲瀷"
+ prop="businessType"
required
- class="form-item-type">
- <up-radio-group v-model="form.templateType"
- class="type-radio-group"
- placement="row"
- @change="onTemplateTypeChange">
- <up-radio v-for="opt in TEMPLATE_TYPE_OPTIONS"
- :key="opt.value"
- :name="opt.value"
- :label="opt.name" />
- </up-radio-group>
+ class="form-item-select"
+ @click="openBusinessTypeSheet">
+ <up-input :model-value="businessTypeText"
+ placeholder="璇烽�夋嫨瀹℃壒绫诲瀷"
+ readonly />
+ <template #right>
+ <up-icon name="arrow-right"
+ @click.stop="openBusinessTypeSheet" />
+ </template>
</up-form-item>
<up-form-item label="鍚敤鐘舵��"
class="form-item-switch">
@@ -311,6 +310,12 @@
</scroll-view>
</view>
</up-popup>
+
+ <up-action-sheet :show="showBusinessTypeSheet"
+ title="閫夋嫨瀹℃壒绫诲瀷"
+ :actions="businessTypeActions"
+ @select="onSelectBusinessType"
+ @close="showBusinessTypeSheet = false" />
</view>
</template>
@@ -325,6 +330,7 @@
} from "@/api/oa/approvalTemplate.js";
import { userListNoPageByTenantId } from "@/api/system/user";
import { formatDateToYMD } from "@/utils/ruoyi";
+ import { fetchApprovalTemplateTypes } from "../../_utils/approvalTemplateType.js";
const EDIT_STORAGE_KEY = "oa_approve_template_edit_row";
@@ -384,6 +390,7 @@
const form = reactive({
templateName: "",
+ businessType: null,
templateType: 1,
enabled: "1",
description: "",
@@ -413,11 +420,11 @@
const rules = {
templateName: [{ required: true, message: "璇疯緭鍏ユā鏉垮悕绉�", trigger: "blur" }],
- templateType: [
+ businessType: [
{
validator: (_rule, value, callback) => {
if (value === "" || value === null || value === undefined) {
- callback(new Error("璇烽�夋嫨妯℃澘绫诲瀷"));
+ callback(new Error("璇烽�夋嫨瀹℃壒绫诲瀷"));
return;
}
callback();
@@ -427,10 +434,22 @@
],
};
- const TEMPLATE_TYPE_OPTIONS = [
- { name: "绯荤粺鍐呯疆", value: 0 },
- { name: "鑷畾涔�", value: 1 },
- ];
+ const businessTypeOptions = ref([]);
+ const showBusinessTypeSheet = ref(false);
+
+ const businessTypeActions = computed(() =>
+ businessTypeOptions.value.map(opt => ({
+ name: opt.name,
+ value: opt.value,
+ }))
+ );
+
+ const businessTypeText = computed(() => {
+ const matched = businessTypeOptions.value.find(
+ opt => String(opt.value) === String(form.businessType)
+ );
+ return matched?.name || "";
+ });
const presetActions = FORM_PRESETS.map(item => ({
name: item.name,
@@ -487,10 +506,12 @@
if (!row) return;
templateId.value = row.id;
form.templateName = row.templateName || "";
- form.templateType =
- row.templateType === 0 || row.templateType === 1
- ? row.templateType
- : Number(row.templateType) || 1;
+ const parsedBusiness = Number(row.businessType);
+ form.businessType = Number.isNaN(parsedBusiness)
+ ? row.businessType
+ : parsedBusiness;
+ const parsedTemplateType = Number(row.templateType);
+ form.templateType = Number.isNaN(parsedTemplateType) ? 1 : parsedTemplateType;
form.enabled = String(row.enabled ?? "1");
form.description = row.description || "";
@@ -526,8 +547,18 @@
uni.navigateBack();
};
- const onTemplateTypeChange = () => {
- formRef.value?.validateField?.("templateType");
+ const openBusinessTypeSheet = () => {
+ if (!businessTypeOptions.value.length) {
+ uni.showToast({ title: "瀹℃壒绫诲瀷鍔犺浇涓�", icon: "none" });
+ return;
+ }
+ showBusinessTypeSheet.value = true;
+ };
+
+ const onSelectBusinessType = action => {
+ form.businessType = action.value;
+ showBusinessTypeSheet.value = false;
+ formRef.value?.validateField?.("businessType");
};
const onSelectPreset = action => {
@@ -710,6 +741,7 @@
templateName: form.templateName.trim(),
enabled: form.enabled,
description: form.description?.trim() || "",
+ businessType: form.businessType,
templateType: form.templateType,
formConfig: JSON.stringify({
prompt: formConfig.prompt?.trim() || "",
@@ -792,7 +824,25 @@
}
});
+ const loadTemplateTypes = () =>
+ fetchApprovalTemplateTypes()
+ .then(opts => {
+ businessTypeOptions.value = opts;
+ if (!templateId.value && opts.length) {
+ const matched = opts.some(
+ opt => String(opt.value) === String(form.businessType)
+ );
+ if (!matched) {
+ form.businessType = opts[0].value;
+ }
+ }
+ })
+ .catch(() => {
+ uni.showToast({ title: "鑾峰彇瀹℃壒绫诲瀷澶辫触", icon: "none" });
+ });
+
onMounted(() => {
+ loadTemplateTypes();
userListNoPageByTenantId()
.then(res => {
userList.value = res?.data || [];
@@ -926,18 +976,18 @@
font-size: 15px !important;
}
- :deep(.form-item-type .u-form-item__body) {
+ :deep(.form-item-select .u-form-item__body) {
align-items: center !important;
}
- .type-radio-group {
- display: flex;
- justify-content: flex-end;
- flex-wrap: nowrap;
+ :deep(.form-item-select .u-form-item__content) {
+ flex: 1 !important;
+ min-width: 0 !important;
+ justify-content: flex-end !important;
}
- :deep(.type-radio-group .u-radio) {
- margin-left: 20px;
+ :deep(.form-item-select .u-input__content__field-wrapper__field) {
+ text-align: right !important;
}
:deep(.form-item-switch .u-form-item__body) {
--
Gitblit v1.9.3