Authored by zhangwenxue

feat(finances/invoice): send logisticsCompanyName, sync logisticsCompanyName to formItem

... ... @@ -118,12 +118,29 @@ export default {
created() {
this.invoiceAPI = new InvoiceService();
this.tradeAPI = new TradeService();
if (this.expressList.length === 0) {
this.tradeAPI.allotExpressCompList().then(data => {
this.expressList = data;
});
// create expressId2Name map
const ExpressId2Name = data.reduce((acc, item) => {
acc[item.id] = item.companyName;
return acc;
}, {});
this.$watch(
'formItem.logisticsId',
newVal => {
if (newVal === '' || newVal == null) {
this.formItem.logisticsCompanyName = '';
} else {
this.formItem.logisticsCompanyName = ExpressId2Name[newVal] || '';
}
},
{
immediate: true,
}
);
});
},
methods: {
setTitle(invoice) {
if (invoice.status === InvoiceStatusName2Id.UNOPEN) {
... ... @@ -141,6 +158,7 @@ export default {
pdfUrl: null,
logisticsId: null,
expressNumber: null,
logisticsCompanyName: null,
logisticsSwitch: this.LOGISTICS_YES,
...invoice,
};
... ... @@ -241,12 +259,11 @@ export default {
'pdfUrl',
'type',
'logisticsId',
// logisticsCompanyName
'logisticsCompanyName',
'expressNumber',
'logisticsSwitch',
]);
// clean data?
if (!this.updateState(params)) {
this.close();
return;
... ... @@ -277,7 +294,6 @@ export default {
},
};
</script>
<style lang="scss" scoped>
.modal-footer {
& > span {
... ...