cnhis-design-vue 3.0.4 → 3.0.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
3
  "private": false,
4
- "version": "3.0.4",
4
+ "version": "3.0.7",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",
7
7
  "scripts": {
@@ -171,14 +171,11 @@ import { useFormat } from "./hooks/useFormat";
171
171
  import { useTableParse } from "./hooks/useTableParse";
172
172
  import { useBatchEditing } from "./hooks/useBatchEditing";
173
173
  import { useNestTable } from "./hooks/useNestTable";
174
- import { useEdit } from './hooks/useEdit';
174
+ import { useEdit, comps } from './hooks/useEdit';
175
175
  import { SettingsSharp, SyncOutline, CopyOutline, CaretDown, CaretForward } from "@vicons/ionicons5";
176
176
  import NoData from "./components/NoData.vue";
177
177
  import TextOverTooltip from "./components/TextOverTooltip.vue";
178
178
  import SvgIcon from '@/component/svg/index.vue';
179
- import EditSelectTable from './components/edit-form/edit-select-table.vue'
180
- import EditInput from './components/edit-form/edit-input.vue'
181
- import EditSelect from './components/edit-form/edit-select.vue'
182
179
  import {
183
180
  NButton,
184
181
  NCheckbox,
@@ -271,7 +268,7 @@ const {
271
268
  recordClickBtnInfo,
272
269
  getInlineOpreateRow
273
270
  }: any = useBatchEditing(props, state, emit, xGrid);
274
- const { initEditTable, activeMethod, deleteRow, onClickSelectTable, onUpdateInput, getDefaultValue } = useEdit(props, state, emit, xGrid)
271
+ const { initEditTable, activeMethod, deleteRow, onClickSelectTable, onFormChange, getDefaultValue } = useEdit(props, state, emit, xGrid)
275
272
 
276
273
  const {
277
274
  isAboutNestTable,
@@ -377,7 +374,7 @@ const unBindDocumentClick = () => {
377
374
  }
378
375
  onMounted(() => {
379
376
  bindDocumentClick();
380
- state.tableHeight = handleTableHeight(state, props);
377
+ state.tableHeight = handleTableHeight(state, props) || 'auto';
381
378
 
382
379
  // // 子列表在mounted后初始化 直接watch无法触发
383
380
  if (!props.isNestTable) return;
@@ -706,27 +703,29 @@ const formatColumns = (map: any) => {
706
703
  const formatterEdit = (params: any, col: any) => {
707
704
  let { row, column, $rowIndex, rowIndex } = params
708
705
  let formType = column.formType || col.formType || ''
709
- // if (formType === 'selectTable') {
710
- // const propsData = {
711
- // row,
712
- // col
713
- // }
714
- // return <EditSelectTable {...propsData} v-model={[row[col.columnName], 'value']} onClickSelectTable={onClickSelectTable} />
715
- // }
706
+ if (!formType) return null
716
707
  if (formType === 'custom') {
717
708
  return col.slotFn(params)
718
709
  }
719
- const propsData = {
710
+ const Comp = comps[formType] || ''
711
+ if (!Comp) return null
712
+ const propsData: any = {
720
713
  col,
721
714
  row,
722
- index: $rowIndex
715
+ index: $rowIndex,
716
+ // vModel: [row[col.columnName], formType === 'date' ? 'formattedValue' :'value'],
717
+ type: formType,
718
+ onFormChange
723
719
  }
724
- if (formType === 'input' || formType === 'number') {
725
- return <EditInput {...propsData} type={formType} v-model={[row[col.columnName], 'value']} onUpdateInput={onUpdateInput} />
720
+ if (formType === 'date') {
721
+ propsData.defaultFormattedValue = row[col.columnName]
722
+ } else {
723
+ propsData.defaultValue = row[col.columnName]
726
724
  }
727
725
  if (formType === 'select') {
728
- return <EditSelect {...propsData} v-model={[row[col.columnName], 'value']} onSetOptions={(options: any[]) => row[`${col.columnName}_options`] = options} />
726
+ propsData.onSetOptions = (options: any[]) => (row[`${col.columnName}_options`] = options)
729
727
  }
728
+ return <Comp {...propsData} />
730
729
  }
731
730
  const getEditBtn = (row: any, col: any, index: number) => {
732
731
  return col.tileBtnList?.map((btn: any) => {
@@ -826,8 +825,7 @@ const formatter = (params: any, col: any) => {
826
825
  return getOrCode(row, own, attrType);
827
826
  }
828
827
  if (column.property === "operatorColumn") {
829
- // if (props.columnConfig.isEdit && !row.initRow) {
830
- if (props.columnConfig.isEdit) {
828
+ if (props.columnConfig.isEdit && !row.initRow) {
831
829
  return getEditBtn(row, col, $rowIndex)
832
830
  }
833
831
 
@@ -41,8 +41,7 @@ const bigTableEmits: string[] = [
41
41
  "selectionChangeLocal",
42
42
  "switchBtnOnChange",
43
43
  "asyncTableChange",
44
- // "clickSelectTable"
45
- "updateInput"
44
+ "formChange"
46
45
  ];
47
46
 
48
47
  export default bigTableEmits;
@@ -0,0 +1,41 @@
1
+ <script lang="tsx">
2
+ import { defineComponent, ref, reactive, resolveComponent } from 'vue'
3
+ import { NDatePicker } from 'naive-ui'
4
+
5
+ export default defineComponent({
6
+ name: 'EditDate',
7
+ inheritAttrs: false,
8
+ components: {
9
+ NDatePicker
10
+ },
11
+ props: {
12
+ col: {
13
+ type: Object,
14
+ default: () => ({})
15
+ },
16
+ row: {
17
+ type: Object,
18
+ default: () => ({})
19
+ },
20
+ index: {
21
+ type: [Number, Object],
22
+ default: 0
23
+ }
24
+ },
25
+ emits: ['formChange'],
26
+ setup (props, { attrs, slots, emit }) {
27
+ const onConfirm = (value: any) => {
28
+ emit('formChange', { value, row: props.row, column: props.col, index: props.index })
29
+ }
30
+ const config = {
31
+ type: props.col.type || 'datetime',
32
+ clearable: props.col.clearable || true,
33
+ disabled: props.col.disabled || false,
34
+ valueFormat: props.col.valueFormat || 'yyyy-MM-dd HH:mm:ss',
35
+ to: false
36
+ }
37
+ return () => <NDatePicker {...attrs} {...config} onUpdateFormattedValue={onConfirm} />
38
+ }
39
+ })
40
+ </script>
41
+ <style lang="less" scoped></style>
@@ -27,10 +27,10 @@ export default defineComponent({
27
27
  default: 0
28
28
  }
29
29
  },
30
- emits: ['updateInput'],
30
+ emits: ['formChange'],
31
31
  setup (props, { attrs, slots, emit }) {
32
32
  const onUpdateValue = (value: number | string | null) => {
33
- emit('updateInput', { value, row: props.row, column: props.col, index: props.index })
33
+ emit('formChange', { value, row: props.row, column: props.col, index: props.index })
34
34
  }
35
35
  return () => props.type === 'input' ? <NInput {...attrs} onUpdateValue={onUpdateValue } /> : <NInputNumber {...attrs} onUpdateValue={onUpdateValue} />
36
36
  }
@@ -11,14 +11,18 @@ export default defineComponent({
11
11
  props: {
12
12
  col: {
13
13
  type: Object,
14
- default: () => {}
14
+ default: () => ({})
15
15
  },
16
16
  row: {
17
17
  type: Object,
18
- default: () => {}
18
+ default: () => ({})
19
+ },
20
+ index: {
21
+ type: [Number, Object],
22
+ default: 0
19
23
  }
20
24
  },
21
- emits: ['setOptions'],
25
+ emits: ['setOptions', 'formChange'],
22
26
  setup (props, { attrs, slots, emit }) {
23
27
 
24
28
  const state = reactive({
@@ -40,6 +44,10 @@ export default defineComponent({
40
44
 
41
45
  setOptions()
42
46
 
47
+ const onUpdateValue = (value: any[] | string | number | null) => {
48
+ emit('formChange', { value, row: props.row, column: props.col, index: props.index })
49
+ }
50
+
43
51
  return () => [
44
52
  <NSelect
45
53
  {...attrs}
@@ -49,6 +57,7 @@ export default defineComponent({
49
57
  filterable
50
58
  to={false}
51
59
  placeholder="请选择"
60
+ onUpdateValue={onUpdateValue}
52
61
  />
53
62
  ]
54
63
  }
@@ -1,4 +1,15 @@
1
1
  import { computed, ref, reactive, watch, onMounted } from 'vue'
2
+ import EditInput from '../components/edit-form/edit-input.vue'
3
+ import EditSelect from '../components/edit-form/edit-select.vue'
4
+ import EditDate from '../components/edit-form/edit-date.vue'
5
+
6
+
7
+ export const comps = {
8
+ 'input': EditInput,
9
+ 'number': EditInput,
10
+ 'select': EditSelect,
11
+ 'date': EditDate
12
+ }
2
13
 
3
14
  export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
4
15
 
@@ -71,8 +82,9 @@ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
71
82
  xGrid.value.clearActived()
72
83
  }
73
84
 
74
- const onUpdateInput = ({ value, row, column }: {value: number | string | null, row: any, column: any}) => {
75
- emit('updateInput', { value, row, column })
85
+ const onFormChange = ({ value, row, column }: {value: number | string | null, row: any, column: any}) => {
86
+ row[column.columnName] = value
87
+ emit('formChange', { value, row, column })
76
88
  }
77
89
 
78
90
  const getDefaultValue = (params: any, item: any) => {
@@ -94,7 +106,7 @@ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
94
106
  activeMethod,
95
107
  deleteRow,
96
108
  onClickSelectTable,
97
- onUpdateInput,
109
+ onFormChange,
98
110
  getDefaultValue
99
111
  }
100
- }
112
+ }
@@ -58,17 +58,16 @@ interface Props {
58
58
  previewText?: string
59
59
  formatEditText?: string
60
60
  identityVerificationTitle?: string
61
- params: any[],
62
- hisParams: any
61
+ params?: any[],
63
62
  prevFn?: Function
64
63
  verifyUser?: Function
65
64
  queryPrintFormatByNumber: Function
66
65
  queryTemplateParams?: Function
67
66
  strategy?: string
68
- versionType?: number | string
67
+ printParams?: any[]
69
68
  }
70
69
  const props = withDefaults(defineProps<Props>(), {
71
- // baseUrl: '',
70
+ params: () => ([]),
72
71
  btnText: '打印',
73
72
  printText: '直接打印',
74
73
  previewText: '打印预览',
@@ -79,7 +78,6 @@ const props = withDefaults(defineProps<Props>(), {
79
78
  queryPrintFormatByNumber: () => Promise.resolve({}),
80
79
  queryTemplateParams: () => Promise.resolve({}),
81
80
  strategy: 'MULTI',
82
- versionType: '2'
83
81
  });
84
82
  const emit = defineEmits(['success', 'error']);
85
83
 
@@ -140,36 +138,8 @@ const prevFnError = () => {
140
138
  };
141
139
  emit('error', error);
142
140
  }
143
- const getHisParams = (index: number = 0) => {
144
- const { reportid = '280' } = (props.hisParams as any);
145
- const { id, name } = (state.templateParams as any);
146
- return {
147
- reportid,
148
- formatid: state.currentFormatId || id,
149
- formatname: name,
150
- param: props.params[index]
151
- };
152
- }
153
- const getOnceHisParams = () => {
154
- const { reportid = '280' } = (props.hisParams as any);
155
- const { id, name } = (state.templateParams as any);
156
- const obj: any = {}
157
- Object.keys((props.params as any)[0]).forEach(v => {
158
- obj[v] = [];
159
- props.params.forEach((k: any) => {
160
- obj[v].push(k[v]);
161
- });
162
- obj[v] = obj[v].join(',');
163
- });
164
- return {
165
- reportid,
166
- formatid: state.currentFormatId || id,
167
- formatname: name,
168
- param: obj
169
- };
170
- }
171
141
  const getPrintParams = (index: number = 0) => {
172
- const params = state.printParams[index];
142
+ const params = props.printParams?.length ? props.printParams[index] : state.printParams[index];
173
143
  return JSON.stringify(params);
174
144
  }
175
145
  const getOnceParams = () => {
@@ -215,55 +185,30 @@ const handleClickPrint = () => {
215
185
  return Promise.reject();
216
186
  })
217
187
  .then(() => {
218
- if (props.versionType == 1 || props.versionType == 3) {
219
- const printFn = props.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
220
- if (props.strategy === 'MULTI') {
221
- for (let i = 0; i < props.params.length; i++) {
222
- const params = getHisParams(i);
223
- printInstance[printFn](7, params)
224
- .then((res: any) => {
225
- console.log(res, '777777777777');
226
- })
227
- .catch((error:any) => {
228
- console.log(error, 'error777');
229
- });
230
- }
231
- } else {
232
- const params = getOnceHisParams();
233
- printInstance[printFn](7, params)
234
- .then((res: any) => {
235
- console.log(res, '777777777777');
236
- })
237
- .catch((error:any) => {
238
- console.log(error, 'error777');
239
- });
240
- }
241
- } else {
242
- if (props.strategy === 'MULTI') {
243
- // 循环多条
244
- for (let i = 0; i < state.printParams.length; i++) {
245
- const queryParams = {
246
- formatId: state.currentFormatId,
247
- templateId: getTemplateIdByFormatId(state.currentFormatId),
248
- params: getPrintParams(i)
249
- };
250
- printInstance.printDirect(queryParams, callLocalServicesSuccessCbTmp, callLocalServicesErrorCb);
251
- }
252
- } else {
253
- // 聚合一条
188
+ if (props.strategy === 'MULTI') {
189
+ // 循环多条
190
+ for (let i = 0; i < state.printParams.length; i++) {
254
191
  const queryParams = {
255
192
  formatId: state.currentFormatId,
256
193
  templateId: getTemplateIdByFormatId(state.currentFormatId),
257
- params: getOnceParams()
194
+ params: getPrintParams(i)
258
195
  };
259
- printInstance.printDirect(
260
- queryParams,
261
- (res: any) => {
262
- callLocalServicesSuccessCb(res, 'print');
263
- },
264
- callLocalServicesErrorCb
265
- );
196
+ printInstance.printDirect(queryParams, callLocalServicesSuccessCbTmp, callLocalServicesErrorCb);
266
197
  }
198
+ } else {
199
+ // 聚合一条
200
+ const queryParams = {
201
+ formatId: state.currentFormatId,
202
+ templateId: getTemplateIdByFormatId(state.currentFormatId),
203
+ params: getOnceParams()
204
+ };
205
+ printInstance.printDirect(
206
+ queryParams,
207
+ (res: any) => {
208
+ callLocalServicesSuccessCb(res, 'print');
209
+ },
210
+ callLocalServicesErrorCb
211
+ );
267
212
  }
268
213
  })
269
214
  .finally(() => {
@@ -277,31 +222,19 @@ const handleClickPreview = async () => {
277
222
  return Promise.reject();
278
223
  })
279
224
  .then(() => {
280
- if (props.versionType == 1 || props.versionType == 3) {
281
- const params = props.strategy === 'MULTI' ? getHisParams() : getOnceHisParams();
282
- const printFn = props.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
283
- printInstance[printFn](8, params)
284
- .then((res: any) => {
285
- console.log(res, 88888888);
286
- })
287
- .catch((error: any) => {
288
- console.log(error, 'error888');
289
- });
290
- } else {
291
- const params = props.strategy === 'MULTI' ? getPrintParams() : getOnceParams();
292
- const queryParams = {
293
- formatId: state.currentFormatId,
294
- templateId: getTemplateIdByFormatId(state.currentFormatId),
295
- params
296
- };
297
- printInstance.preview(
298
- queryParams,
299
- (res: any) => {
300
- callLocalServicesSuccessCb(res, 'preview');
301
- },
302
- callLocalServicesErrorCb
303
- );
304
- }
225
+ const params = props.strategy === 'MULTI' ? getPrintParams() : getOnceParams();
226
+ const queryParams = {
227
+ formatId: state.currentFormatId,
228
+ templateId: getTemplateIdByFormatId(state.currentFormatId),
229
+ params
230
+ };
231
+ printInstance.preview(
232
+ queryParams,
233
+ (res: any) => {
234
+ callLocalServicesSuccessCb(res, 'preview');
235
+ },
236
+ callLocalServicesErrorCb
237
+ );
305
238
  })
306
239
  .finally(() => {
307
240
  state.visible = false;
@@ -314,19 +247,7 @@ const handleClickEdit = () => {
314
247
  return Promise.reject();
315
248
  })
316
249
  .then(() => {
317
- if (props.versionType == 1 || props.versionType == 3) {
318
- const params = props.strategy === 'MULTI' ? getHisParams() : getOnceHisParams();
319
- const printFn = props.versionType == 1 ? 'handleHisPrint' : 'handleOldHisPrint'
320
- printInstance[printFn](9, params)
321
- .then((res: any) => {
322
- console.log(res, 999999);
323
- })
324
- .catch((error: any) => {
325
- console.log(error, 'error999');
326
- });
327
- } else {
328
- state.identityVerification.visible = true;
329
- }
250
+ state.identityVerification.visible = true;
330
251
  })
331
252
  .finally(() => {
332
253
  state.visible = false;
@@ -383,12 +304,6 @@ const setOptions = () => {
383
304
  children
384
305
  })
385
306
  }
386
- const initHIS = (formatListResult: any) => {
387
- state.formatList = formatListResult ? formatListResult.list.filter((item: any) => item.printmark == 1) : [];
388
- setOptions();
389
- state.currentFormatId = getDefaultFormatId(state.formatList, 'printmark');
390
- state.templateParams = state.formatList[0];
391
- }
392
307
  const formatFormatList = (list: any[]): any => {
393
308
  let formatList: any[] = [];
394
309
 
@@ -459,7 +374,7 @@ const formatParams = ({ customizeDataset = [], param = [] }, params: any[] = [])
459
374
  }
460
375
  const initCRM = async (formatListResult: any) => {
461
376
  state.formatList = formatListResult ? formatFormatList(formatListResult.obj) : [];
462
- setOptions();
377
+ console.log('formatListResult', formatListResult)
463
378
  state.currentFormatId = getDefaultFormatId(state.formatList, 'defaultFlag');
464
379
 
465
380
  if (!state.currentFormatId) {
@@ -488,11 +403,7 @@ const init = async () => {
488
403
 
489
404
  instantiatePrintSDK();
490
405
  const formatListResult = await props.queryPrintFormatByNumber()
491
- if (props.versionType == 1 || props.versionType == 3) {
492
- initHIS(formatListResult);
493
- } else {
494
- await initCRM(formatListResult);
495
- }
406
+ await initCRM(formatListResult);
496
407
 
497
408
  setLoaded();
498
409
 
@@ -0,0 +1,11 @@
1
+ import type { App } from "vue";
2
+ // 导入组件
3
+ import SelectPerson from './src/SelectPerson.vue'
4
+
5
+ // 为组件提供 install 安装方法,供按需引入
6
+ SelectPerson.install = function(app: App) {
7
+ app.component(SelectPerson.name, SelectPerson);
8
+ };
9
+
10
+ // 默认导出组件
11
+ export default SelectPerson;