oak-pay-business/es/components/pay/list/index.js

136 lines
3.4 KiB
JavaScript

export default OakComponent({
entity: 'pay',
isList: true,
projection: {
id: 1,
applicationId: 1,
price: 1,
iState: 1,
paid: 1,
refunded: 1,
orderId: 1,
meta: 1,
depositId: 1,
entityId: 1,
entity: 1,
externalId: 1,
order: {
id: 1,
creatorId: 1,
},
creator: {
id: 1,
nickname: 1,
name: 1,
mobile$user: {
$entity: 'mobile',
data: {
id: 1,
ableState: 1,
mobile: 1,
},
filter: {
ableState: 'enabled',
},
indexFrom: 0,
count: 1,
}
},
phantom3: 1,
wpProduct: {
id: 1,
type: 1,
},
offlineAccount: {
id: 1,
type: 1,
}
},
filters: [
{
filter() {
// const applicationId = this.features.application.getApplicationId();
const systemId = this.features.application.getApplication()?.systemId;
return {
application: {
systemId,
}
};
}
}
],
sorters: [
{
sorter: {
$attr: {
$$createAt$$: 1,
},
$direction: 'desc',
}
}
],
formData({ data }) {
const offlines = this.features.cache.get('offlineAccount', {
data: {
id: 1,
type: 1,
channel: 1,
name: 1,
qrCode: 1,
},
filter: {
systemId: this.features.application.getApplication().systemId,
}
}).map(ele => {
const color = this.features.style.getColor('offlineAccount', 'type', ele.type);
return {
color,
...ele,
};
});
return {
offlines,
pays: data.map((ele) => {
const { creator } = ele;
const { nickname, name, mobile$user: mobiles } = creator;
const mobile = mobiles && mobiles[0]?.mobile;
return {
creatorName: name || nickname,
creatorMobile: mobile || '-',
...ele,
};
}),
oakExecutable: this.tryExecute(),
};
},
getTotal: 100,
actions: ['close', 'succeedPaying'],
methods: {
refreshOfflineAccounts() {
this.features.cache.refresh('offlineAccount', {
data: {
id: 1,
channel: 1,
name: 1,
type: 1,
qrCode: 1,
},
filter: {
systemId: this.features.application.getApplication().systemId,
}
});
},
},
lifetimes: {
ready() {
this.refreshOfflineAccounts();
},
},
features: [{
feature: 'application',
callback() {
this.refreshOfflineAccounts();
}
}]
});