buli
2023-07-14 744f42c5496e656a1f9927740a3b37c0b97a6cba
force-app/main/default/lwc/lexSaleAndDelivery/lexSaleAndDelivery.js
@@ -1,95 +1,95 @@
import { LightningElement, wire, api, track } from "lwc";
import { NavigationMixin } from "lightning/navigation";
import init from "@salesforce/apex/LexSaleAndDeliveryController.init"; //cleanUp
import cleanUp from "@salesforce/apex/LexSaleAndDeliveryController.cleanUp";
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";
import { LightningElement, wire, api, track } from 'lwc';
import { NavigationMixin } from 'lightning/navigation';
import init from '@salesforce/apex/LexSaleAndDeliveryController.init'; //cleanUp
import cleanUp from '@salesforce/apex/LexSaleAndDeliveryController.cleanUp';
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";
import { loadStyle } from 'lightning/platformResourceLoader';
import WrappedHeaderTable from '@salesforce/resourceUrl/lexdatatable';
const columns = [
  {
    label: "出库日",
    fieldName: "Outbound_Date__c",
    type: "date",
        label: '出库日',
        fieldName: 'Outbound_Date__c',
        type: 'date',
    hideDefaultActions: true,
    sortable: true,
    initialWidth: 180,
    wrapText: true
  },
  {
    label: "出库单号",
    fieldName: "url",
    type: "url",
        label: '出库单号',
        fieldName: 'url',
        type: 'url',
    typeAttributes: {
      label: {
        fieldName: "Name"
                fieldName: 'Name'
      },
      target: "_blank"
            target: '_blank'
    },
    hideDefaultActions: true,
    sortable: true,
    wrapText: true
  },
  {
    label: "客户名",
    fieldName: "ShipmentAccount__c",
        label: '客户名',
        fieldName: 'ShipmentAccount__c',
    hideDefaultActions: true,
    wrapText: true,
    sortable: true
  },
  {
    label: "科室",
    fieldName: "Order_ForCustomerText__c",
        label: '科室',
        fieldName: 'Order_ForCustomerText__c',
    hideDefaultActions: true,
    initialWidth: 100,
    wrapText: true
  },
  {
    label: "出库单状态",
    fieldName: "SummonsStatus_c__c",
        label: '出库单状态',
        fieldName: 'SummonsStatus_c__c',
    hideDefaultActions: true,
    initialWidth: 100,
    sortable: true,
    wrapText: true
  },
  {
    label: "开票状态",
    fieldName: "Billed_Status__c",
        label: '开票状态',
        fieldName: 'Billed_Status__c',
    hideDefaultActions: true,
    initialWidth: 100,
    sortable: true,
    wrapText: true
  },
  {
    label: "未发票金额(元)",
    fieldName: "InvoiceNotPro_money__c",
        label: '未发票金额(元)',
        fieldName: 'InvoiceNotPro_money__c',
    hideDefaultActions: true,
    initialWidth: 125,
    type: "number",
        type: 'number',
    typeAttributes: {
      minimumFractionDigits: 2
    },
    wrapText: true
  },
  {
    label: "创建日期",
    fieldName: "CreatedDate",
        label: '创建日期',
        fieldName: 'CreatedDate',
    hideDefaultActions: true,
    sortable: true,
    wrapText: true,
    initialWidth: 180,
    type: "date",
        type: 'date',
    typeAttributes: {
      timeZone: "Asia/Shanghai",
      day: "numeric",
      month: "numeric",
      year: "numeric",
      hour: "2-digit",
      minute: "2-digit"
            timeZone: 'Asia/Shanghai',
            day: 'numeric',
            month: 'numeric',
            year: 'numeric',
            hour: '2-digit',
            minute: '2-digit'
    }
  }
];
@@ -98,22 +98,22 @@
) {
  columns = columns;
  @track isShowSpinner = true;
  @track message = "";
  @track deliveryFromDate = "";
  @track deliveryToDate = "";
  @track deliveryOrderNo = "";
  @track contactName = "";
    @track message = '';
    @track deliveryFromDate = '';
    @track deliveryToDate = '';
    @track deliveryOrderNo = '';
    @track contactName = '';
  @track data = [];
  @track userinfoId = "";
  @track accountid = "";
  @track agencyProType = "";
  @track userWorkLocation = "";
    @track userinfoId = '';
    @track accountid = '';
    @track agencyProType = '';
    @track userWorkLocation = '';
  @track showTable = false;
  @track hidecheckboxcolumn = true;
  //排序
  defaultSortDirection = "asc";
  sortDirection = "asc";
    defaultSortDirection = 'asc';
    sortDirection = 'asc';
  sortedBy;
  stylesLoaded = false;
@@ -121,11 +121,11 @@
    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');
        });
    }
  }
@@ -134,37 +134,37 @@
    init()
      .then((r) => {
        r = JSON.parse(JSON.stringify(r));
        console.log("r = " + JSON.stringify(r));
        if (r.status == "Success") {
                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;
                        this.data[i]['url'] =
                            '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
          }
          console.log("this.data = " + JSON.stringify(this.data));
                    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('r = ' + JSON.stringify(r));
                    this.showMyToast('初始化失败', r.msg, 'Error');
        }
      })
      .catch((error) => {
        console.log("error = " + JSON.stringify(error));
        this.showMyToast("错误", "初始化失败", "Error");
                console.log('error = ' + JSON.stringify(error));
                this.showMyToast('错误', '初始化失败', 'Error');
      });
  }
  //新建出库单
  neworderhead() {
    this[NavigationMixin.Navigate]({
      type: "standard__webPage",
            type: 'standard__webPage',
      attributes: {
        url: "/lexsummonscreat"
                url: '/lexsummonscreat'
      }
    });
  }
@@ -173,7 +173,7 @@
  searchOrderInstatusJs() {
    this.isShowSpinner = true;
    this.showTable = false;
    console.log("searchOrderInstatusJs");
        console.log('searchOrderInstatusJs');
    searchOrderInstatus({
      orderDate: this.deliveryFromDate,
      deliverDate: this.deliveryToDate,
@@ -185,28 +185,28 @@
    })
      .then((r) => {
        r = JSON.parse(JSON.stringify(r));
        console.log("r = " + JSON.stringify(r));
        if (r.status == "Success") {
                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.data[i]['url'] =
                            '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
          }
          this.message = r.msg;
          if (this.message == "没有搜索到相关出库单") {
            this.showMyToast("搜索失败", this.message, "Error");
                    if (this.message == '没有搜索到相关出库单') {
                        this.showMyToast('搜索失败', this.message, 'Error');
          } else {
            this.showMyToast("搜索成功", this.message, "Success");
                        this.showMyToast('搜索成功', this.message, 'Success');
          }
          this.isShowSpinner = false;
          //this.isCssLoaded = true
          this.showTable = true;
        } else {
          this.showMyToast("错误", r.msg, "Error");
                    this.showMyToast('错误', r.msg, 'Error');
        }
      })
      .catch((error) => {
        console.log("error = " + JSON.stringify(error));
                console.log('error = ' + JSON.stringify(error));
      });
  }
@@ -214,9 +214,9 @@
  searchConsumableorderdetailsJs() {
    this.isShowSpinner = true;
    this.showTable = false;
    console.log("searchConsumableorderdetailsJs");
    console.log("this.deliveryFromDate = " + this.deliveryFromDate);
    console.log("this.deliveryToDate = " + this.deliveryToDate);
        console.log('searchConsumableorderdetailsJs');
        console.log('this.deliveryFromDate = ' + this.deliveryFromDate);
        console.log('this.deliveryToDate = ' + this.deliveryToDate);
    searchConsumableorderdetails({
      orderDate: this.deliveryFromDate,
      deliverDate: this.deliveryToDate,
@@ -228,28 +228,32 @@
    })
      .then((r) => {
        r = JSON.parse(JSON.stringify(r));
        console.log("r = " + JSON.stringify(r));
        if (r.status == "Success") {
                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.data[i]['url'] =
                            '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
          }
          this.message = r.msg;
          if (this.message == "没有搜索到相关出库单") {
            this.showMyToast("搜索失败", this.message, "Error");
                    if (this.message == '没有搜索到相关出库单') {
                        this.showMyToast('搜索失败', this.message, 'Error');
          } else {
            this.showMyToast("搜索成功", this.message, "Success");
                        this.showMyToast('搜索成功', this.message, 'Success');
          }
          this.isShowSpinner = false;
          this.showTable = true;
        } else {
          this.showMyToast("搜索失败", r.msg, "Error");
                    this.showMyToast('搜索失败', r.msg, 'Error');
        }
      })
      .catch((error) => {
        console.log("error = " + JSON.stringify(error));
        this.showMyToast("搜索失败", "搜索还没出库的出库单出错", "Error");
                console.log('error = ' + JSON.stringify(error));
                this.showMyToast(
                    '搜索失败',
                    '搜索还没出库的出库单出错',
                    'Error'
                );
      });
  }
@@ -257,7 +261,7 @@
  searchConsumableorFinishJs() {
    this.isShowSpinner = true;
    this.showTable = false;
    console.log("searchConsumableorFinishJs");
        console.log('searchConsumableorFinishJs');
    searchConsumableorFinish({
      orderDate: this.deliveryFromDate,
      deliverDate: this.deliveryToDate,
@@ -269,37 +273,41 @@
    })
      .then((r) => {
        r = JSON.parse(JSON.stringify(r));
        console.log("r = " + JSON.stringify(r));
        if (r.status == "Success") {
                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.data[i]['url'] =
                            '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
          }
          this.message = r.msg;
          if (this.message == "没有搜索到相关出库单") {
            this.showMyToast("搜索失败", this.message, "Error");
                    if (this.message == '没有搜索到相关出库单') {
                        this.showMyToast('搜索失败', this.message, 'Error');
          } else {
            this.showMyToast("搜索成功", this.message, "Success");
                        this.showMyToast('搜索成功', this.message, 'Success');
          }
          this.isShowSpinner = false;
          this.showTable = true;
        } else {
          this.showMyToast("搜索失败", r.msg, "Error");
                    this.showMyToast('搜索失败', r.msg, 'Error');
        }
      })
      .catch((error) => {
        console.log("error = " + JSON.stringify(error));
        this.showMyToast("搜索失败", "搜索已出库已开票的出库单出错", "Error");
                console.log('error = ' + JSON.stringify(error));
                this.showMyToast(
                    '搜索失败',
                    '搜索已出库已开票的出库单出错',
                    'Error'
                );
      });
  }
  //清空
  clearJs() {
    this.deliveryFromDate = "";
    this.deliveryToDate = "";
    this.deliveryOrderNo = "";
    this.contactName = "";
        this.deliveryFromDate = '';
        this.deliveryToDate = '';
        this.deliveryOrderNo = '';
        this.contactName = '';
    this.isShowSpinner = true;
    this.showTable = false;
    cleanUp({
@@ -309,28 +317,28 @@
    })
      .then((r) => {
        r = JSON.parse(JSON.stringify(r));
        console.log("r = " + JSON.stringify(r));
        if (r.status == "Success") {
                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.data[i]['url'] =
                            '/s/lexsummonscreat?ESetid=' + this.data[i].Id;
          }
          this.message = r.msg;
          if (this.message == "没有搜索到相关出库单") {
            this.showMyToast("搜索失败", this.message, "Error");
                    if (this.message == '没有搜索到相关出库单') {
                        this.showMyToast('搜索失败', this.message, 'Error');
          } else {
            this.showMyToast("搜索成功", this.message, "Success");
                        this.showMyToast('搜索成功', this.message, 'Success');
          }
          this.isShowSpinner = false;
          this.showTable = true;
        } else {
          this.showMyToast("搜索失败", r.msg, "Error");
                    this.showMyToast('搜索失败', r.msg, 'Error');
        }
      })
      .catch((error) => {
        console.log("error = " + JSON.stringify(error));
        this.showMyToast("搜索失败", "搜索失败", "Error");
                console.log('error = ' + JSON.stringify(error));
                this.showMyToast('搜索失败', '搜索失败', 'Error');
      });
  }
@@ -349,7 +357,7 @@
  onHandleSort(event) {
    const { fieldName: sortedBy, sortDirection } = event.detail;
    const cloneData = [...this.data];
    cloneData.sort(this.sortBy(sortedBy, sortDirection === "asc" ? 1 : -1));
        cloneData.sort(this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1));
    this.data = cloneData;
    this.sortDirection = sortDirection;
    this.sortedBy = sortedBy;
@@ -372,53 +380,57 @@
  }
  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":
            case 'deliveryFromDate':
        this.deliveryFromDate = value;
        break;
      case "deliveryToDate":
            case 'deliveryToDate':
        this.deliveryToDate = value;
        break;
      case "deliveryOrderNo":
            case 'deliveryOrderNo':
        this.deliveryOrderNo = value;
        break;
      case "contactName":
            case 'contactName':
        this.contactName = value;
        break;
      default:
        console.log("no data");
                console.log('no data');
    }
  }
  editProductLimit() {
    this[NavigationMixin.Navigate]({
      type: "standard__webPage",
            type: 'standard__webPage',
      attributes: {
        url: "/lexoutboundorderimport"
                url: '/lexoutboundorderimport'
      }
    });
  }
  showMyToast(title, message, variant) {
    this.isShowSpinner = false;
    console.log("show custom message");
    var iconName = "";
    var content = "";
    if (variant.toLowerCase() == "success") {
      iconName = "utility:check";
        console.log('show custom message');
        var iconName = '';
        var content = '';
        if (variant.toLowerCase() == 'success') {
            iconName = 'utility:check';
    } else {
      iconName = "utility:error";
            iconName = 'utility:error';
    }
    if (message != "") {
        if (message != '') {
      content =
        "<h2><strong>" + title + "<strong/></h2><h5>" + message + "</h5>";
                '<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")
            .querySelector('c-common-toast')
      .showToast(variant, content, iconName, 10000);
  }