cnhis-design-vue 3.0.1 → 3.0.2

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.
Files changed (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/es/big-table/index.css +1 -6
  3. package/es/big-table/index.js +5603 -36408
  4. package/es/button-print/index.css +17 -22
  5. package/es/button-print/index.js +4920 -18073
  6. package/es/drag-layout/index.css +17 -22
  7. package/es/drag-layout/index.js +75 -5733
  8. package/es/grid/index.css +58 -64
  9. package/es/grid/index.js +3 -30623
  10. package/es/index.css +1 -6
  11. package/es/index.js +267 -37863
  12. package/package.json +2 -6
  13. package/packages/big-table/src/BigTable.vue +30 -45
  14. package/packages/big-table/src/bigTableEmits.ts +2 -1
  15. package/packages/big-table/src/components/edit-form/edit-input.vue +27 -7
  16. package/packages/big-table/src/components/edit-form/edit-select.vue +1 -1
  17. package/packages/big-table/src/hooks/useBatchEditing.ts +123 -123
  18. package/packages/big-table/src/hooks/useEdit.ts +42 -23
  19. package/packages/button-print/src/ButtonPrint.vue +11 -144
  20. package/packages/button-print/src/components/IdentityVerification.vue +14 -43
  21. package/packages/grid/index.ts +3 -2
  22. package/packages/grid/src/Grid.tsx +4 -3
  23. package/packages/index.ts +5 -6
  24. package/packages/big-table/src/components/edit-form3/EditForm.vue +0 -426
  25. package/packages/big-table/src/components/edit-form3/edit-component/edit-date-picker/edit-date-picker.vue +0 -66
  26. package/packages/big-table/src/components/edit-form3/edit-component/edit-digital/edit-digital.vue +0 -60
  27. package/packages/big-table/src/components/edit-form3/edit-component/edit-input/edit-input.vue +0 -38
  28. package/packages/big-table/src/components/edit-form3/edit-component/edit-input-password/edit-input-password.vue +0 -89
  29. package/packages/big-table/src/components/edit-form3/edit-component/edit-month-picker/edit-month-picker.vue +0 -38
  30. package/packages/big-table/src/components/edit-form3/edit-component/edit-search/edit-search.vue +0 -63
  31. package/packages/big-table/src/components/edit-form3/edit-component/edit-search-more/edit-search-more.vue +0 -69
  32. package/packages/big-table/src/components/edit-form3/edit-component/edit-select/edit-select.vue +0 -51
  33. package/packages/big-table/src/components/edit-form3/edit-component/edit-select-multiple/edit-select-multiple.vue +0 -60
  34. package/packages/big-table/src/components/edit-form3/edit-component/edit-textarea/edit-textarea.vue +0 -34
  35. package/packages/big-table/src/components/edit-form3/edit-component/edit-time-picker/edit-time-picker.vue +0 -42
  36. package/packages/big-table/src/components/edit-form3/edit-component/editFormProps.ts +0 -91
  37. package/packages/big-table/src/components/edit-form3/edit-component/register-com.ts +0 -18
  38. package/packages/big-table/src/components/edit-form3/hooks/useConfigData.ts +0 -79
  39. package/packages/big-table/src/components/edit-form3/hooks/useDateType.ts +0 -184
  40. package/packages/big-table/src/components/edit-form3/hooks/useFormCommon.ts +0 -373
  41. package/packages/big-table/src/components/edit-form3/hooks/useItemDefault.ts +0 -638
  42. package/packages/big-table/src/components/edit-form3/hooks/useSearch.ts +0 -910
  43. package/packages/big-table/src/components/edit-form3/hooks/useValidateRules.ts +0 -387
  44. package/packages/big-table/src/components/edit-form3/interface.ts +0 -53
  45. package/packages/big-table/src/components/edit-form3/types.ts +0 -3
  46. package/packages/big-table/src/components/edit-form3/utils.ts +0 -247
  47. package/packages/big-table/src/components/svg/index.vue +0 -49
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cnhis-design-vue",
3
3
  "private": false,
4
- "version": "3.0.1",
4
+ "version": "3.0.2",
5
5
  "main": "es/index.js",
6
6
  "module": "es/index.js",
7
7
  "scripts": {
@@ -15,17 +15,13 @@
15
15
  },
16
16
  "peerDependencies": {
17
17
  "@vicons/ionicons5": "^0.12.0",
18
- "axios": "^0.26.1",
19
- "naive-ui": "^2.28.1",
20
- "qs": "^6.10.3"
18
+ "naive-ui": "^2.28.1"
21
19
  },
22
20
  "dependencies": {
23
21
  "@vicons/ionicons5": "^0.12.0",
24
- "axios": "^0.26.1",
25
22
  "crypto-js": "^4.1.1",
26
23
  "moment": "^2.29.1",
27
24
  "naive-ui": "^2.28.1",
28
- "qs": "^6.10.3",
29
25
  "vue": "^3.2.25",
30
26
  "vue-router": "^4.0.13",
31
27
  "vuedraggable": "^4.1.0",
@@ -175,8 +175,7 @@ import { useEdit } 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
- // import SvgIcon from '@/component/svg/index.vue';
179
- import SvgIcon from './components/svg/index.vue'
178
+ import SvgIcon from '@/component/svg/index.vue';
180
179
  import EditSelectTable from './components/edit-form/edit-select-table.vue'
181
180
  import EditInput from './components/edit-form/edit-input.vue'
182
181
  import EditSelect from './components/edit-form/edit-select.vue'
@@ -272,7 +271,7 @@ const {
272
271
  recordClickBtnInfo,
273
272
  getInlineOpreateRow
274
273
  }: any = useBatchEditing(props, state, emit, xGrid);
275
- const { initEditTable, activeMethod, deleteRow, onClickSelectTable } = useEdit(props, state, emit, xGrid)
274
+ const { initEditTable, activeMethod, deleteRow, onClickSelectTable, onUpdateInput, getDefaultValue } = useEdit(props, state, emit, xGrid)
276
275
 
277
276
  const {
278
277
  isAboutNestTable,
@@ -378,8 +377,7 @@ const unBindDocumentClick = () => {
378
377
  }
379
378
  onMounted(() => {
380
379
  bindDocumentClick();
381
- // state.tableHeight = handleTableHeight(state, props);
382
- state.tableHeight = '520px'
380
+ state.tableHeight = handleTableHeight(state, props);
383
381
 
384
382
  // // 子列表在mounted后初始化 直接watch无法触发
385
383
  if (!props.isNestTable) return;
@@ -456,7 +454,7 @@ const loadData = async (data: any) => {
456
454
  // 还是用loadData较好,树表展开需要在更新数据后保留上一次的状态
457
455
  // table.clearSort(); // <-- table.loadData 不会清空sort选项,导致sortChange重复触发
458
456
  await table.loadData(formatList);
459
- initEditTable()
457
+ // initEditTable()
460
458
 
461
459
 
462
460
  table.setCurrentRow({});
@@ -520,9 +518,9 @@ const formatColumns = (map: any) => {
520
518
  let { isBatchSelect, fieldList = [], showButtonTop, isScanMultiTable, isEdit = false, editConfig = {} } = map;
521
519
  if (isEdit) {
522
520
  state.editConfig = Object.assign(state.editConfig, editConfig, {
523
- mode: 'cell',
524
- autoClear: true,
525
- activeMethod
521
+ // mode: 'cell',
522
+ // autoClear: true,
523
+ // activeMethod
526
524
  })
527
525
  }
528
526
  if (selectType) {
@@ -627,24 +625,6 @@ const formatColumns = (map: any) => {
627
625
  type = "";
628
626
  }
629
627
 
630
- const getDefaultValue = (params: any) => {
631
- const value = params.row[item.columnName]
632
- if (item.formType === 'select') {
633
- // console.log('rowrowrow', params.row, value, item)
634
- if (item.options) {
635
- return item.options.find((v: any) => v.value === value)?.label || ''
636
- }
637
- if (item.queryOptions) {
638
- return value
639
- // setTimeout(() => {
640
- // return (params.row[`${col.columnName}_options`]?.find((v: any) => v.value === value)?.label) || ''
641
- // }, 1500)
642
- }
643
- return value
644
- }
645
- return value
646
- }
647
-
648
628
  const col = Object.assign(item, {
649
629
  visible: item.columnName == "operatorColumn" ? showButtonTop == 0 : item.isShow == 1,
650
630
  field: item.columnName,
@@ -678,7 +658,7 @@ const formatColumns = (map: any) => {
678
658
  if(!isEdit || item.columnName === 'operatorColumn' || !item.isEdit) {
679
659
  return formatter(params, item)
680
660
  } else {
681
- return <span>{getDefaultValue(params)}</span>
661
+ return <span>{getDefaultValue(params, item)}</span>
682
662
  }
683
663
  }
684
664
  },
@@ -725,30 +705,34 @@ const formatColumns = (map: any) => {
725
705
  };
726
706
  const formatterEdit = (params: any, col: any) => {
727
707
  let { row, column, $rowIndex, rowIndex } = params
728
- let formType = column.formType || col.formType
729
- if (formType === 'selectTable') {
730
- const propsData = {
731
- row,
732
- col
733
- }
734
- return <EditSelectTable {...propsData} v-model={[row[col.columnName], 'value']} onClickSelectTable={onClickSelectTable} />
708
+ 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
+ // }
716
+ if (formType === 'custom') {
717
+ return col.slotFn(params)
718
+ }
719
+ const propsData = {
720
+ col,
721
+ row,
722
+ index: $rowIndex
735
723
  }
736
- if (formType === 'input') {
737
- return <EditInput v-model={[row[col.columnName], 'value']} />
724
+ if (formType === 'input' || formType === 'number') {
725
+ return <EditInput {...propsData} type={formType} v-model={[row[col.columnName], 'value']} onUpdateInput={onUpdateInput} />
738
726
  }
739
727
  if (formType === 'select') {
740
- const propsData = {
741
- col,
742
- row
743
- }
744
728
  return <EditSelect {...propsData} v-model={[row[col.columnName], 'value']} onSetOptions={(options: any[]) => row[`${col.columnName}_options`] = options} />
745
729
  }
746
730
  }
747
- const getEditBtn = (row: any, col: any) => {
731
+ const getEditBtn = (row: any, col: any, index: number) => {
748
732
  return col.tileBtnList.map((btn: any) => {
749
733
  if (btn.settingObj[0].trigger_type === 'DELETE') {
750
734
  return <NPopconfirm
751
- onPositiveClick={() => deleteRow(row)}
735
+ onPositiveClick={() => deleteRow(row, col, index)}
752
736
  >
753
737
  {{
754
738
  trigger: () => <NButton color={btn.settingObj[0].color || '#999'} text>{btn.name}</NButton>,
@@ -842,8 +826,9 @@ const formatter = (params: any, col: any) => {
842
826
  return getOrCode(row, own, attrType);
843
827
  }
844
828
  if (column.property === "operatorColumn") {
845
- if (props.columnConfig.isEdit && !row.initRow) {
846
- return getEditBtn(row, col)
829
+ // if (props.columnConfig.isEdit && !row.initRow) {
830
+ if (props.columnConfig.isEdit) {
831
+ return getEditBtn(row, col, $rowIndex)
847
832
  }
848
833
 
849
834
  if (state.showButtonTop != 0 || props.isBatchEditing) return;
@@ -41,7 +41,8 @@ const bigTableEmits: string[] = [
41
41
  "selectionChangeLocal",
42
42
  "switchBtnOnChange",
43
43
  "asyncTableChange",
44
- "clickSelectTable"
44
+ // "clickSelectTable"
45
+ "updateInput"
45
46
  ];
46
47
 
47
48
  export default bigTableEmits;
@@ -1,18 +1,38 @@
1
1
  <script lang="tsx">
2
- import { defineComponent, ref, reactive } from 'vue'
3
- import { NInput } from 'naive-ui'
2
+ import { defineComponent, ref, reactive, resolveComponent } from 'vue'
3
+ import { NInput, NInputNumber } from 'naive-ui'
4
4
 
5
5
  export default defineComponent({
6
6
  name: 'EditInput',
7
7
  inheritAttrs: false,
8
8
  components: {
9
- NInput
9
+ NInput,
10
+ NInputNumber
10
11
  },
12
+ props: {
13
+ type: {
14
+ type: String,
15
+ default: 'input'
16
+ },
17
+ col: {
18
+ type: Object,
19
+ default: () => ({})
20
+ },
21
+ row: {
22
+ type: Object,
23
+ default: () => ({})
24
+ },
25
+ index: {
26
+ type: [Number, Object],
27
+ default: 0
28
+ }
29
+ },
30
+ emits: ['updateInput'],
11
31
  setup (props, { attrs, slots, emit }) {
12
-
13
- return () => [
14
- <NInput {...attrs} />
15
- ]
32
+ const onUpdateValue = (value: number | string | null) => {
33
+ emit('updateInput', { value, row: props.row, column: props.col, index: props.index })
34
+ }
35
+ return () => props.type === 'input' ? <NInput {...attrs} onUpdateValue={onUpdateValue } /> : <NInputNumber {...attrs} onUpdateValue={onUpdateValue} />
16
36
  }
17
37
  })
18
38
  </script>
@@ -31,7 +31,7 @@ export default defineComponent({
31
31
  // 此处需要缓存第一次请求到的options,不需要每次都请求,
32
32
  // 此处的row参数应当是selectTable的row
33
33
  const optionsName = `${props.col.columnName}_options`
34
- state.options = props.row[optionsName] || await props.col.queryOptions(props.row.row)
34
+ state.options = props.row[optionsName] || await props.col.queryOptions()
35
35
  if (!props.row[optionsName]) {
36
36
  emit('setOptions', state.options)
37
37
  }
@@ -1,5 +1,5 @@
1
1
  import { computed, ref, reactive, watch, onMounted } from 'vue'
2
- import axios from 'axios'
2
+ // import axios from 'axios'
3
3
 
4
4
  export const useBatchEditing = (props: any, state: any, emit: any, xGrid: any) => {
5
5
 
@@ -67,15 +67,15 @@ export const useBatchEditing = (props: any, state: any, emit: any, xGrid: any) =
67
67
  /**
68
68
  * 校验提交
69
69
  */
70
- watch(
71
- () => props.batchEditDoneNumber,
72
- obj => {
73
- if (!obj || !Object.keys(obj).length || props.isNestTable) return;
74
- if (state.isTree != 0 || !props.isMatchComponent) return false;
75
- if (!checkOperateCurrentTable()) return false;
76
- submitBatchInlineForm(obj);
77
- }
78
- )
70
+ // watch(
71
+ // () => props.batchEditDoneNumber,
72
+ // obj => {
73
+ // if (!obj || !Object.keys(obj).length || props.isNestTable) return;
74
+ // if (state.isTree != 0 || !props.isMatchComponent) return false;
75
+ // if (!checkOperateCurrentTable()) return false;
76
+ // submitBatchInlineForm(obj);
77
+ // }
78
+ // )
79
79
 
80
80
  const checkOperateCurrentTable = () => {
81
81
  if (props.isNestTable) return false;
@@ -382,62 +382,62 @@ export const useBatchEditing = (props: any, state: any, emit: any, xGrid: any) =
382
382
  return arr;
383
383
  }
384
384
 
385
- const savaForm = (formId: any, params: any) => {
386
- let url = `/form/editRows/update/${formId}`;
387
- return axios({
388
- method: 'post',
389
- url,
390
- headers: { 'Content-Type': 'application/json; charset=utf-8' },
391
- data: params
392
- });
393
- }
385
+ // const savaForm = (formId: any, params: any) => {
386
+ // let url = `/form/editRows/update/${formId}`;
387
+ // return axios({
388
+ // method: 'post',
389
+ // url,
390
+ // headers: { 'Content-Type': 'application/json; charset=utf-8' },
391
+ // data: params
392
+ // });
393
+ // }
394
394
 
395
395
  /**
396
396
  * 批量提交form
397
397
  * @param {*} obj
398
398
  * @returns
399
399
  */
400
- const submitBatchInlineForm = (obj: any) => {
401
- if (props.batchError) {
402
- props.resetBatchEditRowStatus();
403
- emit('triggerSpinning', false);
404
- return;
405
- }
406
- let isBatchDoneAll = handleIsBatchDoneAll(obj);
407
- if (!isBatchDoneAll) {
408
- props.resetBatchEditRowStatus();
409
- emit('triggerSpinning', false);
410
- return;
411
- }
412
- let { formId } = props.listFormUnionSetting;
413
- let params = handleSubmitParams(props.batchFormData);
414
- if (!formId || !params) {
415
- props.resetBatchEditRowStatus();
416
- emit('triggerSpinning', false);
417
- return;
418
- }
419
- if (state.isSaveForm) return false;
420
- state.isSaveForm = true;
421
- savaForm(formId, params)
422
- .then(async ({ data }) => {
423
- emit('triggerSpinning', false);
424
- if (data.result !== 'SUCCESS') {
425
- state.isSaveForm = false;
426
- (window as any).$message.error(data.resultMsg);
427
- props.resetBatchEditRowStatus();
428
- return false;
429
- }
430
-
431
- await props.resetInlineBatchEdit();
432
- handleClickBatchCancelBtnByInline();
433
- emit('pubTableReload');
434
- })
435
- .finally(() => {
436
- state.isSaveForm = false;
437
- emit('triggerSpinning', false);
438
- props.resetBatchEditRowStatus();
439
- });
440
- }
400
+ // const submitBatchInlineForm = (obj: any) => {
401
+ // if (props.batchError) {
402
+ // props.resetBatchEditRowStatus();
403
+ // emit('triggerSpinning', false);
404
+ // return;
405
+ // }
406
+ // let isBatchDoneAll = handleIsBatchDoneAll(obj);
407
+ // if (!isBatchDoneAll) {
408
+ // props.resetBatchEditRowStatus();
409
+ // emit('triggerSpinning', false);
410
+ // return;
411
+ // }
412
+ // let { formId } = props.listFormUnionSetting;
413
+ // let params = handleSubmitParams(props.batchFormData);
414
+ // if (!formId || !params) {
415
+ // props.resetBatchEditRowStatus();
416
+ // emit('triggerSpinning', false);
417
+ // return;
418
+ // }
419
+ // if (state.isSaveForm) return false;
420
+ // state.isSaveForm = true;
421
+ // savaForm(formId, params)
422
+ // .then(async ({ data }) => {
423
+ // emit('triggerSpinning', false);
424
+ // if (data.result !== 'SUCCESS') {
425
+ // state.isSaveForm = false;
426
+ // (window as any).$message.error(data.resultMsg);
427
+ // props.resetBatchEditRowStatus();
428
+ // return false;
429
+ // }
430
+
431
+ // await props.resetInlineBatchEdit();
432
+ // handleClickBatchCancelBtnByInline();
433
+ // emit('pubTableReload');
434
+ // })
435
+ // .finally(() => {
436
+ // state.isSaveForm = false;
437
+ // emit('triggerSpinning', false);
438
+ // props.resetBatchEditRowStatus();
439
+ // });
440
+ // }
441
441
 
442
442
  const formatFieldItem = (fieldItem: any) => {
443
443
  return Object.assign({}, fieldItem, {
@@ -483,79 +483,79 @@ export const useBatchEditing = (props: any, state: any, emit: any, xGrid: any) =
483
483
  return fieldLength;
484
484
  }
485
485
 
486
- const handleRequestedUniqueKey = (id: any) => {
487
- return axios
488
- .get('tableList/getPrimaryKey', { params: { tableId: id } })
489
- .then(({ data }) => {
490
- let result;
491
- if (data.result == 'SUCCESS') {
492
- const { map = {} } = data;
493
- result = map.primaryKey || undefined;
494
- } else {
495
- result = undefined;
496
- }
497
- state.cacheUniqueKey[id] = { value: result, status: true };
498
- return result;
499
- })
500
- .catch(err => {
501
- console.log(err);
502
- state.cacheUniqueKey[id] = { value: undefined, status: true };
503
- return undefined;
504
- });
505
- }
486
+ // const handleRequestedUniqueKey = (id: any) => {
487
+ // return axios
488
+ // .get('tableList/getPrimaryKey', { params: { tableId: id } })
489
+ // .then(({ data }) => {
490
+ // let result;
491
+ // if (data.result == 'SUCCESS') {
492
+ // const { map = {} } = data;
493
+ // result = map.primaryKey || undefined;
494
+ // } else {
495
+ // result = undefined;
496
+ // }
497
+ // state.cacheUniqueKey[id] = { value: result, status: true };
498
+ // return result;
499
+ // })
500
+ // .catch(err => {
501
+ // console.log(err);
502
+ // state.cacheUniqueKey[id] = { value: undefined, status: true };
503
+ // return undefined;
504
+ // });
505
+ // }
506
506
 
507
507
  /**
508
508
  * 获取编辑的field
509
509
  */
510
- const handleFieldTheUniqueKey = () => {
511
- return new Promise<void>((resolve, reject) => {
512
- let { paramsList = [] } = props.listFormUnionSetting || {};
513
- let { fieldList = [] } = props.inlineEditFormConfig;
514
- fieldList = JSON.parse(JSON.stringify(fieldList));
515
- _batchFieldList = [];
516
- let batchFieldList = fieldList
517
- .map((item: any) => {
518
- let matchItem = paramsList.find((v: any) => item.val_key === v.tableField);
519
- if (matchItem) {
520
- let NOWORDBOOK = item.wordbook && (item?.wordbook?.type || '') != 'WORDBOOK';
521
- let id = item.wordbook?.id;
522
- if (NOWORDBOOK && id && !state.theUniqueKeyListObj[id]) {
523
- state.theUniqueKeyListObj[id] = id;
524
- }
525
- return item;
526
- }
527
- return null;
528
- })
529
- .filter(Boolean);
530
- if (!batchFieldList || !batchFieldList.length) return resolve();
531
- // 缓存行编辑需要的column配置
532
- state.editColumnMap = handleColumnMap(batchFieldList, paramsList);
533
- _batchFieldList = batchFieldList;
534
- _fieldLength = handleFieldLength();
535
- let keyList = Object.keys(state.theUniqueKeyListObj || {});
536
- if (!keyList.length) return resolve();
537
- keyList.forEach(async item => {
538
- await handleRequestedUniqueKey(item);
539
- });
540
- resolve();
541
- });
542
- }
510
+ // const handleFieldTheUniqueKey = () => {
511
+ // return new Promise<void>((resolve, reject) => {
512
+ // let { paramsList = [] } = props.listFormUnionSetting || {};
513
+ // let { fieldList = [] } = props.inlineEditFormConfig;
514
+ // fieldList = JSON.parse(JSON.stringify(fieldList));
515
+ // _batchFieldList = [];
516
+ // let batchFieldList = fieldList
517
+ // .map((item: any) => {
518
+ // let matchItem = paramsList.find((v: any) => item.val_key === v.tableField);
519
+ // if (matchItem) {
520
+ // let NOWORDBOOK = item.wordbook && (item?.wordbook?.type || '') != 'WORDBOOK';
521
+ // let id = item.wordbook?.id;
522
+ // if (NOWORDBOOK && id && !state.theUniqueKeyListObj[id]) {
523
+ // state.theUniqueKeyListObj[id] = id;
524
+ // }
525
+ // return item;
526
+ // }
527
+ // return null;
528
+ // })
529
+ // .filter(Boolean);
530
+ // if (!batchFieldList || !batchFieldList.length) return resolve();
531
+ // // 缓存行编辑需要的column配置
532
+ // state.editColumnMap = handleColumnMap(batchFieldList, paramsList);
533
+ // _batchFieldList = batchFieldList;
534
+ // _fieldLength = handleFieldLength();
535
+ // let keyList = Object.keys(state.theUniqueKeyListObj || {});
536
+ // if (!keyList.length) return resolve();
537
+ // keyList.forEach(async item => {
538
+ // await handleRequestedUniqueKey(item);
539
+ // });
540
+ // resolve();
541
+ // });
542
+ // }
543
543
 
544
544
  /**
545
545
  * 避免每次点击都查询
546
546
  * 初始化查一次 行编辑 表单search用
547
547
  */
548
548
  // 避免每次点击都查询
549
- const handleFormTheUniqueKey = async () => {
550
- emit('initInlineEditFormConfig', { listFormUnionSetting: props.listFormUnionSetting, inlineEditFormConfig: props.inlineEditFormConfig });
551
- let hasEditRow = props.btnList?.find((item: any) => {
552
- let trigger_type = item.settingObj && item.settingObj[0]?.trigger_type;
553
- if (item.isShow == 1 && trigger_type == 'EDIT_ROW') return true;
554
- return false;
555
- });
556
- if (!hasEditRow) return;
557
- await handleFieldTheUniqueKey();
558
- }
549
+ // const handleFormTheUniqueKey = async () => {
550
+ // emit('initInlineEditFormConfig', { listFormUnionSetting: props.listFormUnionSetting, inlineEditFormConfig: props.inlineEditFormConfig });
551
+ // let hasEditRow = props.btnList?.find((item: any) => {
552
+ // let trigger_type = item.settingObj && item.settingObj[0]?.trigger_type;
553
+ // if (item.isShow == 1 && trigger_type == 'EDIT_ROW') return true;
554
+ // return false;
555
+ // });
556
+ // if (!hasEditRow) return;
557
+ // await handleFieldTheUniqueKey();
558
+ // }
559
559
 
560
560
  return {
561
561
  allSelectedLength,
@@ -1,6 +1,7 @@
1
1
  import { computed, ref, reactive, watch, onMounted } from 'vue'
2
2
 
3
3
  export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
4
+
4
5
  const initEditTable = async () => {
5
6
  const { isEdit, fieldList = [] } = props.columnConfig
6
7
  if (!isEdit) return
@@ -17,29 +18,34 @@ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
17
18
  await xGrid.value.insertAt(record, -1)
18
19
  }
19
20
 
20
- const deleteRow = (row: any) => {
21
+ const deleteRow = (row: any, col: any, index: number) => {
21
22
  xGrid.value.remove(row)
23
+ emit('clickBtn', { row, column: col, index })
22
24
  }
23
25
 
24
26
  const activeMethod = ({ row, rowIndex, column, columnIndex }: { row: any, rowIndex: number, column: any, columnIndex: number }) => {
25
27
  const { isEdit, fieldList } = props.columnConfig
26
- // console.log('activeMethod->', row, column)
27
28
  if (isEdit) {
28
- const selectTableObj = fieldList.find((v: any) => v.formType === 'selectTable')
29
+ // const selectTableObj = fieldList.find((v: any) => v.formType === 'selectTable')
29
30
  const isEditCol = fieldList.find((v: any) => v.columnName === column.field)?.isEdit || false
30
- if (selectTableObj) {
31
- // const isOtherEditCol = Object.keys(row).some(v => v !== selectTableObj.columnName && v !== 'checked' && !!row[v])
32
- if (isEditCol && ((column.field === selectTableObj.columnName && !row[column.field]) || (column.field !== selectTableObj.columnName && !row.initRow))) {
33
- return true
34
- } else {
35
- return false
36
- }
31
+ // if (selectTableObj) {
32
+ // // const isOtherEditCol = Object.keys(row).some(v => v !== selectTableObj.columnName && v !== 'checked' && !!row[v])
33
+ // if (isEditCol && ((column.field === selectTableObj.columnName && !row[column.field]) || (column.field !== selectTableObj.columnName && !row.initRow))) {
34
+ // return true
35
+ // } else {
36
+ // return false
37
+ // }
38
+ // } else {
39
+ // if (isEditCol) {
40
+ // return true
41
+ // } else {
42
+ // return false
43
+ // }
44
+ // }
45
+ if (isEditCol) {
46
+ return true
37
47
  } else {
38
- if (isEditCol) {
39
- return true
40
- } else {
41
- return false
42
- }
48
+ return false
43
49
  }
44
50
  } else {
45
51
  return false
@@ -63,19 +69,32 @@ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
63
69
  const getInsertRecords = xGrid.value.getInsertRecords()
64
70
  const { row: newRow } = await xGrid.value.insertAt(record, getInsertRecords.at(-1))
65
71
  xGrid.value.clearActived()
66
- // xGrid.value.setActiveRow(newRow)
67
- // props.columnConfig.fieldList.forEach((col: any) => {
68
- // console.log('--------------2', col.columnName, col.columnName !== 'operatorColumn' && col.isShow && col.isEdit && col.formType !== 'selectTable')
69
- // if (col.columnName !== 'operatorColumn' && col.isShow && col.isEdit && col.formType !== 'selectTable') {
70
- // xGrid.value.setActiveRow(newRow)
71
- // }
72
- // })
72
+ }
73
+
74
+ const onUpdateInput = ({ value, row, column }: {value: number | string | null, row: any, column: any}) => {
75
+ emit('updateInput', { value, row, column })
76
+ }
77
+
78
+ const getDefaultValue = (params: any, item: any) => {
79
+ const value = params.row[item.columnName]
80
+ if (item.formType === 'select') {
81
+ if (item.options) {
82
+ return item.options.find((v: any) => v.value === value)?.label || ''
83
+ }
84
+ if (item.queryOptions) {
85
+ return (params.row[`${item.columnName}_options`]?.find((v: any) => v.value === value)?.label) || ''
86
+ }
87
+ return value
88
+ }
89
+ return value
73
90
  }
74
91
 
75
92
  return {
76
93
  initEditTable,
77
94
  activeMethod,
78
95
  deleteRow,
79
- onClickSelectTable
96
+ onClickSelectTable,
97
+ onUpdateInput,
98
+ getDefaultValue
80
99
  }
81
100
  }