form-driver 0.4.0 → 0.4.1
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/m3.css +1 -1
- package/dist/m3.js +1 -1
- package/es/m3.css +1 -1
- package/es/m3.js +99 -111
- package/lib/m3.css +1 -1
- package/lib/m3.js +99 -111
- package/package.json +1 -1
- package/src/ui/editor/complex/ACheckDrag.tsx +46 -40
- package/src/ui/widget/SortDrag.less +1 -1
- package/src/ui/widget/SortDrag.tsx +1 -14
package/lib/m3.js
CHANGED
|
@@ -19502,7 +19502,7 @@ var SortDrag = /*#__PURE__*/React.memo(function (props) {
|
|
|
19502
19502
|
var sortList = props.sortList,
|
|
19503
19503
|
changeOriginDataSource = props.changeOriginDataSource;
|
|
19504
19504
|
|
|
19505
|
-
var _useState = React.useState(
|
|
19505
|
+
var _useState = React.useState(sortList),
|
|
19506
19506
|
items = _useState[0],
|
|
19507
19507
|
setItems = _useState[1]; // 记录当前拖拽的 item id
|
|
19508
19508
|
|
|
@@ -19601,22 +19601,6 @@ var SortDrag = /*#__PURE__*/React.memo(function (props) {
|
|
|
19601
19601
|
});
|
|
19602
19602
|
};
|
|
19603
19603
|
}, [items]);
|
|
19604
|
-
React.useEffect(function () {
|
|
19605
|
-
var checkedItems = sortList.filter(function (item) {
|
|
19606
|
-
return item.isChecked;
|
|
19607
|
-
}).sort(function (a, b) {
|
|
19608
|
-
return a.checkedIndex - b.checkedIndex;
|
|
19609
|
-
});
|
|
19610
|
-
var unCheckedItems = sortList.filter(function (item) {
|
|
19611
|
-
return !item.isChecked;
|
|
19612
|
-
});
|
|
19613
|
-
console.log("DRAG: 排序之后实际展示的数据", {
|
|
19614
|
-
sortList: sortList,
|
|
19615
|
-
checkedItems: checkedItems,
|
|
19616
|
-
unCheckedItems: unCheckedItems
|
|
19617
|
-
});
|
|
19618
|
-
setItems([].concat(checkedItems, unCheckedItems));
|
|
19619
|
-
}, [sortList]);
|
|
19620
19604
|
return jsxRuntime.jsx("div", {
|
|
19621
19605
|
className: "sortDrag",
|
|
19622
19606
|
children: items.map(function (item, index) {
|
|
@@ -19721,15 +19705,12 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19721
19705
|
};
|
|
19722
19706
|
|
|
19723
19707
|
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState, snapshot) {
|
|
19724
|
-
|
|
19725
|
-
|
|
19726
|
-
setTimeout(function () {
|
|
19727
|
-
console.log("DRAG: 组件更新", _this2.checkFields, _this2.state.data);
|
|
19708
|
+
setTimeout(function () {// console.log("DRAG: 组件更新", this.checkFields, this.state.data);
|
|
19728
19709
|
}, 2000);
|
|
19729
19710
|
};
|
|
19730
19711
|
|
|
19731
19712
|
_proto.element = function element(ctx) {
|
|
19732
|
-
var
|
|
19713
|
+
var _this2 = this,
|
|
19733
19714
|
_ref;
|
|
19734
19715
|
|
|
19735
19716
|
var data = this.state.data;
|
|
@@ -19744,30 +19725,30 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19744
19725
|
var checkboxs = this.checkFields.map(function (m, index) {
|
|
19745
19726
|
var _ctx$rootProps$schema;
|
|
19746
19727
|
|
|
19747
|
-
var isShow = MUtil.isShow(
|
|
19728
|
+
var isShow = MUtil.isShow(_this2.props.database, (_ctx$rootProps$schema = ctx.rootProps.schema) == null ? void 0 : _ctx$rootProps$schema.objectFields, m.showIf);
|
|
19748
19729
|
if (!isShow) return null;
|
|
19749
19730
|
var checkIndex = values == null ? void 0 : values.findIndex(function (e) {
|
|
19750
19731
|
return e === m.value;
|
|
19751
19732
|
});
|
|
19752
19733
|
|
|
19753
19734
|
if (m.remark === "openOption") {
|
|
19754
|
-
var
|
|
19735
|
+
var _this2$props$schema$o;
|
|
19755
19736
|
|
|
19756
|
-
var key =
|
|
19737
|
+
var key = _this2._inputBoxValue;
|
|
19757
19738
|
var checked = values == null ? void 0 : values.findIndex(function (e) {
|
|
19758
19739
|
return e === key;
|
|
19759
19740
|
});
|
|
19760
19741
|
return [jsxRuntime.jsxs(DIYCheckbox, {
|
|
19761
|
-
disabled:
|
|
19742
|
+
disabled: _this2.props.disable,
|
|
19762
19743
|
checked: checked !== -1,
|
|
19763
19744
|
checkedIcon: checked ? checked + 1 : 1,
|
|
19764
19745
|
onChange: function onChange(e) {
|
|
19765
|
-
var max =
|
|
19746
|
+
var max = _this2.props.schema.max;
|
|
19766
19747
|
|
|
19767
19748
|
if (max > 0 && e.target.checked) {
|
|
19768
19749
|
var len = values ? values.length : 0; // 选择第 max + 1 项时,提示并组织
|
|
19769
19750
|
|
|
19770
|
-
if (len >=
|
|
19751
|
+
if (len >= _this2.props.schema.max) {
|
|
19771
19752
|
antd.Modal.info({
|
|
19772
19753
|
title: "\u6B64\u9898\u6700\u591A\u53EA\u80FD\u9009\u62E9 " + max + " \u9879",
|
|
19773
19754
|
okText: "确认",
|
|
@@ -19779,13 +19760,13 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19779
19760
|
}
|
|
19780
19761
|
}
|
|
19781
19762
|
|
|
19782
|
-
var currentCheckValue = MSetType.change(e.target.checked, key, values,
|
|
19783
|
-
|
|
19784
|
-
|
|
19763
|
+
var currentCheckValue = MSetType.change(e.target.checked, key, values, _this2.props.schema, true); // console.log("当前选中的数据ccc", currentCheckValue);
|
|
19764
|
+
|
|
19765
|
+
_this2.dataRef = currentCheckValue;
|
|
19785
19766
|
setTimeout(function () {
|
|
19786
|
-
_Viewer.prototype.changeValue.call(
|
|
19767
|
+
_Viewer.prototype.changeValue.call(_this2, currentCheckValue);
|
|
19787
19768
|
|
|
19788
|
-
|
|
19769
|
+
_this2.setState({
|
|
19789
19770
|
data: currentCheckValue
|
|
19790
19771
|
});
|
|
19791
19772
|
}, 0);
|
|
@@ -19794,36 +19775,35 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19794
19775
|
style: {
|
|
19795
19776
|
marginRight: "10px"
|
|
19796
19777
|
},
|
|
19797
|
-
children: (
|
|
19778
|
+
children: (_this2$props$schema$o = _this2.props.schema.openOption.label) != null ? _this2$props$schema$o : "其他"
|
|
19798
19779
|
}), jsxRuntime.jsx("span", {
|
|
19799
19780
|
onBlurCapture: function onBlurCapture(e) {
|
|
19800
|
-
console.log("输入框失去焦点",
|
|
19781
|
+
// console.log("输入框失去焦点", this.dataRef);
|
|
19801
19782
|
setTimeout(function () {
|
|
19802
|
-
_Viewer.prototype.changeValue.call(
|
|
19783
|
+
_Viewer.prototype.changeValue.call(_this2, _this2.dataRef);
|
|
19803
19784
|
|
|
19804
|
-
|
|
19805
|
-
data:
|
|
19785
|
+
_this2.setState({
|
|
19786
|
+
data: _this2.dataRef
|
|
19806
19787
|
});
|
|
19807
19788
|
}, 0);
|
|
19808
19789
|
},
|
|
19809
19790
|
children: jsxRuntime.jsx(MFieldViewer, {
|
|
19810
|
-
morph:
|
|
19811
|
-
schema:
|
|
19812
|
-
database:
|
|
19791
|
+
morph: _this2.props.morph,
|
|
19792
|
+
schema: _this2.props.schema.openOption,
|
|
19793
|
+
database: _this2,
|
|
19813
19794
|
path: "_inputBoxValue",
|
|
19814
19795
|
afterChange: function afterChange(path, str, final) {
|
|
19815
|
-
var matchEnum =
|
|
19796
|
+
var matchEnum = _this2.checkFields.find(function (e) {
|
|
19816
19797
|
return e.value === str && e.remark !== "openOption";
|
|
19817
|
-
});
|
|
19798
|
+
}); // console.log("输入框 afterChange", str, values, matchEnum);
|
|
19818
19799
|
|
|
19819
|
-
console.log("输入框 afterChange", str, values, matchEnum);
|
|
19820
19800
|
|
|
19821
19801
|
if (matchEnum) {
|
|
19822
19802
|
// 不能让用户输入某个枚举值
|
|
19823
|
-
|
|
19803
|
+
_this2._inputBoxValue = "";
|
|
19824
19804
|
|
|
19825
19805
|
___default["default"].remove(values, function (e) {
|
|
19826
|
-
return !
|
|
19806
|
+
return !_this2.checkValues.includes(e);
|
|
19827
19807
|
});
|
|
19828
19808
|
|
|
19829
19809
|
if (!values.includes(str)) {
|
|
@@ -19831,15 +19811,15 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19831
19811
|
}
|
|
19832
19812
|
|
|
19833
19813
|
queueMicrotask(function () {
|
|
19834
|
-
_Viewer.prototype.changeValueEx.call(
|
|
19814
|
+
_Viewer.prototype.changeValueEx.call(_this2, values, true, final);
|
|
19835
19815
|
|
|
19836
|
-
|
|
19816
|
+
_this2.setState({
|
|
19837
19817
|
data: values
|
|
19838
19818
|
});
|
|
19839
19819
|
});
|
|
19840
19820
|
} else {
|
|
19841
19821
|
var idx = values.findIndex(function (v) {
|
|
19842
|
-
var index =
|
|
19822
|
+
var index = _this2.checkFields.filter(function (e) {
|
|
19843
19823
|
return e.remark !== "openOption";
|
|
19844
19824
|
}).findIndex(function (e) {
|
|
19845
19825
|
return e.value === v;
|
|
@@ -19849,24 +19829,24 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19849
19829
|
});
|
|
19850
19830
|
|
|
19851
19831
|
if (!___default["default"].isNil(idx) || str === "") {
|
|
19852
|
-
|
|
19832
|
+
_this2._inputBoxValue = str;
|
|
19853
19833
|
values[idx] = str;
|
|
19854
|
-
|
|
19855
|
-
|
|
19834
|
+
_this2.dataRef = values;
|
|
19835
|
+
_this2.checkFields = _this2.checkFields.map(function (e) {
|
|
19856
19836
|
return e.remark === "openOption" ? _objectSpread$9(_objectSpread$9({}, e), {}, {
|
|
19857
19837
|
value: str
|
|
19858
19838
|
}) : e;
|
|
19859
|
-
});
|
|
19860
|
-
|
|
19861
|
-
|
|
19862
|
-
|
|
19863
|
-
|
|
19864
|
-
|
|
19865
|
-
MUtil.set(
|
|
19839
|
+
}); // console.log("输入框数据", {
|
|
19840
|
+
// values,
|
|
19841
|
+
// checkFields: this.checkFields,
|
|
19842
|
+
// dataRef: this.dataRef,
|
|
19843
|
+
// });
|
|
19844
|
+
|
|
19845
|
+
MUtil.set(_this2.props.database, _this2.props.path, values);
|
|
19866
19846
|
}
|
|
19867
19847
|
}
|
|
19868
19848
|
},
|
|
19869
|
-
parent:
|
|
19849
|
+
parent: _this2.props.schema,
|
|
19870
19850
|
forceValid: false,
|
|
19871
19851
|
disable: openIndex < 0,
|
|
19872
19852
|
style: {
|
|
@@ -19874,22 +19854,22 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19874
19854
|
}
|
|
19875
19855
|
})
|
|
19876
19856
|
})]
|
|
19877
|
-
}, "openOption"),
|
|
19857
|
+
}, "openOption"), _this2._createBr()];
|
|
19878
19858
|
}
|
|
19879
19859
|
|
|
19880
19860
|
return [jsxRuntime.jsx(DIYCheckbox, {
|
|
19881
|
-
disabled:
|
|
19861
|
+
disabled: _this2.props.disable,
|
|
19882
19862
|
checkedIcon: checkIndex === -1 ? 1 : checkIndex + 1,
|
|
19883
19863
|
checked: ___default["default"].includes(values, m.value),
|
|
19884
19864
|
onChange: function onChange(e) {
|
|
19885
|
-
var currentCheckValue = MSetType.change(e.target.checked, m.value, values,
|
|
19886
|
-
|
|
19887
|
-
var max =
|
|
19865
|
+
var currentCheckValue = MSetType.change(e.target.checked, m.value, values, _this2.props.schema, true); // console.log("当前变化的 value", values, currentCheckValue);
|
|
19866
|
+
|
|
19867
|
+
var max = _this2.props.schema.max;
|
|
19888
19868
|
|
|
19889
19869
|
if (max > 0 && e.target.checked) {
|
|
19890
19870
|
var len = values ? values.length : 0; // 选择第 max + 1 项时,提示并组织
|
|
19891
19871
|
|
|
19892
|
-
if (len >=
|
|
19872
|
+
if (len >= _this2.props.schema.max) {
|
|
19893
19873
|
antd.Modal.info({
|
|
19894
19874
|
title: "\u6B64\u9898\u6700\u591A\u53EA\u80FD\u9009\u62E9 " + max + " \u9879",
|
|
19895
19875
|
okText: "确认",
|
|
@@ -19901,22 +19881,22 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19901
19881
|
}
|
|
19902
19882
|
}
|
|
19903
19883
|
|
|
19904
|
-
|
|
19884
|
+
_this2.dataRef = currentCheckValue;
|
|
19905
19885
|
queueMicrotask(function () {
|
|
19906
|
-
_Viewer.prototype.changeValue.call(
|
|
19886
|
+
_Viewer.prototype.changeValue.call(_this2, currentCheckValue);
|
|
19907
19887
|
|
|
19908
|
-
|
|
19888
|
+
_this2.setState({
|
|
19909
19889
|
data: currentCheckValue
|
|
19910
19890
|
});
|
|
19911
19891
|
});
|
|
19912
19892
|
},
|
|
19913
19893
|
children: ACheckBoxLabel(m)
|
|
19914
|
-
}, m.value),
|
|
19894
|
+
}, m.value), _this2._createBr()];
|
|
19915
19895
|
}); // 定义更换数据源的方法
|
|
19916
19896
|
|
|
19917
19897
|
var changeOriginDataSource = function changeOriginDataSource(newData) {
|
|
19918
|
-
console.log("新数据", newData);
|
|
19919
|
-
|
|
19898
|
+
// console.log("新数据", newData);
|
|
19899
|
+
// 更新排序后的选项数据
|
|
19920
19900
|
var sortedCheckFields = newData.map(function (item) {
|
|
19921
19901
|
return _objectSpread$9(_objectSpread$9({}, item), {}, {
|
|
19922
19902
|
label: item.label,
|
|
@@ -19930,12 +19910,12 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19930
19910
|
return item.id;
|
|
19931
19911
|
}); // 同时更新schema中的option顺序,以确保后续操作基于新的排序
|
|
19932
19912
|
|
|
19933
|
-
var newSchema = _objectSpread$9({},
|
|
19913
|
+
var newSchema = _objectSpread$9({}, _this2.props.schema);
|
|
19934
19914
|
|
|
19935
19915
|
var isHaveOpenOption = sortedCheckFields.filter(function (e) {
|
|
19936
19916
|
return e.remark === "openOption";
|
|
19937
|
-
});
|
|
19938
|
-
|
|
19917
|
+
}); // console.log("isHaveOpenOption", isHaveOpenOption);
|
|
19918
|
+
|
|
19939
19919
|
newSchema.option = isHaveOpenOption ? sortedCheckFields == null ? void 0 : sortedCheckFields.filter(function (e) {
|
|
19940
19920
|
return e.remark !== "openOption";
|
|
19941
19921
|
}) : sortedCheckFields;
|
|
@@ -19946,52 +19926,60 @@ var ACheckDrag = /*#__PURE__*/function (_Viewer) {
|
|
|
19946
19926
|
// newSchema,
|
|
19947
19927
|
// });
|
|
19948
19928
|
|
|
19949
|
-
|
|
19950
|
-
|
|
19929
|
+
_this2.checkFields = sortedCheckFields;
|
|
19930
|
+
_this2.dataRef = sortedData;
|
|
19951
19931
|
setTimeout(function () {
|
|
19952
|
-
|
|
19932
|
+
_this2.setState({
|
|
19953
19933
|
data: sortedData
|
|
19954
19934
|
});
|
|
19955
19935
|
|
|
19956
|
-
MUtil.set(
|
|
19936
|
+
MUtil.set(_this2.props.database, _this2.props.path, sortedData);
|
|
19957
19937
|
}, 0);
|
|
19958
19938
|
};
|
|
19959
19939
|
|
|
19960
|
-
|
|
19961
|
-
|
|
19962
|
-
|
|
19963
|
-
|
|
19964
|
-
|
|
19965
|
-
|
|
19966
|
-
|
|
19967
|
-
|
|
19940
|
+
var sortList = (_ref = checkboxs != null ? checkboxs : []) == null ? void 0 : _ref.map(function (cpn, index) {
|
|
19941
|
+
var _this2$checkFields$in, _this2$checkFields$in2, _this2$dataRef, _this2$dataRef2, _this2$checkFields$in3, _this2$checkFields$in4;
|
|
19942
|
+
|
|
19943
|
+
var checkFieldsValue;
|
|
19944
|
+
checkFieldsValue = (_this2$checkFields$in = _this2.checkFields[index]) == null ? void 0 : _this2$checkFields$in.value;
|
|
19945
|
+
var isOpenOp = ((_this2$checkFields$in2 = _this2.checkFields[index]) == null ? void 0 : _this2$checkFields$in2.remark) === "openOption";
|
|
19946
|
+
|
|
19947
|
+
if (isOpenOp) {
|
|
19948
|
+
checkFieldsValue = _this2._inputBoxValue;
|
|
19949
|
+
} // console.log("DRAG: 实际传递进如 SortDrag的数据", {
|
|
19950
|
+
// data,
|
|
19951
|
+
// dataRef: this.dataRef,
|
|
19952
|
+
// checkFields: this.checkFields,
|
|
19953
|
+
// schema: this.props.database,
|
|
19954
|
+
// isOpenOp,
|
|
19955
|
+
// openValue: this._inputBoxValue,
|
|
19956
|
+
// });
|
|
19968
19957
|
|
|
19969
|
-
if (isOpenOp) {
|
|
19970
|
-
checkFieldsValue = _this3._inputBoxValue;
|
|
19971
|
-
}
|
|
19972
19958
|
|
|
19973
|
-
|
|
19974
|
-
|
|
19975
|
-
|
|
19976
|
-
|
|
19977
|
-
|
|
19978
|
-
|
|
19979
|
-
|
|
19980
|
-
|
|
19981
|
-
|
|
19982
|
-
|
|
19983
|
-
|
|
19984
|
-
|
|
19985
|
-
checkedIndex: ((_this3$dataRef2 = _this3.dataRef) == null ? void 0 : _this3$dataRef2.findIndex(function (e) {
|
|
19986
|
-
return e === checkFieldsValue;
|
|
19987
|
-
})) + 1,
|
|
19988
|
-
cpn: cpn,
|
|
19989
|
-
id: "" + checkFieldsValue,
|
|
19990
|
-
label: (_this3$checkFields$in3 = _this3.checkFields[index]) == null ? void 0 : _this3$checkFields$in3.label,
|
|
19991
|
-
remark: (_this3$checkFields$in4 = _this3.checkFields[index]) == null ? void 0 : _this3$checkFields$in4.remark
|
|
19992
|
-
};
|
|
19993
|
-
})
|
|
19959
|
+
return {
|
|
19960
|
+
isChecked: _this2.dataRef ? ((_this2$dataRef = _this2.dataRef) == null ? void 0 : _this2$dataRef.findIndex(function (e) {
|
|
19961
|
+
return e === checkFieldsValue;
|
|
19962
|
+
})) !== -1 : false,
|
|
19963
|
+
checkedIndex: ((_this2$dataRef2 = _this2.dataRef) == null ? void 0 : _this2$dataRef2.findIndex(function (e) {
|
|
19964
|
+
return e === checkFieldsValue;
|
|
19965
|
+
})) + 1,
|
|
19966
|
+
cpn: cpn,
|
|
19967
|
+
id: "" + checkFieldsValue,
|
|
19968
|
+
label: (_this2$checkFields$in3 = _this2.checkFields[index]) == null ? void 0 : _this2$checkFields$in3.label,
|
|
19969
|
+
remark: (_this2$checkFields$in4 = _this2.checkFields[index]) == null ? void 0 : _this2$checkFields$in4.remark
|
|
19970
|
+
};
|
|
19994
19971
|
});
|
|
19972
|
+
var finalSortList = sortList.filter(function (item) {
|
|
19973
|
+
return item.isChecked;
|
|
19974
|
+
}).sort(function (a, b) {
|
|
19975
|
+
return a.checkedIndex - b.checkedIndex;
|
|
19976
|
+
}).concat(sortList.filter(function (item) {
|
|
19977
|
+
return !item.isChecked;
|
|
19978
|
+
}));
|
|
19979
|
+
return jsxRuntime.jsx(SortDrag, {
|
|
19980
|
+
changeOriginDataSource: changeOriginDataSource,
|
|
19981
|
+
sortList: finalSortList
|
|
19982
|
+
}, MUtil.unique());
|
|
19995
19983
|
};
|
|
19996
19984
|
|
|
19997
19985
|
return ACheckDrag;
|
package/package.json
CHANGED
|
@@ -95,7 +95,7 @@ export class ACheckDrag extends Viewer<ACheckDragState> {
|
|
|
95
95
|
snapshot?: any
|
|
96
96
|
): void {
|
|
97
97
|
setTimeout(() => {
|
|
98
|
-
console.log("DRAG: 组件更新", this.checkFields, this.state.data);
|
|
98
|
+
// console.log("DRAG: 组件更新", this.checkFields, this.state.data);
|
|
99
99
|
}, 2000);
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -150,7 +150,7 @@ export class ACheckDrag extends Viewer<ACheckDragState> {
|
|
|
150
150
|
this.props.schema,
|
|
151
151
|
true
|
|
152
152
|
);
|
|
153
|
-
console.log("当前选中的数据ccc", currentCheckValue);
|
|
153
|
+
// console.log("当前选中的数据ccc", currentCheckValue);
|
|
154
154
|
this.dataRef = currentCheckValue;
|
|
155
155
|
setTimeout(() => {
|
|
156
156
|
super.changeValue(currentCheckValue);
|
|
@@ -165,7 +165,7 @@ export class ACheckDrag extends Viewer<ACheckDragState> {
|
|
|
165
165
|
</span>
|
|
166
166
|
<span
|
|
167
167
|
onBlurCapture={(e) => {
|
|
168
|
-
console.log("输入框失去焦点", this.dataRef);
|
|
168
|
+
// console.log("输入框失去焦点", this.dataRef);
|
|
169
169
|
setTimeout(() => {
|
|
170
170
|
super.changeValue(this.dataRef);
|
|
171
171
|
this.setState({
|
|
@@ -183,7 +183,7 @@ export class ACheckDrag extends Viewer<ACheckDragState> {
|
|
|
183
183
|
const matchEnum = this.checkFields.find(
|
|
184
184
|
(e) => e.value === str && e.remark !== "openOption"
|
|
185
185
|
);
|
|
186
|
-
console.log("输入框 afterChange", str, values, matchEnum);
|
|
186
|
+
// console.log("输入框 afterChange", str, values, matchEnum);
|
|
187
187
|
if (matchEnum) {
|
|
188
188
|
// 不能让用户输入某个枚举值
|
|
189
189
|
this._inputBoxValue = "";
|
|
@@ -212,11 +212,11 @@ export class ACheckDrag extends Viewer<ACheckDragState> {
|
|
|
212
212
|
this.checkFields = this.checkFields.map((e) =>
|
|
213
213
|
e.remark === "openOption" ? { ...e, value: str } : e
|
|
214
214
|
);
|
|
215
|
-
console.log("输入框数据", {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
});
|
|
215
|
+
// console.log("输入框数据", {
|
|
216
|
+
// values,
|
|
217
|
+
// checkFields: this.checkFields,
|
|
218
|
+
// dataRef: this.dataRef,
|
|
219
|
+
// });
|
|
220
220
|
MUtil.set(this.props.database, this.props.path, values);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
@@ -246,7 +246,7 @@ export class ACheckDrag extends Viewer<ACheckDragState> {
|
|
|
246
246
|
this.props.schema,
|
|
247
247
|
true
|
|
248
248
|
);
|
|
249
|
-
console.log("当前变化的 value", values, currentCheckValue);
|
|
249
|
+
// console.log("当前变化的 value", values, currentCheckValue);
|
|
250
250
|
const max = this.props.schema.max;
|
|
251
251
|
if (max > 0 && e.target.checked) {
|
|
252
252
|
const len = values ? values.length : 0;
|
|
@@ -279,7 +279,7 @@ export class ACheckDrag extends Viewer<ACheckDragState> {
|
|
|
279
279
|
|
|
280
280
|
// 定义更换数据源的方法
|
|
281
281
|
const changeOriginDataSource = (newData) => {
|
|
282
|
-
console.log("新数据", newData);
|
|
282
|
+
// console.log("新数据", newData);
|
|
283
283
|
// 更新排序后的选项数据
|
|
284
284
|
const sortedCheckFields = newData.map((item) => ({
|
|
285
285
|
...item,
|
|
@@ -296,7 +296,7 @@ export class ACheckDrag extends Viewer<ACheckDragState> {
|
|
|
296
296
|
const isHaveOpenOption = sortedCheckFields.filter(
|
|
297
297
|
(e) => e.remark === "openOption"
|
|
298
298
|
);
|
|
299
|
-
console.log("isHaveOpenOption", isHaveOpenOption);
|
|
299
|
+
// console.log("isHaveOpenOption", isHaveOpenOption);
|
|
300
300
|
newSchema.option = isHaveOpenOption
|
|
301
301
|
? sortedCheckFields?.filter((e) => e.remark !== "openOption")
|
|
302
302
|
: sortedCheckFields;
|
|
@@ -319,37 +319,43 @@ export class ACheckDrag extends Viewer<ACheckDragState> {
|
|
|
319
319
|
}, 0);
|
|
320
320
|
};
|
|
321
321
|
|
|
322
|
+
const sortList = (checkboxs ?? [])?.map((cpn, index) => {
|
|
323
|
+
let checkFieldsValue;
|
|
324
|
+
checkFieldsValue = this.checkFields[index]?.value;
|
|
325
|
+
const isOpenOp = this.checkFields[index]?.remark === "openOption";
|
|
326
|
+
if (isOpenOp) {
|
|
327
|
+
checkFieldsValue = this._inputBoxValue;
|
|
328
|
+
}
|
|
329
|
+
// console.log("DRAG: 实际传递进如 SortDrag的数据", {
|
|
330
|
+
// data,
|
|
331
|
+
// dataRef: this.dataRef,
|
|
332
|
+
// checkFields: this.checkFields,
|
|
333
|
+
// schema: this.props.database,
|
|
334
|
+
// isOpenOp,
|
|
335
|
+
// openValue: this._inputBoxValue,
|
|
336
|
+
// });
|
|
337
|
+
|
|
338
|
+
return {
|
|
339
|
+
isChecked: this.dataRef
|
|
340
|
+
? this.dataRef?.findIndex((e) => e === checkFieldsValue) !== -1
|
|
341
|
+
: false,
|
|
342
|
+
checkedIndex:
|
|
343
|
+
this.dataRef?.findIndex((e) => e === checkFieldsValue) + 1,
|
|
344
|
+
cpn,
|
|
345
|
+
id: "" + checkFieldsValue,
|
|
346
|
+
label: this.checkFields[index]?.label,
|
|
347
|
+
remark: this.checkFields[index]?.remark,
|
|
348
|
+
};
|
|
349
|
+
});
|
|
350
|
+
const finalSortList = sortList
|
|
351
|
+
.filter((item) => item.isChecked)
|
|
352
|
+
.sort((a, b) => a.checkedIndex - b.checkedIndex)
|
|
353
|
+
.concat(sortList.filter((item) => !item.isChecked));
|
|
322
354
|
return (
|
|
323
355
|
<SortDrag
|
|
356
|
+
key={MUtil.unique()}
|
|
324
357
|
changeOriginDataSource={changeOriginDataSource}
|
|
325
|
-
sortList={
|
|
326
|
-
let checkFieldsValue;
|
|
327
|
-
checkFieldsValue = this.checkFields[index]?.value;
|
|
328
|
-
const isOpenOp = this.checkFields[index]?.remark === "openOption";
|
|
329
|
-
if (isOpenOp) {
|
|
330
|
-
checkFieldsValue = this._inputBoxValue;
|
|
331
|
-
}
|
|
332
|
-
console.log("DRAG: 实际传递进如 SortDrag的数据", {
|
|
333
|
-
data,
|
|
334
|
-
dataRef: this.dataRef,
|
|
335
|
-
checkFields: this.checkFields,
|
|
336
|
-
schema: this.props.database,
|
|
337
|
-
isOpenOp,
|
|
338
|
-
openValue: this._inputBoxValue,
|
|
339
|
-
});
|
|
340
|
-
|
|
341
|
-
return {
|
|
342
|
-
isChecked: this.dataRef
|
|
343
|
-
? this.dataRef?.findIndex((e) => e === checkFieldsValue) !== -1
|
|
344
|
-
: false,
|
|
345
|
-
checkedIndex:
|
|
346
|
-
this.dataRef?.findIndex((e) => e === checkFieldsValue) + 1,
|
|
347
|
-
cpn,
|
|
348
|
-
id: "" + checkFieldsValue,
|
|
349
|
-
label: this.checkFields[index]?.label,
|
|
350
|
-
remark: this.checkFields[index]?.remark,
|
|
351
|
-
};
|
|
352
|
-
})}
|
|
358
|
+
sortList={finalSortList}
|
|
353
359
|
/>
|
|
354
360
|
);
|
|
355
361
|
}
|
|
@@ -21,7 +21,7 @@ type SortDragProps = {
|
|
|
21
21
|
|
|
22
22
|
const SortDrag: React.FC<SortDragProps> = memo((props) => {
|
|
23
23
|
const { sortList, changeOriginDataSource } = props;
|
|
24
|
-
const [items, setItems] = useState<SortDragProps["sortList"]>(
|
|
24
|
+
const [items, setItems] = useState<SortDragProps["sortList"]>(sortList);
|
|
25
25
|
|
|
26
26
|
// 记录当前拖拽的 item id
|
|
27
27
|
const [draggingId, setDraggingId] = useState<string | null>(null);
|
|
@@ -99,19 +99,6 @@ const SortDrag: React.FC<SortDragProps> = memo((props) => {
|
|
|
99
99
|
};
|
|
100
100
|
}, [items]);
|
|
101
101
|
|
|
102
|
-
useEffect(() => {
|
|
103
|
-
const checkedItems = sortList
|
|
104
|
-
.filter((item) => item.isChecked)
|
|
105
|
-
.sort((a, b) => a.checkedIndex - b.checkedIndex);
|
|
106
|
-
const unCheckedItems = sortList.filter((item) => !item.isChecked);
|
|
107
|
-
console.log("DRAG: 排序之后实际展示的数据", {
|
|
108
|
-
sortList,
|
|
109
|
-
checkedItems,
|
|
110
|
-
unCheckedItems,
|
|
111
|
-
});
|
|
112
|
-
setItems([...checkedItems, ...unCheckedItems]);
|
|
113
|
-
}, [sortList]);
|
|
114
|
-
|
|
115
102
|
return (
|
|
116
103
|
<div className="sortDrag">
|
|
117
104
|
{items.map((item, index) => {
|