buli
2023-07-14 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7
force-app/main/default/lwc/lexCancelRemoveBox/lexCancelRemoveBox.js
@@ -1,12 +1,12 @@
import { LightningElement, wire, api, track } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import oninit from '@salesforce/apex/LexCancelRemoveBoxController.init';
import searchDeatail from '@salesforce/apex/LexCancelRemoveBoxController.searchConsumableorderdetails';
import oninit from "@salesforce/apex/LexCancelRemoveBoxController.init";
import searchDeatail from "@salesforce/apex/LexCancelRemoveBoxController.searchConsumableorderdetails"
import saveConfirm from '@salesforce/apex/LexCancelRemoveBoxController.cancelRemoveBoxConfirm';
//table css
import { loadStyle } from 'lightning/platformResourceLoader';
import WrappedHeaderTable from '@salesforce/resourceUrl/lexdatatable';
import { loadStyle } from "lightning/platformResourceLoader";
import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
const columns = [
    {
        label: '消耗品名称',
@@ -14,13 +14,15 @@
        hideDefaultActions: true,
        wrapText: true
        // initialWidth: 350,
    },
    {
        label: '规格',
        fieldName: 'ProductPacking_list_manual__c',
        hideDefaultActions: true,
        cellAttributes: { alignment: 'right' },
        initialWidth: 50
      cellAttributes: { alignment: "right" },
      initialWidth: 50,
    },
    {
        label: 'CFDA状态',
@@ -28,6 +30,7 @@
        hideDefaultActions: true,
        initialWidth: 100,
        wrapText: true
    },
    {
        label: '注册证编码号',
@@ -57,20 +60,25 @@
        fieldName: 'Name__c',
        hideDefaultActions: true,
        wrapText: true
    },
    {
        label: 'BarCode',
        fieldName: 'Bar_Code__c',
        wrapText: true,
        hideDefaultActions: true
      hideDefaultActions: true,
        // initialWidth:600
    },
    }
    ,
    {
        label: '错误原因',
        fieldName: 'ErrorReason',
        hideDefaultActions: true
      hideDefaultActions: true,
    }
];
export default class LexCancelRemoveBox extends LightningElement {
    columns = columns;
@@ -80,38 +88,40 @@
    @track errorDetail = [];
    // 显示
    @track showTable = false;
    @track showTable = false
    @track showSpinner = false;
    //数据构成
    @track accountName;
    @track userWorkLocation;
    @track agencyProType;
    @track barcode = '';
    @track saveFLGbln = false;
    @track accountName
    @track userWorkLocation
    @track agencyProType
    @track barcode = ''
    @track saveFLGbln = false
    @track dataSize = 0;
    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() {
        console.log('初始化');
        // this.showTable = false;
        oninit()
            .then((result) => {
      oninit().then((result) => {
                result = JSON.parse(JSON.stringify(result));
                console.log('result =' + JSON.stringify(result));
                if ((result.status = 'Success')) {
        if (result.status = 'Success') {
                    console.log('result');
                    this.agencyProType = result.entity.agencyProType;
                    this.userWorkLocation = result.entity.userWorkLocation;
@@ -121,8 +131,7 @@
                } else {
                    this.showMyToast('初始化失败', result.msg, 'error');
                }
            })
            .catch((error) => {
      }).catch((error) => {
                console.log('error = ' + JSON.stringify(error));
            });
    }
@@ -135,40 +144,27 @@
            userWorkLocation: this.userWorkLocation,
            agencyProType: this.agencyProType,
            barcode: this.barcode
        })
            .then((result) => {
    }).then((result) => {
                result = JSON.parse(JSON.stringify(result));
                console.log('result =' + JSON.stringify(result));
                if (result.status == 'Success') {
                    console.log('成功');
                    this.data = JSON.parse(
                        result.entity.ConsumableorderdetailsRecordsdummy
                    );
                    this.errorDetail = JSON.parse(
                        result.entity.ConsumableorderdetailsRecordserror
                    );
        this.data = JSON.parse(result.entity.ConsumableorderdetailsRecordsdummy);
        this.errorDetail = JSON.parse(result.entity.ConsumableorderdetailsRecordserror);
                    this.dataSize = result.entity.dataSize;
                    for (let i in this.data) {
                        this.data[i]['Name__c'] = this.data[i].Prod.Name__c;
                        this.data[i]['ProductPacking_list_manual__c'] =
                            this.data[i].esd.ProductPacking_list_manual__c;
                        this.data[i]['CFDA_Status__c'] =
                            this.data[i].esd.CFDA_Status__c;
                        this.data[i]['Report_Product_Approbation__c'] =
                            this.data[i].esd.Report_Product_Approbation__c;
                        this.data[i]['Report_Product_Expiration__c'] =
                            this.data[i].esd.Report_Product_Expiration__c;
                        this.data[i]['Bar_Code__c'] =
                            this.data[i].esd.Bar_Code__c;
          this.data[i]['ProductPacking_list_manual__c'] = this.data[i].esd.ProductPacking_list_manual__c;
          this.data[i]['CFDA_Status__c'] = this.data[i].esd.CFDA_Status__c;
          this.data[i]['Report_Product_Approbation__c'] = this.data[i].esd.Report_Product_Approbation__c;
          this.data[i]['Report_Product_Expiration__c'] = this.data[i].esd.Report_Product_Expiration__c;
          this.data[i]['Bar_Code__c'] = this.data[i].esd.Bar_Code__c;
                    }
                    // this.showTable = true;
                    for (let i in this.errorDetail) {
                        this.errorDetail[i]['Name__c'] =
                            this.errorDetail[i].Prod.Name__c;
                        this.errorDetail[i]['Bar_Code__c'] =
                            this.errorDetail[i].esd.Bar_Code__c;
                        this.errorDetail[i]['ErrorReason'] =
                            this.errorDetail[i].ErrorReason;
          this.errorDetail[i]['Name__c'] = this.errorDetail[i].Prod.Name__c;
          this.errorDetail[i]['Bar_Code__c'] = this.errorDetail[i].esd.Bar_Code__c;
          this.errorDetail[i]['ErrorReason'] = this.errorDetail[i].ErrorReason;
                    }
                    // this.showTables = true;
                    this.showSpinner = false;
@@ -176,10 +172,10 @@
                    this.showMyToast('获取失败', result.msg, 'error');
                    this.showSpinner = false;
                }
            })
            .catch((error) => {
    }).catch((error) => {
                console.log('error = ' + JSON.stringify(error));
            });
    }
    //获取当前输入值
    handleChange(event) {
@@ -189,8 +185,9 @@
        console.log('this.barcode' + this.barcode);
    }
    saveConfirm() {
        let msg = '确认取消拆盒吗';
    let msg = "确认取消拆盒吗";
        if (this.dataSize > 0) {
            if (confirm(msg) == true) {
                this.CancelRemoveBox();
@@ -206,8 +203,7 @@
            accountName: this.accountName,
            userWorkLocation: this.userWorkLocation,
            agencyProType: this.agencyProType
        })
            .then((result) => {
    }).then((result) => {
                result = JSON.parse(JSON.stringify(result));
                console.log('result保存 = ' + JSON.stringify(result));
                if (result.status == 'Success') {
@@ -216,6 +212,8 @@
                    if (this.saveFLGbln) {
                        this.showMyToast(result.msg, '', 'success');
                        this.showSpinner = false;
                    }
                } else {
                    this.showMyToast('取消拆盒失败', result.msg, 'error');
@@ -225,6 +223,7 @@
            .catch((error) => {
                console.log('error = ' + JSON.stringify(error));
            });
    }
    showMyToast(title, message, variant) {
        console.log('show custom message');
@@ -236,17 +235,15 @@
            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);
    }
}