list组件改动,attributes超过8个的才scroll
This commit is contained in:
parent
d683d2e709
commit
61d9e4cc8f
|
|
@ -51,7 +51,7 @@ function Render(props) {
|
|||
case 'Select': {
|
||||
var options2 = options.map(function (ele) { return ({
|
||||
label: typeof ele.value === 'boolean'
|
||||
? t("".concat(ele.value ? 'filter2:tip.yes' : 'tip.no'))
|
||||
? t("".concat(ele.value ? 'tip.yes' : 'tip.no'))
|
||||
: t("".concat(entityI18n, ":v.").concat(attrI18n, ".").concat(ele.value)),
|
||||
value: ele.value,
|
||||
}); });
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ function Render(props) {
|
|||
var _f = (0, react_1.useContext)(listPro_1.TableContext), tableAttributes = _f.tableAttributes, setSchema = _f.setSchema;
|
||||
// 为了i18更新时能够重新渲染
|
||||
var zhCNKeys = ((_b = (_a = i18n === null || i18n === void 0 ? void 0 : i18n.store) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.zh_CN) && Object.keys(i18n.store.data.zh_CN).length;
|
||||
// 如果字段过多,给table加上
|
||||
var showScroll = attributes && attributes.length >= 8;
|
||||
(0, react_1.useEffect)(function () {
|
||||
if (schema) {
|
||||
setSchema && setSchema(schema);
|
||||
|
|
@ -91,9 +93,10 @@ function Render(props) {
|
|||
setSelectedRowKeys(selectedRowKeys);
|
||||
(rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange) && (rowSelection === null || rowSelection === void 0 ? void 0 : rowSelection.onChange(selectedRowKeys, row, info));
|
||||
}
|
||||
}, loading: loading, dataSource: data, columns: tableColumns, pagination: tablePagination, scroll: {
|
||||
}, loading: loading, dataSource: data, columns: tableColumns, pagination: tablePagination, scroll: showScroll ? {
|
||||
scrollToFirstRowOnChange: true,
|
||||
x: 1200,
|
||||
}, onRow: function (record) {
|
||||
} : {}, onRow: function (record) {
|
||||
return {
|
||||
onClick: function () {
|
||||
var index = selectedRowKeys.findIndex(function (ele) { return ele === record.id; });
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ var assert_1 = tslib_1.__importDefault(require("assert"));
|
|||
var relation_1 = require("oak-domain/lib/store/relation");
|
||||
var lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
var dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
||||
var money_1 = require("oak-domain/lib/utils/money");
|
||||
var tableWidthMap = {
|
||||
1: 120,
|
||||
2: 200,
|
||||
|
|
@ -147,6 +148,9 @@ function getValue(data, path, entity, attr, attrType, t) {
|
|||
if (attrType === 'boolean' && typeof value === 'boolean') {
|
||||
value = t("common:".concat(String(value)));
|
||||
}
|
||||
if (attrType === 'money' && typeof value === 'number') {
|
||||
value = (0, money_1.ThousandCont)(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
exports.getValue = getValue;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ export default function Render<ED2 extends ED>(
|
|||
const options2 = options.map((ele) => ({
|
||||
label:
|
||||
typeof ele.value === 'boolean'
|
||||
? t(`${ele.value ? 'filter2:tip.yes' : 'tip.no'}`)
|
||||
? t(`${ele.value ? 'tip.yes' : 'tip.no'}`)
|
||||
: t(
|
||||
`${entityI18n as string}:v.${attrI18n}.${
|
||||
ele.value
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ export default function Render(
|
|||
const { tableAttributes, setSchema } = useContext(TableContext);
|
||||
// 为了i18更新时能够重新渲染
|
||||
const zhCNKeys = i18n?.store?.data?.zh_CN && Object.keys(i18n.store.data.zh_CN).length;
|
||||
|
||||
// 如果字段过多,给table加上
|
||||
const showScroll = attributes && attributes.length >= 8;
|
||||
useEffect(() => {
|
||||
if (schema) {
|
||||
setSchema && setSchema(schema);
|
||||
|
|
@ -150,9 +153,10 @@ export default function Render(
|
|||
dataSource={data}
|
||||
columns={tableColumns}
|
||||
pagination={tablePagination}
|
||||
scroll={{
|
||||
scroll={showScroll ? {
|
||||
scrollToFirstRowOnChange: true,
|
||||
x: 1200,
|
||||
}}
|
||||
} : {}}
|
||||
onRow={(record) => {
|
||||
return {
|
||||
onClick: () => {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import {
|
|||
} from 'oak-domain/lib/types/schema/DataTypes';
|
||||
import { ColorDict } from 'oak-domain/lib/types/Style';
|
||||
import dayjs from 'dayjs';
|
||||
import { ThousandCont } from 'oak-domain/lib/utils/money';
|
||||
|
||||
const tableWidthMap: Record<number, number> = {
|
||||
1: 120,
|
||||
|
|
@ -197,6 +198,9 @@ export function getValue<ED extends EntityDict & BaseEntityDict>(
|
|||
if (attrType === 'boolean' && typeof value === 'boolean') {
|
||||
value = t(`common:${String(value)}`);
|
||||
}
|
||||
if (attrType === 'money' && typeof value === 'number') {
|
||||
value = ThousandCont(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue