buli
2023-07-14 744f42c5496e656a1f9927740a3b37c0b97a6cba
force-app/main/default/lwc/lexSaleAndDelivery/lexSaleAndDelivery.js
@@ -1,29 +1,29 @@
import { LightningElement, wire, api, track } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import init from '@salesforce/apex/LexSaleAndDeliveryController.init';//cleanUp
import init from '@salesforce/apex/LexSaleAndDeliveryController.init'; //cleanUp
import cleanUp from '@salesforce/apex/LexSaleAndDeliveryController.cleanUp';
import { ShowToastEvent } from "lightning/platformShowToastEvent";
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import searchOrderInstatus from '@salesforce/apex/LexSaleAndDeliveryController.searchOrderInstatus';
import searchConsumableorderdetails from '@salesforce/apex/LexSaleAndDeliveryController.searchConsumableorderdetails';
import searchConsumableorFinish from '@salesforce/apex/LexSaleAndDeliveryController.searchConsumableorFinish';
//table css
import { loadStyle } from "lightning/platformResourceLoader";
import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
//table css
import { loadStyle } from 'lightning/platformResourceLoader';
import WrappedHeaderTable from '@salesforce/resourceUrl/lexdatatable';
const columns = [
    {
        label: '出库日',
        fieldName: 'Outbound_Date__c',
        type: 'date',
        initialWidth: 130,
        hideDefaultActions: true,
        sortable: true
        sortable: true,
        initialWidth: 180,
        wrapText: true
    },
    {
        label: '出库单号',
        fieldName: 'url',
        type: 'url',
        initialWidth: 175,
        typeAttributes: {
            label: {
                fieldName: 'Name'
@@ -31,8 +31,8 @@
            target: '_blank'
        },
        hideDefaultActions: true,
        initialWidth: 225,
        sortable: true
        sortable: true,
        wrapText: true
    },
    {
        label: '客户名',
@@ -45,50 +45,57 @@
        label: '科室',
        fieldName: 'Order_ForCustomerText__c',
        hideDefaultActions: true,
        initialWidth: 120
        initialWidth: 100,
        wrapText: true
    },
    {
        label: '出库单状态',
        fieldName: 'SummonsStatus_c__c',
        hideDefaultActions: true,
        initialWidth: 100,
        sortable: true,
        initialWidth: 100
        wrapText: true
    },
    {
        label: '开票状态',
        fieldName: 'Billed_Status__c',
        hideDefaultActions: true,
        initialWidth: 100,
        sortable: true,
        initialWidth: 100
        wrapText: true
    },
    {
        label: '未发票金额(元)',
        fieldName: 'InvoiceNotPro_money__c',
        hideDefaultActions: true,
        type: "number",
        initialWidth: 125,
        type: 'number',
        typeAttributes: {
            minimumFractionDigits: 2,
            minimumFractionDigits: 2
        },
        initialWidth: 150
        wrapText: true
    },
    {
        label: '创建日期',
        fieldName: 'CreatedDate',
        hideDefaultActions: true,
        sortable: true,
        type: "date",
        wrapText: true,
        initialWidth: 180,
        type: 'date',
        typeAttributes: {
            timeZone: "Asia/Shanghai",
            day: "numeric",
            month: "numeric",
            year: "numeric",
            hour: "2-digit",
            minute: "2-digit"
        },
        initialWidth: 200
            timeZone: 'Asia/Shanghai',
            day: 'numeric',
            month: 'numeric',
            year: 'numeric',
            hour: '2-digit',
            minute: '2-digit'
        }
    }
];
export default class LexSaleAndDelivery extends NavigationMixin(LightningElement) {
export default class LexSaleAndDelivery extends NavigationMixin(
    LightningElement
) {
    columns = columns;
    @track isShowSpinner = true;
    @track message = '';
@@ -109,49 +116,48 @@
    sortDirection = 'asc';
    sortedBy;
    stylesLoaded = false;
    renderedCallback() {
        if (!this.stylesLoaded) {
            Promise.all([loadStyle(this, WrappedHeaderTable)])
                .then(() => {
                    console.log("Custom styles loaded");
                    console.log('Custom styles loaded');
                    this.stylesLoaded = true;
                })
                .catch((error) => {
                    console.error("Error loading custom styles");
                    console.error('Error loading custom styles');
                });
        }
    }
    connectedCallback() {
        init().then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log('r = ' + JSON.stringify(r));
            if (r.status == 'Success') {
                this.userinfoId = r.entity.userinfoId;
                this.accountid = r.entity.accountid;
                this.agencyProType = r.entity.agencyProType;
                this.userWorkLocation = r.entity.userWorkLocation;
                this.data = r.entity.raesList;
                for (var i in this.data) {
                    this.data[i]['url'] = '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
        init()
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    this.userinfoId = r.entity.userinfoId;
                    this.accountid = r.entity.accountid;
                    this.agencyProType = r.entity.agencyProType;
                    this.userWorkLocation = r.entity.userWorkLocation;
                    this.data = r.entity.raesList;
                    for (var i in this.data) {
                        this.data[i]['url'] =
                            '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
                    }
                    console.log('this.data = ' + JSON.stringify(this.data));
                    this.isShowSpinner = false;
                    this.showTable = true;
                } else {
                    console.log('r = ' + JSON.stringify(r));
                    this.showMyToast('初始化失败', r.msg, 'Error');
                }
                console.log('this.data = ' + JSON.stringify(this.data));
                this.isShowSpinner = false;
                this.showTable = true;
            } else {
                console.log('r = ' + JSON.stringify(r))
                this.showMyToast('初始化失败', r.msg,'Error');
            }
        }).catch((error) => {
            console.log('error = ' + JSON.stringify(error))
            this.showMyToast('错误', '初始化失败','Error');
        })
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
                this.showMyToast('错误', '初始化失败', 'Error');
            });
    }
    //新建出库单
    neworderhead() {
@@ -176,29 +182,32 @@
            userWorkLocation: this.userWorkLocation,
            category1: this.deliveryOrderNo,
            category2: this.contactName
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log('r = ' + JSON.stringify(r));
            if (r.status == 'Success') {
                this.data = r.entity.raesList;
                for (var i in this.data) {
                    this.data[i]['url'] = '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
                }
                this.message = r.msg;
                if (this.message == '没有搜索到相关出库单') {
                    this.showMyToast('搜索失败', this.message,'Error');
                } else {
                    this.showMyToast('搜索成功', this.message,'Success');
                }
                this.isShowSpinner = false;
                //this.isCssLoaded = true
                this.showTable = true;
            } else {
                this.showMyToast('错误',  r.msg,'Error');
            }
        }).catch((error) => {
            console.log('error = ' + JSON.stringify(error))
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    this.data = r.entity.raesList;
                    for (var i in this.data) {
                        this.data[i]['url'] =
                            '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
                    }
                    this.message = r.msg;
                    if (this.message == '没有搜索到相关出库单') {
                        this.showMyToast('搜索失败', this.message, 'Error');
                    } else {
                        this.showMyToast('搜索成功', this.message, 'Success');
                    }
                    this.isShowSpinner = false;
                    //this.isCssLoaded = true
                    this.showTable = true;
                } else {
                    this.showMyToast('错误', r.msg, 'Error');
                }
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
            });
    }
    //还没出库的出库单
@@ -216,29 +225,36 @@
            userWorkLocation: this.userWorkLocation,
            category1: this.deliveryOrderNo,
            category2: this.contactName
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log('r = ' + JSON.stringify(r));
            if (r.status == 'Success') {
                this.data = r.entity.raesList;
                for (var i in this.data) {
                    this.data[i]['url'] = '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
                }
                this.message = r.msg;
                if (this.message == '没有搜索到相关出库单') {
                    this.showMyToast('搜索失败', this.message,'Error');
                } else {
                    this.showMyToast('搜索成功', this.message,'Success');
                }
                this.isShowSpinner = false;
                this.showTable = true;
            } else {
                this.showMyToast('搜索失败', r.msg,'Error');
            }
        }).catch((error) => {
            console.log('error = ' + JSON.stringify(error))
            this.showMyToast('搜索失败', '搜索还没出库的出库单出错','Error');
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    this.data = r.entity.raesList;
                    for (var i in this.data) {
                        this.data[i]['url'] =
                            '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
                    }
                    this.message = r.msg;
                    if (this.message == '没有搜索到相关出库单') {
                        this.showMyToast('搜索失败', this.message, 'Error');
                    } else {
                        this.showMyToast('搜索成功', this.message, 'Success');
                    }
                    this.isShowSpinner = false;
                    this.showTable = true;
                } else {
                    this.showMyToast('搜索失败', r.msg, 'Error');
                }
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
                this.showMyToast(
                    '搜索失败',
                    '搜索还没出库的出库单出错',
                    'Error'
                );
            });
    }
    //已出库已开票的出库单
@@ -254,29 +270,36 @@
            userWorkLocation: this.userWorkLocation,
            category1: this.deliveryOrderNo,
            category2: this.contactName
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log('r = ' + JSON.stringify(r));
            if (r.status == 'Success') {
                this.data = r.entity.raesList;
                for (var i in this.data) {
                    this.data[i]['url'] = '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
                }
                this.message = r.msg;
                if (this.message == '没有搜索到相关出库单') {
                    this.showMyToast('搜索失败', this.message,'Error');
                } else {
                    this.showMyToast('搜索成功', this.message,'Success');
                }
                this.isShowSpinner = false;
                this.showTable = true;
            } else {
                this.showMyToast('搜索失败', r.msg,'Error');
            }
        }).catch((error) => {
            console.log('error = ' + JSON.stringify(error))
            this.showMyToast('搜索失败', '搜索已出库已开票的出库单出错','Error');
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    this.data = r.entity.raesList;
                    for (var i in this.data) {
                        this.data[i]['url'] =
                            '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
                    }
                    this.message = r.msg;
                    if (this.message == '没有搜索到相关出库单') {
                        this.showMyToast('搜索失败', this.message, 'Error');
                    } else {
                        this.showMyToast('搜索成功', this.message, 'Success');
                    }
                    this.isShowSpinner = false;
                    this.showTable = true;
                } else {
                    this.showMyToast('搜索失败', r.msg, 'Error');
                }
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
                this.showMyToast(
                    '搜索失败',
                    '搜索已出库已开票的出库单出错',
                    'Error'
                );
            });
    }
    //清空
@@ -290,30 +313,33 @@
        cleanUp({
            accountid: this.accountid,
            agencyProType: this.agencyProType,
            userWorkLocation: this.userWorkLocation,
        }).then((r) => {
            r = JSON.parse(JSON.stringify(r));
            console.log('r = ' + JSON.stringify(r));
            if (r.status == 'Success') {
                this.data = r.entity.raesList;
                for (var i in this.data) {
                    this.data[i]['url'] = '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
                }
                this.message = r.msg;
                if (this.message == '没有搜索到相关出库单') {
                    this.showMyToast('搜索失败', this.message,'Error');
                } else {
                    this.showMyToast('搜索成功', this.message,'Success');
                }
                this.isShowSpinner = false;
                this.showTable = true;
            } else {
                this.showMyToast('搜索失败', r.msg,'Error');
            }
        }).catch((error) => {
            console.log('error = ' + JSON.stringify(error))
            this.showMyToast('搜索失败', '搜索失败','Error');
            userWorkLocation: this.userWorkLocation
        })
            .then((r) => {
                r = JSON.parse(JSON.stringify(r));
                console.log('r = ' + JSON.stringify(r));
                if (r.status == 'Success') {
                    this.data = r.entity.raesList;
                    for (var i in this.data) {
                        this.data[i]['url'] =
                            '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
                    }
                    this.message = r.msg;
                    if (this.message == '没有搜索到相关出库单') {
                        this.showMyToast('搜索失败', this.message, 'Error');
                    } else {
                        this.showMyToast('搜索成功', this.message, 'Success');
                    }
                    this.isShowSpinner = false;
                    this.showTable = true;
                } else {
                    this.showMyToast('搜索失败', r.msg, 'Error');
                }
            })
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
                this.showMyToast('搜索失败', '搜索失败', 'Error');
            });
    }
    //Capture the event fired from the paginator component
@@ -340,11 +366,11 @@
    sortBy(field, reverse, primer) {
        const key = primer
            ? function (x) {
                return primer(x[field]);
            }
                  return primer(x[field]);
              }
            : function (x) {
                return x[field];
            };
                  return x[field];
              };
        return function (a, b) {
            a = key(a);
@@ -353,27 +379,25 @@
        };
    }
    dataChange(event) {
        let fieldName = event.target.getAttribute("data-field");
        let fieldName = event.target.getAttribute('data-field');
        let value = event.detail.value;
        switch (fieldName) {
            case 'deliveryFromDate':
                this.deliveryFromDate = value;
                break
                break;
            case 'deliveryToDate':
                this.deliveryToDate = value;
                break
                break;
            case 'deliveryOrderNo':
                this.deliveryOrderNo = value;
                break
                break;
            case 'contactName':
                this.contactName = value;
                break
                break;
            default:
                console.log('no data');
        }
    }
    editProductLimit() {
@@ -396,11 +420,18 @@
            iconName = 'utility:error';
        }
        if (message != '') {
            content = '<h2><strong>' + title + '<strong/></h2><h5>' + message + '</h5>';
            content =
                '<h2><strong>' +
                title +
                '<strong/></h2><h5>' +
                message +
                '</h5>';
        } else {
            content = '<h2><strong>' + title + '<strong/></h2>';
        }
        this.template.querySelector('c-common-toast').showToast(variant, content, iconName, 10000);
        this.template
            .querySelector('c-common-toast')
            .showToast(variant, content, iconName, 10000);
    }
    @track isModalOpen = false;