buli
2023-07-10 f05bfc9a39bccc8afb928efe7555f21e0e69c5bd
force-app/main/default/lwc/lexArriveGoodsMain/lexArriveGoodsMain.js
@@ -1,23 +1,25 @@
import { LightningElement,wire,api,track } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import init from '@salesforce/apex/LexArriveGoodsMainController.init';
import searchConsumableorderdetails from '@salesforce/apex/LexArriveGoodsMainController.searchConsumableorderdetails';
import initTotalNum from '@salesforce/apex/LexConsumableGoodsInfo.initTotalNum';
import initArrDet from '@salesforce/apex/LexConsumableGoodsInfo.initArrDet';
import initArrDetAll from '@salesforce/apex/LexConsumableGoodsInfo.initArrDetAll';
import initDeliveryDet from '@salesforce/apex/LexConsumableGoodsInfo.initDeliveryDet';
import initDeliveryDetAll from '@salesforce/apex/LexConsumableGoodsInfo.initDeliveryDetAll';
import initNotArrDet from '@salesforce/apex/LexConsumableGoodsInfo.initNotArrDet';
import initNotArrDetAll from '@salesforce/apex/LexConsumableGoodsInfo.initNotArrDetAll';
import initMoreThan7 from '@salesforce/apex/LexConsumableGoodsInfo.initMoreThan7';
import initMoreThan7All from '@salesforce/apex/LexConsumableGoodsInfo.initMoreThan7All';
import { LightningElement, wire, api, track } from "lwc";
import { CurrentPageReference } from "lightning/navigation";
import { ShowToastEvent } from "lightning/platformShowToastEvent";
import { NavigationMixin } from "lightning/navigation";
import init from "@salesforce/apex/LexArriveGoodsMainController.init";
import searchConsumableorderdetails from "@salesforce/apex/LexArriveGoodsMainController.searchConsumableorderdetails";
import initTotalNum from "@salesforce/apex/LexConsumableGoodsInfo.initTotalNum";
import initArrDet from "@salesforce/apex/LexConsumableGoodsInfo.initArrDet";
import initArrDetAll from "@salesforce/apex/LexConsumableGoodsInfo.initArrDetAll";
import initDeliveryDet from "@salesforce/apex/LexConsumableGoodsInfo.initDeliveryDet";
import initDeliveryDetAll from "@salesforce/apex/LexConsumableGoodsInfo.initDeliveryDetAll";
import initNotArrDet from "@salesforce/apex/LexConsumableGoodsInfo.initNotArrDet";
import initNotArrDetAll from "@salesforce/apex/LexConsumableGoodsInfo.initNotArrDetAll";
import initMoreThan7 from "@salesforce/apex/LexConsumableGoodsInfo.initMoreThan7";
import initMoreThan7All from "@salesforce/apex/LexConsumableGoodsInfo.initMoreThan7All";
//table css 
import { loadStyle } from "lightning/platformResourceLoader";
import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
export default class LexArriveGoodsMain extends NavigationMixin(LightningElement) {
export default class LexArriveGoodsMain extends NavigationMixin(
  LightningElement
) {
    //页面基础变量
    @track agencyProType;
    @track category1;
@@ -48,62 +50,107 @@
        // {label:'待系统操作入库数量',fieldName:'Delivery_detail_count__c'},
        // {label:'还没发货数量',fieldName:'OrderNumber_notarrive__c'},
        // {label:'发货七天还未到货数',fieldName:'More_than_seven_days__c'},
        {label:'消耗品订单名称',
    {
      label: "消耗品订单名称",
            type: "customOutputGood",
            typeAttributes: {
                outputValue: { fieldName: "Name" },
                type: 'Title',
        type: "Title",
                recordId: { fieldName: "Id" }
            },
            hideDefaultActions: true,initialWidth:200,wrapText:true},
        {label:'SAP合同号',fieldName:'ContractNo__c',hideDefaultActions: true,wrapText:true,initialWidth:180},
        {label:'订单总数',
      hideDefaultActions: true,
      // initialWidth: 200,
      wrapText: true
    },
    {
      label: "SAP合同号",
      fieldName: "ContractNo__c",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 180
    },
    {
      label: "订单总数",
            type: "customOutputGood",
            typeAttributes: {
                outputValue: { fieldName: "Total_num__c" },
                type: 'TotalNum',
        type: "TotalNum",
                recordId: { fieldName: "Id" }
            },
            hideDefaultActions: true, initialWidth: 100,cellAttributes: { alignment: "right" }},
        {label:'已到货数量',
      hideDefaultActions: true,
      initialWidth: 100,
      cellAttributes: { alignment: "right" }
    },
    {
      label: "已到货数量",
            type: "customOutputGood",
            typeAttributes: {
                outputValue: { fieldName: "OrderNumber_arrived__c" },
                type: 'ArrDet',
        type: "ArrDet",
                recordId: { fieldName: "Id" }
            },
            hideDefaultActions: true, initialWidth: 110,cellAttributes: { alignment: "right" }},
        {label:'待系统操作入库数量',
      hideDefaultActions: true,
      initialWidth: 100,
      cellAttributes: { alignment: "right" }
    },
    {
      label: "待系统操作入库数量",
            type: "customOutputGood",
            typeAttributes: {
                outputValue: { fieldName: "Delivery_detail_count__c" },
                type: 'DeliveryDet',
        type: "DeliveryDet",
                recordId: { fieldName: "Id" }
            },
            hideDefaultActions: true, initialWidth: 180,cellAttributes: { alignment: "right" }},
        {label:'还没发货数量',
      hideDefaultActions: true,
      initialWidth: 150,
      cellAttributes: { alignment: "right" }
    },
    {
      label: "还没发货数量",
            type: "customOutputGood",
            typeAttributes: {
                outputValue: { fieldName: "OrderNumber_notarrive__c" },
                type: 'NotArrDet',
        type: "NotArrDet",
                recordId: { fieldName: "Id" }
            },
            hideDefaultActions: true, initialWidth: 120,cellAttributes: { alignment: "right" }},
        {label:'发货七天还未到货数',
      hideDefaultActions: true,
      initialWidth: 120,
      cellAttributes: { alignment: "right" }
    },
    {
      label: "发货七天还未到货数",
            type: "customOutputGood",
            typeAttributes: {
                outputValue: { fieldName: "More_than_seven_days__c" },
                type: 'MoreThan7',
        type: "MoreThan7",
                recordId: { fieldName: "Id" }
            },
            hideDefaultActions: true, initialWidth: 180,cellAttributes: { alignment: "right" }},
        {label:'最新发货日期',fieldName:'Shipment_date__c',hideDefaultActions: true, initialWidth: 140},
        {label:'首次发货日期',fieldName:'First_Delivery__c',hideDefaultActions: true, initialWidth: 140}
      hideDefaultActions: true,
      initialWidth: 150,
      cellAttributes: { alignment: "right" }
    },
    {
      label: "最新发货日期",
      fieldName: "Shipment_date__c",
      hideDefaultActions: true,
      initialWidth: 105
    },
    {
      label: "首次发货日期",
      fieldName: "First_Delivery__c",
      hideDefaultActions: true,
      initialWidth: 105
    }
    ];
    @track colms2 = [
        {label:'产品型号',fieldName:'prodModel',hideDefaultActions: true},
        {label:'数量',fieldName:'recordCount',hideDefaultActions: true,initialWidth: 100}
    { label: "产品型号", fieldName: "prodModel", hideDefaultActions: true },
    {
      label: "数量",
      fieldName: "recordCount",
      hideDefaultActions: true,
      initialWidth: 100
    }
    ];
    //获取参数
@@ -130,10 +177,9 @@
   
    //初始化
    connectedCallback(){
        init()
            .then(result=>{
    init().then((result) => {
                this.isNoteStay = result.isNoteStay;
                if(result.result == 'Success'){
      if (result.result == "Success") {
                    this.agencyProType = result.agencyProType;
                    this.accountId = result.accountId;
                    this.title = result.title;
@@ -144,15 +190,23 @@
                    this.orderNumberNotarrive = result.orderNumberNotarrive;
                    this.moreThanSevenDays = result.moreThanSevenDays;
                    this.raesList = result.raesList;
                    this.raesList.push({Id:'1',Name:'订单明细汇总',Total_num__c:this.totalNum,OrderNumber_arrived__c:this.orderNumberArrived,Delivery_detail_count__c:this.deliveryDetailCount,OrderNumber_notarrive__c:this.orderNumberNotarrive,More_than_seven_days__c:this.moreThanSevenDays});
        this.raesList.push({
          Id: "1",
          Name: "订单明细汇总",
          Total_num__c: this.totalNum,
          OrderNumber_arrived__c: this.orderNumberArrived,
          Delivery_detail_count__c: this.deliveryDetailCount,
          OrderNumber_notarrive__c: this.orderNumberNotarrive,
          More_than_seven_days__c: this.moreThanSevenDays
        });
                    this.showSpinner = false;
                    this.showPage = true;
                }else{
                    this.showSpinner = false;
                    console.log("Error:"+result.errorMsg);
                    this.showMyToast('初始化页面失败',result.errorMsg,'error');
        this.showMyToast("初始化页面失败", result.errorMsg, "error");
                }
            })
    });
    }
    //点击链接
@@ -161,134 +215,160 @@
        var outputType = event.detail.data.type;
        var recordId = event.detail.data.recordId;
        console.log("click:"+outputValue+"---"+outputType+"---"+recordId);
        if(outputType == 'Title'){
    if (outputType == "Title") {
            const config = {
                type: 'standard__webPage',
        type: "standard__webPage",
                attributes: {
                   url: '/lexarrivegoods?ESetId='+recordId
          url: "/lexarrivegoods?ESetId=" + recordId
                }
            };
            this[NavigationMixin.Navigate](config);
        }else if(outputType == 'TotalNum'){
            this.popTitle = '所有产品一览';
            initTotalNum({ordId:recordId, type:'all'})
            .then(result=>{
                if(result.result == 'Success'){
    } else if (outputType == "TotalNum") {
      this.popTitle = "所有产品一览";
      initTotalNum({ ordId: recordId, type: "all" }).then((result) => {
        if (result.result == "Success") {
                    // this.recordList = result.recordList;
                    var dataStr = JSON.stringify(result.recordList);
                    this.recordList = JSON.parse(dataStr);
                    console.log('data:'+JSON.stringify(this.recordList));
          console.log("data:" + JSON.stringify(this.recordList));
                    this.showPop = true;
                }else{
                    this.showMyToast('加载所有产品一览页面失败',result.errorMsg,'error');
          this.showMyToast(
            "加载所有产品一览页面失败",
            result.errorMsg,
            "error"
          );
                }
            })
        }else if(outputType == 'ArrDet'){
            if(recordId == '1'){
                this.popTitle = '所有已到货产品一览';
                initArrDetAll({type:'all'})
                .then(result=>{
                    if(result.result == 'Success'){
      });
    } else if (outputType == "ArrDet") {
      if (recordId == "1") {
        this.popTitle = "所有已到货产品一览";
        initArrDetAll({ type: "all" }).then((result) => {
          if (result.result == "Success") {
                        // this.recordList = result.recordList;
                        var dataStr = JSON.stringify(result.recordList);
                        this.recordList = JSON.parse(dataStr);
                        console.log('data:'+JSON.stringify(this.recordList));
            console.log("data:" + JSON.stringify(this.recordList));
                        this.showPop = true;
                    }else{
                        this.showMyToast('加载所有已到货产品一览页面失败',result.errorMsg,'error');
            this.showMyToast(
              "加载所有已到货产品一览页面失败",
              result.errorMsg,
              "error"
            );
                    }
                })
        });
            }else{
                this.popTitle = '已到货产品一览';
                initArrDet({orderId:recordId})
                .then(result=>{
                    if(result.result == 'Success'){
        this.popTitle = "已到货产品一览";
        initArrDet({ orderId: recordId }).then((result) => {
          if (result.result == "Success") {
                        this.recordList = result.recordList;
                        console.log('data:'+JSON.stringify(this.recordList));
            console.log("data:" + JSON.stringify(this.recordList));
                        this.showPop = true;
                    }else{
                        this.showMyToast('加载已到货产品一览页面失败',result.errorMsg,'error');
            this.showMyToast(
              "加载已到货产品一览页面失败",
              result.errorMsg,
              "error"
            );
                    }
                })
        });
            }
        }else if(outputType == 'DeliveryDet'){
            if(recordId == '1'){
                this.popTitle = '所有已发货还没到货产品一览';
                initDeliveryDetAll({type:'all'})
                .then(result=>{
                    if(result.result == 'Success'){
    } else if (outputType == "DeliveryDet") {
      if (recordId == "1") {
        this.popTitle = "所有已发货还没到货产品一览";
        initDeliveryDetAll({ type: "all" }).then((result) => {
          if (result.result == "Success") {
                        this.recordList = result.recordList;
                        console.log('data:'+JSON.stringify(this.recordList));
            console.log("data:" + JSON.stringify(this.recordList));
                        this.showPop = true;
                    }else{
                        this.showMyToast('加载所有已发货还没到货产品一览页面失败',result.errorMsg,'error');
            this.showMyToast(
              "加载所有已发货还没到货产品一览页面失败",
              result.errorMsg,
              "error"
            );
                    }
                })
        });
            }else{
                this.popTitle = '未到货产品一览';
                initDeliveryDet({orderId:recordId})
                .then(result=>{
                    if(result.result == 'Success'){
        this.popTitle = "未到货产品一览";
        initDeliveryDet({ orderId: recordId }).then((result) => {
          if (result.result == "Success") {
                        this.recordList = result.recordList;
                        console.log('data:'+JSON.stringify(this.recordList));
            console.log("data:" + JSON.stringify(this.recordList));
                        this.showPop = true;
                    }else{
                        this.showMyToast('加载未到货产品一览页面失败',result.errorMsg,'error');
            this.showMyToast(
              "加载未到货产品一览页面失败",
              result.errorMsg,
              "error"
            );
                    }
                })
        });
            }
        }else if(outputType == 'NotArrDet'){
            if(recordId == '1'){
                this.popTitle = '所有还没发货产品一览';
                initNotArrDetAll({type:'all'})
                .then(result=>{
                    if(result.result == 'Success'){
    } else if (outputType == "NotArrDet") {
      if (recordId == "1") {
        this.popTitle = "所有还没发货产品一览";
        initNotArrDetAll({ type: "all" }).then((result) => {
          if (result.result == "Success") {
                        this.recordList = result.recordList;
                        console.log('data:'+JSON.stringify(this.recordList));
            console.log("data:" + JSON.stringify(this.recordList));
                        this.showPop = true;
                    }else{
                        this.showMyToast('加载所有还没发货产品一览页面失败',result.errorMsg,'error');
            this.showMyToast(
              "加载所有还没发货产品一览页面失败",
              result.errorMsg,
              "error"
            );
                    }
                })
        });
            }else{
                this.popTitle = '还没发货数量';
                initNotArrDet({orderId:recordId})
                .then(result=>{
                    if(result.result == 'Success'){
        this.popTitle = "还没发货数量";
        initNotArrDet({ orderId: recordId }).then((result) => {
          if (result.result == "Success") {
                        this.recordList = result.recordList;
                        console.log('data:'+JSON.stringify(this.recordList));
            console.log("data:" + JSON.stringify(this.recordList));
                        this.showPop = true;
                    }else{
                        this.showMyToast('加载还没发货数量页面失败',result.errorMsg,'error');
            this.showMyToast(
              "加载还没发货数量页面失败",
              result.errorMsg,
              "error"
            );
                    }
                })
        });
            }
        }else if(outputType == 'MoreThan7'){
            if(recordId == '1'){
                this.popTitle = '所有发货七天还未到货数';
                initMoreThan7All({type:'all'})
                .then(result=>{
                    if(result.result == 'Success'){
    } else if (outputType == "MoreThan7") {
      if (recordId == "1") {
        this.popTitle = "所有发货七天还未到货数";
        initMoreThan7All({ type: "all" }).then((result) => {
          if (result.result == "Success") {
                        this.recordList = result.recordList;
                        console.log('data:'+JSON.stringify(this.recordList));
            console.log("data:" + JSON.stringify(this.recordList));
                        this.showPop = true;
                    }else{
                        this.showMyToast('加载所有发货七天还未到货数页面失败',result.errorMsg,'error');
            this.showMyToast(
              "加载所有发货七天还未到货数页面失败",
              result.errorMsg,
              "error"
            );
                    }
                })
        });
            }else{
                this.popTitle = '发货七天还未到货数';
                initMoreThan7({orderId:recordId})
                .then(result=>{
                    if(result.result == 'Success'){
        this.popTitle = "发货七天还未到货数";
        initMoreThan7({ orderId: recordId }).then((result) => {
          if (result.result == "Success") {
                        this.recordList = result.recordList;
                        console.log('data:'+JSON.stringify(this.recordList));
            console.log("data:" + JSON.stringify(this.recordList));
                        this.showPop = true;
                    }else{
                        this.showMyToast('加载发货七天还未到货数页面失败',result.errorMsg,'error');
            this.showMyToast(
              "加载发货七天还未到货数页面失败",
              result.errorMsg,
              "error"
            );
                    }
                })
        });
            }
        }
    }
@@ -316,58 +396,82 @@
            cate2Str:this.cate2,
            accountidStr:this.accountId,
            userWorkLocationStr:this.userWorkLocation,
            agencyProTypeStr:this.agencyProType})
        .then(result=>{
      agencyProTypeStr: this.agencyProType
    }).then((result) => {
            this.showSpinner = false;
            if(result.result == 'Success'){
      if (result.result == "Success") {
                this.raesList = result.raesList;
                this.raesList.push({Id:'1',Name:'订单明细汇总',Total_num__c:this.totalNum,OrderNumber_arrived__c:this.orderNumberArrived,Delivery_detail_count__c:this.deliveryDetailCount,OrderNumber_notarrive__c:this.orderNumberNotarrive,More_than_seven_days__c:this.moreThanSevenDays});
        this.raesList.push({
          Id: "1",
          Name: "订单明细汇总",
          Total_num__c: this.totalNum,
          OrderNumber_arrived__c: this.orderNumberArrived,
          Delivery_detail_count__c: this.deliveryDetailCount,
          OrderNumber_notarrive__c: this.orderNumberNotarrive,
          More_than_seven_days__c: this.moreThanSevenDays
        });
                if(this.raesList.length > 1){
                    var count = this.raesList.length - 1;
                    this.showMyToast('搜索成功','共搜索到'+count+'条数据','success');
          this.showMyToast(
            "搜索成功",
            "共搜索到" + count + "条数据",
            "success"
          );
                }else{
                    this.showMyToast('未搜索到数据','','error');
          this.showMyToast("未搜索到数据", "", "error");
                }
            }else{
                this.showMyToast('搜索失败',result.errorMsg,'error');
        this.showMyToast("搜索失败", result.errorMsg, "error");
            }
        })
    });
    }
    
    //清空搜索框
    clear(){
        this.showSpinner = true;
        this.category1 = '';
    this.category1 = "";
        this.cate2 = null;
        searchConsumableorderdetails({
            category1Str:this.category1,
            cate2Str:this.cate2,
            accountidStr:this.accountId,
            userWorkLocationStr:this.userWorkLocation,
            agencyProTypeStr:this.agencyProType})
        .then(result=>{
      agencyProTypeStr: this.agencyProType
    }).then((result) => {
            this.showSpinner = false;
            if(result.result == 'Success'){
      if (result.result == "Success") {
                this.raesList = result.raesList;
                this.raesList.push({Id:'1',Name:'订单明细汇总',Total_num__c:this.totalNum,OrderNumber_arrived__c:this.orderNumberArrived,Delivery_detail_count__c:this.deliveryDetailCount,OrderNumber_notarrive__c:this.orderNumberNotarrive,More_than_seven_days__c:this.moreThanSevenDays});
        this.raesList.push({
          Id: "1",
          Name: "订单明细汇总",
          Total_num__c: this.totalNum,
          OrderNumber_arrived__c: this.orderNumberArrived,
          Delivery_detail_count__c: this.deliveryDetailCount,
          OrderNumber_notarrive__c: this.orderNumberNotarrive,
          More_than_seven_days__c: this.moreThanSevenDays
        });
                if(this.raesList.length > 1){
                    var count = this.raesList.length - 1;
                    this.showMyToast('搜索成功','共搜索到'+count+'条数据','success');
          this.showMyToast(
            "搜索成功",
            "共搜索到" + count + "条数据",
            "success"
          );
                }else{
                    this.showMyToast('未搜索到数据','','error');
          this.showMyToast("未搜索到数据", "", "error");
                }
            }else{
                this.showMyToast('搜索失败',result.errorMsg,'error');
        this.showMyToast("搜索失败", result.errorMsg, "error");
            }
        })
    });
    }
    //入库
    orderArrive(){
        const config = {
            type: 'standard__webPage',
      type: "standard__webPage",
            attributes: {
               url: '/lexarrivegoods?ArrType=Arr'
        url: "/lexarrivegoods?ArrType=Arr"
            }
        };
        this[NavigationMixin.Navigate](config);
@@ -376,30 +480,32 @@
    //返品
    orderReturn(){
        const config = {
            type: 'standard__webPage',
      type: "standard__webPage",
            attributes: {
               url: '/lexarrivegoods?ArrType=ReG'
        url: "/lexarrivegoods?ArrType=ReG"
            }
        };
        this[NavigationMixin.Navigate](config);
    }
    showMyToast(title, message, variant) {
        console.log('show custom message');
        var iconName = '';
        var content = '';
        if(variant == 'success'){
           iconName = 'utility:check';
    console.log("show custom message");
    var iconName = "";
    var content = "";
    if (variant == "success") {
      iconName = "utility:check";
        }else{
           iconName = 'utility:error';
      iconName = "utility:error";
        }
        if(message != ''){
           content = '<h2><strong>'+title+'<strong/></h2><h5>'+message+'</h5>';
    if (message != "") {
      content =
        "<h2><strong>" + title + "<strong/></h2><h5>" + message + "</h5>";
        }else{
           content = '<h2><strong>'+title+'<strong/></h2>';
      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);
        // var mode;
        // if(this.isNoteStay){
        //     mode ='sticky';