build的一些小问题
This commit is contained in:
parent
fde3fe5ef6
commit
9fc852541c
|
|
@ -0,0 +1,11 @@
|
||||||
|
/// <reference types="react" />
|
||||||
|
declare type Props = {
|
||||||
|
src: string;
|
||||||
|
alt?: string;
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
bordered?: boolean;
|
||||||
|
type?: 'fill' | 'contain' | 'cover' | 'none' | 'scale-down' | 'initial' | 'inherit';
|
||||||
|
};
|
||||||
|
declare function ImgBox(props: Props): JSX.Element;
|
||||||
|
export default ImgBox;
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
var tslib_1 = require("tslib");
|
||||||
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
||||||
|
var index_module_less_1 = tslib_1.__importDefault(require("./index.module.less"));
|
||||||
|
function ImgBox(props) {
|
||||||
|
var width = props.width, height = props.height, _a = props.bordered, bordered = _a === void 0 ? false : _a, _b = props.type, type = _b === void 0 ? 'contain' : _b, src = props.src, alt = props.alt;
|
||||||
|
if (bordered) {
|
||||||
|
return ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: index_module_less_1.default.imgBox }, { children: (0, jsx_runtime_1.jsx)("img", { width: 72 || width, height: 72 || height, src: src, style: {
|
||||||
|
objectFit: type,
|
||||||
|
borderRadius: 8,
|
||||||
|
}, alt: 'img' || alt }) })));
|
||||||
|
}
|
||||||
|
return ((0, jsx_runtime_1.jsx)("img", { width: 72 || width, height: 72 || height, src: src, style: {
|
||||||
|
objectFit: type,
|
||||||
|
}, alt: 'img' || alt }));
|
||||||
|
}
|
||||||
|
exports.default = ImgBox;
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
.imgBox {
|
||||||
|
padding: 4px;
|
||||||
|
border-radius: 8px;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
}
|
||||||
|
|
@ -41,7 +41,7 @@ exports.default = OakComponent({
|
||||||
lifetimes: {
|
lifetimes: {
|
||||||
ready: function () {
|
ready: function () {
|
||||||
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
||||||
var _a, attributes, entity, data, attributesMb, schema, colorDict, columnDef, converter;
|
var _a, attributes, entity, data, attributesMb, schema, colorDict, converter;
|
||||||
var _this = this;
|
var _this = this;
|
||||||
return tslib_1.__generator(this, function (_b) {
|
return tslib_1.__generator(this, function (_b) {
|
||||||
_a = this.props, attributes = _a.attributes, entity = _a.entity, data = _a.data, attributesMb = _a.attributesMb;
|
_a = this.props, attributes = _a.attributes, entity = _a.entity, data = _a.data, attributesMb = _a.attributesMb;
|
||||||
|
|
@ -49,13 +49,6 @@ exports.default = OakComponent({
|
||||||
colorDict = this.features.style.getColorDict();
|
colorDict = this.features.style.getColorDict();
|
||||||
(0, assert_1.default)(!!data, 'data不能为空');
|
(0, assert_1.default)(!!data, 'data不能为空');
|
||||||
(0, assert_1.default)(!!entity, 'list属性entity不能为空');
|
(0, assert_1.default)(!!entity, 'list属性entity不能为空');
|
||||||
if (attributes && attributes.length) {
|
|
||||||
columnDef = (0, usefulFn_1.analyzeAttrDefForTable)(schema, entity, attributes, function (k, params) { return _this.t(k, params); }, attributesMb).columnDef;
|
|
||||||
this.setState({
|
|
||||||
columns: columnDef,
|
|
||||||
colorDict: colorDict,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (attributesMb) {
|
if (attributesMb) {
|
||||||
converter = (0, usefulFn_1.analyzeAttrMobileForCard)(schema, entity, function (k, params) { return _this.t(k, params); }, attributesMb, colorDict);
|
converter = (0, usefulFn_1.analyzeAttrMobileForCard)(schema, entity, function (k, params) { return _this.t(k, params); }, attributesMb, colorDict);
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
@ -77,6 +70,6 @@ exports.default = OakComponent({
|
||||||
action: action,
|
action: action,
|
||||||
cascadeAction: cascadeAction,
|
cascadeAction: cascadeAction,
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,14 @@ import { WebComponentProps } from '../../types/Page';
|
||||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
import { ColorDict } from 'oak-domain/lib/types/Style';
|
import { ColorDict } from 'oak-domain/lib/types/Style';
|
||||||
import { StorageSchema } from 'oak-domain/lib/types/Storage';
|
import { StorageSchema } from 'oak-domain/lib/types/Storage';
|
||||||
import { ColumnDefProps, AttrRender, onActionFnDef } from '../../types/AbstractComponent';
|
import { OakAbsAttrDef, ColumnDefProps, AttrRender, onActionFnDef } from '../../types/AbstractComponent';
|
||||||
export default function Render(props: WebComponentProps<EntityDict & BaseEntityDict, keyof EntityDict, false, {
|
export default function Render(props: WebComponentProps<EntityDict & BaseEntityDict, keyof EntityDict, false, {
|
||||||
width: 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
width: 'xl' | 'lg' | 'md' | 'sm' | 'xs';
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
extraActions: string[];
|
extraActions: string[];
|
||||||
entity: string;
|
entity: string;
|
||||||
schema: StorageSchema<EntityDict & BaseEntityDict>;
|
schema: StorageSchema<EntityDict & BaseEntityDict>;
|
||||||
|
attributes: OakAbsAttrDef[];
|
||||||
columns: ColumnDefProps[];
|
columns: ColumnDefProps[];
|
||||||
mobileData: AttrRender[];
|
mobileData: AttrRender[];
|
||||||
data: any[];
|
data: any[];
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,22 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
||||||
var react_1 = require("react");
|
var react_1 = require("react");
|
||||||
var antd_1 = require("antd");
|
var antd_1 = require("antd");
|
||||||
var assert_1 = tslib_1.__importDefault(require("assert"));
|
var assert_1 = tslib_1.__importDefault(require("assert"));
|
||||||
var lodash_1 = require("oak-domain/lib/utils/lodash");
|
|
||||||
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
|
||||||
var actionBtn_1 = tslib_1.__importDefault(require("../actionBtn"));
|
var actionBtn_1 = tslib_1.__importDefault(require("../actionBtn"));
|
||||||
|
var usefulFn_1 = require("../../utils/usefulFn");
|
||||||
|
var imgBox_1 = tslib_1.__importDefault(require("../imgBox"));
|
||||||
|
function getDownload(file) {
|
||||||
|
var aLink = document.createElement('a');
|
||||||
|
fetch(file === null || file === void 0 ? void 0 : file.url)
|
||||||
|
.then(function (res) { return res.blob(); })
|
||||||
|
.then(function (blob) {
|
||||||
|
// 将链接地址字符内容转变成blob地址
|
||||||
|
aLink.href = URL.createObjectURL(blob);
|
||||||
|
aLink.download = file === null || file === void 0 ? void 0 : file.filename;
|
||||||
|
aLink.style.display = 'none';
|
||||||
|
document.body.appendChild(aLink);
|
||||||
|
aLink.click();
|
||||||
|
});
|
||||||
|
}
|
||||||
function RenderCell(props) {
|
function RenderCell(props) {
|
||||||
var value = props.value, type = props.type, color = props.color;
|
var value = props.value, type = props.type, color = props.color;
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
|
@ -17,6 +30,21 @@ function RenderCell(props) {
|
||||||
else if (type === 'tag') {
|
else if (type === 'tag') {
|
||||||
return ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: color }, { children: value })));
|
return ((0, jsx_runtime_1.jsx)(antd_1.Tag, tslib_1.__assign({ color: color }, { children: value })));
|
||||||
}
|
}
|
||||||
|
else if (type === 'img') {
|
||||||
|
if (value instanceof Array) {
|
||||||
|
return ((0, jsx_runtime_1.jsx)(antd_1.Space, { children: value.map(function (ele) { return ((0, jsx_runtime_1.jsx)(imgBox_1.default, { src: ele.url, width: 120, height: 70 })); }) }));
|
||||||
|
}
|
||||||
|
return ((0, jsx_runtime_1.jsx)(imgBox_1.default, { src: value.url, width: 120, height: 70 }));
|
||||||
|
}
|
||||||
|
else if (type === 'avatar') {
|
||||||
|
return ((0, jsx_runtime_1.jsx)(antd_1.Avatar, { src: value }));
|
||||||
|
}
|
||||||
|
else if (type === 'file') {
|
||||||
|
if (value instanceof Array) {
|
||||||
|
return ((0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ direction: "vertical" }, { children: value.map(function (ele) { return ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "dashed" /* icon={} */, onClick: function () { return getDownload(ele); } }, { children: ele.filename }))); }) })));
|
||||||
|
}
|
||||||
|
return ((0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "dashed" /* icon={} */, onClick: function () { return getDownload(value); } }, { children: value.filename })));
|
||||||
|
}
|
||||||
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: value }));
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: value }));
|
||||||
}
|
}
|
||||||
var sizeForWidth = {
|
var sizeForWidth = {
|
||||||
|
|
@ -38,33 +66,31 @@ function Render(props) {
|
||||||
var t = methods.t;
|
var t = methods.t;
|
||||||
var _a = tslib_1.__read((0, react_1.useState)([]), 2), selectedRowKeys = _a[0], setSelectedRowKeys = _a[1];
|
var _a = tslib_1.__read((0, react_1.useState)([]), 2), selectedRowKeys = _a[0], setSelectedRowKeys = _a[1];
|
||||||
var _b = tslib_1.__read((0, react_1.useState)([]), 2), tableColumns = _b[0], setTabelColumns = _b[1];
|
var _b = tslib_1.__read((0, react_1.useState)([]), 2), tableColumns = _b[0], setTabelColumns = _b[1];
|
||||||
var loading = oakData.loading, entity = oakData.entity, schema = oakData.schema, extraActions = oakData.extraActions, oakEntity = oakData.oakEntity, data = oakData.data, columns = oakData.columns, colorDict = oakData.colorDict, _c = oakData.disabledOp, disabledOp = _c === void 0 ? false : _c, handleClick = oakData.handleClick, tablePagination = oakData.tablePagination, onAction = oakData.onAction, rowSelection = oakData.rowSelection, width = oakData.width, scroll = oakData.scroll;
|
var loading = oakData.loading, entity = oakData.entity, schema = oakData.schema, extraActions = oakData.extraActions, oakEntity = oakData.oakEntity, data = oakData.data, columns = oakData.columns, colorDict = oakData.colorDict, _c = oakData.disabledOp, disabledOp = _c === void 0 ? false : _c, handleClick = oakData.handleClick, tablePagination = oakData.tablePagination, onAction = oakData.onAction, rowSelection = oakData.rowSelection, width = oakData.width, scroll = oakData.scroll, attributes = oakData.attributes;
|
||||||
(0, react_1.useEffect)(function () {
|
(0, react_1.useEffect)(function () {
|
||||||
var tableColumns = columns && columns.map(function (ele) {
|
var tableColumns = attributes && attributes.map(function (ele) {
|
||||||
|
var path = (0, usefulFn_1.getPath)(ele);
|
||||||
|
var _a = (0, usefulFn_1.resolvePath)(schema, entity, path), attrType = _a.attrType, attr = _a.attr, attribute = _a.attribute, entityI8n = _a.entity;
|
||||||
|
var title = (0, usefulFn_1.getLabel)(ele, entityI8n, attr, t);
|
||||||
|
var width = (0, usefulFn_1.getWidth)(ele, attrType, 'table');
|
||||||
|
var type = (0, usefulFn_1.getType)(ele, attrType);
|
||||||
var column = {
|
var column = {
|
||||||
dataIndex: ele.path,
|
key: path,
|
||||||
title: ele.title,
|
title: title,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: function (v, row) {
|
render: function (v, row) {
|
||||||
var _a, _b;
|
var _a, _b;
|
||||||
if (v && ele.type === 'text') {
|
var value = (0, usefulFn_1.getValue)(ele, row, path, entityI8n, attr, attrType, t);
|
||||||
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: v });
|
|
||||||
}
|
|
||||||
var value = (0, lodash_1.get)(row, ele.path);
|
|
||||||
var color = 'black';
|
var color = 'black';
|
||||||
if (ele.type === 'tag' && !!value) {
|
if (type === 'tag' && !!value) {
|
||||||
(0, assert_1.default)(!!((_b = (_a = colorDict === null || colorDict === void 0 ? void 0 : colorDict[ele.entity]) === null || _a === void 0 ? void 0 : _a[ele.attr]) === null || _b === void 0 ? void 0 : _b[value]), "".concat(entity, "\u5B9E\u4F53iState\u989C\u8272\u5B9A\u4E49\u7F3A\u5931"));
|
(0, assert_1.default)(!!((_b = (_a = colorDict === null || colorDict === void 0 ? void 0 : colorDict[entityI8n]) === null || _a === void 0 ? void 0 : _a[attr]) === null || _b === void 0 ? void 0 : _b[value]), "".concat(entity, "\u5B9E\u4F53iState\u989C\u8272\u5B9A\u4E49\u7F3A\u5931"));
|
||||||
color = colorDict[ele.entity][ele.attr][value];
|
color = colorDict[entityI8n][attr][value];
|
||||||
value = t("".concat(ele.entity, ":v.").concat(ele.attr, ".").concat(value));
|
|
||||||
}
|
}
|
||||||
if (ele.type === 'datetime' && !!value) {
|
return ((0, jsx_runtime_1.jsx)(RenderCell, { color: color, value: value, type: type }));
|
||||||
value = (0, dayjs_1.default)(value).format('YYYY-MM-DD HH:mm');
|
|
||||||
}
|
|
||||||
return ((0, jsx_runtime_1.jsx)(RenderCell, { color: color, value: value, type: ele.type }));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (ele.width) {
|
if (width) {
|
||||||
Object.assign(column, { width: ele.width });
|
Object.assign(column, { width: width });
|
||||||
}
|
}
|
||||||
return column;
|
return column;
|
||||||
});
|
});
|
||||||
|
|
@ -96,20 +122,22 @@ function Render(props) {
|
||||||
return {
|
return {
|
||||||
onClick: function () {
|
onClick: function () {
|
||||||
var index = selectedRowKeys.findIndex(function (ele) { return ele === record.id; });
|
var index = selectedRowKeys.findIndex(function (ele) { return ele === record.id; });
|
||||||
|
var keys = selectedRowKeys;
|
||||||
if ((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'checkbox') {
|
if ((rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.type) === 'checkbox') {
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
selectedRowKeys.splice(index, 1);
|
keys.splice(index, 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
selectedRowKeys.push(record.id);
|
keys.push(record.id);
|
||||||
}
|
}
|
||||||
setSelectedRowKeys(tslib_1.__spreadArray([], tslib_1.__read(selectedRowKeys), false));
|
setSelectedRowKeys(tslib_1.__spreadArray([], tslib_1.__read(selectedRowKeys), false));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
keys = [record.id];
|
||||||
setSelectedRowKeys([record.id]);
|
setSelectedRowKeys([record.id]);
|
||||||
}
|
}
|
||||||
var row = data.filter(function (ele) { return selectedRowKeys.includes(ele.id); });
|
var row = data.filter(function (ele) { return keys.includes(ele.id); });
|
||||||
(rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange) && (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange(selectedRowKeys, row, { type: 'all' }));
|
(rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange) && (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange(keys, row, { type: 'all' }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
} }));
|
} }));
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,34 @@ exports.default = OakComponent({
|
||||||
mode: String, // 'default' | 'card'
|
mode: String, // 'default' | 'card'
|
||||||
},
|
},
|
||||||
formData: function () {
|
formData: function () {
|
||||||
var data = this.props.data;
|
var _this = this;
|
||||||
|
var _a = this.props, data = _a.data, entity = _a.entity;
|
||||||
var transformer = this.state.transformer;
|
var transformer = this.state.transformer;
|
||||||
var renderData = transformer(data);
|
var renderData = transformer(data);
|
||||||
|
var renderData1 = renderData === null || renderData === void 0 ? void 0 : renderData.map(function (ele) {
|
||||||
|
var label = ele.label, attr = ele.attr, type = ele.type, required = ele.required;
|
||||||
|
var label2 = label;
|
||||||
|
if (!label2) {
|
||||||
|
if (type === 'ref') {
|
||||||
|
var refEntity = ele.entity;
|
||||||
|
if (attr === 'entityId') {
|
||||||
|
// 反指
|
||||||
|
label2 = _this.t("".concat(refEntity, ":name"));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
label2 = _this.t("".concat(entity, ":attr.").concat(attr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
label2 = _this.t("".concat(entity, ":attr.").concat(attr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Object.assign(ele, { label: label2 });
|
||||||
|
return ele;
|
||||||
|
});
|
||||||
return {
|
return {
|
||||||
renderData: renderData,
|
name: 'ddd',
|
||||||
|
renderData: renderData1,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
|
|
|
||||||
|
|
@ -97,14 +97,16 @@ function makeAttrInput(attrRender, onValueChange, t, label) {
|
||||||
}) })));
|
}) })));
|
||||||
}
|
}
|
||||||
case 'ref': {
|
case 'ref': {
|
||||||
return ((0, jsx_runtime_1.jsx)(refAttr_1.default, { multiple: false, entityId: value, pickerRender: attrRender, onChange: function (value) { onValueChange(value); } }));
|
return ((0, jsx_runtime_1.jsx)(refAttr_1.default, { multiple: false, entityId: value, pickerRender: attrRender, onChange: function (value) {
|
||||||
|
onValueChange(value);
|
||||||
|
} }));
|
||||||
}
|
}
|
||||||
case 'coordinate': {
|
case 'coordinate': {
|
||||||
var coordinate = (value || {}).coordinate;
|
var coordinate = (value || {}).coordinate;
|
||||||
var extra = attrRender.extra;
|
var extra = attrRender.extra;
|
||||||
var poiNameAttr_1 = (extra === null || extra === void 0 ? void 0 : extra.poiName) || 'poiName';
|
var poiNameAttr_1 = (extra === null || extra === void 0 ? void 0 : extra.poiName) || 'poiName';
|
||||||
var areaIdAttr_1 = (extra === null || extra === void 0 ? void 0 : extra.areaId) || 'areaId';
|
var areaIdAttr_1 = (extra === null || extra === void 0 ? void 0 : extra.areaId) || 'areaId';
|
||||||
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ width: '80vw', open: sl, closable: false, onCancel: function () { return setSl(false); }, okText: "\u786E\u8BA4", cancelText: "\u53D6\u6D88", okButtonProps: {
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Modal, tslib_1.__assign({ width: "80vw", open: sl, closable: false, onCancel: function () { return setSl(false); }, okText: "\u786E\u8BA4", cancelText: "\u53D6\u6D88", okButtonProps: {
|
||||||
disabled: !poi,
|
disabled: !poi,
|
||||||
}, onOk: function () {
|
}, onOk: function () {
|
||||||
var _a;
|
var _a;
|
||||||
|
|
@ -125,9 +127,7 @@ function makeAttrInput(attrRender, onValueChange, t, label) {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
} }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", size: 8 }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ align: "center" }, { children: (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "dashed", onClick: function () {
|
} }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, tslib_1.__assign({ direction: "vertical", size: 8 }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ align: "center" }, { children: (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "dashed", onClick: function () {
|
||||||
setSl(true);
|
setSl(true);
|
||||||
} }, { children: value
|
} }, { children: value ? '重选位置' : '选择位置' })) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: {
|
||||||
? '重选位置'
|
|
||||||
: '选择位置' })) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: {
|
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
|
@ -141,6 +141,7 @@ function makeAttrInput(attrRender, onValueChange, t, label) {
|
||||||
function render(props) {
|
function render(props) {
|
||||||
var _a = props.data, _b = _a.renderData, renderData = _b === void 0 ? [] : _b, helps = _a.helps, entity = _a.entity;
|
var _a = props.data, _b = _a.renderData, renderData = _b === void 0 ? [] : _b, helps = _a.helps, entity = _a.entity;
|
||||||
var _c = props.methods, update = _c.update, t = _c.t;
|
var _c = props.methods, update = _c.update, t = _c.t;
|
||||||
|
console.log(renderData);
|
||||||
return ((0, jsx_runtime_1.jsx)(antd_1.Form, tslib_1.__assign({ labelCol: { span: 4 }, layout: "horizontal", style: {
|
return ((0, jsx_runtime_1.jsx)(antd_1.Form, tslib_1.__assign({ labelCol: { span: 4 }, layout: "horizontal", style: {
|
||||||
margin: '0px auto',
|
margin: '0px auto',
|
||||||
maxWidth: '100%',
|
maxWidth: '100%',
|
||||||
|
|
@ -148,26 +149,25 @@ function render(props) {
|
||||||
// 因为i18n渲染机制的缘故,t必须放到这里来计算
|
// 因为i18n渲染机制的缘故,t必须放到这里来计算
|
||||||
var label = ele.label, attr = ele.attr, type = ele.type, required = ele.required;
|
var label = ele.label, attr = ele.attr, type = ele.type, required = ele.required;
|
||||||
var label2 = label;
|
var label2 = label;
|
||||||
if (!label2) {
|
// if (!label2) {
|
||||||
if (type === 'ref') {
|
// if (type === 'ref') {
|
||||||
var refEntity = ele.entity;
|
// const { entity: refEntity } =
|
||||||
if (attr === 'entityId') {
|
// ele as OakAbsRefAttrPickerRender<ED, keyof ED>;
|
||||||
// 反指
|
// if (attr === 'entityId') {
|
||||||
label2 = t("".concat(refEntity, ":name"));
|
// // 反指
|
||||||
}
|
// label2 = t(`${refEntity}:name`);
|
||||||
else {
|
// } else {
|
||||||
label2 = t("".concat(entity, ":attr.").concat(attr));
|
// label2 = t(`${entity}:attr.${attr}`);
|
||||||
}
|
// }
|
||||||
}
|
// } else {
|
||||||
else {
|
// label2 = t(`${entity}:attr.${attr}`);
|
||||||
label2 = t("".concat(entity, ":attr.").concat(attr));
|
// }
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
return ((0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: label2, rules: [
|
return ((0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ label: label2, rules: [
|
||||||
{
|
{
|
||||||
required: !!required,
|
required: !!required,
|
||||||
},
|
},
|
||||||
], help: helps && helps[attr] }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: makeAttrInput(ele, function (value, extra) {
|
], help: helps && helps[attr], name: required ? attr : '' }, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: makeAttrInput(ele, function (value, extra) {
|
||||||
var _a;
|
var _a;
|
||||||
var attr = ele.attr;
|
var attr = ele.attr;
|
||||||
update(tslib_1.__assign((_a = {}, _a[attr] = value, _a), extra));
|
update(tslib_1.__assign((_a = {}, _a[attr] = value, _a), extra));
|
||||||
|
|
|
||||||
|
|
@ -504,9 +504,6 @@ function translateListeners(listeners) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function createComponent(option, features) {
|
function createComponent(option, features) {
|
||||||
if (option.observers) {
|
|
||||||
console.error('observers即将废弃(已经没有效果),请使用listeners重写');
|
|
||||||
}
|
|
||||||
var entity = option.entity, data = option.data, properties = option.properties, methods = option.methods, wechatMp = option.wechatMp, lifetimes = option.lifetimes, listeners = option.listeners;
|
var entity = option.entity, data = option.data, properties = option.properties, methods = option.methods, wechatMp = option.wechatMp, lifetimes = option.lifetimes, listeners = option.listeners;
|
||||||
var _a = lifetimes || {}, attached = _a.attached, show = _a.show, hide = _a.hide, created = _a.created, detached = _a.detached, ready = _a.ready, moved = _a.moved, error = _a.error;
|
var _a = lifetimes || {}, attached = _a.attached, show = _a.show, hide = _a.hide, created = _a.created, detached = _a.detached, ready = _a.ready, moved = _a.moved, error = _a.error;
|
||||||
var _b = wechatMp || {}, options = _b.options, externalClasses = _b.externalClasses;
|
var _b = wechatMp || {}, options = _b.options, externalClasses = _b.externalClasses;
|
||||||
|
|
|
||||||
|
|
@ -428,9 +428,6 @@ function translateListeners(listeners) {
|
||||||
var DEFAULT_REACH_BOTTOM_DISTANCE = 50;
|
var DEFAULT_REACH_BOTTOM_DISTANCE = 50;
|
||||||
function createComponent(option, features) {
|
function createComponent(option, features) {
|
||||||
var _a = option, data = _a.data, methods = _a.methods, lifetimes = _a.lifetimes, getRender = _a.getRender, path = _a.path, listeners = _a.listeners;
|
var _a = option, data = _a.data, methods = _a.methods, lifetimes = _a.lifetimes, getRender = _a.getRender, path = _a.path, listeners = _a.listeners;
|
||||||
if (option.observers) {
|
|
||||||
console.error('observers即将废弃(已经没有效果),请使用listeners重写');
|
|
||||||
}
|
|
||||||
var fn = translateListeners(listeners).fn;
|
var fn = translateListeners(listeners).fn;
|
||||||
var OakComponentWrapper = /** @class */ (function (_super) {
|
var OakComponentWrapper = /** @class */ (function (_super) {
|
||||||
tslib_1.__extends(OakComponentWrapper, _super);
|
tslib_1.__extends(OakComponentWrapper, _super);
|
||||||
|
|
|
||||||
|
|
@ -52,24 +52,24 @@ export declare type RowWithActions<ED extends EntityDict & BaseEntityDict, T ext
|
||||||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
interface ComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends DataOption, TProperty extends PropertyOption> {
|
interface ComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends DataOption, TProperty extends PropertyOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> {
|
||||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => T);
|
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => T);
|
||||||
path?: string;
|
path?: string;
|
||||||
isList: IsList;
|
isList: IsList;
|
||||||
features?: (keyof (FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>))[];
|
features?: (keyof (FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>))[];
|
||||||
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => {
|
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => {
|
||||||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||||
};
|
};
|
||||||
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ActionDef<ED, T>[]);
|
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ActionDef<ED, T>[]);
|
||||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['data'] | undefined);
|
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['data'] | undefined);
|
||||||
append?: boolean;
|
append?: boolean;
|
||||||
pagination?: Pagination;
|
pagination?: Pagination;
|
||||||
filters?: Array<{
|
filters?: Array<{
|
||||||
filter: ED[T]['Selection']['filter'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['filter'] | undefined);
|
filter: ED[T]['Selection']['filter'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['filter'] | undefined);
|
||||||
'#name'?: string;
|
'#name'?: string;
|
||||||
}>;
|
}>;
|
||||||
sorters?: Array<{
|
sorters?: Array<{
|
||||||
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => NonNullable<ED[T]['Selection']['sorter']>[number]);
|
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => NonNullable<ED[T]['Selection']['sorter']>[number]);
|
||||||
'#name'?: string;
|
'#name'?: string;
|
||||||
}>;
|
}>;
|
||||||
formData?: (options: {
|
formData?: (options: {
|
||||||
|
|
@ -77,10 +77,11 @@ interface ComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyo
|
||||||
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD;
|
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD;
|
||||||
props: Partial<PropertyOptionToData<TProperty>>;
|
props: Partial<PropertyOptionToData<TProperty>>;
|
||||||
legalActions: ActionDef<ED, T>[];
|
legalActions: ActionDef<ED, T>[];
|
||||||
}) => FormedData & ThisType<ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList>>;
|
}) => FormedData;
|
||||||
ns?: T | T[];
|
ns?: T | T[];
|
||||||
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => TData) | TData;
|
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => TData) | TData;
|
||||||
properties?: TProperty;
|
properties?: TProperty;
|
||||||
|
methods?: TMethod;
|
||||||
}
|
}
|
||||||
export declare type MiniprogramStyleMethods = {
|
export declare type MiniprogramStyleMethods = {
|
||||||
animate(selector: string, keyFrames: WechatMiniprogram.Component.KeyFrame[], duration: number, callback?: () => void): void;
|
animate(selector: string, keyFrames: WechatMiniprogram.Component.KeyFrame[], duration: number, callback?: () => void): void;
|
||||||
|
|
@ -109,8 +110,7 @@ export declare type ComponentFullThisType<ED extends EntityDict & BaseEntityDict
|
||||||
setState: (data: Partial<OakComponentData<ED, T>>, callback?: () => void) => void;
|
setState: (data: Partial<OakComponentData<ED, T>>, callback?: () => void) => void;
|
||||||
triggerEvent: <DetailType = any>(name: string, detail?: DetailType, options?: WechatMiniprogram.Component.TriggerEventOption) => void;
|
triggerEvent: <DetailType = any>(name: string, detail?: DetailType, options?: WechatMiniprogram.Component.TriggerEventOption) => void;
|
||||||
} & OakCommonComponentMethods<ED, T> & OakListComponentMethods<ED, T> & OakSingleComponentMethods<ED, T>;
|
} & OakCommonComponentMethods<ED, T> & OakListComponentMethods<ED, T> & OakSingleComponentMethods<ED, T>;
|
||||||
export declare type OakComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends Record<string, any>, TProperty extends PropertyOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = ComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty> & Partial<{
|
export declare type OakComponentOption<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>, FormedData extends Record<string, any>, IsList extends boolean, TData extends Record<string, any>, TProperty extends PropertyOption, TMethod extends Record<string, Function>, EMethod extends Record<string, Function> = {}> = ComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod> & Partial<{
|
||||||
methods: TMethod;
|
|
||||||
lifetimes: {
|
lifetimes: {
|
||||||
created?(): void;
|
created?(): void;
|
||||||
attached?(): void;
|
attached?(): void;
|
||||||
|
|
@ -121,8 +121,7 @@ export declare type OakComponentOption<ED extends EntityDict & BaseEntityDict, T
|
||||||
show?(): void;
|
show?(): void;
|
||||||
hide?(): void;
|
hide?(): void;
|
||||||
};
|
};
|
||||||
observers: Record<string, (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod>, ...args: any[]) => any>;
|
listeners: Record<string, (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
||||||
listeners: Record<string, (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
|
||||||
}> & Partial<{
|
}> & Partial<{
|
||||||
wechatMp: {
|
wechatMp: {
|
||||||
externalClasses?: string[];
|
externalClasses?: string[];
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
import { EntityDict } from 'oak-domain/lib/types';
|
import { EntityDict } from 'oak-domain/lib/types';
|
||||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||||
import { StorageSchema, Attribute } from 'oak-domain/lib/types';
|
import { StorageSchema, Attribute } from 'oak-domain/lib/types';
|
||||||
import { OakAbsAttrDef, CardDef, DataTransformer, ColumnDefProps, OakAbsAttrUpsertDef, AttrUpsertRender } from '../types/AbstractComponent';
|
import { OakAbsAttrDef, CardDef, DataTransformer, OakAbsAttrUpsertDef, AttrUpsertRender } from '../types/AbstractComponent';
|
||||||
import { DataType } from 'oak-domain/lib/types/schema/DataTypes';
|
import { DataType } from 'oak-domain/lib/types/schema/DataTypes';
|
||||||
import { ColorDict } from 'oak-domain/lib/types/Style';
|
import { ColorDict } from 'oak-domain/lib/types/Style';
|
||||||
export declare function getAttributes(attributes: Record<string, Attribute>): Record<string, Attribute>;
|
export declare function getAttributes(attributes: Record<string, Attribute>): Record<string, Attribute>;
|
||||||
|
|
@ -12,11 +12,13 @@ export declare function resolvePath<ED extends EntityDict & BaseEntityDict>(data
|
||||||
attrType: DataType | "ref";
|
attrType: DataType | "ref";
|
||||||
attribute: Attribute;
|
attribute: Attribute;
|
||||||
};
|
};
|
||||||
|
export declare function getPath(attribute: OakAbsAttrDef): string;
|
||||||
|
export declare function getLabel<ED extends EntityDict & BaseEntityDict>(attribute: OakAbsAttrDef, entity: keyof ED, attr: string, t: (k: string, params?: object) => string): string;
|
||||||
|
export declare function getWidth(attribute: OakAbsAttrDef, attrType: string, useFor: 'table' | 'other'): number | undefined;
|
||||||
|
export declare function getValue<ED extends EntityDict & BaseEntityDict>(attribute: OakAbsAttrDef, data: any, path: string, entity: keyof ED, attr: string, attrType: string, t: (k: string, params?: object) => string): any;
|
||||||
|
export declare function getType(attribute: OakAbsAttrDef, attrType: string): string | undefined;
|
||||||
export declare function makeDataTransformer<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, attrDefs: OakAbsAttrDef[], colorDict?: ColorDict<ED>): DataTransformer;
|
export declare function makeDataTransformer<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, attrDefs: OakAbsAttrDef[], colorDict?: ColorDict<ED>): DataTransformer;
|
||||||
export declare function analyzeDataUpsertTransformer<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, attrUpsertDefs: OakAbsAttrUpsertDef<ED>[]): (data: any) => AttrUpsertRender<ED>[];
|
export declare function analyzeDataUpsertTransformer<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, attrUpsertDefs: OakAbsAttrUpsertDef<ED>[]): (data: any) => AttrUpsertRender<ED>[];
|
||||||
export declare function analyzeAttrDefForTable<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, attrDefs: OakAbsAttrDef[], t: (k: string, params?: object) => string, mobileAttrDef?: CardDef, colorDict?: ColorDict<ED>): {
|
|
||||||
columnDef: ColumnDefProps[];
|
|
||||||
};
|
|
||||||
export declare function analyzeAttrMobileForCard<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, t: (k: string, params?: object) => string, mobileAttrDef: CardDef, colorDict: ColorDict<ED>): (data: any[]) => {
|
export declare function analyzeAttrMobileForCard<ED extends EntityDict & BaseEntityDict>(dataSchema: StorageSchema<ED>, entity: string, t: (k: string, params?: object) => string, mobileAttrDef: CardDef, colorDict: ColorDict<ED>): (data: any[]) => {
|
||||||
title: string;
|
title: string;
|
||||||
rows: {
|
rows: {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.analyzeAttrMobileForCard = exports.analyzeAttrDefForTable = exports.analyzeDataUpsertTransformer = exports.makeDataTransformer = exports.resolvePath = exports.getAttributes = void 0;
|
exports.analyzeAttrMobileForCard = exports.analyzeDataUpsertTransformer = exports.makeDataTransformer = exports.getType = exports.getValue = exports.getWidth = exports.getLabel = exports.getPath = exports.resolvePath = exports.getAttributes = void 0;
|
||||||
var tslib_1 = require("tslib");
|
var tslib_1 = require("tslib");
|
||||||
var assert_1 = tslib_1.__importDefault(require("assert"));
|
var assert_1 = tslib_1.__importDefault(require("assert"));
|
||||||
var relation_1 = require("oak-domain/lib/store/relation");
|
var relation_1 = require("oak-domain/lib/store/relation");
|
||||||
|
|
@ -86,6 +86,7 @@ function getPath(attribute) {
|
||||||
}
|
}
|
||||||
return attribute.path;
|
return attribute.path;
|
||||||
}
|
}
|
||||||
|
exports.getPath = getPath;
|
||||||
function getLabel(attribute, entity, attr, t) {
|
function getLabel(attribute, entity, attr, t) {
|
||||||
var label = t("".concat(entity, ":attr.").concat(attr));
|
var label = t("".concat(entity, ":attr.").concat(attr));
|
||||||
if (attr === '$$createAt$$' ||
|
if (attr === '$$createAt$$' ||
|
||||||
|
|
@ -98,6 +99,7 @@ function getLabel(attribute, entity, attr, t) {
|
||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
exports.getLabel = getLabel;
|
||||||
// 目前width属性可以是undefined,只有特殊type或用户自定义才有值,这样其余attr属性可以自适应
|
// 目前width属性可以是undefined,只有特殊type或用户自定义才有值,这样其余attr属性可以自适应
|
||||||
function getWidth(attribute, attrType, useFor) {
|
function getWidth(attribute, attrType, useFor) {
|
||||||
var width;
|
var width;
|
||||||
|
|
@ -112,6 +114,7 @@ function getWidth(attribute, attrType, useFor) {
|
||||||
}
|
}
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
exports.getWidth = getWidth;
|
||||||
function getValue(attribute, data, path, entity, attr, attrType, t) {
|
function getValue(attribute, data, path, entity, attr, attrType, t) {
|
||||||
var value = (0, lodash_1.get)(data, path);
|
var value = (0, lodash_1.get)(data, path);
|
||||||
// 枚举类型还要通过i18转一下中文
|
// 枚举类型还要通过i18转一下中文
|
||||||
|
|
@ -127,19 +130,20 @@ function getValue(attribute, data, path, entity, attr, attrType, t) {
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
exports.getValue = getValue;
|
||||||
function getType(attribute, attrType) {
|
function getType(attribute, attrType) {
|
||||||
var type = 'text';
|
|
||||||
if (attrType === 'enum') {
|
if (attrType === 'enum') {
|
||||||
type = 'tag';
|
return 'tag';
|
||||||
}
|
}
|
||||||
if (attrType === 'datetime') {
|
if (attrType === 'datetime') {
|
||||||
type = 'datetime';
|
return 'datetime';
|
||||||
}
|
}
|
||||||
if (isAttrbuteType(attribute).type) {
|
if (isAttrbuteType(attribute).type) {
|
||||||
type = isAttrbuteType(attrType).type;
|
return isAttrbuteType(attrType).type;
|
||||||
}
|
}
|
||||||
return type;
|
return attrType;
|
||||||
}
|
}
|
||||||
|
exports.getType = getType;
|
||||||
function getLabelI18(dataSchema, entity, path, t) {
|
function getLabelI18(dataSchema, entity, path, t) {
|
||||||
var _a = resolvePath(dataSchema, entity, path), attr = _a.attr, entityI8n = _a.entity;
|
var _a = resolvePath(dataSchema, entity, path), attr = _a.attr, entityI8n = _a.entity;
|
||||||
return t("".concat(entityI8n, ":attr.").concat(attr));
|
return t("".concat(entityI8n, ":attr.").concat(attr));
|
||||||
|
|
@ -247,28 +251,6 @@ function analyzeDataUpsertTransformer(dataSchema, entity, attrUpsertDefs) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
exports.analyzeDataUpsertTransformer = analyzeDataUpsertTransformer;
|
exports.analyzeDataUpsertTransformer = analyzeDataUpsertTransformer;
|
||||||
function analyzeAttrDefForTable(dataSchema, entity, attrDefs, t, mobileAttrDef, colorDict) {
|
|
||||||
// web使用
|
|
||||||
var columnDef = attrDefs.map(function (ele) {
|
|
||||||
var path = getPath(ele);
|
|
||||||
var _a = resolvePath(dataSchema, entity, path), attrType = _a.attrType, attr = _a.attr, attribute = _a.attribute, entityI8n = _a.entity;
|
|
||||||
var title = getLabel(ele, entity, attr, t);
|
|
||||||
var width = getWidth(ele, attrType, 'table');
|
|
||||||
var type = getType(ele, attrType);
|
|
||||||
return {
|
|
||||||
title: title,
|
|
||||||
width: width,
|
|
||||||
type: type,
|
|
||||||
path: path,
|
|
||||||
entity: entityI8n,
|
|
||||||
attr: attr,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
columnDef: columnDef,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
exports.analyzeAttrDefForTable = analyzeAttrDefForTable;
|
|
||||||
function analyzeAttrMobileForCard(dataSchema, entity, t, mobileAttrDef, colorDict) {
|
function analyzeAttrMobileForCard(dataSchema, entity, t, mobileAttrDef, colorDict) {
|
||||||
return function (data) {
|
return function (data) {
|
||||||
// 遍历用户传入的数据源
|
// 遍历用户传入的数据源
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ function getDownload(file: { filename: string; url: string }) {
|
||||||
document.body.appendChild(aLink);
|
document.body.appendChild(aLink);
|
||||||
aLink.click();
|
aLink.click();
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
type RenderCellProps = {
|
type RenderCellProps = {
|
||||||
value: any;
|
value: any;
|
||||||
|
|
@ -76,7 +76,7 @@ function RenderCell(props: RenderCellProps) {
|
||||||
return (
|
return (
|
||||||
<Space direction="vertical">
|
<Space direction="vertical">
|
||||||
{value.map((ele) => (
|
{value.map((ele) => (
|
||||||
<Button type="dashed" icon={} onClick={() => getDownload(ele)}>
|
<Button type="dashed" /* icon={} */ onClick={() => getDownload(ele)}>
|
||||||
{ele.filename}
|
{ele.filename}
|
||||||
</Button>
|
</Button>
|
||||||
))}
|
))}
|
||||||
|
|
@ -84,7 +84,7 @@ function RenderCell(props: RenderCellProps) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Button type="dashed" icon={} onClick={() => getDownload(value)}>
|
<Button type="dashed" /* icon={} */onClick={() => getDownload(value)}>
|
||||||
{value.filename}
|
{value.filename}
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ export default OakComponent({
|
||||||
return ele;
|
return ele;
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
|
name: 'ddd',
|
||||||
renderData: renderData1,
|
renderData: renderData1,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -731,10 +731,6 @@ export function createComponent<
|
||||||
>,
|
>,
|
||||||
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD,
|
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD,
|
||||||
) {
|
) {
|
||||||
if (option.observers) {
|
|
||||||
console.error('observers即将废弃(已经没有效果),请使用listeners重写');
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
entity,
|
entity,
|
||||||
data,
|
data,
|
||||||
|
|
|
||||||
|
|
@ -693,10 +693,6 @@ export function createComponent<
|
||||||
getRender: () => React.ComponentType<any>;
|
getRender: () => React.ComponentType<any>;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (option.observers) {
|
|
||||||
console.error('observers即将废弃(已经没有效果),请使用listeners重写');
|
|
||||||
}
|
|
||||||
|
|
||||||
const { fn } = translateListeners(listeners);
|
const { fn } = translateListeners(listeners);
|
||||||
class OakComponentWrapper extends OakComponentBase<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod> {
|
class OakComponentWrapper extends OakComponentBase<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod> {
|
||||||
features = features;
|
features = features;
|
||||||
|
|
|
||||||
|
|
@ -114,24 +114,26 @@ interface ComponentOption<
|
||||||
IsList extends boolean,
|
IsList extends boolean,
|
||||||
TData extends DataOption,
|
TData extends DataOption,
|
||||||
TProperty extends PropertyOption,
|
TProperty extends PropertyOption,
|
||||||
|
TMethod extends Record<string, Function>,
|
||||||
|
EMethod extends Record<string, Function> = {},
|
||||||
> {
|
> {
|
||||||
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => T);
|
entity?: T | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => T);
|
||||||
path?: string;
|
path?: string;
|
||||||
isList: IsList;
|
isList: IsList;
|
||||||
features?: (keyof (FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>))[];
|
features?: (keyof (FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>))[];
|
||||||
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => {
|
cascadeActions?: (this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => {
|
||||||
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
[K in keyof ED[T]['Schema']]?: ActionDef<ED, keyof ED>[];
|
||||||
},
|
},
|
||||||
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ActionDef<ED, T>[]);
|
actions?: ActionDef<ED, T>[] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ActionDef<ED, T>[]);
|
||||||
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['data'] | undefined);
|
projection?: ED[T]['Selection']['data'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['data'] | undefined);
|
||||||
append?: boolean;
|
append?: boolean;
|
||||||
pagination?: Pagination;
|
pagination?: Pagination;
|
||||||
filters?: Array<{
|
filters?: Array<{
|
||||||
filter: ED[T]['Selection']['filter'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => ED[T]['Selection']['filter'] | undefined);
|
filter: ED[T]['Selection']['filter'] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => ED[T]['Selection']['filter'] | undefined);
|
||||||
'#name'?: string;
|
'#name'?: string;
|
||||||
}>;
|
}>;
|
||||||
sorters?: Array<{
|
sorters?: Array<{
|
||||||
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => NonNullable<ED[T]['Selection']['sorter']>[number]);
|
sorter: NonNullable<ED[T]['Selection']['sorter']>[number] | ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => NonNullable<ED[T]['Selection']['sorter']>[number]);
|
||||||
'#name'?: string;
|
'#name'?: string;
|
||||||
}>;
|
}>;
|
||||||
formData?: (options: {
|
formData?: (options: {
|
||||||
|
|
@ -139,10 +141,11 @@ interface ComponentOption<
|
||||||
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD;
|
features: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>> & FD;
|
||||||
props: Partial<PropertyOptionToData<TProperty>>;
|
props: Partial<PropertyOptionToData<TProperty>>;
|
||||||
legalActions: ActionDef<ED, T>[];
|
legalActions: ActionDef<ED, T>[];
|
||||||
}) => FormedData & ThisType<ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList>>;
|
}) => FormedData;
|
||||||
ns?: T | T[];
|
ns?: T | T[];
|
||||||
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty>) => TData) | TData;
|
data?: ((this: ComponentPublicThisType<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod>) => TData) | TData;
|
||||||
properties?: TProperty;
|
properties?: TProperty;
|
||||||
|
methods?: TMethod;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type MiniprogramStyleMethods = {
|
export type MiniprogramStyleMethods = {
|
||||||
|
|
@ -193,7 +196,7 @@ export type ComponentPublicThisType<
|
||||||
TData extends Record<string, any> = {},
|
TData extends Record<string, any> = {},
|
||||||
TProperty extends PropertyOption = {},
|
TProperty extends PropertyOption = {},
|
||||||
TMethod extends MethodOption = {},
|
TMethod extends MethodOption = {},
|
||||||
EMethod extends Record<string, Function> = {}
|
EMethod extends Record<string, Function> = {},
|
||||||
> = {
|
> = {
|
||||||
subscribed: Array<() => void>;
|
subscribed: Array<() => void>;
|
||||||
features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||||
|
|
@ -244,10 +247,9 @@ export type OakComponentOption<
|
||||||
TData extends Record<string, any>,
|
TData extends Record<string, any>,
|
||||||
TProperty extends PropertyOption,
|
TProperty extends PropertyOption,
|
||||||
TMethod extends Record<string, Function>,
|
TMethod extends Record<string, Function>,
|
||||||
EMethod extends Record<string, Function> = {}
|
EMethod extends Record<string, Function> = {},
|
||||||
> = ComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty> &
|
> = ComponentOption<ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod> &
|
||||||
Partial<{
|
Partial<{
|
||||||
methods: TMethod;
|
|
||||||
lifetimes: {
|
lifetimes: {
|
||||||
created?(): void;
|
created?(): void;
|
||||||
attached?(): void;
|
attached?(): void;
|
||||||
|
|
@ -258,11 +260,8 @@ export type OakComponentOption<
|
||||||
show?(): void;
|
show?(): void;
|
||||||
hide?(): void;
|
hide?(): void;
|
||||||
};
|
};
|
||||||
observers: Record<string, (this: ComponentPublicThisType<
|
|
||||||
ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod
|
|
||||||
>, ...args: any[]) => any>; // 待废弃
|
|
||||||
listeners: Record<string, (this: ComponentPublicThisType<
|
listeners: Record<string, (this: ComponentPublicThisType<
|
||||||
ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod
|
ED, T, Cxt, FrontCxt, AD, FD, FormedData, IsList, TData, TProperty, TMethod, EMethod
|
||||||
>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
>, prev: Record<string, any>, next: Record<string, any>) => void>;
|
||||||
}> &
|
}> &
|
||||||
Partial<{
|
Partial<{
|
||||||
|
|
@ -308,74 +307,74 @@ export type OakNavigateToParameters<ED extends EntityDict & BaseEntityDict, T ex
|
||||||
export type OakCommonComponentMethods<
|
export type OakCommonComponentMethods<
|
||||||
ED extends EntityDict & BaseEntityDict,
|
ED extends EntityDict & BaseEntityDict,
|
||||||
T extends keyof ED
|
T extends keyof ED
|
||||||
> = {
|
> = {
|
||||||
setDisablePulldownRefresh: (able: boolean) => void;
|
setDisablePulldownRefresh: (able: boolean) => void;
|
||||||
sub: (type: string, callback: Function) => void;
|
sub: (type: string, callback: Function) => void;
|
||||||
unsub: (type: string, callback: Function) => void;
|
unsub: (type: string, callback: Function) => void;
|
||||||
pub: (type: string, options?: any) => void;
|
pub: (type: string, options?: any) => void;
|
||||||
unsubAll: (type: string) => void;
|
unsubAll: (type: string) => void;
|
||||||
save: (key: string, item: any) => void;
|
save: (key: string, item: any) => void;
|
||||||
load: (key: string) => any;
|
load: (key: string) => any;
|
||||||
clear: () => void;
|
clear: () => void;
|
||||||
resolveInput: <K extends string>(
|
resolveInput: <K extends string>(
|
||||||
input: any,
|
input: any,
|
||||||
keys?: K[]
|
keys?: K[]
|
||||||
) => { dataset?: Record<string, any>; value?: string } & {
|
) => { dataset?: Record<string, any>; value?: string } & {
|
||||||
[k in K]?: any;
|
[k in K]?: any;
|
||||||
};
|
};
|
||||||
setNotification: (data: NotificationProps) => void;
|
setNotification: (data: NotificationProps) => void;
|
||||||
consumeNotification: () => NotificationProps | undefined;
|
consumeNotification: () => NotificationProps | undefined;
|
||||||
setMessage: (data: MessageProps) => void;
|
setMessage: (data: MessageProps) => void;
|
||||||
consumeMessage: () => MessageProps | undefined;
|
consumeMessage: () => MessageProps | undefined;
|
||||||
reRender: (extra?: Record<string, any>) => void;
|
reRender: (extra?: Record<string, any>) => void;
|
||||||
getFreshValue: (
|
getFreshValue: (
|
||||||
path?: string
|
path?: string
|
||||||
) =>
|
) =>
|
||||||
| Partial<ED[keyof ED]['Schema']>[]
|
| Partial<ED[keyof ED]['Schema']>[]
|
||||||
| Partial<ED[keyof ED]['Schema']>
|
| Partial<ED[keyof ED]['Schema']>
|
||||||
| undefined;
|
| undefined;
|
||||||
navigateTo: <T2 extends keyof ED>(
|
navigateTo: <T2 extends keyof ED>(
|
||||||
options: { url: string } & OakNavigateToParameters<ED, T2>,
|
options: { url: string } & OakNavigateToParameters<ED, T2>,
|
||||||
state?: Record<string, any>,
|
state?: Record<string, any>,
|
||||||
disableNamespace?: boolean
|
disableNamespace?: boolean
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
navigateBack: (delta?: number) => Promise<void>;
|
navigateBack: (delta?: number) => Promise<void>;
|
||||||
redirectTo: <T2 extends keyof ED>(
|
redirectTo: <T2 extends keyof ED>(
|
||||||
options: Parameters<typeof wx.redirectTo>[0] &
|
options: Parameters<typeof wx.redirectTo>[0] &
|
||||||
OakNavigateToParameters<ED, T2>,
|
OakNavigateToParameters<ED, T2>,
|
||||||
state?: Record<string, any>,
|
state?: Record<string, any>,
|
||||||
disableNamespace?: boolean
|
disableNamespace?: boolean
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
switchTab: <T2 extends keyof ED>(
|
switchTab: <T2 extends keyof ED>(
|
||||||
options: Parameters<typeof wx.switchTab>[0] &
|
options: Parameters<typeof wx.switchTab>[0] &
|
||||||
OakNavigateToParameters<ED, T2>,
|
OakNavigateToParameters<ED, T2>,
|
||||||
state?: Record<string, any>,
|
state?: Record<string, any>,
|
||||||
disableNamespace?: boolean
|
disableNamespace?: boolean
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
// setProps: (props: Record<string, any>, usingState?: true) => void;
|
// setProps: (props: Record<string, any>, usingState?: true) => void;
|
||||||
clean: (path?: string) => void;
|
clean: (path?: string) => void;
|
||||||
|
|
||||||
t(key: string, params?: object): string;
|
t(key: string, params?: object): string;
|
||||||
execute: (
|
execute: (
|
||||||
action?: ED[T]['Action'],
|
action?: ED[T]['Action'],
|
||||||
messageProps?: boolean | MessageProps
|
messageProps?: boolean | MessageProps
|
||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
checkOperation: (
|
checkOperation: (
|
||||||
entity: T,
|
entity: T,
|
||||||
action: ED[T]['Action'],
|
action: ED[T]['Action'],
|
||||||
data?: ED[T]['Update']['data'],
|
data?: ED[T]['Update']['data'],
|
||||||
filter?: ED[T]['Update']['filter'],
|
filter?: ED[T]['Update']['filter'],
|
||||||
checkerTypes?: CheckerType[]
|
checkerTypes?: CheckerType[]
|
||||||
) => boolean;
|
) => boolean;
|
||||||
tryExecute: (path?: string) => boolean | Error;
|
tryExecute: (path?: string) => boolean | Error;
|
||||||
getOperations: (
|
getOperations: (
|
||||||
path?: string
|
path?: string
|
||||||
) => { operation: ED[T]['Operation']; entity: T }[] | undefined;
|
) => { operation: ED[T]['Operation']; entity: T }[] | undefined;
|
||||||
refresh: () => Promise<void>;
|
refresh: () => Promise<void>;
|
||||||
aggregate: (
|
aggregate: (
|
||||||
aggregation: ED[T]['Aggregation']
|
aggregation: ED[T]['Aggregation']
|
||||||
) => Promise<AggregationResult<ED[T]['Schema']>>;
|
) => Promise<AggregationResult<ED[T]['Schema']>>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type OakSingleComponentMethods<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
export type OakSingleComponentMethods<ED extends EntityDict & BaseEntityDict, T extends keyof ED> = {
|
||||||
setId: (id: string) => void;
|
setId: (id: string) => void;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue