@jzt-packages/components 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.
Files changed (145) hide show
  1. package/package.json +68 -0
  2. package/src/JztBackTop/index.vue +255 -0
  3. package/src/JztButtonList/index.vue +88 -0
  4. package/src/JztChart/index.vue +95 -0
  5. package/src/JztCharts/index.vue +317 -0
  6. package/src/JztClassTabs/index.vue +156 -0
  7. package/src/JztDateSelect/dateSelect.vue +186 -0
  8. package/src/JztDateSelect/dateType.vue +54 -0
  9. package/src/JztDateSelect/index.ts +135 -0
  10. package/src/JztDateSelect/interface/index.ts +13 -0
  11. package/src/JztDialog/index.vue +249 -0
  12. package/src/JztEllipsisTooltip/index.vue +61 -0
  13. package/src/JztEmpty/index.vue +45 -0
  14. package/src/JztErrorPage/403.vue +30 -0
  15. package/src/JztErrorPage/404.vue +19 -0
  16. package/src/JztErrorPage/500.vue +18 -0
  17. package/src/JztErrorPage/assets/401.png +0 -0
  18. package/src/JztErrorPage/assets/403.png +0 -0
  19. package/src/JztErrorPage/assets/404.png +0 -0
  20. package/src/JztErrorPage/assets/500.png +0 -0
  21. package/src/JztErrorPage/index.scss +35 -0
  22. package/src/JztErrorPage/index.vue +35 -0
  23. package/src/JztFilePreview/components/pdfViewer.vue +221 -0
  24. package/src/JztFilePreview/hooks/useImageMethod.ts +256 -0
  25. package/src/JztFilePreview/index.scss +171 -0
  26. package/src/JztFilePreview/index.vue +68 -0
  27. package/src/JztFilePreview/interface/index.ts +18 -0
  28. package/src/JztFilePreview/previewFile.vue +371 -0
  29. package/src/JztFormGrid/README.md +520 -0
  30. package/src/JztFormGrid/components/formItem.vue +209 -0
  31. package/src/JztFormGrid/components/formItemValue.vue +384 -0
  32. package/src/JztFormGrid/components/showDetailForm.vue +172 -0
  33. package/src/JztFormGrid/index.scss +60 -0
  34. package/src/JztFormGrid/index.vue +513 -0
  35. package/src/JztFormGrid/interface/index.ts +106 -0
  36. package/src/JztGrid/components/GridItem.vue +68 -0
  37. package/src/JztGrid/index.vue +179 -0
  38. package/src/JztGrid/interface/index.ts +6 -0
  39. package/src/JztImportExcel/assets/delete.png +0 -0
  40. package/src/JztImportExcel/index.scss +46 -0
  41. package/src/JztImportExcel/index.vue +430 -0
  42. package/src/JztImportExcel/interface/index.ts +25 -0
  43. package/src/JztLabelTitle/index.vue +65 -0
  44. package/src/JztLeftRightMode/components/CollapseButton.vue +80 -0
  45. package/src/JztLeftRightMode/components/LeftCard.vue +203 -0
  46. package/src/JztLeftRightMode/components/LeftLayout.vue +173 -0
  47. package/src/JztLeftRightMode/components/RightHeader.vue +186 -0
  48. package/src/JztLeftRightMode/components/RightLayout.vue +235 -0
  49. package/src/JztLeftRightMode/components/RightTableHeader.vue +43 -0
  50. package/src/JztLeftRightMode/hooks/useCollapse.ts +17 -0
  51. package/src/JztLeftRightMode/hooks/useDefaultProps.ts +19 -0
  52. package/src/JztLeftRightMode/hooks/useLeftLayout.ts +201 -0
  53. package/src/JztLeftRightMode/hooks/useMode.ts +20 -0
  54. package/src/JztLeftRightMode/hooks/usePrevNext.ts +60 -0
  55. package/src/JztLeftRightMode/hooks/useRightLayout.ts +215 -0
  56. package/src/JztLeftRightMode/hooks/useSlots.ts +15 -0
  57. package/src/JztLeftRightMode/index.ts +3 -0
  58. package/src/JztLeftRightMode/index.vue +494 -0
  59. package/src/JztLeftRightMode/types/index.ts +457 -0
  60. package/src/JztLoading/fullScreen.ts +45 -0
  61. package/src/JztLoading/index.scss +67 -0
  62. package/src/JztLoading/index.vue +18 -0
  63. package/src/JztLogin/components/LoginFooter.vue +17 -0
  64. package/src/JztLogin/components/LoginForm.vue +99 -0
  65. package/src/JztLogin/hooks/useLogin.ts +186 -0
  66. package/src/JztLogin/index.scss +142 -0
  67. package/src/JztLogin/index.vue +31 -0
  68. package/src/JztLogin/interface/index.ts +47 -0
  69. package/src/JztNumericalRange/index.vue +81 -0
  70. package/src/JztPageCard/comm/datePicker.vue +151 -0
  71. package/src/JztPageCard/comm/details.vue +60 -0
  72. package/src/JztPageCard/comm/export.vue +24 -0
  73. package/src/JztPageCard/comm/tabs.vue +94 -0
  74. package/src/JztPageCard/comm/tooltip.vue +31 -0
  75. package/src/JztPageCard/index.vue +287 -0
  76. package/src/JztPagination/index.vue +70 -0
  77. package/src/JztProductInfo/components/imagePreview.vue +275 -0
  78. package/src/JztProductInfo/components/qxUnique.vue +101 -0
  79. package/src/JztProductInfo/components/records.vue +265 -0
  80. package/src/JztProductInfo/hooks/useParams.ts +143 -0
  81. package/src/JztProductInfo/hooks/useQxUnique.tsx +466 -0
  82. package/src/JztProductInfo/images/defaultProduct.png +0 -0
  83. package/src/JztProductInfo/index.ts +116 -0
  84. package/src/JztProductInfo/index.vue +108 -0
  85. package/src/JztProductInfo/interface/index.ts +15 -0
  86. package/src/JztQueryDetailTable/index.scss +100 -0
  87. package/src/JztQueryDetailTable/index.vue +400 -0
  88. package/src/JztQueryDetailTable/interface/index.ts +10 -0
  89. package/src/JztQueryTable/QueryTable /345/212/237/350/203/275.md" +1580 -0
  90. package/src/JztQueryTable/README.md +567 -0
  91. package/src/JztQueryTable/components/ColSetting.vue +67 -0
  92. package/src/JztQueryTable/components/ColumnsSetting.vue +404 -0
  93. package/src/JztQueryTable/components/ColumnsSetting1.vue +220 -0
  94. package/src/JztQueryTable/components/DeployToAccountLevelSetting.vue +351 -0
  95. package/src/JztQueryTable/components/Pagination.vue +54 -0
  96. package/src/JztQueryTable/components/TableColumn.vue +109 -0
  97. package/src/JztQueryTable/const.ts +1 -0
  98. package/src/JztQueryTable/hooks/useQueryTable.ts +194 -0
  99. package/src/JztQueryTable/hooks/useSelection.ts +47 -0
  100. package/src/JztQueryTable/hooks/useTableSetting.ts +197 -0
  101. package/src/JztQueryTable/hooks/useTemplate.ts +127 -0
  102. package/src/JztQueryTable/index.scss +91 -0
  103. package/src/JztQueryTable/index.vue +1445 -0
  104. package/src/JztQueryTable/interface/index.ts +185 -0
  105. package/src/JztRegionSelect/index.vue +134 -0
  106. package/src/JztSearchForm/components/SearchFormItem.vue +473 -0
  107. package/src/JztSearchForm/index.vue +530 -0
  108. package/src/JztSearchForm/interface/index.ts +100 -0
  109. package/src/JztSelectFilter/index.scss +63 -0
  110. package/src/JztSelectFilter/index.vue +110 -0
  111. package/src/JztSelectTable/index.vue +257 -0
  112. package/src/JztTable/index.scss +72 -0
  113. package/src/JztTable/index.vue +353 -0
  114. package/src/JztTable/interface/index.ts +1 -0
  115. package/src/JztTime/comm/agencySelect.vue +112 -0
  116. package/src/JztTime/comm/collapseRow.vue +132 -0
  117. package/src/JztTime/comm/dateSelect.vue +292 -0
  118. package/src/JztTime/comm/deptSelect.vue +193 -0
  119. package/src/JztTime/comm/typeSelect.vue +97 -0
  120. package/src/JztTime/index.ts +216 -0
  121. package/src/JztTime/index.vue +303 -0
  122. package/src/JztTime/interface/index.ts +23 -0
  123. package/src/JztTreeFilter/index.scss +44 -0
  124. package/src/JztTreeFilter/index.vue +177 -0
  125. package/src/JztUploadFile/interface/index.ts +21 -0
  126. package/src/JztUploadFile/multiple.scss +215 -0
  127. package/src/JztUploadFile/multiple.vue +318 -0
  128. package/src/JztUploadFile/single.scss +226 -0
  129. package/src/JztUploadFile/single.vue +274 -0
  130. package/src/JztUploadImg/Img.vue +294 -0
  131. package/src/JztUploadImg/Imgs.vue +411 -0
  132. package/src/JztUploadImg/index.scss +138 -0
  133. package/src/JztUploadImg/interface/index.ts +22 -0
  134. package/src/SelectIcon/index.scss +39 -0
  135. package/src/SelectIcon/index.vue +106 -0
  136. package/src/SvgIcon/index.vue +22 -0
  137. package/src/hooks/useAuthButtons.ts +58 -0
  138. package/src/hooks/useFormByUserType.ts +90 -0
  139. package/src/hooks/useTableEvents.ts +30 -0
  140. package/src/hooks/useUploadFileHook.ts +262 -0
  141. package/src/index.ts +91 -0
  142. package/src/typings/global.d.ts +101 -0
  143. package/src/utils/index.ts +107 -0
  144. package/src/utils/tree.ts +57 -0
  145. package/tsconfig.json +45 -0
@@ -0,0 +1,194 @@
1
+ import { ElMessage } from 'element-plus'
2
+ import { Table } from '../interface/index'
3
+ import { ref, toRefs, reactive, computed, nextTick } from 'vue'
4
+ /**
5
+ * @description table 页面操作方法封装
6
+ * @param {Function} api 获取表格数据 api 方法 (必传)
7
+ * @param {Object} initParam 获取数据初始化参数 (非必传,默认为{})
8
+ * @param {Boolean} isPageable 是否有分页 (非必传,默认为true)
9
+ * @param {Function} dataCallBack 对后台返回的数据进行处理的方法 (非必传)
10
+ * */
11
+
12
+ // 展开grid
13
+ const isShow = ref(true)
14
+ const isExpandAll = ref(false)
15
+ const toggleExpandAll = async (status?: boolean) => {
16
+ isShow.value = false
17
+ if (status) {
18
+ isExpandAll.value = true
19
+ } else {
20
+ isExpandAll.value = !isExpandAll.value
21
+ }
22
+ await nextTick()
23
+ isShow.value = true
24
+ }
25
+ export const useOperation = () => {
26
+ return {
27
+ isShow,
28
+ isExpandAll,
29
+ toggleExpandAll
30
+ }
31
+ }
32
+
33
+ export const useTable = (
34
+ validateSearchForm?: () => Promise<any>,
35
+ api?: (params: any) => Promise<any>,
36
+ initParam: object = {},
37
+ isPageable: boolean = true,
38
+ dataCallBack?: (data: any) => any,
39
+ requestError?: (error: any) => void,
40
+ searchFilter?: (data: any) => Record<string, any>,
41
+ tableLoaded?: (data: any) => void,
42
+ loading: any = false,
43
+ formatterForm?: (data: any) => Record<string, any>
44
+ ) => {
45
+ const state = reactive<Table.StateProps>({
46
+ // 表格数据
47
+ tableData: [],
48
+ // 分页数据
49
+ pageable: {
50
+ // 当前页数
51
+ pageIndex: 1,
52
+ // 每页显示条数
53
+ pageSize: 10,
54
+ // 总条数
55
+ total: 0
56
+ },
57
+ // 查询参数(只包括查询)
58
+ searchParam: {},
59
+ // 初始化默认的查询参数
60
+ searchInitParam: {},
61
+ initParams: {} //外部传递的固定参数
62
+ })
63
+ state.initParams = initParam
64
+
65
+ /**
66
+ * @description 分页查询参数(只包括分页和表格字段排序,其他排序方式可自行配置)
67
+ * */
68
+ const pageParam = computed({
69
+ get: () => {
70
+ return {
71
+ pageIndex: state.pageable.pageIndex - 1,
72
+ pageSize: state.pageable.pageSize
73
+ }
74
+ },
75
+ set: (newVal: any) => {
76
+ console.log('我是分页更新之后的值', newVal)
77
+ }
78
+ })
79
+
80
+ /**
81
+ * @description 获取表格数据
82
+ * @return void
83
+ * */
84
+ const getTableList = async () => {
85
+ await new Promise((resolve, reject) => {
86
+ nextTick(async () => {
87
+ if (!api) return
88
+ if (validateSearchForm) {
89
+ const valid = await validateSearchForm()
90
+ if (!valid) return ElMessage.error('请检查必填项!')
91
+ }
92
+ try {
93
+ loading.value = true
94
+ // 初始化为空数据,解决bug(未清空数据)
95
+ state.tableData = []
96
+ const form =
97
+ formatterForm &&
98
+ formatterForm({
99
+ ...state.searchInitParam,
100
+ ...state.initParams,
101
+ ...state.searchParam
102
+ })
103
+
104
+ let data = await api({
105
+ ...(searchFilter ? searchFilter(form) : form),
106
+ ...(isPageable ? pageParam.value : {})
107
+ })
108
+
109
+ dataCallBack && (data = dataCallBack(data))
110
+ if (!data) {
111
+ data = { list: [], totalCount: 0 }
112
+ }
113
+ if (Array.isArray(data)) {
114
+ state.tableData = data || []
115
+ } else {
116
+ state.tableData = data?.result || data?.list || []
117
+ }
118
+ // state.tableData = isPageable ? data.result : data.result || data
119
+ // 解构后台返回的分页数据 (如果有分页更新分页信息)
120
+ if (isPageable) {
121
+ state.pageable.total = data.totalCount
122
+ }
123
+ setTimeout(() => {
124
+ tableLoaded && tableLoaded(data)
125
+ })
126
+ resolve(data)
127
+ } catch (error) {
128
+ loading.value = false
129
+ requestError && requestError(error)
130
+ reject(error)
131
+ } finally {
132
+ setTimeout(() => {
133
+ loading.value = false
134
+ }, 100)
135
+ }
136
+ })
137
+ })
138
+ }
139
+
140
+ /**
141
+ * @description 表格数据查询
142
+ * @return void
143
+ * */
144
+ const search = async () => {
145
+ state.pageable.pageIndex = 1
146
+ await getTableList()
147
+ }
148
+
149
+ /**
150
+ * @description 表格数据重置
151
+ * @return void
152
+ * */
153
+ const reset = async () => {
154
+ state.pageable.pageIndex = 1
155
+ // 重置搜索表单的时,如果有默认搜索参数,则重置默认的搜索参数
156
+ state.searchParam = { ...state.searchInitParam }
157
+ await getTableList()
158
+ }
159
+
160
+ /**
161
+ * @description 每页条数改变
162
+ * @param {Number} val 当前条数
163
+ * @return void
164
+ * */
165
+ const handleSizeChange = async (val: number) => {
166
+ state.pageable.pageIndex = 1
167
+ state.pageable.pageSize = val
168
+ await getTableList()
169
+ }
170
+
171
+ /**
172
+ * @description 当前页改变
173
+ * @param {Number} val 当前页
174
+ * @return void
175
+ * */
176
+ const handleCurrentChange = async (val: number) => {
177
+ state.pageable.pageIndex = val
178
+ await getTableList()
179
+ }
180
+ // 更新默认传参, tab切换时可调用此方法
181
+ const changeInitParams = async params => {
182
+ state.initParams = params
183
+ }
184
+
185
+ return {
186
+ ...toRefs(state),
187
+ getTableList,
188
+ search,
189
+ reset,
190
+ handleSizeChange,
191
+ handleCurrentChange,
192
+ changeInitParams
193
+ }
194
+ }
@@ -0,0 +1,47 @@
1
+ import { ref, computed } from "vue";
2
+ /**
3
+ * @description 表格多选数据操作
4
+ * @param {String} rowKey 当表格可以多选时,所指定的 id
5
+ * */
6
+ export const useSelection = (rowKey: string = "id") => {
7
+ const isSelected = ref<boolean>(false);
8
+ const selectedList = ref<{ [key: string]: any }[]>([]);
9
+
10
+ // 当前选中的所有 ids 数组
11
+ // 修复: rowKey 对应的值可能是 string 或 number,返回类型改为联合类型
12
+ const selectedListIds = computed((): (string | number)[] => {
13
+ return selectedList.value.map((item) => item[rowKey])
14
+ });
15
+
16
+ /**
17
+ * @description 多选操作
18
+ * @param {Array} rowArr 当前选择的所有数据
19
+ * @return void
20
+ */
21
+ const selectionChange = (rowArr: { [key: string]: any }[]) => {
22
+ rowArr.length ? (isSelected.value = true) : (isSelected.value = false);
23
+ selectedList.value = rowArr;
24
+ // emit("selectionChange", {
25
+ // isSelected: isSelected.value,
26
+ // selectedList: selectedList.value,
27
+ // selectedListIds: selectedListIds.value,
28
+ // });
29
+ };
30
+
31
+ const headerDragend = (
32
+ newWidth: number,
33
+ oldWidth: number,
34
+ column: any,
35
+ event: MouseEvent
36
+ ): void => {
37
+ console.log(newWidth, oldWidth, column, event);
38
+ };
39
+
40
+ return {
41
+ isSelected,
42
+ selectedList,
43
+ selectedListIds,
44
+ selectionChange,
45
+ headerDragend,
46
+ };
47
+ };
@@ -0,0 +1,197 @@
1
+ import { deleteGridConfig, getGridConfig, saveGridConfig } from '@jzt-spd/utils/commonApi'
2
+ import { ElMessage } from 'element-plus'
3
+ import { sortBy } from 'lodash-es'
4
+ import { ref } from 'vue'
5
+ import { ColumnProps, GridParams } from '../interface'
6
+ /**
7
+ * @description table 页面操作方法封装
8
+ * @param {Function} api 获取表格数据 api 方法 (必传)
9
+ * @param {Object} initParam 获取数据初始化参数 (非必传,默认为{})
10
+ * @param {Boolean} isPageable 是否有分页 (非必传,默认为true)
11
+ * @param {Function} dataCallBack 对后台返回的数据进行处理的方法 (非必传)
12
+ *
13
+ * */
14
+ export const useSettingTable = () => {
15
+ const currentTableColumns = ref<ColumnProps[]>([]) // 当前表格列数据(接口返回的)
16
+ const getTableSetting = async (
17
+ gridParams,
18
+ tableColumns: ColumnProps[],
19
+ loadingFn: any,
20
+ backupColumns: ColumnProps[]
21
+ ): Promise<{
22
+ columns: ColumnProps[] // 表格列
23
+ pageSize: number
24
+ id: string
25
+ }> => {
26
+ // console.log('backupColumns---->', backupColumns)
27
+ loadingFn && loadingFn(true)
28
+ return new Promise(async (resolve, reject) => {
29
+ // const asyncColumns = ref<ColumnProps[]>(tableColumns)
30
+ try {
31
+ const { pageSize, list, id } = await getGridConfigFn(gridParams)
32
+ const endColumns = setTable({
33
+ gridColumns: list,
34
+ // columns: asyncColumns.value,
35
+ backupColumns
36
+ })
37
+ loadingFn && loadingFn(false)
38
+ currentTableColumns.value = list && list.length ? endColumns : []
39
+ resolve({
40
+ columns: endColumns,
41
+ pageSize: pageSize,
42
+ id: id
43
+ })
44
+ } catch (error) {
45
+ currentTableColumns.value = []
46
+ } finally {
47
+ setTimeout(() => {
48
+ loadingFn && loadingFn(false)
49
+ }, 800)
50
+ }
51
+ })
52
+ }
53
+ return {
54
+ getTableSetting,
55
+ setTableSetting,
56
+ removeGridConfig,
57
+ currentTableColumns
58
+ }
59
+ }
60
+
61
+ const getGridConfigFn = async (
62
+ gridParams: GridParams
63
+ ): Promise<{
64
+ list: ColumnProps[]
65
+ pageSize: number
66
+ id: string
67
+ }> => {
68
+ try {
69
+ if (!gridParams || !gridParams.url) return { list: [], pageSize: 10 }
70
+ const res = await getGridConfig(gridParams)
71
+
72
+ const list = JSON.parse(res.result.configValue) || []
73
+ return {
74
+ list: list,
75
+ pageSize: res.result?.pageSize,
76
+ id: res.result?.id
77
+ }
78
+ } catch (error) {
79
+ return {
80
+ list: [],
81
+ pageSize: 10,
82
+ id: ''
83
+ }
84
+ }
85
+ }
86
+
87
+ export const setTable = ({ gridColumns, backupColumns }) => {
88
+ const list = gridColumns
89
+ if (list && list.length) {
90
+ const list2 = [] as ColumnProps[]
91
+ backupColumns.forEach(item => {
92
+ const index = list.findIndex(i => (i.field || i.text || i.prop) === item.prop)
93
+ if (index !== -1) {
94
+ const width = (item.width || item.minWidth) as number
95
+ const asyncWidth = list[index]?.width || (list[index]?.minWidth as number)
96
+ const colWidth = asyncWidth || width
97
+ list2.push({
98
+ ...item,
99
+ label: list[index]?.text || list[index]?.label || '',
100
+ hidden: list[index]?.hidden ?? false,
101
+ isSetShow: list[index]?.hidden !== true,
102
+ width: '',
103
+ minWidth: colWidth > 80 ? colWidth : 80,
104
+ sortIndex: index
105
+ })
106
+ } else {
107
+ const width = (item.width || item.minWidth) as number
108
+ list2.push({
109
+ ...item,
110
+ isSetShow: true,
111
+ hidden: false,
112
+ width: '',
113
+ minWidth: width > 80 ? width : 80,
114
+ sortIndex: 999
115
+ })
116
+ }
117
+ })
118
+ let sortedList = sortBy(list2, ['sortIndex'])
119
+ return sortedList
120
+ // list.forEach(item => {
121
+ // const index = backupColumns.findIndex((column: any) => item.field === column.prop)
122
+ // const width = (item.width || item.minWidth) as number
123
+ // if (index !== -1) {
124
+ // list2.push({
125
+ // ...backupColumns[index],
126
+ // hidden: item.hidden,
127
+ // label: item.text || '',
128
+ // isSetShow: item.hidden !== true,
129
+ // width: '',
130
+ // minWidth: width > 80 ? width : 80
131
+ // })
132
+ // }
133
+ // })
134
+ // return list2
135
+ } else {
136
+ const endColumns = [] as ColumnProps[]
137
+ backupColumns?.forEach(item => {
138
+ // if (item.prop !== 'operation' || item.label !== '操作') {
139
+ const width = (item.width || item.minWidth) as number
140
+ endColumns.push({
141
+ ...item,
142
+ width: '',
143
+ isSetShow: item.hidden !== true,
144
+ minWidth: width > 80 ? width : 80
145
+ })
146
+ // }
147
+ })
148
+ return endColumns
149
+ }
150
+ }
151
+ interface SetTableSettingParams {
152
+ gridParams: GridParams
153
+ tableColumns: ColumnProps[]
154
+ pageSize: number
155
+ toast: boolean
156
+ }
157
+ const setTableSetting = async (params: SetTableSettingParams) => {
158
+ const { gridParams, tableColumns, pageSize, toast } = params
159
+ return new Promise(async (resolve, reject) => {
160
+ const list = [] as any[]
161
+ try {
162
+ tableColumns.forEach((item: any) => {
163
+ list.push({
164
+ columnId: item.prop,
165
+ field: item.prop,
166
+ // hidden: item.hidden,
167
+ hidden: !item.isSetShow,
168
+ width: item.width || item.minWidth || 60,
169
+ text: item.label
170
+ })
171
+ })
172
+ // console.log(list)
173
+ const res = await saveGridConfig({
174
+ configValue: JSON.stringify(list),
175
+ ...gridParams,
176
+ pageSize: pageSize
177
+ })
178
+ // console.log(res.result);
179
+ resolve({
180
+ id: res.result.id,
181
+ columns: list
182
+ })
183
+ if (toast) {
184
+ ElMessage.success('设置成功')
185
+ }
186
+ } catch (error) {
187
+ reject()
188
+ } finally {
189
+ }
190
+ })
191
+ }
192
+
193
+ const removeGridConfig = async (gridParams: GridParams, cancelFn) => {
194
+ const res = await deleteGridConfig(gridParams)
195
+ ElMessage.success('重置成功')
196
+ cancelFn && cancelFn()
197
+ }
@@ -0,0 +1,127 @@
1
+ import { localGetRolesIds } from '@jzt-spd/utils'
2
+ import { deleteGridConfigTemplate, getGridConfigTemplateList, pushGridConfigTemplate } from '@jzt-spd/utils/commonApi'
3
+ import { reactivePick } from '@vueuse/core'
4
+ import { ElMessage, ElMessageBox } from 'element-plus'
5
+ import * as _ from 'lodash-es'
6
+ import { computed, ref, type Ref } from 'vue'
7
+ import type { ColumnProps, GridParams } from '../interface'
8
+ import { setTable } from './useTableSetting'
9
+
10
+ export function useTemplate(
11
+ gridParams: () => GridParams,
12
+ setPageSize: () => number,
13
+ dragListColumn: Ref<ColumnProps[]>,
14
+ originalColumn: Ref<ColumnProps[]>,
15
+ processColumns: (columns: any) => Promise<any>,
16
+ onValidIsAllHidden: () => boolean
17
+ ) {
18
+ const loading = ref(false)
19
+ const deployVisible = ref(false)
20
+ const deployMode = ref<'add' | 'edit' | 'view'>('add')
21
+ const isAdmin = computed(() => localGetRolesIds()?.split(',').includes('3a02558d-8b3f-0128-d1ae-092fc6620210'))
22
+ const configValue = computed(() => {
23
+ return dragListColumn.value.map((item: any) => {
24
+ return {
25
+ columnId: item.prop,
26
+ field: item.prop,
27
+ hidden: !item.isSetShow,
28
+ width: item.width || item.minWidth || 60,
29
+ text: item.label
30
+ }
31
+ })
32
+ })
33
+
34
+ const gridTemplateList = ref<any[]>([])
35
+ const formData = ref<any>({ configName: '', templateId: null })
36
+
37
+ const onOpenDeployDialog = (mode: 'add' | 'edit' | 'view') => {
38
+ if (!onValidIsAllHidden()) return
39
+ if (mode === 'add' && gridTemplateList.value.length === 50) {
40
+ ElMessage.error('已达上限50个,无法继续添加')
41
+ return
42
+ }
43
+ if (mode === 'add') {
44
+ formData.value.configName = ''
45
+ }
46
+ deployMode.value = mode
47
+ deployVisible.value = true
48
+ }
49
+
50
+ const onRemoveTemplate = async () => {
51
+ loading.value = true
52
+ try {
53
+ await ElMessageBox.confirm('确认删除该角色列配置?删除后角色列配置不会重置,即保持现状!', '提示', {
54
+ confirmButtonText: '确定',
55
+ cancelButtonText: '取消',
56
+ type: 'warning'
57
+ })
58
+ const { message } = await deleteGridConfigTemplate({ templateId: formData.value.templateId })
59
+ ElMessage.success(message)
60
+ await onQueryTemplate()
61
+ } finally {
62
+ loading.value = false
63
+ }
64
+ }
65
+
66
+ const onSaveTemplate = async () => {
67
+ loading.value = true
68
+ try {
69
+ await ElMessageBox.confirm('列配置保存并下发后,会对配置下的账号实时生效!', '提示', {
70
+ confirmButtonText: '确定',
71
+ cancelButtonText: '取消',
72
+ type: 'warning'
73
+ })
74
+ const { message } = await pushGridConfigTemplate({
75
+ pageSize: setPageSize(),
76
+ configValue: JSON.stringify(configValue.value),
77
+ ...gridParams(),
78
+ ...reactivePick(formData.value, ['templateId', 'concurrencyStamp'])
79
+ })
80
+ ElMessage.success(message)
81
+ await onQueryTemplate(formData.value.templateId)
82
+ } finally {
83
+ loading.value = false
84
+ }
85
+ }
86
+
87
+ const onQueryTemplate = async (templateId: string = '0') => {
88
+ if (!isAdmin.value) {
89
+ return
90
+ }
91
+ try {
92
+ loading.value = true
93
+ const { result } = await getGridConfigTemplateList(gridParams())
94
+ gridTemplateList.value = [{ id: '0', configName: '当前账号列配置' }, ...result]
95
+ onChangeTemplate(templateId)
96
+ } finally {
97
+ loading.value = false
98
+ }
99
+ }
100
+
101
+ const onChangeTemplate = async (templateId: string) => {
102
+ const template = gridTemplateList.value.find(item => item.id === templateId) || {}
103
+ formData.value = { ...template, templateId }
104
+ if (templateId === '0') {
105
+ dragListColumn.value = _.cloneDeep(originalColumn.value)
106
+ } else {
107
+ dragListColumn.value = setTable({
108
+ gridColumns: JSON.parse(template.configValue ?? '[]'),
109
+ backupColumns: originalColumn.value
110
+ })
111
+ }
112
+ }
113
+
114
+ return {
115
+ loading,
116
+ deployVisible,
117
+ deployMode,
118
+ isAdmin,
119
+ formData,
120
+ gridTemplateList,
121
+ onOpenDeployDialog,
122
+ onRemoveTemplate,
123
+ onSaveTemplate,
124
+ onQueryTemplate,
125
+ onChangeTemplate
126
+ }
127
+ }
@@ -0,0 +1,91 @@
1
+ .el-popover {
2
+ min-width: 200px;
3
+ max-width: 300px;
4
+ }
5
+ .fullscreen-page {
6
+ position: absolute;
7
+ top: 0;
8
+ left: 0;
9
+ width: 100vw;
10
+ height: 100vh;
11
+ z-index: 99;
12
+ }
13
+
14
+ /* queryTable */
15
+ .table-main {
16
+ display: flex;
17
+ flex: 1;
18
+ flex-direction: column;
19
+ width: 100%;
20
+ height: 100%;
21
+ padding: 8px;
22
+
23
+ // 表格 header 样式
24
+ .table-header {
25
+ .header-button-lf,
26
+ .header-button-ri {
27
+ display: flex;
28
+ flex-wrap: wrap;
29
+ // gap: 15px 12px;
30
+ gap: 5px 2px;
31
+ // margin-bottom: 2px;
32
+ text-align: right;
33
+ // margin-top: 4px;
34
+ .el-button:not(.el-input .el-button) {
35
+ margin-left: 0;
36
+ }
37
+ }
38
+ .header-button-ri {
39
+ justify-content: flex-end;
40
+ align-items: center;
41
+ padding: 2px 0;
42
+ :deep(.el-button) {
43
+ margin-left: 4px !important;
44
+ }
45
+ }
46
+ :deep(.tool_btn.el-button) {
47
+ width: var(--el-component-size);
48
+ // height: 32px;
49
+ .el-icon,
50
+ .iconfont {
51
+ font-size: 16px;
52
+ }
53
+ }
54
+ }
55
+
56
+ // .el-table {
57
+ // // flex: 1;
58
+ // margin-top: 4px;
59
+ // .el-scrollbar {
60
+ // min-height: 150px;
61
+ // }
62
+ // }
63
+
64
+ // .el-tabs .el-tabs__header.is-top {
65
+ // margin-bottom: 2px !important;
66
+ // }
67
+ }
68
+
69
+ // .el-dialog {
70
+ // .table-search {
71
+ // padding-top: 0;
72
+ // margin-bottom: 0;
73
+ // }
74
+ // .spd-card {
75
+ // border: none !important;
76
+ // box-shadow: none !important;
77
+ // padding: 0 10px;
78
+ // }
79
+ // }
80
+
81
+ .el-form-item--default {
82
+ .el-form-item__label {
83
+ height: 30px !important;
84
+ line-height: 30px !important;
85
+ }
86
+ }
87
+
88
+ .el-form-item--default .el-form-item__content {
89
+ height: 30px !important;
90
+ line-height: 30px !important;
91
+ }