tor-univer-sheet 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/App.vue.d.ts +2 -0
- package/dist/components/ContentWrap/index.d.ts +2 -0
- package/dist/components/ContentWrap/src/ContentWrap.vue.d.ts +57 -0
- package/dist/components/Form/src/componentMap.d.ts +4 -0
- package/dist/components/Form/src/components/InputNumberWrapper.vue.d.ts +2 -0
- package/dist/components/Form/src/types.d.ts +16 -0
- package/dist/components/GlobalLoading/GlobalLoading.vue.d.ts +8 -0
- package/dist/components/GlobalLoading/index.d.ts +7 -0
- package/dist/components/IndicatorPointSelect/IndicatorPointSelect.vue.d.ts +2 -0
- package/dist/components/UniverSheet/UniverSheet.data.d.ts +23 -0
- package/dist/components/UniverSheet/UniverSheet.vue.d.ts +515 -0
- package/dist/components/UniverSheet/data.d.ts +9 -0
- package/dist/components/UniverSheet/plugins/Plugins.d.ts +29 -0
- package/dist/components/UniverSheet/plugins/importFile/ImportFileIcon.vue.d.ts +2 -0
- package/dist/components/UniverSheet/plugins/importFile/ImportFilePlugin.d.ts +14 -0
- package/dist/components/UniverSheet/plugins/index.d.ts +2 -0
- package/dist/components/UniverSheet/plugins/indicatorsContextMenu/IndicatorsContextMenuPlugin.d.ts +16 -0
- package/dist/components/UniverSheet/plugins/indicatorsContextMenu/components/IndicatorsMenu.vue.d.ts +2 -0
- package/dist/components/UniverSheet/plugins/indicatorsContextMenu/components/IndicatorsUniverSheetConfigDialog.vue.d.ts +234 -0
- package/dist/components/UniverSheet/plugins/saveButton/ButtonIcon.vue.d.ts +2 -0
- package/dist/components/UniverSheet/plugins/saveButton/SaveButton.d.ts +14 -0
- package/dist/components/UniverSheet/plugins/syncContextMenu/SyncContextMenu.vue.d.ts +2 -0
- package/dist/components/UniverSheet/plugins/syncContextMenu/SyncContextMenuPlugin.d.ts +14 -0
- package/dist/components/UniverSheet/plugins/timeConfigContextMenu/TimeConfigContextMenuPlugin.d.ts +16 -0
- package/dist/components/UniverSheet/plugins/timeConfigContextMenu/components/TimeConfigMenu.vue.d.ts +2 -0
- package/dist/components/UniverSheet/plugins/timeConfigContextMenu/components/TimeConfigUniverSheetConfigDialog.vue.d.ts +234 -0
- package/dist/favicon.ico +0 -0
- package/dist/hooks/useMessage.d.ts +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/main.d.ts +0 -0
- package/dist/tor-univer-sheet.es.js +213 -0
- package/dist/tor-univer-sheet.umd.js +1 -0
- package/dist/types/components.d.ts +52 -0
- package/dist/types/external-components.d.ts +14 -0
- package/dist/types/form.d.ts +51 -0
- package/dist/utils/decimal.d.ts +59 -0
- package/dist/utils/fileHelp.d.ts +8 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/is.d.ts +33 -0
- package/dist/utils/propTypes.d.ts +10 -0
- package/package.json +88 -0
- package/src/App.vue +16 -0
- package/src/components/ContentWrap/index.ts +3 -0
- package/src/components/ContentWrap/src/ContentWrap.vue +50 -0
- package/src/components/Form/src/componentMap.ts +51 -0
- package/src/components/Form/src/components/InputNumberWrapper.vue +12 -0
- package/src/components/Form/src/types.ts +18 -0
- package/src/components/GlobalLoading/GlobalLoading.vue +89 -0
- package/src/components/GlobalLoading/index.ts +45 -0
- package/src/components/IndicatorPointSelect/IndicatorPointSelect.vue +9 -0
- package/src/components/UniverSheet/UniverSheet.data.ts +521 -0
- package/src/components/UniverSheet/UniverSheet.vue +339 -0
- package/src/components/UniverSheet/data.ts +18 -0
- package/src/components/UniverSheet/plugins/Plugins.ts +246 -0
- package/src/components/UniverSheet/plugins/importFile/ImportFileIcon.vue +26 -0
- package/src/components/UniverSheet/plugins/importFile/ImportFilePlugin.ts +109 -0
- package/src/components/UniverSheet/plugins/index.ts +10 -0
- package/src/components/UniverSheet/plugins/indicatorsContextMenu/IndicatorsContextMenuPlugin.ts +134 -0
- package/src/components/UniverSheet/plugins/indicatorsContextMenu/components/IndicatorsMenu.vue +49 -0
- package/src/components/UniverSheet/plugins/indicatorsContextMenu/components/IndicatorsUniverSheetConfigDialog.vue +153 -0
- package/src/components/UniverSheet/plugins/saveButton/ButtonIcon.vue +19 -0
- package/src/components/UniverSheet/plugins/saveButton/SaveButton.ts +68 -0
- package/src/components/UniverSheet/plugins/syncContextMenu/SyncContextMenu.vue +24 -0
- package/src/components/UniverSheet/plugins/syncContextMenu/SyncContextMenuPlugin.ts +65 -0
- package/src/components/UniverSheet/plugins/timeConfigContextMenu/TimeConfigContextMenuPlugin.ts +133 -0
- package/src/components/UniverSheet/plugins/timeConfigContextMenu/components/TimeConfigMenu.vue +10 -0
- package/src/components/UniverSheet/plugins/timeConfigContextMenu/components/TimeConfigUniverSheetConfigDialog.vue +152 -0
- package/src/hooks/useMessage.ts +93 -0
- package/src/index.ts +10 -0
- package/src/main.ts +14 -0
- package/src/types/components.d.ts +52 -0
- package/src/types/external-components.d.ts +16 -0
- package/src/types/form.d.ts +52 -0
- package/src/utils/decimal.ts +98 -0
- package/src/utils/fileHelp.ts +71 -0
- package/src/utils/index.ts +32 -0
- package/src/utils/is.ts +168 -0
- package/src/utils/propTypes.ts +24 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="univer-wrapper">
|
|
3
|
+
<div ref="container" class="univer-container"></div>
|
|
4
|
+
<IndicatorsUniverSheetConfigDialog ref="indicatorsUniverSheetConfigDialogRef" />
|
|
5
|
+
<TimeConfigUniverSheetConfigDialog ref="timeConfigUniverSheetConfigDialogRef" />
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { onMounted, onBeforeUnmount, ref, nextTick } from 'vue'
|
|
10
|
+
import {
|
|
11
|
+
createUniver,
|
|
12
|
+
defaultTheme,
|
|
13
|
+
LocaleType,
|
|
14
|
+
greenTheme,
|
|
15
|
+
mergeLocales,
|
|
16
|
+
merge,
|
|
17
|
+
Univer,
|
|
18
|
+
FUniver,
|
|
19
|
+
IWorkbookData,
|
|
20
|
+
ICellData,
|
|
21
|
+
IRange,
|
|
22
|
+
IObjectMatrixPrimitiveType,
|
|
23
|
+
FEventName,
|
|
24
|
+
} from '@univerjs/presets'
|
|
25
|
+
// import { UniverSheetsCorePreset } from '@univerjs/preset-sheets-core'
|
|
26
|
+
import { CommandService, CommandType, ICommandService } from '@univerjs/core'
|
|
27
|
+
import { Inject, Injector } from '@univerjs/core'
|
|
28
|
+
// 导入中文语言包
|
|
29
|
+
import zhCN from '@univerjs/preset-sheets-core/locales/zh-CN'
|
|
30
|
+
import { UniverSheetsAdvancedPreset } from '@univerjs/preset-sheets-advanced'
|
|
31
|
+
import UniverPresetSheetsAdvancedZhCN from '@univerjs/preset-sheets-advanced/locales/zh-CN'
|
|
32
|
+
import { UniverSheetsConditionalFormattingPreset } from '@univerjs/presets/preset-sheets-conditional-formatting'
|
|
33
|
+
import sheetsConditionalFormattingZhCN from '@univerjs/presets/preset-sheets-conditional-formatting/locales/zh-CN'
|
|
34
|
+
import { UniverSheetsCorePreset } from '@univerjs/presets/preset-sheets-core'
|
|
35
|
+
import sheetsCoreZhCN from '@univerjs/presets/preset-sheets-core/locales/zh-CN'
|
|
36
|
+
import { UniverSheetsDataValidationPreset } from '@univerjs/presets/preset-sheets-data-validation'
|
|
37
|
+
import sheetsDataValidationZhCN from '@univerjs/presets/preset-sheets-data-validation/locales/zh-CN'
|
|
38
|
+
import { UniverSheetsDrawingPreset } from '@univerjs/presets/preset-sheets-drawing'
|
|
39
|
+
import UniverPresetSheetsDrawingZhCN from '@univerjs/preset-sheets-drawing/locales/zh-CN'
|
|
40
|
+
import sheetsDrawingZhCN from '@univerjs/presets/preset-sheets-drawing/locales/zh-CN'
|
|
41
|
+
import { UniverSheetsFilterPreset } from '@univerjs/presets/preset-sheets-filter'
|
|
42
|
+
import sheetsFilterZhCN from '@univerjs/presets/preset-sheets-filter/locales/zh-CN'
|
|
43
|
+
import { UniverSheetsHyperLinkPreset } from '@univerjs/presets/preset-sheets-hyper-link'
|
|
44
|
+
import sheetsHyperLinkZhCN from '@univerjs/presets/preset-sheets-hyper-link/locales/zh-CN'
|
|
45
|
+
// 批注
|
|
46
|
+
import { UniverSheetsNotePreset } from '@univerjs/preset-sheets-note'
|
|
47
|
+
import UniverPresetSheetsNoteZhCN from '@univerjs/preset-sheets-note/locales/zh-CN'
|
|
48
|
+
// vue3支持
|
|
49
|
+
import { UniverVue3AdapterPlugin } from '@univerjs/ui-adapter-vue3'
|
|
50
|
+
|
|
51
|
+
// 自定义插件
|
|
52
|
+
import SaveButtonPlugin from './plugins/saveButton/SaveButton'
|
|
53
|
+
import SyncContextMenuPlugin from './plugins/syncContextMenu/SyncContextMenuPlugin'
|
|
54
|
+
import IndicatorsContextMenuPlugin from './plugins/indicatorsContextMenu/IndicatorsContextMenuPlugin'
|
|
55
|
+
import ImportFilePlugin from './plugins/importFile/ImportFilePlugin'
|
|
56
|
+
import TimeConfigContextMenuPlugin from './plugins/timeConfigContextMenu/TimeConfigContextMenuPlugin'
|
|
57
|
+
// 插件内弹窗组件
|
|
58
|
+
import IndicatorsUniverSheetConfigDialog from './plugins/indicatorsContextMenu/components/IndicatorsUniverSheetConfigDialog.vue'
|
|
59
|
+
import TimeConfigUniverSheetConfigDialog from './plugins/timeConfigContextMenu/components/TimeConfigUniverSheetConfigDialog.vue'
|
|
60
|
+
|
|
61
|
+
import '@univerjs/presets/lib/styles/preset-sheets-core.css'
|
|
62
|
+
import '@univerjs/presets/lib/styles/preset-sheets-conditional-formatting.css'
|
|
63
|
+
import '@univerjs/presets/lib/styles/preset-sheets-data-validation.css'
|
|
64
|
+
import '@univerjs/presets/lib/styles/preset-sheets-drawing.css'
|
|
65
|
+
import '@univerjs/presets/lib/styles/preset-sheets-filter.css'
|
|
66
|
+
import '@univerjs/presets/lib/styles/preset-sheets-hyper-link.css'
|
|
67
|
+
import '@univerjs/preset-sheets-note/lib/index.css'
|
|
68
|
+
import '@univerjs/preset-sheets-drawing/lib/index.css'
|
|
69
|
+
import '@univerjs/preset-sheets-advanced/lib/index.css'
|
|
70
|
+
// 其他
|
|
71
|
+
import { globalLoading } from '@/components/GlobalLoading/index'
|
|
72
|
+
import { UniverSheetsProps, ModeEnum } from './UniverSheet.data'
|
|
73
|
+
import { isEmpty, isNullOrUnDef, isNumber } from '@/utils/is'
|
|
74
|
+
import { useMessage } from '@/hooks/useMessage'
|
|
75
|
+
|
|
76
|
+
const props = withDefaults(defineProps<UniverSheetsProps>(), {
|
|
77
|
+
mode: ModeEnum.view,
|
|
78
|
+
showImportFilePlugin: false,
|
|
79
|
+
showIndicatorsContextMenuPlugin: false,
|
|
80
|
+
showSyncContextMenuPlugin: false,
|
|
81
|
+
showTimeConfigContextMenuPlugin: false,
|
|
82
|
+
license: '',
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
const emit = defineEmits(['active-sheet-changed'])
|
|
86
|
+
|
|
87
|
+
const message = useMessage() // 消息弹窗
|
|
88
|
+
const { openLoading, closeLoading } = globalLoading
|
|
89
|
+
|
|
90
|
+
const indicatorsUniverSheetConfigDialogRef = ref()
|
|
91
|
+
const timeConfigUniverSheetConfigDialogRef = ref()
|
|
92
|
+
|
|
93
|
+
const container = ref<HTMLDivElement | null>(null)
|
|
94
|
+
let globalUniverApi: FUniver | null = null
|
|
95
|
+
let univer: Univer | null = null
|
|
96
|
+
let ActiveSheetChangedEvent: any = null
|
|
97
|
+
|
|
98
|
+
async function generate(data = {}) {
|
|
99
|
+
if (!container.value) return
|
|
100
|
+
if (globalUniverApi || univer) {
|
|
101
|
+
destroyUniver()
|
|
102
|
+
}
|
|
103
|
+
await nextTick()
|
|
104
|
+
try {
|
|
105
|
+
const { univerAPI, univer: univerInstance } = createUniver({
|
|
106
|
+
locale: LocaleType.ZH_CN,
|
|
107
|
+
locales: {
|
|
108
|
+
[LocaleType.ZH_CN]: mergeLocales(
|
|
109
|
+
zhCN,
|
|
110
|
+
sheetsCoreZhCN,
|
|
111
|
+
sheetsConditionalFormattingZhCN,
|
|
112
|
+
sheetsDataValidationZhCN,
|
|
113
|
+
sheetsDrawingZhCN,
|
|
114
|
+
sheetsFilterZhCN,
|
|
115
|
+
sheetsHyperLinkZhCN,
|
|
116
|
+
UniverPresetSheetsNoteZhCN,
|
|
117
|
+
UniverPresetSheetsDrawingZhCN,
|
|
118
|
+
UniverPresetSheetsAdvancedZhCN,
|
|
119
|
+
),
|
|
120
|
+
},
|
|
121
|
+
theme: defaultTheme,
|
|
122
|
+
// theme: greenTheme,
|
|
123
|
+
presets: [
|
|
124
|
+
UniverSheetsCorePreset({
|
|
125
|
+
container: container.value,
|
|
126
|
+
toolbar: props.mode !== 'view',
|
|
127
|
+
contextMenu: props.mode !== 'view',
|
|
128
|
+
formulaBar: props.mode !== 'view',
|
|
129
|
+
footer:
|
|
130
|
+
props.mode !== 'view'
|
|
131
|
+
? { sheetBar: true, statisticBar: true, menus: true, zoomSlider: true }
|
|
132
|
+
: false,
|
|
133
|
+
}),
|
|
134
|
+
UniverSheetsConditionalFormattingPreset(),
|
|
135
|
+
UniverSheetsDataValidationPreset(),
|
|
136
|
+
UniverSheetsDrawingPreset(),
|
|
137
|
+
UniverSheetsFilterPreset(),
|
|
138
|
+
UniverSheetsHyperLinkPreset(),
|
|
139
|
+
UniverSheetsNotePreset(),
|
|
140
|
+
UniverSheetsAdvancedPreset({
|
|
141
|
+
license: props.license,
|
|
142
|
+
// universerEndpoint: import.meta.env.VITE_BASE_URL
|
|
143
|
+
// universerEndpoint: ''
|
|
144
|
+
}),
|
|
145
|
+
],
|
|
146
|
+
plugins: [],
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
globalUniverApi = univerAPI
|
|
150
|
+
univer = univerInstance
|
|
151
|
+
|
|
152
|
+
// 创建一个新的工作簿
|
|
153
|
+
globalUniverApi.createWorkbook(data)
|
|
154
|
+
return Promise.resolve(true)
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error(error)
|
|
157
|
+
return Promise.reject(error)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
async function registerPlugin() {
|
|
162
|
+
univer?.registerPlugin(UniverVue3AdapterPlugin)
|
|
163
|
+
if (props.showImportFilePlugin) {
|
|
164
|
+
univer?.registerPlugin(ImportFilePlugin as any, { univerAPI: globalUniverApi })
|
|
165
|
+
}
|
|
166
|
+
if (props.showIndicatorsContextMenuPlugin) {
|
|
167
|
+
univer?.registerPlugin(IndicatorsContextMenuPlugin, {
|
|
168
|
+
univerAPI: globalUniverApi,
|
|
169
|
+
dialogRef: indicatorsUniverSheetConfigDialogRef.value,
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
if (props.showTimeConfigContextMenuPlugin) {
|
|
173
|
+
univer?.registerPlugin(TimeConfigContextMenuPlugin, {
|
|
174
|
+
univerAPI: globalUniverApi,
|
|
175
|
+
dialogRef: timeConfigUniverSheetConfigDialogRef.value,
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
if (props.showSyncContextMenuPlugin) {
|
|
179
|
+
univer?.registerPlugin(SyncContextMenuPlugin, { univerAPI: globalUniverApi })
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function setPermission() {
|
|
184
|
+
if (!globalUniverApi) {
|
|
185
|
+
return Promise.resolve(false)
|
|
186
|
+
}
|
|
187
|
+
if (props.mode === ModeEnum.edit) {
|
|
188
|
+
ActiveSheetChangedEvent = globalUniverApi.addEvent(
|
|
189
|
+
globalUniverApi.Event.ActiveSheetChanged,
|
|
190
|
+
({ workbook, activeSheet }) => {
|
|
191
|
+
console.log('ActiveSheetChanged', { workbook, activeSheet })
|
|
192
|
+
emit('active-sheet-changed', { workbook, activeSheet })
|
|
193
|
+
},
|
|
194
|
+
)
|
|
195
|
+
// globalUniverApi.addEvent(globalUniverApi.Event.SheetEditEnded, (params: any) => {
|
|
196
|
+
// console.log('SheetEditEnded', params)
|
|
197
|
+
// const { workbook, worksheet, row, column, eventType } = params
|
|
198
|
+
// console.log('123123', worksheet.getRange(row, column).getValue())
|
|
199
|
+
// })
|
|
200
|
+
return Promise.resolve(false)
|
|
201
|
+
}
|
|
202
|
+
globalUniverApi.addEvent(globalUniverApi.Event.LifeCycleChanged, ({ stage }) => {
|
|
203
|
+
if (stage === globalUniverApi?.Enum.LifecycleStages.Rendered) {
|
|
204
|
+
const fWorkbook = globalUniverApi.getActiveWorkbook()!
|
|
205
|
+
|
|
206
|
+
// disable selection
|
|
207
|
+
fWorkbook.disableSelection()
|
|
208
|
+
|
|
209
|
+
// set read only
|
|
210
|
+
const permission = fWorkbook.getWorkbookPermission()
|
|
211
|
+
permission.setReadOnly()
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function destroyUniver() {
|
|
217
|
+
globalUniverApi?.dispose()
|
|
218
|
+
univer?.dispose()
|
|
219
|
+
globalUniverApi = null
|
|
220
|
+
univer = null
|
|
221
|
+
if (ActiveSheetChangedEvent) {
|
|
222
|
+
ActiveSheetChangedEvent.dispose()
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function getWorkbookData() {
|
|
227
|
+
if (!globalUniverApi) {
|
|
228
|
+
message.warning('工作簿实例未创建')
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
const workbook = globalUniverApi.getActiveWorkbook()
|
|
232
|
+
return workbook?.save()
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
async function createUniverSheets(data = {}) {
|
|
236
|
+
await generate(data)
|
|
237
|
+
await registerPlugin()
|
|
238
|
+
await setPermission()
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function executeCalculation() {
|
|
242
|
+
if (!globalUniverApi) {
|
|
243
|
+
message.warning('工作簿实例未创建')
|
|
244
|
+
return
|
|
245
|
+
}
|
|
246
|
+
// 执行公式计算
|
|
247
|
+
const formulaEngine = globalUniverApi.getFormula()
|
|
248
|
+
formulaEngine.executeCalculation()
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// 批量更新单元格值
|
|
252
|
+
async function batchUpdateCells(cells: IObjectMatrixPrimitiveType<ICellData>, sheetId: string) {
|
|
253
|
+
if (!globalUniverApi) {
|
|
254
|
+
message.warning('工作簿实例未创建')
|
|
255
|
+
return
|
|
256
|
+
}
|
|
257
|
+
if (!sheetId) return
|
|
258
|
+
if (!cells) return
|
|
259
|
+
const fWorkbook = globalUniverApi.getActiveWorkbook()
|
|
260
|
+
const fWorksheet = fWorkbook!.getActiveSheet()
|
|
261
|
+
const currentSheetId = fWorksheet?.getSheetId()
|
|
262
|
+
if (currentSheetId !== sheetId) {
|
|
263
|
+
message.warning('当前工作表与目标工作表不一致')
|
|
264
|
+
throw new Error('当前工作表与目标工作表不一致')
|
|
265
|
+
}
|
|
266
|
+
for (const [rowNum, cols] of Object.entries(cells)) {
|
|
267
|
+
for (const [colNum, cellData] of Object.entries(cols)) {
|
|
268
|
+
const { custom } = cellData as ICellData
|
|
269
|
+
const fRange = fWorksheet.getRange(Number(rowNum), Number(colNum))
|
|
270
|
+
// const itemData: ICellData = cellData as ICellData
|
|
271
|
+
// if (!isEmpty(itemData?.v)) {
|
|
272
|
+
// itemData.v = isNaN(itemData.v)
|
|
273
|
+
// }
|
|
274
|
+
|
|
275
|
+
fRange.setValue({
|
|
276
|
+
// 优先默认内容
|
|
277
|
+
...fRange.getCellData(),
|
|
278
|
+
...(cellData! as ICellData),
|
|
279
|
+
})
|
|
280
|
+
if (custom?.cellType === 'indicator') {
|
|
281
|
+
fRange.createOrUpdateNote({
|
|
282
|
+
id: `${fRange.getSheetId()}-${rowNum}-${colNum}`, // Unique identifier for the note
|
|
283
|
+
row: Number(rowNum), // Row index of the cell
|
|
284
|
+
col: Number(colNum), // Column index of the cell
|
|
285
|
+
note: `指标名称:${custom?.indicatorName};指标编码: ${custom?.indicatorCode};指标ID: ${custom?.indicatorId};businessDate:${custom?.businessDate}`,
|
|
286
|
+
width: 200,
|
|
287
|
+
height: 100,
|
|
288
|
+
show: false,
|
|
289
|
+
})
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// 获取工作表数据
|
|
296
|
+
async function getActiveSheetData() {
|
|
297
|
+
if (!globalUniverApi) {
|
|
298
|
+
return Promise.resolve(false)
|
|
299
|
+
}
|
|
300
|
+
const fWorkbook = globalUniverApi.getActiveWorkbook()
|
|
301
|
+
const fWorksheet = fWorkbook!.getActiveSheet()
|
|
302
|
+
const sheetSnapshot = fWorksheet.getSheet().getSnapshot()
|
|
303
|
+
// console.log('sheetSnapshot', sheetSnapshot)
|
|
304
|
+
return Promise.resolve(sheetSnapshot)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
defineExpose({
|
|
308
|
+
createUniverSheets,
|
|
309
|
+
destroyUniver,
|
|
310
|
+
getWorkbookData,
|
|
311
|
+
getActiveSheetData,
|
|
312
|
+
batchUpdateCells,
|
|
313
|
+
executeCalculation,
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
onMounted(async () => {
|
|
317
|
+
createUniverSheets()
|
|
318
|
+
})
|
|
319
|
+
|
|
320
|
+
onBeforeUnmount(() => {
|
|
321
|
+
destroyUniver()
|
|
322
|
+
})
|
|
323
|
+
</script>
|
|
324
|
+
|
|
325
|
+
<style scoped>
|
|
326
|
+
.univer-wrapper {
|
|
327
|
+
width: 100%;
|
|
328
|
+
height: 100%;
|
|
329
|
+
position: relative;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.univer-container {
|
|
333
|
+
width: 100%;
|
|
334
|
+
height: 100%;
|
|
335
|
+
position: absolute;
|
|
336
|
+
top: 0;
|
|
337
|
+
left: 0;
|
|
338
|
+
}
|
|
339
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { generateUUID } from '@/utils'
|
|
2
|
+
import { IWorkbookData, IWorksheetData, ICellData, LocaleType } from '@univerjs/presets'
|
|
3
|
+
|
|
4
|
+
type UseDataType = {
|
|
5
|
+
workbookData: IWorkbookData
|
|
6
|
+
id?: string
|
|
7
|
+
name?: string
|
|
8
|
+
appVersion?: string
|
|
9
|
+
}
|
|
10
|
+
export function useData(data: UseDataType): IWorkbookData {
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
...data?.workbookData,
|
|
14
|
+
id: data?.id || generateUUID(),
|
|
15
|
+
name: data?.name || '未命名',
|
|
16
|
+
appVersion: data?.appVersion || '1.0.0',
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { h, Component } from 'vue'
|
|
2
|
+
import { FormSchema } from '@/types/form'
|
|
3
|
+
import { handleClearInput } from '@/utils/index'
|
|
4
|
+
|
|
5
|
+
// 定义外部组件注入接口
|
|
6
|
+
export interface ExternalComponents {
|
|
7
|
+
IndicatorPointSelect?: Component
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// 全局变量存储外部组件
|
|
11
|
+
let externalComponents: ExternalComponents = {}
|
|
12
|
+
|
|
13
|
+
// 注册外部组件的方法
|
|
14
|
+
export function registerExternalComponents(components: ExternalComponents) {
|
|
15
|
+
externalComponents = { ...externalComponents, ...components }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// 获取外部组件
|
|
19
|
+
function getExternalComponent(name: keyof ExternalComponents): Component | undefined {
|
|
20
|
+
return externalComponents[name]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export enum CycleTypeEnum {
|
|
24
|
+
无 = 'no',
|
|
25
|
+
年 = 'year',
|
|
26
|
+
月 = 'month',
|
|
27
|
+
周 = 'week',
|
|
28
|
+
天 = 'day',
|
|
29
|
+
班组 = 'shift',
|
|
30
|
+
小时 = 'hour',
|
|
31
|
+
半小时 = 'half_hour'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const CycleTypeOptions = [
|
|
35
|
+
{ label: '无', value: 'no' },
|
|
36
|
+
{ label: '年', value: 'year' },
|
|
37
|
+
{ label: '月', value: 'month' },
|
|
38
|
+
{ label: '周', value: 'week' },
|
|
39
|
+
{ label: '天', value: 'day' },
|
|
40
|
+
{ label: '班组', value: 'shift' },
|
|
41
|
+
{ label: '小时', value: 'hour' },
|
|
42
|
+
{ label: '半小时', value: 'half_hour' },
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
export type ExtendedFormSchema = Omit<FormSchema, 'hidden'> & {
|
|
46
|
+
hidden?: boolean | ((formModel: Recordable) => boolean)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Use the new type in your FormType
|
|
50
|
+
export type FormType = {
|
|
51
|
+
title: string
|
|
52
|
+
schemas: ExtendedFormSchema[]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const schemas: FormType[] = [
|
|
56
|
+
{
|
|
57
|
+
title: '基本信息',
|
|
58
|
+
schemas: [
|
|
59
|
+
{
|
|
60
|
+
label: '指标名称',
|
|
61
|
+
field: 'indicatorName',
|
|
62
|
+
component: 'Input',
|
|
63
|
+
formItemProps: {
|
|
64
|
+
rules: [{ required: true, message: '请输入指标名称', trigger: 'blur' }]
|
|
65
|
+
},
|
|
66
|
+
render: ({ formModel }) => {
|
|
67
|
+
const IndicatorPointSelect = getExternalComponent('IndicatorPointSelect')
|
|
68
|
+
return h(IndicatorPointSelect, {
|
|
69
|
+
modelValue: formModel.indicatorName,
|
|
70
|
+
onSelect: (select) => {
|
|
71
|
+
const obj = {
|
|
72
|
+
indicatorName: select?.indicatorName,
|
|
73
|
+
indicatorCode: select?.indicatorCoding,
|
|
74
|
+
indicatorId: select?.id,
|
|
75
|
+
indicatorDimensionName: select?.indicatorDimensionName,
|
|
76
|
+
indicatorDimensionConfig: select?.indicatorDimensionConfig
|
|
77
|
+
}
|
|
78
|
+
Object.assign(formModel, obj)
|
|
79
|
+
},
|
|
80
|
+
onClear: () => {
|
|
81
|
+
handleClearInput(formModel, [
|
|
82
|
+
'indicatorName',
|
|
83
|
+
'indicatorCode',
|
|
84
|
+
'indicatorId',
|
|
85
|
+
'indicatorDimensionName',
|
|
86
|
+
'indicatorDimensionConfig'
|
|
87
|
+
])
|
|
88
|
+
},
|
|
89
|
+
'onUpdate:modelValue': (val) => {
|
|
90
|
+
formModel.indicatorName = val
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
label: '指标编码',
|
|
97
|
+
field: 'indicatorCode',
|
|
98
|
+
component: 'Input',
|
|
99
|
+
componentProps: {
|
|
100
|
+
disabled: true
|
|
101
|
+
},
|
|
102
|
+
formItemProps: {
|
|
103
|
+
rules: [{ required: true, message: '请输入指标编码', trigger: 'blur' }]
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
label: '指标ID',
|
|
108
|
+
field: 'indicatorId',
|
|
109
|
+
component: 'Input',
|
|
110
|
+
componentProps: {
|
|
111
|
+
disabled: true
|
|
112
|
+
},
|
|
113
|
+
formItemProps: {
|
|
114
|
+
rules: [{ required: true, message: '请输入指标指标ID', trigger: 'blur' }]
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
label: '维度名称',
|
|
119
|
+
field: 'indicatorDimensionName',
|
|
120
|
+
component: 'Input',
|
|
121
|
+
componentProps: {
|
|
122
|
+
disabled: true
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
label: '维度编码',
|
|
127
|
+
field: 'indicatorDimensionConfig',
|
|
128
|
+
component: 'Input',
|
|
129
|
+
componentProps: {
|
|
130
|
+
disabled: true
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
label: '是否必填',
|
|
135
|
+
field: 'required',
|
|
136
|
+
component: 'ElCheckbox'
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
title: '时间条件',
|
|
142
|
+
schemas: [
|
|
143
|
+
{
|
|
144
|
+
label: '周期类型',
|
|
145
|
+
field: 'cycleType',
|
|
146
|
+
component: 'Select',
|
|
147
|
+
componentProps: (formModel) => {
|
|
148
|
+
return {
|
|
149
|
+
options: CycleTypeOptions.filter(
|
|
150
|
+
(item: any) => ![CycleTypeEnum.无, CycleTypeEnum.半小时, CycleTypeEnum.班组, CycleTypeEnum.周].includes(item.value)
|
|
151
|
+
),
|
|
152
|
+
onChange: (val) => {
|
|
153
|
+
formModel.cycleType = val
|
|
154
|
+
formModel.timeIncrement = 0
|
|
155
|
+
formModel.defaultShift = false
|
|
156
|
+
formModel.forwardPush = false
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
label: '时间递增量',
|
|
163
|
+
field: 'timeIncrement',
|
|
164
|
+
component: 'InputNumber',
|
|
165
|
+
value: 0,
|
|
166
|
+
componentProps: {
|
|
167
|
+
min: 0,
|
|
168
|
+
precision: 0
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
label: '默认排班班次',
|
|
173
|
+
field: 'defaultShift',
|
|
174
|
+
component: 'ElCheckbox',
|
|
175
|
+
componentProps: (formModel) => {
|
|
176
|
+
return {
|
|
177
|
+
onChange: (val) => {
|
|
178
|
+
formModel.defaultShift = val
|
|
179
|
+
formModel.forwardPush = false
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
hidden: (formModel) => ![CycleTypeEnum.天, CycleTypeEnum.小时].includes(formModel.cycleType)
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
label: '向前推7天',
|
|
187
|
+
field: 'forwardPush',
|
|
188
|
+
component: 'ElCheckbox',
|
|
189
|
+
componentProps: (formModel) => {
|
|
190
|
+
return {
|
|
191
|
+
disabled: formModel.defaultShift
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
hidden: (formModel) => formModel.cycleType !== CycleTypeEnum.天
|
|
195
|
+
}
|
|
196
|
+
// {
|
|
197
|
+
// label: '初始时间',
|
|
198
|
+
// field: 'initialHour',
|
|
199
|
+
// component: 'TimePicker',
|
|
200
|
+
// componentProps: {
|
|
201
|
+
// valueFormat: 'HH:00:00'
|
|
202
|
+
// },
|
|
203
|
+
// hidden: (formModel) => formModel.cycleType !== CycleTypeEnum.小时
|
|
204
|
+
// }
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
title: '拓展形式',
|
|
209
|
+
schemas: [
|
|
210
|
+
{
|
|
211
|
+
label: '复制方式',
|
|
212
|
+
field: 'copyType',
|
|
213
|
+
component: 'Select',
|
|
214
|
+
componentProps: (formModel) => {
|
|
215
|
+
return {
|
|
216
|
+
options: [
|
|
217
|
+
{ label: '向右', value: 'right' },
|
|
218
|
+
{ label: '向下', value: 'down' }
|
|
219
|
+
],
|
|
220
|
+
onClear: () => {
|
|
221
|
+
handleClearInput(formModel, ['copyType', 'copyInterval'])
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
value: null
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
label: '跨多少(行/列)复制',
|
|
229
|
+
field: 'copyInterval',
|
|
230
|
+
component: 'InputNumber',
|
|
231
|
+
value: 0,
|
|
232
|
+
componentProps: {
|
|
233
|
+
min: 0,
|
|
234
|
+
precision: 0
|
|
235
|
+
},
|
|
236
|
+
formItemProps: {
|
|
237
|
+
labelWidth: 130
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
|
|
244
|
+
export const indicatorsFormSchemas = schemas
|
|
245
|
+
|
|
246
|
+
export const timeConfigFormSchemas = schemas.filter((item) => item.title !== '基本信息')
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg
|
|
3
|
+
t="1741329372991"
|
|
4
|
+
class="icon"
|
|
5
|
+
viewBox="0 0 1024 1024"
|
|
6
|
+
version="1.1"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
p-id="5157"
|
|
9
|
+
width="16"
|
|
10
|
+
height="16"
|
|
11
|
+
>
|
|
12
|
+
<path
|
|
13
|
+
d="M947.26 577.96a54.296 54.296 0 0 0-54.296 54.288v230.376c0 0.504-0.56 1.208-1.608 1.208H110.5c-1.056 0-1.616-0.704-1.616-1.208V161.376c0-0.512 0.56-1.208 1.616-1.208h191.4a54.288 54.288 0 1 0 0-108.568H110.5C49.74 51.6 0.316 100.84 0.316 161.384v701.248c0 60.528 49.424 109.792 110.184 109.792h780.856c60.752 0 110.184-49.256 110.184-109.792V632.248a54.288 54.288 0 0 0-54.28-54.288z"
|
|
14
|
+
fill="#17A29E"
|
|
15
|
+
p-id="5158"
|
|
16
|
+
></path>
|
|
17
|
+
<path
|
|
18
|
+
d="M1023.356 100.008a54.24 54.24 0 0 0-59.84-48.104c-5.344 0.592-132.504 15.096-267.216 89.432-141.632 78.16-238.824 193.08-286.072 336.552L350.692 305.76a54.28 54.28 0 1 0-102.592 35.496l106.752 308.616a54.312 54.312 0 0 0 69.088 33.552l0.632-0.224 309.424-111.584a54.296 54.296 0 0 0-36.832-102.144l-191.896 69.2c34.664-129.656 115.224-230.552 240.392-300.552 115.944-64.848 228.584-78.16 229.72-78.288a54.272 54.272 0 0 0 47.976-59.824z"
|
|
19
|
+
fill="#17A29E"
|
|
20
|
+
p-id="5159"
|
|
21
|
+
></path>
|
|
22
|
+
</svg>
|
|
23
|
+
</template>
|
|
24
|
+
<script lang="ts" setup>
|
|
25
|
+
defineOptions({ name: 'ImportFileIcon' })
|
|
26
|
+
</script>
|