124 lines
3.2 KiB
JavaScript
124 lines
3.2 KiB
JavaScript
import { generateNewIdAsync } from "oak-domain/lib/utils/uuid";
|
|
export default OakComponent({
|
|
entity: 'shipServiceSystem',
|
|
isList: true,
|
|
actions: ['create', 'remove'],
|
|
projection: {
|
|
id: 1,
|
|
systemId: 1,
|
|
shipService: {
|
|
id: 1,
|
|
name: 1,
|
|
shipCompany: {
|
|
id: 1,
|
|
name: 1,
|
|
abbr: 1,
|
|
wechatMpName: 1,
|
|
}
|
|
},
|
|
},
|
|
formData({ data, legalActions, features }) {
|
|
const [system] = features.cache.get('system', {
|
|
data: {
|
|
id: 1,
|
|
name: 1,
|
|
},
|
|
filter: {
|
|
id: this.props.systemId,
|
|
}
|
|
});
|
|
const canCreate = legalActions?.includes('create');
|
|
return {
|
|
shipServiceSystems: data,
|
|
canCreate,
|
|
systemName: system.name,
|
|
};
|
|
},
|
|
filters: [
|
|
{
|
|
filter() {
|
|
const { systemId } = this.props;
|
|
return {
|
|
systemId,
|
|
};
|
|
}
|
|
}
|
|
],
|
|
sorters: [
|
|
{
|
|
sorter: {
|
|
$attr: {
|
|
$$createAt$$: 1,
|
|
},
|
|
$direction: 'desc',
|
|
}
|
|
}
|
|
],
|
|
properties: {
|
|
systemId: '',
|
|
},
|
|
pagination: {
|
|
currentPage: 1,
|
|
pageSize: 100,
|
|
},
|
|
getTotal: 100,
|
|
features: ['application'],
|
|
data: {
|
|
shipServices: [],
|
|
searchLoading: false,
|
|
},
|
|
methods: {
|
|
async addShipServices(shipServiceIds) {
|
|
const { systemId } = this.props;
|
|
await this.execute(undefined, undefined, undefined, await Promise.all(shipServiceIds.map(async (shipServiceId) => ({
|
|
entity: 'shipServiceSystem',
|
|
operation: {
|
|
id: await generateNewIdAsync(),
|
|
action: 'create',
|
|
data: {
|
|
id: await generateNewIdAsync(),
|
|
systemId,
|
|
shipServiceId,
|
|
}
|
|
}
|
|
}))));
|
|
},
|
|
async searchShipService(searchValue) {
|
|
const { systemId } = this.props;
|
|
this.setState({
|
|
searchLoading: true,
|
|
});
|
|
const filter = {
|
|
shipServiceSystem$shipService: {
|
|
'#sqp': 'not in',
|
|
systemId,
|
|
}
|
|
};
|
|
if (searchValue) {
|
|
filter.shipCompany = {
|
|
name: {
|
|
$startsWith: searchValue,
|
|
},
|
|
};
|
|
}
|
|
const { data: shipServices } = await this.features.cache.refresh('shipService', {
|
|
data: {
|
|
id: 1,
|
|
name: 1,
|
|
shipCompany: {
|
|
id: 1,
|
|
name: 1,
|
|
abbr: 1,
|
|
wechatMpName: 1,
|
|
},
|
|
},
|
|
filter,
|
|
});
|
|
this.setState({
|
|
shipServices,
|
|
searchLoading: false,
|
|
});
|
|
},
|
|
},
|
|
});
|