@blueking/bkui-form 0.0.30 → 0.0.31
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/dist/bkui-form-es-min.js +3 -3
- package/dist/bkui-form-es.js +168 -16
- package/dist/bkui-form-es.js.map +1 -1
- package/dist/bkui-form-umd-min.js +3 -3
- package/dist/bkui-form-umd.js +168 -16
- package/dist/bkui-form-umd.js.map +1 -1
- package/dist/bkui-form.css +9 -0
- package/dist/types/bkui-form.d.ts +1 -1
- package/package.json +1 -1
package/dist/bkui-form-umd.js
CHANGED
|
@@ -2200,22 +2200,24 @@
|
|
|
2200
2200
|
value: function removeWidgetNode(path, instance) {
|
|
2201
2201
|
var node = this.widgetMap[path];
|
|
2202
2202
|
|
|
2203
|
-
if (node
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
if (index > -1) {
|
|
2210
|
-
children.splice(index, 1);
|
|
2211
|
-
children.slice(index).forEach(function (node, i) {
|
|
2212
|
-
node.index = index + i;
|
|
2203
|
+
if (node) {
|
|
2204
|
+
if (node.parent) {
|
|
2205
|
+
var children = node.parent.children;
|
|
2206
|
+
var index = children.findIndex(function (item) {
|
|
2207
|
+
return item.instance === instance;
|
|
2213
2208
|
});
|
|
2209
|
+
|
|
2210
|
+
if (index > -1) {
|
|
2211
|
+
children.splice(index, 1);
|
|
2212
|
+
children.slice(index).forEach(function (node, i) {
|
|
2213
|
+
node.index = index + i;
|
|
2214
|
+
});
|
|
2215
|
+
}
|
|
2214
2216
|
}
|
|
2215
|
-
}
|
|
2216
2217
|
|
|
2217
|
-
|
|
2218
|
-
|
|
2218
|
+
if (node.instance === instance) {
|
|
2219
|
+
delete this.widgetMap[path];
|
|
2220
|
+
}
|
|
2219
2221
|
}
|
|
2220
2222
|
}
|
|
2221
2223
|
}]);
|
|
@@ -10570,7 +10572,9 @@
|
|
|
10570
10572
|
})
|
|
10571
10573
|
}, mergeDeep(uiVnodeData, {
|
|
10572
10574
|
props: _objectSpread2(_objectSpread2({}, this.state), {}, {
|
|
10573
|
-
datasource: this.datasource
|
|
10575
|
+
datasource: this.datasource,
|
|
10576
|
+
readonly: this.readonly,
|
|
10577
|
+
readonlyMode: this.readonlyMode
|
|
10574
10578
|
}),
|
|
10575
10579
|
attrs: _objectSpread2({}, this.state)
|
|
10576
10580
|
})));
|
|
@@ -11215,12 +11219,160 @@
|
|
|
11215
11219
|
}
|
|
11216
11220
|
});
|
|
11217
11221
|
|
|
11222
|
+
// 获取表格单行默认值
|
|
11223
|
+
|
|
11224
|
+
var getRowDefaultData = function getRowDefaultData() {
|
|
11225
|
+
var properties = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
11226
|
+
var keys = Object.keys(properties);
|
|
11227
|
+
var data = {};
|
|
11228
|
+
keys.forEach(function (key) {
|
|
11229
|
+
data[key] = Schema.getSchemaDefaultValue(properties[key]);
|
|
11230
|
+
});
|
|
11231
|
+
return [data];
|
|
11232
|
+
};
|
|
11233
|
+
|
|
11218
11234
|
var TableWidget = Vue__default["default"].extend({
|
|
11219
11235
|
name: 'TableWidget',
|
|
11236
|
+
props: props,
|
|
11237
|
+
methods: {
|
|
11238
|
+
// 单元格表单编辑
|
|
11239
|
+
handleCellValChange: function handleCellValChange(_ref) {
|
|
11240
|
+
var path = _ref.path,
|
|
11241
|
+
value = _ref.value;
|
|
11242
|
+
var subPath = Path.getSubPath(this.path, path);
|
|
11243
|
+
var newValue = Path.setPathValue(this.value, subPath, value);
|
|
11244
|
+
this.$emit('input', newValue);
|
|
11245
|
+
},
|
|
11246
|
+
// 新增
|
|
11247
|
+
handleAddRow: function handleAddRow(index) {
|
|
11248
|
+
var _this$$props$schema$i;
|
|
11249
|
+
|
|
11250
|
+
var newValue = this.value.slice(0);
|
|
11251
|
+
newValue.splice.apply(newValue, [index + 1, 0].concat(_toConsumableArray(getRowDefaultData((_this$$props$schema$i = this.$props.schema.items) === null || _this$$props$schema$i === void 0 ? void 0 : _this$$props$schema$i.properties))));
|
|
11252
|
+
this.$emit('input', newValue);
|
|
11253
|
+
},
|
|
11254
|
+
// 删除
|
|
11255
|
+
handleDelRow: function handleDelRow(index) {
|
|
11256
|
+
var newValue = this.value.slice(0);
|
|
11257
|
+
newValue.splice(index, 1);
|
|
11258
|
+
this.$emit('input', newValue);
|
|
11259
|
+
}
|
|
11260
|
+
},
|
|
11220
11261
|
render: function render(h) {
|
|
11262
|
+
var _schema$items,
|
|
11263
|
+
_this = this;
|
|
11264
|
+
|
|
11265
|
+
var self = this;
|
|
11266
|
+
var _this$$props = this.$props,
|
|
11267
|
+
schema = _this$$props.schema,
|
|
11268
|
+
readonly = _this$$props.readonly,
|
|
11269
|
+
readonlyMode = _this$$props.readonlyMode,
|
|
11270
|
+
path = _this$$props.path,
|
|
11271
|
+
context = _this$$props.context,
|
|
11272
|
+
rootData = _this$$props.rootData,
|
|
11273
|
+
value = _this$$props.value;
|
|
11274
|
+
var columnsKey = Object.keys(((_schema$items = schema.items) === null || _schema$items === void 0 ? void 0 : _schema$items.properties) || []);
|
|
11275
|
+
|
|
11276
|
+
var getTableColumn = function getTableColumn() {
|
|
11277
|
+
var VNodeList = columnsKey.map(function (key) {
|
|
11278
|
+
var colField = schema.items.properties[key];
|
|
11279
|
+
return h(registry.getBaseWidget('table-column'), {
|
|
11280
|
+
props: {
|
|
11281
|
+
label: colField.title
|
|
11282
|
+
},
|
|
11283
|
+
scopedSlots: {
|
|
11284
|
+
default: function _default(props) {
|
|
11285
|
+
return h(SchemaField, {
|
|
11286
|
+
props: {
|
|
11287
|
+
context: context,
|
|
11288
|
+
rootData: rootData,
|
|
11289
|
+
readonly: readonly,
|
|
11290
|
+
readonlyMode: readonlyMode,
|
|
11291
|
+
schema: mergeDeep(colField, {
|
|
11292
|
+
'ui:props': {
|
|
11293
|
+
// 默认不展示标题
|
|
11294
|
+
showTitle: false,
|
|
11295
|
+
// 0.1 兼容formItem设置 labelWidth 0 不生效问题
|
|
11296
|
+
labelWidth: 0.1
|
|
11297
|
+
}
|
|
11298
|
+
}),
|
|
11299
|
+
path: Path.getCurPath(path, "".concat(props.$index, ".").concat(key)),
|
|
11300
|
+
value: props.row[key]
|
|
11301
|
+
},
|
|
11302
|
+
on: {
|
|
11303
|
+
input: function input(data) {
|
|
11304
|
+
self.handleCellValChange(data);
|
|
11305
|
+
}
|
|
11306
|
+
}
|
|
11307
|
+
}, [props.row]);
|
|
11308
|
+
}
|
|
11309
|
+
}
|
|
11310
|
+
});
|
|
11311
|
+
});
|
|
11312
|
+
|
|
11313
|
+
if (!_this.readonly) {
|
|
11314
|
+
VNodeList.push(h(registry.getBaseWidget('table-column'), {
|
|
11315
|
+
props: {
|
|
11316
|
+
label: '操作',
|
|
11317
|
+
width: 100
|
|
11318
|
+
},
|
|
11319
|
+
scopedSlots: {
|
|
11320
|
+
default: function _default(props) {
|
|
11321
|
+
return h('div', {
|
|
11322
|
+
class: 'table-widget-actions'
|
|
11323
|
+
}, [h('i', {
|
|
11324
|
+
class: 'bk-icon icon-plus-circle action-btn',
|
|
11325
|
+
on: {
|
|
11326
|
+
click: function click() {
|
|
11327
|
+
self.handleAddRow(props.$index);
|
|
11328
|
+
}
|
|
11329
|
+
}
|
|
11330
|
+
}), h('i', {
|
|
11331
|
+
class: 'bk-icon icon-minus-circle action-btn',
|
|
11332
|
+
on: {
|
|
11333
|
+
click: function click() {
|
|
11334
|
+
self.handleDelRow(props.$index);
|
|
11335
|
+
}
|
|
11336
|
+
}
|
|
11337
|
+
})]);
|
|
11338
|
+
}
|
|
11339
|
+
}
|
|
11340
|
+
}));
|
|
11341
|
+
}
|
|
11342
|
+
|
|
11343
|
+
return VNodeList;
|
|
11344
|
+
};
|
|
11345
|
+
|
|
11221
11346
|
return h(registry.getBaseWidget('table'), {
|
|
11222
|
-
props: _objectSpread2({},
|
|
11223
|
-
|
|
11347
|
+
props: _objectSpread2(_objectSpread2({}, schema['ui:component'].props || {}), {}, {
|
|
11348
|
+
data: value
|
|
11349
|
+
}),
|
|
11350
|
+
on: {
|
|
11351
|
+
input: function input(_ref2) {
|
|
11352
|
+
var path = _ref2.path,
|
|
11353
|
+
value = _ref2.value;
|
|
11354
|
+
self.$emit('input', {
|
|
11355
|
+
path: path,
|
|
11356
|
+
value: value
|
|
11357
|
+
});
|
|
11358
|
+
}
|
|
11359
|
+
},
|
|
11360
|
+
scopedSlots: {
|
|
11361
|
+
empty: function empty() {
|
|
11362
|
+
return _this.readonly ? null : h('div', {
|
|
11363
|
+
style: {
|
|
11364
|
+
'color': '#3a84ff',
|
|
11365
|
+
'cursor': 'pointer'
|
|
11366
|
+
},
|
|
11367
|
+
on: {
|
|
11368
|
+
click: function click() {
|
|
11369
|
+
self.handleAddRow(0);
|
|
11370
|
+
}
|
|
11371
|
+
}
|
|
11372
|
+
}, '点击添加数据');
|
|
11373
|
+
}
|
|
11374
|
+
}
|
|
11375
|
+
}, getTableColumn());
|
|
11224
11376
|
}
|
|
11225
11377
|
});
|
|
11226
11378
|
|