sun-biz 0.0.2-beta.5 → 0.0.2-beta.6

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.
@@ -261,7 +261,7 @@ function useTableConfigColumn(changeInputSort, length) {
261
261
  prop: 'displayFlag',
262
262
  minWidth: 170,
263
263
  editable: true,
264
- render: (row)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)('el-checkbox', {
264
+ render: (row)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)(__WEBPACK_EXTERNAL_MODULE_element_sun__.ElCheckbox, {
265
265
  class: 'w-full justify-center',
266
266
  'true-label': 1,
267
267
  'false-label': 0,
@@ -274,7 +274,7 @@ function useTableConfigColumn(changeInputSort, length) {
274
274
  label: '列宽 (最小值)',
275
275
  prop: 'minWidth',
276
276
  minWidth: 170,
277
- render: (row)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)('el-input-number', {
277
+ render: (row)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)(__WEBPACK_EXTERNAL_MODULE_element_sun__.ElInputNumber, {
278
278
  maxLength: 16,
279
279
  'controls-position': 'right',
280
280
  modelValue: row.minWidth,
@@ -287,7 +287,7 @@ function useTableConfigColumn(changeInputSort, length) {
287
287
  label: '排序',
288
288
  prop: 'sort',
289
289
  minWidth: 170,
290
- render: (row, index)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)('el-input-number', {
290
+ render: (row, index)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)(__WEBPACK_EXTERNAL_MODULE_element_sun__.ElInputNumber, {
291
291
  max: length,
292
292
  min: 0,
293
293
  'controls-position': 'right',
@@ -641,7 +641,7 @@ const _hoisted_3 = {
641
641
  sort: index + 1,
642
642
  columnClass: 'truncate',
643
643
  render: (row, index)=>{
644
- if (item.render) return (0, __WEBPACK_EXTERNAL_MODULE_vue__.h)('el-button', {
644
+ if (item.render) return (0, __WEBPACK_EXTERNAL_MODULE_vue__.h)(__WEBPACK_EXTERNAL_MODULE_element_sun__.ElButton, {
645
645
  type: 'text',
646
646
  class: 'pointer-events-none h-5',
647
647
  disabled: true
@@ -953,7 +953,7 @@ const _hoisted_3 = {
953
953
  const dbgrid_component_setting_exports_ = /*#__PURE__*/ (0, exportHelper["default"])(dbgrid_component_settingvue_type_script_setup_true_lang_tsx, [
954
954
  [
955
955
  '__scopeId',
956
- "data-v-6b73f6ca"
956
+ "data-v-5ff76b6b"
957
957
  ]
958
958
  ]);
959
959
  /* ESM default export */ const dbgrid_component_setting = dbgrid_component_setting_exports_;
@@ -1058,7 +1058,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1058
1058
  default: void 0
1059
1059
  },
1060
1060
  componentNo: {
1061
- default: ''
1061
+ default: ""
1062
1062
  },
1063
1063
  fetchData: {
1064
1064
  type: Function,
@@ -1073,7 +1073,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1073
1073
  default: false
1074
1074
  },
1075
1075
  rowKey: {
1076
- default: 'id'
1076
+ default: "id"
1077
1077
  },
1078
1078
  loading: {
1079
1079
  type: Boolean,
@@ -1114,11 +1114,11 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1114
1114
  });
1115
1115
  const serveColumn = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)([]);
1116
1116
  const columnTypes = [
1117
- 'selection',
1118
- 'radio',
1119
- 'index',
1120
- 'expand',
1121
- 'sort'
1117
+ "selection",
1118
+ "radio",
1119
+ "index",
1120
+ "expand",
1121
+ "sort"
1122
1122
  ];
1123
1123
  const dbgridComponentSettingRef = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)();
1124
1124
  const formRef = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)();
@@ -1126,23 +1126,75 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1126
1126
  const uuid = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)((0, __WEBPACK_EXTERNAL_MODULE_vue__.useId)());
1127
1127
  // 定义 emit 事件
1128
1128
  const emit = __emit;
1129
+ const attrs = (0, __WEBPACK_EXTERNAL_MODULE_vue__.useAttrs)();
1130
+ /**
1131
+ *获取参与排序的列表 索引 是否可以拖拽
1132
+ */ function getDragSortData(newIndex, data, startIndexObj, sortData) {
1133
+ data.forEach((item, index)=>{
1134
+ startIndexObj.startIndex += 1;
1135
+ if (startIndexObj.startIndex > newIndex) return;
1136
+ if (startIndexObj.startIndex === newIndex) {
1137
+ sortData.curIndex = index;
1138
+ sortData.curData = item;
1139
+ sortData.result = data;
1140
+ }
1141
+ if (item?.[attrs?.["tree-props"]?.children]) getDragSortData(newIndex, item?.[attrs?.["tree-props"]?.children], startIndexObj, sortData);
1142
+ });
1143
+ return sortData;
1144
+ }
1145
+ /**
1146
+ * 获取拖拽排序数据结果
1147
+ */ function getSortableResult(newIndex, oldIndex) {
1148
+ let data = [
1149
+ ...state.tableData
1150
+ ];
1151
+ if (attrs?.["tree-props"]) {
1152
+ let { result, curIndex: newCurIndex, curData: newCurData } = getDragSortData(newIndex, data, {
1153
+ startIndex: -1
1154
+ }, {
1155
+ result: [],
1156
+ curIndex: 0,
1157
+ curData: {}
1158
+ });
1159
+ let { curIndex: oldCurIndex, curData: oldCurData } = getDragSortData(oldIndex, data, {
1160
+ startIndex: -1
1161
+ }, {
1162
+ result: [],
1163
+ curIndex: 0,
1164
+ curData: {}
1165
+ });
1166
+ if (newCurData.belongGroupElementId !== oldCurData.belongGroupElementId) {
1167
+ __WEBPACK_EXTERNAL_MODULE_element_sun__.ElMessage.warning("暂不支持跨层级拖拽配置");
1168
+ return [];
1169
+ }
1170
+ const [removedItem] = result.splice(oldCurIndex, 1);
1171
+ result.splice(newCurIndex, 0, removedItem);
1172
+ data = result;
1173
+ } else {
1174
+ const [removedItem] = data.splice(oldIndex, 1);
1175
+ data.splice(newIndex, 0, removedItem);
1176
+ }
1177
+ return data;
1178
+ }
1129
1179
  /***
1130
1180
  * 表格拖拽排序
1131
1181
  **/ const initDragSort = ()=>{
1132
1182
  const tbody = document.querySelector(`#${uuid.value} tbody`);
1183
+ let initialHTML = ""; //暂不支持跨层级拖拽
1133
1184
  if (tbody) __WEBPACK_EXTERNAL_MODULE_sortablejs__["default"].create(tbody, {
1134
- handle: '.cursor-move',
1185
+ handle: ".cursor-move",
1135
1186
  animation: 300,
1136
1187
  onEnd (evt) {
1137
1188
  const { newIndex, oldIndex } = evt;
1138
1189
  if (newIndex === oldIndex || void 0 === newIndex || void 0 === oldIndex) return;
1139
1190
  //获取拖动后的排序
1140
- const data = [
1141
- ...state.tableData
1142
- ];
1143
- const [removedItem] = data.splice(oldIndex, 1);
1144
- data.splice(newIndex, 0, removedItem);
1145
- emit('drag-end', data);
1191
+ let data = getSortableResult(newIndex, oldIndex);
1192
+ if (data.length) emit("drag-end", data);
1193
+ else evt.from.innerHTML = initialHTML;
1194
+ },
1195
+ onStart (evt) {
1196
+ // 在拖拽开始时,记录当前容器的 HTML
1197
+ initialHTML = evt.from.innerHTML;
1146
1198
  }
1147
1199
  });
1148
1200
  };
@@ -1152,7 +1204,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1152
1204
  });
1153
1205
  async function fetchDbgridComponent() {
1154
1206
  let [, result] = await queryDbgridComponentByExample({
1155
- componentNo: props.componentNo || ''
1207
+ componentNo: props.componentNo || ""
1156
1208
  });
1157
1209
  if (result?.success) try {
1158
1210
  let column = result.data.dbgridSettingValue && JSON.parse(result.data.dbgridSettingValue) || [];
@@ -1185,7 +1237,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1185
1237
  state.pageInfo.pageNumber = 1;
1186
1238
  state.pageInfo.pageSize = val;
1187
1239
  fetchList();
1188
- } else emit('size-page-change', val);
1240
+ } else emit("size-page-change", val);
1189
1241
  };
1190
1242
  /**
1191
1243
  * 分页组件改变 当前页数 事件
@@ -1193,7 +1245,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1193
1245
  if (props.fetchData) {
1194
1246
  state.pageInfo.pageNumber = val;
1195
1247
  fetchList();
1196
- } else emit('current-page-change', val);
1248
+ } else emit("current-page-change", val);
1197
1249
  }
1198
1250
  // 超级表格 ref
1199
1251
  const proTableRef = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)();
@@ -1210,7 +1262,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1210
1262
  if (Object.keys(props.filterObj).length) return [
1211
1263
  ...state.tableData
1212
1264
  ].filter((item)=>Object.keys(props.filterObj).every((cur)=>!props.filterObj[cur] && [
1213
- '',
1265
+ "",
1214
1266
  void 0,
1215
1267
  null
1216
1268
  ].includes(props.filterObj[cur]) || item[cur] === props.filterObj[cur]));
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as __WEBPACK_EXTERNAL_MODULE_vue__ from "vue";
2
- import * as __WEBPACK_EXTERNAL_MODULE_sortablejs__ from "sortablejs";
3
2
  import * as __WEBPACK_EXTERNAL_MODULE_element_sun__ from "element-sun";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_sortablejs__ from "sortablejs";
4
4
  import * as __WEBPACK_EXTERNAL_MODULE__element_sun_icons_vue__ from "@element-sun/icons-vue";
5
5
  import * as __WEBPACK_EXTERNAL_MODULE__sun_toolkit_enums__ from "@sun-toolkit/enums";
6
6
  import * as __WEBPACK_EXTERNAL_MODULE__sun_toolkit_request__ from "@sun-toolkit/request";
@@ -229,7 +229,7 @@ function useTableConfigColumn(changeInputSort, length) {
229
229
  prop: 'displayFlag',
230
230
  minWidth: 170,
231
231
  editable: true,
232
- render: (row)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)('el-checkbox', {
232
+ render: (row)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)(__WEBPACK_EXTERNAL_MODULE_element_sun__.ElCheckbox, {
233
233
  class: 'w-full justify-center',
234
234
  'true-label': 1,
235
235
  'false-label': 0,
@@ -242,7 +242,7 @@ function useTableConfigColumn(changeInputSort, length) {
242
242
  label: '列宽 (最小值)',
243
243
  prop: 'minWidth',
244
244
  minWidth: 170,
245
- render: (row)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)('el-input-number', {
245
+ render: (row)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)(__WEBPACK_EXTERNAL_MODULE_element_sun__.ElInputNumber, {
246
246
  maxLength: 16,
247
247
  'controls-position': 'right',
248
248
  modelValue: row.minWidth,
@@ -255,7 +255,7 @@ function useTableConfigColumn(changeInputSort, length) {
255
255
  label: '排序',
256
256
  prop: 'sort',
257
257
  minWidth: 170,
258
- render: (row, index)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)('el-input-number', {
258
+ render: (row, index)=>(0, __WEBPACK_EXTERNAL_MODULE_vue__.h)(__WEBPACK_EXTERNAL_MODULE_element_sun__.ElInputNumber, {
259
259
  max: length,
260
260
  min: 0,
261
261
  'controls-position': 'right',
@@ -610,7 +610,7 @@ const _hoisted_3 = {
610
610
  sort: index + 1,
611
611
  columnClass: 'truncate',
612
612
  render: (row, index)=>{
613
- if (item.render) return (0, __WEBPACK_EXTERNAL_MODULE_vue__.h)('el-button', {
613
+ if (item.render) return (0, __WEBPACK_EXTERNAL_MODULE_vue__.h)(__WEBPACK_EXTERNAL_MODULE_element_sun__.ElButton, {
614
614
  type: 'text',
615
615
  class: 'pointer-events-none h-5',
616
616
  disabled: true
@@ -922,7 +922,7 @@ const _hoisted_3 = {
922
922
  const dbgrid_component_setting_exports_ = /*#__PURE__*/ (0, exportHelper["default"])(dbgrid_component_settingvue_type_script_setup_true_lang_tsx, [
923
923
  [
924
924
  '__scopeId',
925
- "data-v-6b73f6ca"
925
+ "data-v-5ff76b6b"
926
926
  ]
927
927
  ]);
928
928
  /* ESM default export */ const dbgrid_component_setting = dbgrid_component_setting_exports_;
@@ -1027,7 +1027,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1027
1027
  default: void 0
1028
1028
  },
1029
1029
  componentNo: {
1030
- default: ''
1030
+ default: ""
1031
1031
  },
1032
1032
  fetchData: {
1033
1033
  type: Function,
@@ -1042,7 +1042,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1042
1042
  default: false
1043
1043
  },
1044
1044
  rowKey: {
1045
- default: 'id'
1045
+ default: "id"
1046
1046
  },
1047
1047
  loading: {
1048
1048
  type: Boolean,
@@ -1083,11 +1083,11 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1083
1083
  });
1084
1084
  const serveColumn = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)([]);
1085
1085
  const columnTypes = [
1086
- 'selection',
1087
- 'radio',
1088
- 'index',
1089
- 'expand',
1090
- 'sort'
1086
+ "selection",
1087
+ "radio",
1088
+ "index",
1089
+ "expand",
1090
+ "sort"
1091
1091
  ];
1092
1092
  const dbgridComponentSettingRef = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)();
1093
1093
  const formRef = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)();
@@ -1095,23 +1095,75 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1095
1095
  const uuid = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)((0, __WEBPACK_EXTERNAL_MODULE_vue__.useId)());
1096
1096
  // 定义 emit 事件
1097
1097
  const emit = __emit;
1098
+ const attrs = (0, __WEBPACK_EXTERNAL_MODULE_vue__.useAttrs)();
1099
+ /**
1100
+ *获取参与排序的列表 索引 是否可以拖拽
1101
+ */ function getDragSortData(newIndex, data, startIndexObj, sortData) {
1102
+ data.forEach((item, index)=>{
1103
+ startIndexObj.startIndex += 1;
1104
+ if (startIndexObj.startIndex > newIndex) return;
1105
+ if (startIndexObj.startIndex === newIndex) {
1106
+ sortData.curIndex = index;
1107
+ sortData.curData = item;
1108
+ sortData.result = data;
1109
+ }
1110
+ if (item?.[attrs?.["tree-props"]?.children]) getDragSortData(newIndex, item?.[attrs?.["tree-props"]?.children], startIndexObj, sortData);
1111
+ });
1112
+ return sortData;
1113
+ }
1114
+ /**
1115
+ * 获取拖拽排序数据结果
1116
+ */ function getSortableResult(newIndex, oldIndex) {
1117
+ let data = [
1118
+ ...state.tableData
1119
+ ];
1120
+ if (attrs?.["tree-props"]) {
1121
+ let { result, curIndex: newCurIndex, curData: newCurData } = getDragSortData(newIndex, data, {
1122
+ startIndex: -1
1123
+ }, {
1124
+ result: [],
1125
+ curIndex: 0,
1126
+ curData: {}
1127
+ });
1128
+ let { curIndex: oldCurIndex, curData: oldCurData } = getDragSortData(oldIndex, data, {
1129
+ startIndex: -1
1130
+ }, {
1131
+ result: [],
1132
+ curIndex: 0,
1133
+ curData: {}
1134
+ });
1135
+ if (newCurData.belongGroupElementId !== oldCurData.belongGroupElementId) {
1136
+ __WEBPACK_EXTERNAL_MODULE_element_sun__.ElMessage.warning("暂不支持跨层级拖拽配置");
1137
+ return [];
1138
+ }
1139
+ const [removedItem] = result.splice(oldCurIndex, 1);
1140
+ result.splice(newCurIndex, 0, removedItem);
1141
+ data = result;
1142
+ } else {
1143
+ const [removedItem] = data.splice(oldIndex, 1);
1144
+ data.splice(newIndex, 0, removedItem);
1145
+ }
1146
+ return data;
1147
+ }
1098
1148
  /***
1099
1149
  * 表格拖拽排序
1100
1150
  **/ const initDragSort = ()=>{
1101
1151
  const tbody = document.querySelector(`#${uuid.value} tbody`);
1152
+ let initialHTML = ""; //暂不支持跨层级拖拽
1102
1153
  if (tbody) __WEBPACK_EXTERNAL_MODULE_sortablejs__["default"].create(tbody, {
1103
- handle: '.cursor-move',
1154
+ handle: ".cursor-move",
1104
1155
  animation: 300,
1105
1156
  onEnd (evt) {
1106
1157
  const { newIndex, oldIndex } = evt;
1107
1158
  if (newIndex === oldIndex || void 0 === newIndex || void 0 === oldIndex) return;
1108
1159
  //获取拖动后的排序
1109
- const data = [
1110
- ...state.tableData
1111
- ];
1112
- const [removedItem] = data.splice(oldIndex, 1);
1113
- data.splice(newIndex, 0, removedItem);
1114
- emit('drag-end', data);
1160
+ let data = getSortableResult(newIndex, oldIndex);
1161
+ if (data.length) emit("drag-end", data);
1162
+ else evt.from.innerHTML = initialHTML;
1163
+ },
1164
+ onStart (evt) {
1165
+ // 在拖拽开始时,记录当前容器的 HTML
1166
+ initialHTML = evt.from.innerHTML;
1115
1167
  }
1116
1168
  });
1117
1169
  };
@@ -1121,7 +1173,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1121
1173
  });
1122
1174
  async function fetchDbgridComponent() {
1123
1175
  let [, result] = await queryDbgridComponentByExample({
1124
- componentNo: props.componentNo || ''
1176
+ componentNo: props.componentNo || ""
1125
1177
  });
1126
1178
  if (result?.success) try {
1127
1179
  let column = result.data.dbgridSettingValue && JSON.parse(result.data.dbgridSettingValue) || [];
@@ -1154,7 +1206,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1154
1206
  state.pageInfo.pageNumber = 1;
1155
1207
  state.pageInfo.pageSize = val;
1156
1208
  fetchList();
1157
- } else emit('size-page-change', val);
1209
+ } else emit("size-page-change", val);
1158
1210
  };
1159
1211
  /**
1160
1212
  * 分页组件改变 当前页数 事件
@@ -1162,7 +1214,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1162
1214
  if (props.fetchData) {
1163
1215
  state.pageInfo.pageNumber = val;
1164
1216
  fetchList();
1165
- } else emit('current-page-change', val);
1217
+ } else emit("current-page-change", val);
1166
1218
  }
1167
1219
  // 超级表格 ref
1168
1220
  const proTableRef = (0, __WEBPACK_EXTERNAL_MODULE_vue__.ref)();
@@ -1179,7 +1231,7 @@ const pro_tablevue_type_script_lang_ts_setup_true_name_ProTable_hoisted_1 = {
1179
1231
  if (Object.keys(props.filterObj).length) return [
1180
1232
  ...state.tableData
1181
1233
  ].filter((item)=>Object.keys(props.filterObj).every((cur)=>!props.filterObj[cur] && [
1182
- '',
1234
+ "",
1183
1235
  void 0,
1184
1236
  null
1185
1237
  ].includes(props.filterObj[cur]) || item[cur] === props.filterObj[cur]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sun-biz",
3
- "version": "0.0.2-beta.5",
3
+ "version": "0.0.2-beta.6",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {