cnhis-design-vue 0.3.2-beta → 0.3.5-beta
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/env.d.ts +2 -0
- package/es/big-table/index.css +1 -0
- package/es/big-table/index.js +97 -64
- package/es/button-print/index.css +1 -0
- package/es/button-print/index.js +8806 -11
- package/es/drag-layout/index.css +2 -1
- package/es/drag-layout/index.js +33 -58
- package/es/grid/index.css +2 -1
- package/es/grid/index.js +3 -4
- package/es/index.css +2 -1
- package/es/index.js +9467 -664
- package/package.json +5 -2
- package/packages/big-table/index.ts +17 -0
- package/packages/big-table/src/BigTable.vue +2514 -0
- package/packages/big-table/src/assets/iconfont/iconfont.less +21 -0
- package/packages/big-table/src/assets/iconfont/iconfont.ttf +0 -0
- package/packages/big-table/src/assets/img/failure.png +0 -0
- package/packages/big-table/src/assets/img/icon-asc.png +0 -0
- package/packages/big-table/src/assets/img/icon-desc.png +0 -0
- package/packages/big-table/src/assets/img/no-permission.png +0 -0
- package/packages/big-table/src/assets/img/nodata.png +0 -0
- package/packages/big-table/src/assets/img/notfound.png +0 -0
- package/packages/big-table/src/assets/img/qr.png +0 -0
- package/packages/big-table/src/assets/img/video_default_cover.png +0 -0
- package/packages/big-table/src/assets/img/xb_big.png +0 -0
- package/packages/big-table/src/assets/img/xb_small.png +0 -0
- package/packages/big-table/src/assets/style/table-base.less +275 -0
- package/packages/big-table/src/assets/style/table-global.less +167 -0
- package/packages/big-table/src/bigTableEmits.ts +46 -0
- package/packages/big-table/src/bigTableProps.ts +125 -0
- package/packages/big-table/src/bigTableState.ts +62 -0
- package/packages/big-table/src/components/NoData.vue +90 -0
- package/packages/big-table/src/components/SvgIcon.vue +49 -0
- package/packages/big-table/src/components/TextOverTooltip.vue +110 -0
- package/packages/big-table/src/components/edit-form/EditForm.vue +426 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-date-picker/edit-date-picker.vue +66 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-digital/edit-digital.vue +60 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-input/edit-input.vue +38 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-input-password/edit-input-password.vue +89 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-month-picker/edit-month-picker.vue +38 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-search/edit-search.vue +63 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-search-more/edit-search-more.vue +69 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-select/edit-select.vue +51 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-select-multiple/edit-select-multiple.vue +60 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-textarea/edit-textarea.vue +34 -0
- package/packages/big-table/src/components/edit-form/edit-component/edit-time-picker/edit-time-picker.vue +42 -0
- package/packages/big-table/src/components/edit-form/edit-component/editFormProps.ts +91 -0
- package/packages/big-table/src/components/edit-form/edit-component/register-com.ts +18 -0
- package/packages/big-table/src/components/edit-form/hooks/useConfigData.ts +79 -0
- package/packages/big-table/src/components/edit-form/hooks/useDateType.ts +184 -0
- package/packages/big-table/src/components/edit-form/hooks/useFormCommon.ts +373 -0
- package/packages/big-table/src/components/edit-form/hooks/useItemDefault.ts +638 -0
- package/packages/big-table/src/components/edit-form/hooks/useSearch.ts +910 -0
- package/packages/big-table/src/components/edit-form/hooks/useValidateRules.ts +387 -0
- package/packages/big-table/src/components/edit-form/interface.ts +53 -0
- package/packages/big-table/src/components/edit-form/types.ts +3 -0
- package/packages/big-table/src/components/edit-form/utils.ts +247 -0
- package/packages/big-table/src/hooks/useBatchEditing.ts +574 -0
- package/packages/big-table/src/hooks/useFormat.ts +612 -0
- package/packages/big-table/src/hooks/useNestTable.ts +109 -0
- package/packages/big-table/src/hooks/useTableParse.ts +169 -0
- package/packages/big-table/src/utils.ts +705 -0
- package/packages/button-print/index.ts +15 -0
- package/packages/button-print/src/ButtonPrint.vue +697 -0
- package/packages/button-print/src/components/IdentityVerification.vue +149 -0
- package/packages/button-print/src/interfaces.ts +19 -0
- package/packages/button-print/src/utils/crypto.js +25 -0
- package/packages/button-print/src/utils/print.es.min.js +1 -0
- package/packages/drag-layout/index.ts +15 -0
- package/packages/drag-layout/src/DragFormLeftItem.vue +131 -0
- package/packages/drag-layout/src/DragFormRightItem.vue +277 -0
- package/packages/drag-layout/src/DragLayout.vue +712 -0
- package/packages/grid/index.ts +17 -0
- package/packages/grid/src/Grid.tsx +22 -0
- package/packages/grid/src/hooks.ts +168 -0
- package/packages/index.ts +36 -0
- package/src/component/svg/index.vue +49 -0
- package/src/core/create.ts +5 -0
- package/src/global/variable.ts +2 -0
- package/src/utils/clickoutside.ts +80 -0
- package/src/utils/crypto.js +25 -0
- package/src/utils/vexutils.ts +811 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { App } from "vue";
|
|
2
|
+
// 导入组件
|
|
3
|
+
import ButtonPrint from "./src/ButtonPrint.vue"
|
|
4
|
+
|
|
5
|
+
type SFCWithInstall<T> = T & { install(app: App): void }; // vue 安装
|
|
6
|
+
|
|
7
|
+
// 为组件提供 install 安装方法,供按需引入
|
|
8
|
+
ButtonPrint.install = function(app: App) {
|
|
9
|
+
app.component(ButtonPrint.name, ButtonPrint);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const CButtonPrint: SFCWithInstall<typeof ButtonPrint> = ButtonPrint; // 增加类型
|
|
13
|
+
|
|
14
|
+
// 默认导出组件
|
|
15
|
+
export default CButtonPrint;
|
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span @click="handleClickWrap">
|
|
3
|
+
<NDropdown
|
|
4
|
+
placement="bottom-start"
|
|
5
|
+
:show="state.visible"
|
|
6
|
+
@clickoutside="handleClickOutside"
|
|
7
|
+
:options="options"
|
|
8
|
+
@select="handleSelect"
|
|
9
|
+
>
|
|
10
|
+
<slot
|
|
11
|
+
name="button"
|
|
12
|
+
:handleClickPrintBtn="handleClickBtn"
|
|
13
|
+
:printSpinning="state.spinning"
|
|
14
|
+
:printbtnText="btnText"
|
|
15
|
+
:printVisible="state.visible"
|
|
16
|
+
>
|
|
17
|
+
<NButton class="dropdown-button" style="margin: 0 8px 8px 0" @click.stop="handleClickBtn">
|
|
18
|
+
<NIcon v-if="state.spinning" :component="Reload" style="line-height: 10px" />
|
|
19
|
+
{{ btnText }}
|
|
20
|
+
<NIcon :component="ChevronDown" />
|
|
21
|
+
</NButton>
|
|
22
|
+
</slot>
|
|
23
|
+
</NDropdown>
|
|
24
|
+
|
|
25
|
+
<IdentityVerification
|
|
26
|
+
:visible.sync="state.identityVerification.visible"
|
|
27
|
+
:printConfig="printConfig"
|
|
28
|
+
:baseUrl="baseUrl"
|
|
29
|
+
:verifyUserUrl="verifyUserUrl"
|
|
30
|
+
:identityVerificationTitle="identityVerificationTitle"
|
|
31
|
+
@success="verifiySuccess"
|
|
32
|
+
></IdentityVerification>
|
|
33
|
+
</span>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script lang="ts">
|
|
37
|
+
import create from '@/core/create';
|
|
38
|
+
export default create({
|
|
39
|
+
name: "ButtonPrint"
|
|
40
|
+
})
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
import { ref, reactive, computed, watch, onMounted, nextTick } from 'vue'
|
|
45
|
+
import { NDropdown, NButton, NIcon } from 'naive-ui'
|
|
46
|
+
import { ChevronDown, Reload } from "@vicons/ionicons5";
|
|
47
|
+
import { useMessage } from 'naive-ui'
|
|
48
|
+
import type { DropdownOption } from 'naive-ui'
|
|
49
|
+
import Print from './utils/print.es.min.js';
|
|
50
|
+
// import vClickoutside from '@/utils/clickoutside';
|
|
51
|
+
import vexutils from '@/utils/vexutils';
|
|
52
|
+
// import type { Props } from './interfaces'
|
|
53
|
+
import IdentityVerification from './components/IdentityVerification.vue';
|
|
54
|
+
import axios from 'axios'
|
|
55
|
+
import moment from 'moment';
|
|
56
|
+
// const Print:any = import.meta.globEager('./utils/print.es.min.js')['./utils/print.es.min.js'].default;
|
|
57
|
+
|
|
58
|
+
(window as any).$message = useMessage()
|
|
59
|
+
let printInstance: any = null;
|
|
60
|
+
let httpFn: any = null;
|
|
61
|
+
|
|
62
|
+
// 在.vue文件中使用导入的interface会报错,提示要使用字面量类型,当前在github上vue的issue已经有这个问题了,目前还没解决
|
|
63
|
+
interface Props {
|
|
64
|
+
baseUrl: string
|
|
65
|
+
btnText?: string
|
|
66
|
+
printText?: string
|
|
67
|
+
previewText?: string
|
|
68
|
+
formatEditText?: string
|
|
69
|
+
identityVerificationTitle?: string
|
|
70
|
+
authorizationKey: string
|
|
71
|
+
templateNumber: number | string
|
|
72
|
+
params: any[],
|
|
73
|
+
hisParams: any
|
|
74
|
+
prevFn?: Function
|
|
75
|
+
verifyUserUrl?: string
|
|
76
|
+
getPrintFormatByNumberUrl?: string
|
|
77
|
+
getTemplateParamsUrl?: string
|
|
78
|
+
strategy?: string
|
|
79
|
+
printConfig?: any
|
|
80
|
+
versionType?: number | string
|
|
81
|
+
}
|
|
82
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
83
|
+
baseUrl: '',
|
|
84
|
+
btnText: '打印',
|
|
85
|
+
printText: '直接打印',
|
|
86
|
+
previewText: '打印预览',
|
|
87
|
+
formatEditText: '格式编辑',
|
|
88
|
+
identityVerificationTitle: '打印服务身份校验',
|
|
89
|
+
prevFn: () => Promise.resolve(),
|
|
90
|
+
verifyUserUrl: '/verifyUser',
|
|
91
|
+
getPrintFormatByNumberUrl: '/getPrintFormatByNumber',
|
|
92
|
+
getTemplateParamsUrl: '/getTemplateParams',
|
|
93
|
+
strategy: 'MULTI',
|
|
94
|
+
printConfig: () => {},
|
|
95
|
+
versionType: '2'
|
|
96
|
+
});
|
|
97
|
+
const emit = defineEmits(['success', 'error']);
|
|
98
|
+
|
|
99
|
+
const state = reactive({
|
|
100
|
+
spinning: false,
|
|
101
|
+
visible: false,
|
|
102
|
+
formatList: [],
|
|
103
|
+
templateParams: {},
|
|
104
|
+
printParams: [],
|
|
105
|
+
currentFormatId: '',
|
|
106
|
+
identityVerification: {
|
|
107
|
+
visible: false
|
|
108
|
+
},
|
|
109
|
+
isInited: false,
|
|
110
|
+
watchPrintParamsReformatFn: null,
|
|
111
|
+
spinTimer: null
|
|
112
|
+
});
|
|
113
|
+
const options: Array<DropdownOption> = reactive([
|
|
114
|
+
{
|
|
115
|
+
label: props.printText,
|
|
116
|
+
key: 'printText'
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
label: props.previewText,
|
|
120
|
+
key: 'previewText'
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: props.formatEditText,
|
|
124
|
+
key: 'formatEditText'
|
|
125
|
+
}
|
|
126
|
+
]);
|
|
127
|
+
|
|
128
|
+
const currentFormatItem = computed(() => {
|
|
129
|
+
if (!state.currentFormatId) return {};
|
|
130
|
+
let id = state.currentFormatId;
|
|
131
|
+
return state.formatList.find((item: any) => item.id === id);
|
|
132
|
+
})
|
|
133
|
+
const formatTitle = computed(() => (currentFormatItem.value as any).name || '格式选择')
|
|
134
|
+
|
|
135
|
+
const getTemplateIdByFormatId = (id: string | number) => {
|
|
136
|
+
let find: any = state.formatList.find((item: any) => item.id === id);
|
|
137
|
+
return find.templateId;
|
|
138
|
+
}
|
|
139
|
+
const callLocalServicesSuccessCb = (res: any, type: any) => {
|
|
140
|
+
let info = {
|
|
141
|
+
type,
|
|
142
|
+
formatId: state.currentFormatId,
|
|
143
|
+
templateId: getTemplateIdByFormatId(state.currentFormatId)
|
|
144
|
+
};
|
|
145
|
+
emit('success', res, info);
|
|
146
|
+
}
|
|
147
|
+
const callLocalServicesErrorCb = (res: any) => {
|
|
148
|
+
emit('error', res);
|
|
149
|
+
}
|
|
150
|
+
const prevFnError = () => {
|
|
151
|
+
let error = {
|
|
152
|
+
message: '前置条件执行错误'
|
|
153
|
+
};
|
|
154
|
+
emit('error', error);
|
|
155
|
+
}
|
|
156
|
+
const getHisParams = (index: number = 0) => {
|
|
157
|
+
const { reportid = '280' } = (props.hisParams as any);
|
|
158
|
+
const { id, name } = (state.templateParams as any);
|
|
159
|
+
return {
|
|
160
|
+
reportid,
|
|
161
|
+
formatid: state.currentFormatId || id,
|
|
162
|
+
formatname: name,
|
|
163
|
+
param: props.params[index]
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
const getOnceHisParams = () => {
|
|
167
|
+
const { reportid = '280' } = (props.hisParams as any);
|
|
168
|
+
const { id, name } = (state.templateParams as any);
|
|
169
|
+
const obj: any = {}
|
|
170
|
+
Object.keys((props.params as any)[0]).forEach(v => {
|
|
171
|
+
obj[v] = [];
|
|
172
|
+
props.params.forEach((k: any) => {
|
|
173
|
+
obj[v].push(k[v]);
|
|
174
|
+
});
|
|
175
|
+
obj[v] = obj[v].join(',');
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
reportid,
|
|
179
|
+
formatid: state.currentFormatId || id,
|
|
180
|
+
formatname: name,
|
|
181
|
+
param: obj
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const getPrintParams = (index: number = 0) => {
|
|
185
|
+
const params = state.printParams[index];
|
|
186
|
+
return JSON.stringify(params);
|
|
187
|
+
}
|
|
188
|
+
const getOnceParams = () => {
|
|
189
|
+
// 聚合一条
|
|
190
|
+
let params = {};
|
|
191
|
+
let obj: any = {};
|
|
192
|
+
if ((state.templateParams as any).customizeDataset?.length) {
|
|
193
|
+
// 有模板数据
|
|
194
|
+
const key = Object.keys((state.printParams[0] as any).datasetData || {})?.[0] || '';
|
|
195
|
+
const datasetDataKeyVal = JSON.stringify(state.printParams.map((v: any) => JSON.parse(v.datasetData[key])));
|
|
196
|
+
obj = {
|
|
197
|
+
datasetData: {}
|
|
198
|
+
};
|
|
199
|
+
obj.datasetData[key] = datasetDataKeyVal;
|
|
200
|
+
} else {
|
|
201
|
+
// 无模板数据
|
|
202
|
+
Object.keys(state.printParams[0]).forEach(v => {
|
|
203
|
+
obj[v] = [];
|
|
204
|
+
state.printParams.forEach(k => {
|
|
205
|
+
obj[v].push(k[v]);
|
|
206
|
+
});
|
|
207
|
+
obj[v] = obj[v].join(',');
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
params = Object.assign({}, JSON.parse(getPrintParams(0)), obj);
|
|
211
|
+
return JSON.stringify(params);
|
|
212
|
+
}
|
|
213
|
+
const handleClickPrint = () => {
|
|
214
|
+
let len = state.printParams.length;
|
|
215
|
+
const callLocalServicesSuccessCbTmp = async (data: any) => {
|
|
216
|
+
try {
|
|
217
|
+
if (--len <= 0) {
|
|
218
|
+
callLocalServicesSuccessCb(data, 'print');
|
|
219
|
+
}
|
|
220
|
+
} catch (error) {
|
|
221
|
+
console.log('error', error);
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
props.prevFn()
|
|
226
|
+
.catch(() => {
|
|
227
|
+
prevFnError();
|
|
228
|
+
return Promise.reject();
|
|
229
|
+
})
|
|
230
|
+
.then(() => {
|
|
231
|
+
if (props.versionType == 1 || props.versionType == 3) {
|
|
232
|
+
const printFn = props.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
|
|
233
|
+
if (props.strategy === 'MULTI') {
|
|
234
|
+
for (let i = 0; i < props.params.length; i++) {
|
|
235
|
+
const params = getHisParams(i);
|
|
236
|
+
printInstance[printFn](7, params)
|
|
237
|
+
.then((res: any) => {
|
|
238
|
+
console.log(res, '777777777777');
|
|
239
|
+
})
|
|
240
|
+
.catch((error:any) => {
|
|
241
|
+
console.log(error, 'error777');
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
} else {
|
|
245
|
+
const params = getOnceHisParams();
|
|
246
|
+
printInstance[printFn](7, params)
|
|
247
|
+
.then((res: any) => {
|
|
248
|
+
console.log(res, '777777777777');
|
|
249
|
+
})
|
|
250
|
+
.catch((error:any) => {
|
|
251
|
+
console.log(error, 'error777');
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
if (props.strategy === 'MULTI') {
|
|
256
|
+
// 循环多条
|
|
257
|
+
for (let i = 0; i < state.printParams.length; i++) {
|
|
258
|
+
const queryParams = {
|
|
259
|
+
formatId: state.currentFormatId,
|
|
260
|
+
templateId: getTemplateIdByFormatId(state.currentFormatId),
|
|
261
|
+
params: getPrintParams(i)
|
|
262
|
+
};
|
|
263
|
+
printInstance.printDirect(queryParams, callLocalServicesSuccessCbTmp, callLocalServicesErrorCb);
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
// 聚合一条
|
|
267
|
+
const queryParams = {
|
|
268
|
+
formatId: state.currentFormatId,
|
|
269
|
+
templateId: getTemplateIdByFormatId(state.currentFormatId),
|
|
270
|
+
params: getOnceParams()
|
|
271
|
+
};
|
|
272
|
+
printInstance.printDirect(
|
|
273
|
+
queryParams,
|
|
274
|
+
(res: any) => {
|
|
275
|
+
callLocalServicesSuccessCb(res, 'print');
|
|
276
|
+
},
|
|
277
|
+
callLocalServicesErrorCb
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
.finally(() => {
|
|
283
|
+
state.visible = false;
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
const handleClickPreview = async () => {
|
|
287
|
+
props.prevFn()
|
|
288
|
+
.catch(() => {
|
|
289
|
+
prevFnError();
|
|
290
|
+
return Promise.reject();
|
|
291
|
+
})
|
|
292
|
+
.then(() => {
|
|
293
|
+
if (props.versionType == 1 || props.versionType == 3) {
|
|
294
|
+
const params = props.strategy === 'MULTI' ? getHisParams() : getOnceHisParams();
|
|
295
|
+
const printFn = props.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
|
|
296
|
+
printInstance[printFn](8, params)
|
|
297
|
+
.then((res: any) => {
|
|
298
|
+
console.log(res, 88888888);
|
|
299
|
+
})
|
|
300
|
+
.catch((error: any) => {
|
|
301
|
+
console.log(error, 'error888');
|
|
302
|
+
});
|
|
303
|
+
} else {
|
|
304
|
+
const params = props.strategy === 'MULTI' ? getPrintParams() : getOnceParams();
|
|
305
|
+
const queryParams = {
|
|
306
|
+
formatId: state.currentFormatId,
|
|
307
|
+
templateId: getTemplateIdByFormatId(state.currentFormatId),
|
|
308
|
+
params
|
|
309
|
+
};
|
|
310
|
+
printInstance.preview(
|
|
311
|
+
queryParams,
|
|
312
|
+
(res: any) => {
|
|
313
|
+
callLocalServicesSuccessCb(res, 'preview');
|
|
314
|
+
},
|
|
315
|
+
callLocalServicesErrorCb
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
.finally(() => {
|
|
320
|
+
state.visible = false;
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
const handleClickEdit = () => {
|
|
324
|
+
props.prevFn()
|
|
325
|
+
.catch(() => {
|
|
326
|
+
prevFnError();
|
|
327
|
+
return Promise.reject();
|
|
328
|
+
})
|
|
329
|
+
.then(() => {
|
|
330
|
+
if (props.versionType == 1 || props.versionType == 3) {
|
|
331
|
+
const params = props.strategy === 'MULTI' ? getHisParams() : getOnceHisParams();
|
|
332
|
+
const printFn = props.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
|
|
333
|
+
printInstance[printFn](9, params)
|
|
334
|
+
.then((res: any) => {
|
|
335
|
+
console.log(res, 999999);
|
|
336
|
+
})
|
|
337
|
+
.catch((error: any) => {
|
|
338
|
+
console.log(error, 'error999');
|
|
339
|
+
});
|
|
340
|
+
} else {
|
|
341
|
+
state.identityVerification.visible = true;
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
.finally(() => {
|
|
345
|
+
state.visible = false;
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
const handleSelect = (key: string) => {
|
|
349
|
+
switch(key) {
|
|
350
|
+
case 'printText':
|
|
351
|
+
handleClickPrint();
|
|
352
|
+
break;
|
|
353
|
+
case 'previewText':
|
|
354
|
+
handleClickPreview();
|
|
355
|
+
break;
|
|
356
|
+
case 'formatEditText':
|
|
357
|
+
handleClickEdit();
|
|
358
|
+
break;
|
|
359
|
+
default:
|
|
360
|
+
state.currentFormatId = key;
|
|
361
|
+
break;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
const handleClickOutside = () => {
|
|
365
|
+
state.visible = false;
|
|
366
|
+
}
|
|
367
|
+
const handleClickWrap = () => {
|
|
368
|
+
setTimeout(() => {
|
|
369
|
+
state.visible = true;
|
|
370
|
+
}, 0);
|
|
371
|
+
}
|
|
372
|
+
const setTimeoutSpin = () => {
|
|
373
|
+
(state as any).spinTimer = setTimeout(() => {
|
|
374
|
+
state.spinning = true;
|
|
375
|
+
}, 1500);
|
|
376
|
+
}
|
|
377
|
+
const instantiatePrintSDK = () => {
|
|
378
|
+
if (printInstance) return false;
|
|
379
|
+
printInstance = new Print();
|
|
380
|
+
}
|
|
381
|
+
const queryFormatList = () => {
|
|
382
|
+
const { templateNumber, authorizationKey, baseUrl, getPrintFormatByNumberUrl, versionType } = props;
|
|
383
|
+
const suffix = [1, 3].includes(+versionType) ? `jsessionids=${vexutils.cookie.get('jsessionids') || '31e5fc0e-955f-4c89-9679-39c43d0171321636163291241'}` : `authorizationKey=${authorizationKey}`;
|
|
384
|
+
const url = `${baseUrl}${getPrintFormatByNumberUrl}?number=${templateNumber}&${suffix}`;
|
|
385
|
+
return httpFn
|
|
386
|
+
.get(url)
|
|
387
|
+
.then(async ({ data = {} }) => {
|
|
388
|
+
if ((data as any).result !== 'SUCCESS') {
|
|
389
|
+
(window as any).$message.error((data as any).resultMsg || '参数异常,请联系管理员');
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
return data;
|
|
393
|
+
})
|
|
394
|
+
.catch((e: any) => {
|
|
395
|
+
return false;
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
const getDefaultFormatId = (list: any[], key: string | number) => {
|
|
399
|
+
if (!list?.length) return '';
|
|
400
|
+
let findDefault = list.find(item => item[key] == 1);
|
|
401
|
+
return findDefault?.id || list[0].id;
|
|
402
|
+
}
|
|
403
|
+
const setOptions = () => {
|
|
404
|
+
const children = state.formatList.map((v: any): DropdownOption => {
|
|
405
|
+
return {
|
|
406
|
+
label: v.name,
|
|
407
|
+
key: v.id
|
|
408
|
+
}
|
|
409
|
+
})
|
|
410
|
+
options.unshift({
|
|
411
|
+
label: formatTitle.value,
|
|
412
|
+
key: 'format',
|
|
413
|
+
children
|
|
414
|
+
})
|
|
415
|
+
}
|
|
416
|
+
const initHIS = (formatListResult: any) => {
|
|
417
|
+
state.formatList = formatListResult ? formatListResult.list.filter((item: any) => item.printmark == 1) : [];
|
|
418
|
+
setOptions();
|
|
419
|
+
state.currentFormatId = getDefaultFormatId(state.formatList, 'printmark');
|
|
420
|
+
state.templateParams = state.formatList[0];
|
|
421
|
+
}
|
|
422
|
+
const formatFormatList = (list: any[]): any => {
|
|
423
|
+
let formatList: any[] = [];
|
|
424
|
+
|
|
425
|
+
list.forEach(item => {
|
|
426
|
+
if (!item.format) return false;
|
|
427
|
+
formatList.push(...item.format);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
return formatList;
|
|
431
|
+
}
|
|
432
|
+
const setLoaded = () => {
|
|
433
|
+
state.spinning = false;
|
|
434
|
+
if (!state.spinTimer) return false;
|
|
435
|
+
clearTimeout(state.spinTimer);
|
|
436
|
+
state.spinTimer = null;
|
|
437
|
+
}
|
|
438
|
+
const requestError = () => {
|
|
439
|
+
state.isInited = false;
|
|
440
|
+
setLoaded();
|
|
441
|
+
setTimeout(() => {
|
|
442
|
+
state.visible = false;
|
|
443
|
+
}, 0);
|
|
444
|
+
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
447
|
+
const queryTemplateParams = () => {
|
|
448
|
+
const { templateNumber, authorizationKey, baseUrl, getTemplateParamsUrl } = props;
|
|
449
|
+
const { templateId } = state.formatList[0] || {};
|
|
450
|
+
const url = `${baseUrl}${getTemplateParamsUrl}?number=${templateNumber}&templateId=${templateId}&authorizationKey=${authorizationKey}`;
|
|
451
|
+
|
|
452
|
+
return httpFn
|
|
453
|
+
.get(url)
|
|
454
|
+
.then(async ({ data = {} }) => {
|
|
455
|
+
if ((data as any).result !== 'SUCCESS') {
|
|
456
|
+
(window as any).$message.error((data as any).resultMsg || '参数异常,请联系管理员');
|
|
457
|
+
return false;
|
|
458
|
+
}
|
|
459
|
+
return (data as any)?.obj || {};
|
|
460
|
+
})
|
|
461
|
+
.catch((e: any) => {
|
|
462
|
+
return false;
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
const formatDefaultVal = (i: any, tableVal?: any) => {
|
|
466
|
+
let val = i.defaultValue || '';
|
|
467
|
+
let tVal = tableVal;
|
|
468
|
+
if (i.type === 'NUMBER') {
|
|
469
|
+
tVal = Number(tableVal) || 0;
|
|
470
|
+
}
|
|
471
|
+
if (i.type === 'DATE') {
|
|
472
|
+
tVal = tableVal ? moment(tableVal).format('YYYY-MM-DD') : '';
|
|
473
|
+
}
|
|
474
|
+
if (i.type === 'DATETIME') {
|
|
475
|
+
tVal = tableVal ? moment(tableVal).format('YYYY-MM-DD HH:mm:ss') : '';
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return val ? val : tVal;
|
|
479
|
+
}
|
|
480
|
+
const formatPrintParams = (paramObj: any, fieldList: any[], keyName: string) => {
|
|
481
|
+
const obj: any = {};
|
|
482
|
+
fieldList.forEach((i: any) => {
|
|
483
|
+
let defaultVal = formatDefaultVal(i, paramObj[i[keyName]]);
|
|
484
|
+
if (paramObj[i[keyName]] && defaultVal) {
|
|
485
|
+
obj[i[keyName]] = defaultVal;
|
|
486
|
+
}
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
return obj;
|
|
490
|
+
}
|
|
491
|
+
const formatParams = ({ customizeDataset = [], param = [] }, params: any[] = []): any => {
|
|
492
|
+
return params.map(paramObj => {
|
|
493
|
+
let res: any = {};
|
|
494
|
+
|
|
495
|
+
// 自定义结果集
|
|
496
|
+
customizeDataset.forEach((dataSetItem: any) => {
|
|
497
|
+
const selectFieldList = dataSetItem.dataSetting[0].selectFieldList;
|
|
498
|
+
res['datasetData'] = {
|
|
499
|
+
[dataSetItem.name]: JSON.stringify(formatPrintParams(paramObj, selectFieldList, 'fieldName'))
|
|
500
|
+
};
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
// 参数
|
|
504
|
+
res = Object.assign({}, res, formatPrintParams(paramObj, param, 'key'));
|
|
505
|
+
return res;
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
const initCRM = async (formatListResult: any) => {
|
|
509
|
+
state.formatList = formatListResult ? formatFormatList(formatListResult.obj) : [];
|
|
510
|
+
setOptions();
|
|
511
|
+
state.currentFormatId = getDefaultFormatId(state.formatList, 'defaultFlag');
|
|
512
|
+
|
|
513
|
+
if (!state.currentFormatId) {
|
|
514
|
+
(window as any).$message.error('获取打印格式失败,请联系管理员!');
|
|
515
|
+
return requestError();
|
|
516
|
+
}
|
|
517
|
+
if (!state.currentFormatId) {
|
|
518
|
+
requestError();
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
521
|
+
let templateParamsResult = await queryTemplateParams();
|
|
522
|
+
// let templateParamsResult = {
|
|
523
|
+
// "param": [],
|
|
524
|
+
// "customizeDataset": [
|
|
525
|
+
// {
|
|
526
|
+
// "dataSetting": [
|
|
527
|
+
// {
|
|
528
|
+
// "selectFieldList": [
|
|
529
|
+
// {
|
|
530
|
+
// "fieldName": "name",
|
|
531
|
+
// "type": "TEXT"
|
|
532
|
+
// },
|
|
533
|
+
// {
|
|
534
|
+
// "fieldName": "age",
|
|
535
|
+
// "type": "NUMBER"
|
|
536
|
+
// },
|
|
537
|
+
// {
|
|
538
|
+
// "fieldName": "money",
|
|
539
|
+
// "type": "NUMBER"
|
|
540
|
+
// }
|
|
541
|
+
// ],
|
|
542
|
+
// "jsonType": "jsonObject",
|
|
543
|
+
// "required": false,
|
|
544
|
+
// "downloadFields": ""
|
|
545
|
+
// }
|
|
546
|
+
// ],
|
|
547
|
+
// "name": "结果集1",
|
|
548
|
+
// "defaultJson": {
|
|
549
|
+
// "money": 0,
|
|
550
|
+
// "name": "",
|
|
551
|
+
// "age": 0
|
|
552
|
+
// },
|
|
553
|
+
// "customize": true,
|
|
554
|
+
// "key": 1
|
|
555
|
+
// }
|
|
556
|
+
// ]
|
|
557
|
+
// }
|
|
558
|
+
|
|
559
|
+
if (templateParamsResult) {
|
|
560
|
+
state.templateParams = templateParamsResult;
|
|
561
|
+
} else {
|
|
562
|
+
return requestError();
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
state.printParams = formatParams(state.templateParams, props.params);
|
|
566
|
+
}
|
|
567
|
+
const init = async () => {
|
|
568
|
+
if (state.isInited) return true;
|
|
569
|
+
state.isInited = true;
|
|
570
|
+
|
|
571
|
+
setTimeoutSpin();
|
|
572
|
+
|
|
573
|
+
instantiatePrintSDK();
|
|
574
|
+
let config: any = {
|
|
575
|
+
withCredentials: false,
|
|
576
|
+
timeout: 5000
|
|
577
|
+
};
|
|
578
|
+
let printUrlPrefix = props?.printConfig?.printUrlPrefix;
|
|
579
|
+
if (printUrlPrefix) {
|
|
580
|
+
config.baseURL = printUrlPrefix;
|
|
581
|
+
}
|
|
582
|
+
httpFn = axios.create({
|
|
583
|
+
...config
|
|
584
|
+
});
|
|
585
|
+
const formatListResult = await queryFormatList();
|
|
586
|
+
// const formatListResult = {
|
|
587
|
+
// "result": "SUCCESS",
|
|
588
|
+
// "code": 0,
|
|
589
|
+
// "resultMsg": "",
|
|
590
|
+
// "list": [],
|
|
591
|
+
// "obj": [
|
|
592
|
+
// {
|
|
593
|
+
// "number": "170testtemp",
|
|
594
|
+
// "name": "170公有模板",
|
|
595
|
+
// "format": [
|
|
596
|
+
// {
|
|
597
|
+
// "number": "170testtemp",
|
|
598
|
+
// "defaultFlag": 0,
|
|
599
|
+
// "printType": "1",
|
|
600
|
+
// "rowNum": 1,
|
|
601
|
+
// "name": "170公有格式1",
|
|
602
|
+
// "id": "1420212788840570880",
|
|
603
|
+
// "templateId": "1420212316842958848",
|
|
604
|
+
// "privateValue": 1
|
|
605
|
+
// },
|
|
606
|
+
// {
|
|
607
|
+
// "number": "170testtemp",
|
|
608
|
+
// "defaultFlag": 0,
|
|
609
|
+
// "printType": "1",
|
|
610
|
+
// "rowNum": 2,
|
|
611
|
+
// "name": "测试格式名称",
|
|
612
|
+
// "id": "1420242022380281856",
|
|
613
|
+
// "templateId": "1420212316842958848",
|
|
614
|
+
// "privateValue": 1
|
|
615
|
+
// }
|
|
616
|
+
// ],
|
|
617
|
+
// "id": "1420212316842958848"
|
|
618
|
+
// }
|
|
619
|
+
// ],
|
|
620
|
+
// "total": 0,
|
|
621
|
+
// "recordsTotal": 0,
|
|
622
|
+
// "recordsFiltered": 0
|
|
623
|
+
// }
|
|
624
|
+
if (props.versionType == 1 || props.versionType == 3) {
|
|
625
|
+
initHIS(formatListResult);
|
|
626
|
+
} else {
|
|
627
|
+
await initCRM(formatListResult);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
setLoaded();
|
|
631
|
+
|
|
632
|
+
return true;
|
|
633
|
+
}
|
|
634
|
+
const handleClickBtn = async () => {
|
|
635
|
+
if (!state.visible) {
|
|
636
|
+
let result = await init();
|
|
637
|
+
if (!result) return false;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
state.visible = !state.visible;
|
|
641
|
+
}
|
|
642
|
+
const reformatPrintParams = () => {
|
|
643
|
+
state.watchPrintParamsReformatFn && (state.watchPrintParamsReformatFn as any)();
|
|
644
|
+
/*
|
|
645
|
+
还没初始化完毕时(还没获取到模板格式配置等..)
|
|
646
|
+
触发再格式化逻辑,需等待初始化完毕,再重新执行格式化
|
|
647
|
+
*/
|
|
648
|
+
if (!state.isInited) {
|
|
649
|
+
(state.watchPrintParamsReformatFn as any) = () => watch(() => state.isInited, val => {
|
|
650
|
+
if (!val) return false;
|
|
651
|
+
reformatPrintParams();
|
|
652
|
+
});
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
state.printParams = formatParams(state.templateParams, props.params);
|
|
657
|
+
}
|
|
658
|
+
const verifiySuccess = (token: string) => {
|
|
659
|
+
state.identityVerification.visible = false;
|
|
660
|
+
|
|
661
|
+
const queryParams = {
|
|
662
|
+
formatId: state.currentFormatId,
|
|
663
|
+
templateId: getTemplateIdByFormatId(state.currentFormatId),
|
|
664
|
+
params: getPrintParams(),
|
|
665
|
+
token
|
|
666
|
+
};
|
|
667
|
+
printInstance.editPrintFormat(
|
|
668
|
+
queryParams,
|
|
669
|
+
(res: any) => {
|
|
670
|
+
callLocalServicesSuccessCb(res, 'edit');
|
|
671
|
+
},
|
|
672
|
+
callLocalServicesErrorCb
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
onMounted(() => {
|
|
677
|
+
state.isInited = false;
|
|
678
|
+
})
|
|
679
|
+
|
|
680
|
+
watch(() => props.params,
|
|
681
|
+
(val: any) => {
|
|
682
|
+
if (!val?.length) return false;
|
|
683
|
+
reformatPrintParams();
|
|
684
|
+
},
|
|
685
|
+
{ deep: true }
|
|
686
|
+
)
|
|
687
|
+
|
|
688
|
+
</script>
|
|
689
|
+
|
|
690
|
+
<style lang="less" scoped>
|
|
691
|
+
.dropdown-button {
|
|
692
|
+
color: #212121;
|
|
693
|
+
border-color: #d5d5d5 !important;
|
|
694
|
+
margin-left: 8px;
|
|
695
|
+
margin-bottom: 8px;
|
|
696
|
+
}
|
|
697
|
+
</style>
|