ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<script lang="ts" setup>
import { reactive, toRefs } from 'vue';
 
import { useModal } from '@jnpf/ui/modal';
 
import HeaderFooterCustomModal from './HeaderFooterCustomModal.vue';
 
const props = defineProps(['formState', 'configOptions', 'sheetsOption', 'activeSheetFreeze']);
const [registerHeaderFooterCustomModal, { openModal: openHeaderFooterCustomModal }] = useModal();
 
interface State {
  hasXFreeze: boolean;
  hasYFreeze: boolean;
}
const state = reactive<State>({
  hasXFreeze: false,
  hasYFreeze: false,
});
const { hasXFreeze, hasYFreeze } = toRefs(state);
 
const headerFooterTypeOptions = [
  { id: 'default', fullName: '默认' },
  { id: 'custom', fullName: '自定义' },
];
 
function handleChangedPrintAreaType() {
  if (props.formState.printArea === 'currentSheet') {
    const { xSplit = 0, ySplit = 0 } = props.activeSheetFreeze ?? {}; // xSplit表示列冻结了
 
    state.hasXFreeze = ySplit > 0;
    state.hasYFreeze = xSplit > 0;
 
    props.formState.xFreeze = state.hasYFreeze;
    props.formState.yFreeze = state.hasXFreeze;
  } else {
    state.hasXFreeze = true;
    state.hasYFreeze = true;
 
    if (props.formState.xFreeze) {
      props.formState.xFreeze = false;
    }
 
    if (props.formState.yFreeze) {
      props.formState.yFreeze = false;
    }
  }
}
 
function handleOpenHeaderFooterCustom() {
  openHeaderFooterCustomModal(true, props.formState.customHeaderFooterValue);
}
 
function onHeaderFooterCustomConfirm(data: any) {
  props.formState.customHeaderFooterValue = { ...data };
}
 
defineExpose({
  handleChangedPrintAreaType,
});
</script>
 
<template>
  <a-form class="print-config-form" layout="vertical" :model="formState" :colon="false">
    <a-form-item label="选择" name="partSheets" v-if="formState.printArea === 'partSheets'">
      <jnpf-select v-model:value="formState.partSheets" multiple :options="sheetsOption" />
    </a-form-item>
    <a-form-item label="纸张类型" name="paperType">
      <jnpf-select v-model:value="formState.paperType" :options="configOptions.paperTypeOptions" />
    </a-form-item>
    <a-form-item label="纸张方向" name="direction">
      <jnpf-radio v-model:value="formState.direction" :options="configOptions.printDirectionOptions" option-type="button" button-style="solid" />
    </a-form-item>
    <a-form-item label="页面缩放" name="printScale">
      <jnpf-select v-model:value="formState.printScale" :options="configOptions.printScaleOptions" />
    </a-form-item>
    <a-form-item label="上下对齐" name="vAlign">
      <jnpf-radio v-model:value="formState.vAlign" :options="configOptions.printVAlignOptions" option-type="button" button-style="solid" />
    </a-form-item>
    <a-form-item label="左右对齐" name="hAlign">
      <jnpf-radio v-model:value="formState.hAlign" :options="configOptions.printHAlignOptions" option-type="button" button-style="solid" />
    </a-form-item>
    <a-form-item label="网格线" name="gridlines">
      <a-switch v-model:checked="formState.gridlines" />
    </a-form-item>
    <a-form-item label="页眉页脚">
      <jnpf-radio v-model:value="formState.headerFooterType" :options="headerFooterTypeOptions" option-type="button" button-style="solid" />
    </a-form-item>
    <template v-if="formState.headerFooterType === 'default'">
      <a-form-item label="页码" name="pageNumber">
        <a-switch v-model:checked="formState.pageNumber" />
      </a-form-item>
      <a-form-item label="报表名称" name="workbookTitle">
        <a-switch v-model:checked="formState.workbookTitle" />
      </a-form-item>
      <a-form-item label="工作表名" name="WorksheetTitle">
        <a-switch v-model:checked="formState.worksheetTitle" />
      </a-form-item>
      <a-form-item label="当前日期" name="printDate">
        <a-switch v-model:checked="formState.printDate" />
      </a-form-item>
      <a-form-item label="当前时间" name="printTime">
        <a-switch v-model:checked="formState.printTime" />
      </a-form-item>
    </template>
    <template v-else>
      <a-form-item label="自定义页眉页脚">
        <a-button block @click="handleOpenHeaderFooterCustom">自定义配置</a-button>
      </a-form-item>
    </template>
    <a-form-item>
      <template #label>
        重复冻结行<BasicHelp text="无冻结/无冻结行时,打印不显示重复的冻结区域;反之,允许配置在打印预览/打印时是否显示重复的冻结区域" />
      </template>
      <a-switch v-model:checked="formState.yFreeze" :disabled="!hasXFreeze" />
    </a-form-item>
    <a-form-item>
      <template #label>
        重复冻结列<BasicHelp text="无冻结/无冻结列时,打印不显示重复的冻结区域;反之,允许配置在打印预览/打印时是否显示重复的冻结区域" />
      </template>
      <a-switch v-model:checked="formState.xFreeze" :disabled="!hasYFreeze" />
    </a-form-item>
  </a-form>
  <HeaderFooterCustomModal @register="registerHeaderFooterCustomModal" @confirm="onHeaderFooterCustomConfirm" />
</template>
 
<style lang="scss">
.print-config-form {
  padding: 10px;
  background: var(--component-background);
}
</style>