buli
2023-07-14 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { LightningElement,wire,api,track } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import initPage from '@salesforce/apex/TopPageLwcController.initPage';
 
export default class TopPageLwc extends NavigationMixin(LightningElement) {
 
    @track title = [];
    @track raesList = [];
    @track column = [];
    @track overlimitdateorderdetails = [];
    @track accountInfo;
    @track accountId;
    @track pageRecords = [];
    @track csvData = [];
    @track product_Limit;
    @track over_view = false;
    @track overlimit = false;
    @track hasHos = false;
    @track activeSections = ['A', 'B','C'];
    @track isRender = false;
    @track consumableorderdetailsRecordsview;
 
 
    connectedCallback(){
        initPage()
            .then(result=>{
                if(result.result == 'Success'){
                    this.title = result.title;
                    this.raesList = result.raesList;
                    this.column = result.column;
                    this.accountInfo = result.accountInfo;
                    this.accountId = result.accountInfo.Id;
                    this.pageRecords = result.pageRecords;
                    this.overlimitdateorderdetails = result.overlimitdateorderdetails;
                    this.over_view = result.over_view;
                    this.overlimit = result.overlimit;
                    this.hasHos = result.hasHos;
                    this.product_Limit = result.product_Limit;
                    this.consumableorderdetailsRecordsview = result.consumableorderdetailsRecordsview;
                    console.log('this.accountId:'+this.accountId);
                    console.log('this.accountInfo:'+JSON.stringify(this.accountInfo));
                }else{
                    console.log("Error:"+result.errorMsg);
                    const evt = new ShowToastEvent({
                        title : '初始化页面失败',
                        message: result.errorMsg,
                        variant: 'error'
                    });
                    this.dispatchEvent(evt);
                }
            });
    }
 
    renderedCallback(){
        if(!this.isRender){
            this.isRender = true;
            var tableStr = productLimitTableJs(this.product_Limit);
            const container = this.template.querySelector('div.resultDiv');
            container.innerHTML = tableStr;
        }
 
        function productLimitTableJs(str){
            var csv_data = new Array();
            if(str != null && str != ''){
                csv_data = productlist(str);
            }
            var table = '<table border="0" cellpadding="0" cellspacing="0" class="list" Id = "tab1"><tr class="headerRow"><th>产品型号</th><th>库存下限</th><th>库存上限</th></tr>';
            for (var i = 0; i < csv_data.length; i++) {
                table = table + '<tr class="dataRow">';
                var row = csv_data[i];
                for (var j = 0; j < row.length; j++) {
                    table = table + '<td class="dataCell" style="text-align: center" id = "input' + j +'">';
                    var colu = row[j];
                    table = table + colu + '</td>';
                }
                table = table + '</tr>';
            }
            var table = table + '</table>';
            return table;
        }
 
        function productlist(text_data) {
            var records = new Array();
            var record = new Array();
            var column = new Array();
            var quot_flg = false;
            for (var i = 0; i < text_data.size(); i++) {
                var ch = text_data.charAt(i);
                if (ch == ',') {
                    if (quot_flg) {
                        column.push(',');
                    } else {
                        record.push(column.join(''));
                        column = new Array();
                        records.push(record);
                        record = new Array();
                    }
                } else if (ch == '|') {
                    if (quot_flg) {
                        column.push('|');
                    } else {
                        record.push(column.join(''));
                        column = new Array();
                    }
                } else if (ch == '"') {
                    if (quot_flg) {
                        if ((i + 1) < text_data.size() && text_data.charAt((i + 1)) == '"') {
                            i++;
                            column.push('"');
                        } else {
                            quot_flg = false;
                        }
                    } else {
                        quot_flg = true;
                    }
                } else {
                    column.push(ch);
                }
            }
            if (record.length != 0) {
                record.push(column.join(''));
                records.push(record);
            }
            return records;
        }
    }
 
    editProductLimit(event){
        const config = {
            type: 'standard__webPage',
            attributes: {
                url: '/LexProductLimitEdit'
            }
        };
        this[NavigationMixin.Navigate](config);
    }
}