77 lines
2.2 KiB
JavaScript
77 lines
2.2 KiB
JavaScript
import { analyzeAttrMobileForCard, translateAttributes } from '../../utils/usefulFn';
|
||
import { assert } from 'oak-domain/lib/utils/assert';
|
||
export default OakComponent({
|
||
isList: true,
|
||
properties: {
|
||
entity: '',
|
||
extraActions: [],
|
||
onAction: (() => { }),
|
||
disabledOp: false,
|
||
attributes: [],
|
||
data: [],
|
||
loading: false,
|
||
tablePagination: undefined,
|
||
rowSelection: undefined,
|
||
hideHeader: false,
|
||
disableSerialNumber: false, //是否禁用序号 默认启用
|
||
size: 'large',
|
||
scroll: undefined,
|
||
empty: undefined,
|
||
opWidth: undefined,
|
||
oakPath: undefined,
|
||
},
|
||
entity() {
|
||
return this.props.entity;
|
||
},
|
||
formData({ props }) {
|
||
const { converter } = this.state;
|
||
const { data } = props;
|
||
if (converter) {
|
||
const mobileData = converter(data);
|
||
return {
|
||
mobileData,
|
||
};
|
||
}
|
||
return {};
|
||
},
|
||
data: {
|
||
converter: (data) => [],
|
||
judgeAttributes: [],
|
||
},
|
||
listeners: {
|
||
data() {
|
||
this.reRender();
|
||
},
|
||
},
|
||
lifetimes: {
|
||
async ready() {
|
||
// 因为部分i18json数据请求较慢,会导致converter,columnDef解析出错
|
||
const { attributes, entity, data } = this.props;
|
||
const schema = this.features.cache.getSchema();
|
||
assert(!!entity, 'list属性entity不能为空');
|
||
const ttt = this.t.bind(this);
|
||
const converter = analyzeAttrMobileForCard(schema, entity, ttt, attributes);
|
||
const judgeAttributes = translateAttributes(schema, entity, attributes);
|
||
this.setState({
|
||
converter,
|
||
schema,
|
||
judgeAttributes,
|
||
});
|
||
},
|
||
},
|
||
methods: {
|
||
onActionMp(e) {
|
||
const { action, cascadeAction } = e.detail;
|
||
const { row } = e.currentTarget.dataset;
|
||
this.triggerEvent('onAction', {
|
||
record: row,
|
||
action,
|
||
cascadeAction,
|
||
});
|
||
},
|
||
getColor(attr, value) {
|
||
return this.features.style.getColor(this.props.entity, attr, value);
|
||
},
|
||
},
|
||
});
|