cloud-web-corejs 1.0.54-dev.740 → 1.0.54-dev.743

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "cloud-web-corejs",
3
3
  "private": false,
4
- "version": "1.0.54-dev.740",
4
+ "version": "1.0.54-dev.743",
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
7
7
  "lint": "eslint --ext .js,.vue src",
@@ -111,6 +111,28 @@
111
111
  <i class="el-icon-arrow-right"></i>
112
112
  </el-button>
113
113
  </div>
114
+ <div class="base-area-footer">
115
+ <el-button
116
+ type="primary"
117
+ plain
118
+ class="button-sty"
119
+ @mousedown.prevent
120
+ @click="cancelSelection"
121
+ >
122
+ <i class="el-icon-close el-icon"></i>
123
+ {{ cancelText }}
124
+ </el-button>
125
+ <el-button
126
+ type="primary"
127
+ class="button-sty"
128
+ :disabled="!canConfirm"
129
+ @mousedown.prevent
130
+ @click="confirmSelection"
131
+ >
132
+ <i class="el-icon-check el-icon"></i>
133
+ {{ confirmText }}
134
+ </el-button>
135
+ </div>
114
136
  </div>
115
137
  <div slot="reference" class="base-area-trigger">
116
138
  <el-input
@@ -159,6 +181,11 @@ export default {
159
181
  type: Number,
160
182
  default: 4,
161
183
  },
184
+ /** 至少选到该层级才提交值(1-4);分支无下级数据时视为末级 */
185
+ minLevel: {
186
+ type: Number,
187
+ default: 1,
188
+ },
162
189
  locale: {
163
190
  type: String,
164
191
  default: null,
@@ -187,6 +214,14 @@ export default {
187
214
  type: String,
188
215
  default: "暂无匹配地区",
189
216
  },
217
+ confirmText: {
218
+ type: String,
219
+ default: "确 定",
220
+ },
221
+ cancelText: {
222
+ type: String,
223
+ default: "取 消",
224
+ },
190
225
  size: {
191
226
  type: String,
192
227
  default: "small",
@@ -219,6 +254,7 @@ export default {
219
254
  committedBrowseSnapshot: null,
220
255
  committedBoundValue: null,
221
256
  lastSelectionPayload: null,
257
+ pendingLeaf: false,
222
258
  };
223
259
  },
224
260
  computed: {
@@ -268,6 +304,19 @@ export default {
268
304
  browseLevelCount() {
269
305
  return Math.max(this.maxLevel, this.selectedPath.length, 1);
270
306
  },
307
+ effectiveMinLevel() {
308
+ const min = this.minLevel == null ? 1 : this.minLevel;
309
+ return Math.max(1, Math.min(min, this.maxLevel));
310
+ },
311
+ canConfirm() {
312
+ if (!this.selectedPath.length) {
313
+ return false;
314
+ }
315
+ /* 达到最小选择层级,或该地区无下级数据(视为末级) */
316
+ return (
317
+ this.selectedPath.length >= this.effectiveMinLevel || this.pendingLeaf
318
+ );
319
+ },
271
320
  currentLevelLabel() {
272
321
  return LEVEL_LABELS[this.activeLevel - 1] || `第${this.activeLevel}级`;
273
322
  },
@@ -515,6 +564,7 @@ export default {
515
564
  return level === 1 || this.selectedPath.length >= level - 1;
516
565
  },
517
566
  handlePopoverShow() {
567
+ this.pendingLeaf = false;
518
568
  this.saveCommittedBrowseSnapshot();
519
569
  this.$emit("popover-open");
520
570
  this.$nextTick(() => {
@@ -1013,6 +1063,7 @@ export default {
1013
1063
  this.searchKeyword = "";
1014
1064
  this.searchList = [];
1015
1065
  this.searchDropdownVisible = false;
1066
+ this.pendingLeaf = false;
1016
1067
  this.cancelPendingSync();
1017
1068
  this.emitChangeIfCommitted();
1018
1069
  this.restoreBrowseStateIfUncommitted();
@@ -1068,6 +1119,19 @@ export default {
1068
1119
  }
1069
1120
  this.switchLevel(this.activeLevel - 1);
1070
1121
  },
1122
+ confirmSelection() {
1123
+ if (!this.canConfirm) {
1124
+ return;
1125
+ }
1126
+ const last = this.selectedPath[this.selectedPath.length - 1];
1127
+ this.applySelection(last).then(() => {
1128
+ this.popoverVisible = false;
1129
+ });
1130
+ },
1131
+ cancelSelection() {
1132
+ /* 关闭弹层,未确认的浏览状态由 hide 回调恢复 */
1133
+ this.popoverVisible = false;
1134
+ },
1071
1135
  nextLevel() {
1072
1136
  if (!this.canNextLevel) {
1073
1137
  return;
@@ -1080,8 +1144,20 @@ export default {
1080
1144
  this.searchKeyword = "";
1081
1145
  this.searchList = [];
1082
1146
  this.searchDropdownVisible = false;
1083
- this.applySelection(item).then(() => {
1084
- this.popoverVisible = false;
1147
+ this.pendingLeaf = false;
1148
+ if (this.selectedPath.length >= this.effectiveMinLevel) {
1149
+ /* 已达到最小选择层级:等待确认 */
1150
+ return;
1151
+ }
1152
+ /* 搜索结果未达到最小选择层级:有下级只定位下钻,无下级视为末级 */
1153
+ const last = this.selectedPath[this.selectedPath.length - 1] || item;
1154
+ this.fetchChildren(this.getAreaId(last)).then((children) => {
1155
+ if (!children.length) {
1156
+ this.pendingLeaf = true;
1157
+ return;
1158
+ }
1159
+ this.activeLevel = this.selectedPath.length + 1;
1160
+ this.levelItems = children;
1085
1161
  });
1086
1162
  });
1087
1163
  },
@@ -1093,19 +1169,19 @@ export default {
1093
1169
  const level = this.activeLevel;
1094
1170
  this.selectedPath = this.selectedPath.slice(0, level - 1);
1095
1171
  this.selectedPath.push(item);
1096
- this.applySelection(item).then(() => {
1097
- if (level >= this.maxLevel) {
1098
- this.popoverVisible = false;
1172
+ this.pendingLeaf = false;
1173
+ if (level >= this.maxLevel) {
1174
+ /* 已到最大层级:等待确认 */
1175
+ return;
1176
+ }
1177
+ this.fetchChildren(this.getAreaId(item)).then((children) => {
1178
+ if (!children.length) {
1179
+ /* 无下级数据:视为末级,等待确认 */
1180
+ this.pendingLeaf = true;
1099
1181
  return;
1100
1182
  }
1101
- this.fetchChildren(this.getAreaId(item)).then((children) => {
1102
- if (!children.length) {
1103
- this.popoverVisible = false;
1104
- return;
1105
- }
1106
- this.activeLevel = level + 1;
1107
- this.levelItems = children;
1108
- });
1183
+ this.activeLevel = level + 1;
1184
+ this.levelItems = children;
1109
1185
  });
1110
1186
  },
1111
1187
  async clampPathToMaxLevel(path) {
@@ -1450,6 +1526,15 @@ export default {
1450
1526
  user-select: none;
1451
1527
  }
1452
1528
  }
1529
+
1530
+ .base-area-footer {
1531
+ display: flex;
1532
+ align-items: center;
1533
+ justify-content: flex-end;
1534
+ margin-top: 8px;
1535
+ padding-top: 8px;
1536
+ border-top: 1px solid #ebeef5;
1537
+ }
1453
1538
  </style>
1454
1539
 
1455
1540
  <style lang="scss">