@pisell/pisellos 0.0.45 → 0.0.47

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.
@@ -81,7 +81,10 @@ var checkCapacity = ({
81
81
  currentCount = 1
82
82
  }) => {
83
83
  if (currentCount > resource.capacity) {
84
- return false;
84
+ return {
85
+ status: false,
86
+ capacity: resource.capacity
87
+ };
85
88
  }
86
89
  let conflict = (event_list || []).filter((d) => {
87
90
  return isConflict(
@@ -91,16 +94,28 @@ var checkCapacity = ({
91
94
  });
92
95
  if (resource.resourceType === "single") {
93
96
  if (conflict.length === 0) {
94
- return true;
97
+ return {
98
+ status: true,
99
+ capacity: 1
100
+ };
95
101
  } else {
96
- return false;
102
+ return {
103
+ status: false,
104
+ capacity: 1
105
+ };
97
106
  }
98
107
  } else {
99
108
  let conflictCount = getUseableEventCount(conflict, resource.capacity);
100
109
  if (currentCount <= conflictCount) {
101
- return true;
110
+ return {
111
+ status: true,
112
+ capacity: conflictCount
113
+ };
102
114
  } else {
103
- return false;
115
+ return {
116
+ status: false,
117
+ capacity: conflictCount
118
+ };
104
119
  }
105
120
  }
106
121
  };
@@ -113,21 +128,25 @@ var getIsUsableByTimeItem = ({
113
128
  let status = {
114
129
  afterToDay: false,
115
130
  capacity: false,
116
- usable: false
131
+ usable: false,
132
+ remainingCapacity: 0
133
+ // 剩余容量
117
134
  };
118
135
  let earliest = (0, import_dayjs.default)();
119
136
  if (!checkAfterToDay(timeSlice.start_at, earliest)) {
120
137
  return status;
121
138
  }
122
139
  status.afterToDay = true;
123
- if (!checkCapacity({
140
+ const checkCapacityResult = checkCapacity({
124
141
  event_list: time == null ? void 0 : time.event_list,
125
142
  timeSlice,
126
143
  resource,
127
144
  currentCount
128
- })) {
145
+ });
146
+ if (!checkCapacityResult.status) {
129
147
  return status;
130
148
  }
149
+ status.remainingCapacity = checkCapacityResult.capacity;
131
150
  status.capacity = true;
132
151
  status.usable = true;
133
152
  return status;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.45",
4
+ "version": "0.0.47",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",