cnhis-design-vue 0.3.8-beta → 0.3.9-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.
@@ -29,7 +29,7 @@ export default defineComponent({
29
29
  default: ''
30
30
  }
31
31
  },
32
- emits: ['update:value'],
32
+ emits: ['update:value', 'clickSelectTable'],
33
33
  setup (props, { attrs, slots, emit }) {
34
34
  const state = reactive({
35
35
  value: props.value,
@@ -62,11 +62,12 @@ export default defineComponent({
62
62
  state.loading = false
63
63
  }
64
64
  let selectTableSearch = (value: string) => {
65
- console.log('keyword', value)
66
65
  state.keyword = value
67
66
  querySelectTableList()
68
67
  }
69
68
  selectTableSearch = vexutils.debounce(selectTableSearch, 800)
69
+ // 初始化搜索
70
+ selectTableSearch('')
70
71
  const getSelectTableGrid = () => {
71
72
  const config = {
72
73
  border: 'outer',
@@ -86,7 +87,9 @@ export default defineComponent({
86
87
  }}</CGrid>
87
88
  }
88
89
  const onCellClick = (data: any) => {
89
- emit('update:value', data.row?.[props.col.columnName]);
90
+ const { row } = data
91
+ // emit('update:value', data.row?.[props.col.columnName])
92
+ emit('clickSelectTable', row)
90
93
  state.show = false
91
94
  }
92
95
  const getPagination = () => {
@@ -103,6 +106,7 @@ export default defineComponent({
103
106
  return () => [
104
107
  <NSelect
105
108
  class="form-select-table"
109
+ placeholder='请选择'
106
110
  options={[]}
107
111
  consistentMenuWidth={false}
108
112
  clearable
@@ -11,14 +11,35 @@ export default defineComponent({
11
11
  props: {
12
12
  col: {
13
13
  type: Object,
14
- default: {}
14
+ default: () => {}
15
+ },
16
+ row: {
17
+ type: Object,
18
+ default: () => {}
15
19
  }
16
20
  },
21
+ emits: ['setOptions'],
17
22
  setup (props, { attrs, slots, emit }) {
23
+
18
24
  const state = reactive({
19
- options: JSON.parse(JSON.stringify(props.col.options || []))
25
+ options: [] as any
20
26
  })
21
-
27
+ const setOptions = async () => {
28
+ if (props.col.options) {
29
+ state.options = JSON.parse(JSON.stringify(props.col.options))
30
+ } else {
31
+ // 此处需要缓存第一次请求到的options,不需要每次都请求,
32
+ // 此处的row参数应当是selectTable的row
33
+ const optionsName = `${props.col.columnName}_options`
34
+ state.options = props.row[optionsName] || await props.col.queryOptions(props.row.row)
35
+ if (!props.row[optionsName]) {
36
+ emit('setOptions', state.options)
37
+ }
38
+ }
39
+ }
40
+
41
+ setOptions()
42
+
22
43
  return () => [
23
44
  <NSelect
24
45
  {...attrs}
@@ -0,0 +1,73 @@
1
+ import { computed, ref, reactive, watch, onMounted } from 'vue'
2
+
3
+ export const useEdit = (props: any, state: any, emit: any, xGrid: any) => {
4
+ const initEditTable = async () => {
5
+ const { isEdit, fieldList } = props.columnConfig
6
+ if (!isEdit) return
7
+ const hasSelectTable = fieldList.find((v: any) => v.formType === 'selectTable')
8
+ if (!hasSelectTable) return
9
+ const record: any = {
10
+ initRow: true
11
+ }
12
+ props.columnConfig.fieldList.forEach((col: any) => {
13
+ if (col.columnName !== 'operatorColumn') {
14
+ record[col.columnName] = undefined
15
+ }
16
+ })
17
+ await xGrid.value.insertAt(record, -1)
18
+ }
19
+
20
+ const deleteRow = (row: any) => {
21
+ xGrid.value.remove(row)
22
+ }
23
+
24
+ const activeMethod = ({ row, rowIndex, column, columnIndex }: { row: any, rowIndex: number, column: any, columnIndex: number }) => {
25
+ const { isEdit, fieldList } = props.columnConfig
26
+ // console.log('activeMethod->', row, column)
27
+ if (isEdit) {
28
+ const selectTableObj = fieldList.find((v: any) => v.formType === 'selectTable')
29
+ 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
+ }
37
+ } else {
38
+ if (isEditCol) {
39
+ return true
40
+ } else {
41
+ return false
42
+ }
43
+ }
44
+ } else {
45
+ return false
46
+ }
47
+ }
48
+
49
+ const onClickSelectTable = async (row: any) => {
50
+ const record: any = {
51
+ initRow: false,
52
+ row: JSON.parse(JSON.stringify(row))
53
+ }
54
+ props.columnConfig.fieldList.forEach((col: any) => {
55
+ if (col.columnName !== 'operatorColumn') {
56
+ record[col.columnName] = undefined
57
+ if (Object.keys(row).includes(col.columnName)) {
58
+ record[col.columnName] = row[col.columnName]
59
+ }
60
+ }
61
+ })
62
+ const getInsertRecords = xGrid.value.getInsertRecords()
63
+ await xGrid.value.insertAt(record, getInsertRecords.at(-1))
64
+ xGrid.value.clearActived()
65
+ }
66
+
67
+ return {
68
+ initEditTable,
69
+ activeMethod,
70
+ deleteRow,
71
+ onClickSelectTable
72
+ }
73
+ }
@@ -90,8 +90,8 @@ export const useTableParse = (formatData: Function) => {
90
90
  return "";
91
91
  }
92
92
 
93
- const { mergedFeildExpression } = field.settingObj;
94
- if (mergedFeildExpression) {
93
+ if (field.settingObj?.mergedFeildExpression) {
94
+ const { mergedFeildExpression } = field.settingObj
95
95
  const passList: any = [];
96
96
 
97
97
  // 合并字段
@@ -2,14 +2,14 @@ import type { App } from "vue";
2
2
  // 导入组件
3
3
  import ButtonPrint from "./src/ButtonPrint.vue"
4
4
 
5
- type SFCWithInstall<T> = T & { install(app: App): void }; // vue 安装
5
+ // type SFCWithInstall<T> = T & { install(app: App): void }; // vue 安装
6
6
 
7
7
  // 为组件提供 install 安装方法,供按需引入
8
8
  ButtonPrint.install = function(app: App) {
9
9
  app.component(ButtonPrint.name, ButtonPrint);
10
10
  };
11
11
 
12
- const CButtonPrint: SFCWithInstall<typeof ButtonPrint> = ButtonPrint; // 增加类型
12
+ // const CButtonPrint: SFCWithInstall<typeof ButtonPrint> = ButtonPrint; // 增加类型
13
13
 
14
14
  // 默认导出组件
15
- export default CButtonPrint;
15
+ export default ButtonPrint;
@@ -2,14 +2,14 @@ import type { App } from "vue";
2
2
  // 导入组件
3
3
  import DragLayout from "./src/DragLayout.vue"
4
4
 
5
- type SFCWithInstall<T> = T & { install(app: App): void }; // vue 安装
5
+ // type SFCWithInstall<T> = T & { install(app: App): void }; // vue 安装
6
6
 
7
7
  // 为组件提供 install 安装方法,供按需引入
8
8
  DragLayout.install = function(app: App) {
9
9
  app.component(DragLayout.name, DragLayout);
10
10
  };
11
11
 
12
- const CDragLayout: SFCWithInstall<typeof DragLayout> = DragLayout; // 增加类型
12
+ // const CDragLayout: SFCWithInstall<typeof DragLayout> = DragLayout; // 增加类型
13
13
 
14
14
  // 默认导出组件
15
- export default CDragLayout;
15
+ export default DragLayout;
@@ -3,7 +3,7 @@ import type { App } from "vue";
3
3
  // 导入组件
4
4
  import Grid, { VXETable } from "./src/Grid"
5
5
 
6
- type SFCWithInstall<T> = T & { install(app: App): void }; // vue 安装
6
+ // type SFCWithInstall<T> = T & { install(app: App): void }; // vue 安装
7
7
 
8
8
  // 为组件提供 install 安装方法,供按需引入
9
9
  Grid.install = function(app: App) {
@@ -11,7 +11,7 @@ Grid.install = function(app: App) {
11
11
  app.use(VXETable);
12
12
  };
13
13
 
14
- const CGrid: SFCWithInstall<typeof Grid> = Grid; // 增加类型
14
+ // const CGrid: SFCWithInstall<typeof Grid> = Grid; // 增加类型
15
15
 
16
16
  // 默认导出组件
17
- export default CGrid;
17
+ export default Grid;