zhangwencui
4 天以前 f670b79094c95d791fc43c8fc8b5858ebf8426dc
src/pages/oa/ApproveManage/approve-list/template-select.vue
@@ -7,7 +7,6 @@
  <view class="template-select-page sales-account">
    <PageHeader :title="pageHeaderTitle"
                @back="goBack" />
    <view v-if="typeOptions.length && !moduleKey"
          class="step-section">
      <view class="tabs-wrap">
@@ -17,12 +16,6 @@
                 @click="onTabClick" />
      </view>
    </view>
    <view v-if="useAllTemplatesFallback && allTemplates.length"
          class="fallback-hint">
      <text>当前类型下无匹配模板,已显示全部 {{ allTemplates.length }} 个可用模板</text>
    </view>
    <view class="search-section">
      <view class="search-bar">
        <view class="search-input">
@@ -38,7 +31,6 @@
        </view>
      </view>
    </view>
    <scroll-view class="list-scroll"
                 scroll-y
                 :show-scrollbar="false">
@@ -144,29 +136,21 @@
  const currentTypeOption = computed(() => typeOptions.value[activeTab.value]);
  /** 无 moduleKey 且当前 Tab 筛不到时,展示全部模板避免「有数据却空白」 */
  const useAllTemplatesFallback = computed(() => {
    if (moduleKey.value) return false;
    if (!allTemplates.value.length) return false;
    const businessType = currentTypeOption.value?.value;
    if (businessType == null || businessType === "") return true;
    return filterTemplatesByBusinessType(allTemplates.value, businessType).length === 0;
  });
  /** 不允许手工发起审批的类型(采购/报价/发货,由业务单据产生,与 Web 一致) */
  const SUBMIT_EXCLUDED_BUSINESS_TYPES = [5, 6, 7];
  /** 当前 Tab(或业务模块)下可发起的模板 */
  const currentSource = computed(() => {
    if (moduleKey.value && moduleBusinessTypes.value.length) {
      const filtered = filterTemplatesByBusinessTypes(
      return filterTemplatesByBusinessTypes(
        allTemplates.value,
        moduleBusinessTypes.value
      );
      if (filtered.length) return filtered;
      return allTemplates.value;
    }
    if (useAllTemplatesFallback.value) {
      return allTemplates.value;
    }
    const businessType = currentTypeOption.value?.value;
    return filterTemplatesByBusinessType(allTemplates.value, businessType);
    return filterTemplatesByBusinessType(
      allTemplates.value,
      currentTypeOption.value?.value
    );
  });
  const displayList = computed(() => {
@@ -184,15 +168,11 @@
    if (moduleConfig.value?.label) {
      return `暂无${moduleConfig.value.label}可用模板`;
    }
    if (useAllTemplatesFallback.value) {
      return "当前类型下无匹配模板";
    }
    const typeName = currentTypeOption.value?.name || "该审批类型";
    return `暂无${typeName}下的模板(可切换上方类型)`;
  });
  const businessTypeText = type =>
    getBusinessTypeLabel(type, typeLabelMap.value);
  const businessTypeText = type => getBusinessTypeLabel(type, typeLabelMap.value);
  const enabledText = enabled => {
    const val = String(enabled ?? "");
@@ -222,10 +202,15 @@
        fetchApprovalTemplateTypes(),
        fetchEnabledApprovalTemplates(),
      ]);
      let resolvedOpts = opts?.length ? opts : buildTypeOptionsFromTemplates(templates);
      let resolvedOpts = opts?.length
        ? opts
        : buildTypeOptionsFromTemplates(templates);
      if (!resolvedOpts.length) {
        resolvedOpts = [...FALLBACK_BUSINESS_TYPE_OPTIONS];
      }
      resolvedOpts = resolvedOpts.filter(
        opt => !SUBMIT_EXCLUDED_BUSINESS_TYPES.includes(Number(opt.value))
      );
      typeOptions.value = resolvedOpts;
      typeLabelMap.value = buildTypeLabelMap(resolvedOpts);
      allTemplates.value = templates;
@@ -239,8 +224,8 @@
      }
      if (moduleKey.value) {
        const resolved = resolveModuleBusinessType(moduleKey.value, opts);
        const idx = opts.findIndex(
        const resolved = resolveModuleBusinessType(moduleKey.value, resolvedOpts);
        const idx = resolvedOpts.findIndex(
          opt => String(opt.value) === String(resolved)
        );
        activeTab.value =
@@ -292,16 +277,6 @@
    display: flex;
    flex-direction: column;
    min-height: 100vh;
  }
  .fallback-hint {
    margin: 8px 12px 0;
    padding: 8px 12px;
    font-size: 12px;
    color: #e6a23c;
    background: #fdf6ec;
    border-radius: 6px;
    line-height: 1.5;
  }
  .step-section {