懒羊羊
2023-10-17 92cffc135581ce2cf4aecac745ddb88e739c17de
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
layui.use(['form', 'table', 'admin', 'ax', 'func','element'], function () {
    var $ = layui.$;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var func = layui.func;
    var form = layui.form;
    var element = layui.element;
 
    /**
     * 配方配置子信息管理
     */
    var FormulaChildInfo = {
        tableId: "formulaChildInfoTable"
    };
 
    $('#imgs').attr("src", "http://localhost:8081/img/9f2f070828381f30fdf1be0da9014c086f06f0ad.jpg");
 
    /**
     * 初始化表格的列
     */
    FormulaChildInfo.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: 'id'},
            {type:"numbers" ,title:'工步',width:40},
            {field: 'operationSteps', sort: true, title: '操作内容'},
            {field: 'techRequirement', sort: true, title: '技术要求'},
            {field: 'operationType', sort: true, title: '类型'},
        ]];
    };
 
 
    initLineInfo();
 
    var ajax = new $ax(Feng.ctxPath + "/workOrder/list?state=3");
    var result = ajax.start();
    let msg = result.data[0];
    $('#workOrder').text(msg.workOrderCode);
    $('#salesOrderCode').text(msg.salesOrderCode);
    $('#productCode').text(msg.productCode);
    $('#productName').text(msg.productName);
    $('#planQty').text(msg.planQty);
    $('#planStartTime').text(msg.planStartTime);
    $('#planEndTime').text(msg.planEndTime);
    $('#recipeCode').text(msg.recipeCode);
    var radioElement = $('#sex1');
 
    var queryData = {};
    queryData['formulaCode'] = msg.recipeCode;
    // 渲染表格
    table.render({
        elem: '#' + FormulaChildInfo.tableId,
        url: Feng.ctxPath + '/formulaChildInfo/list',
        page: false,
        // height: "full-158",
        // height: 460,
        height: 400,
        cellMinWidth: 100,
        where: queryData,
        cols: FormulaChildInfo.initColumn(),
        done: function (res, curr, count) {
            console.log(res);
            //得到当前页码
            console.log(curr);
            //得到数据总量
            console.log(count);
            // 根据条件判断加背景色
            $.each(res.data, function (index, item) {
                console.log(item)
                console.log(item.spareField1)
                if (item.spareField1 === "3") {
                    // 法1
                    $("#formulaChildInfoTable").next().find('tbody tr[data-index="' + index +
                        '"]').css("background-color", "#00ff66");
                }
            });
        }
    });
 
    function initLineInfo(){
        $.ajax({
            type: "POST",
            contentType: "application/json;charset=UTF-8",
            url: Feng.ctxPath + '/lineInfo/list',
            success: function (result) {
                var initIpConf = new $ax(Feng.ctxPath + "/kanbanConf/initIpConf");
                var initResult = initIpConf.start();
 
                $('#lineCode').append(new Option("请选择产线", ""));// 下拉菜单里添加元素
                $.each(result.data, function (index, value) {
                    $('#lineCode').append(new Option(value.lineCode));// 下拉菜单里添加元素
                });
                if(initResult.data!==""){
                    $('#lineCode').val(initResult.data.lineCode);// 下拉菜单里添加元素
                    $('#locationCode').append(new Option(initResult.data.locationCode));// 下拉菜单里添加元素
                }
                layui.form.render("select");//重新渲染 固定写法
            },
        });
    }
 
    form.on("select", function (data) {
        switch(data.elem.id){
            case 'lineCode':
                console.log(data.value);
                if(data.value === ""){
                    $('#locationCode').empty();
                    layui.form.render("select");//重新渲染 固定写法
                }else {
                    $.ajax({
                        type: "POST",
                        contentType: "application/json;charset=UTF-8",
                        url: Feng.ctxPath + '/locationInfo/list?productionLineCode='+data.value,
                        success: function (result) {
                            $('#locationCode').empty();
                            $('#locationCode').append(new Option("请选择工位", ""));// 下拉菜单里添加元素
 
                            $.each(result.data, function (index, value) {
                                $('#locationCode').append(new Option(value.locationCode));// 下拉菜单里添加元素
                            });
                            layui.form.render("select");//重新渲染 固定写法
                        },
                    });
                }
                break;
            case 'locationCode':
                console.log($('#locationCode').val());
                console.log($('#lineCode').val());
                var getIp = new $ax(Feng.ctxPath + "/kanbanConf/ipSetting?lineCode="+$('#lineCode').val()+"&locationCode="+$('#locationCode').val());
                var result = getIp.start();
                Feng.info("更新完成!")
                break;
        }
    });
 
    // //redio闪烁
    // setInterval(function() {
    //     $('input[name="sex1"][value="nan1"]').prop('checked', true);
    // }, 1000);
    // setInterval(function() {
    //     radioElement.prop('checked', false);
    // }, 2000);
 
    //Hash地址的定位
    var layid = location.hash.replace(/^#test=/, '');
    element.tabChange('test', layid);
 
    element.on('tab(test)', function(elem){
        location.hash = 'test='+ $(this).attr('lay-id');
    });
 
    /**
     * 基础BOM管理
     */
    var ProductBomChildInfo = {
        tableId: "productBomChildInfoTable"
    };
 
    /**
     * 初始化表格的列
     */
    ProductBomChildInfo.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: '主键id'},
            {field: 'opCode', sort: true, title: '工序编码'},
            {field: 'opName', sort: true, title: '工序名称'},
            {field: 'materialCode', sort: true, title: '物料编码'},
            {field: 'costQty', sort: true, title: '单耗'},
            {field: 'bomCode', sort: true, title: 'BOM编码'},
        ]];
    };
 
    var queryData = {};
    queryData['bomCode'] = "301002000021";
    // 渲染表格
    table.render({
        elem: '#' + ProductBomChildInfo.tableId,
        url: Feng.ctxPath + '/productBomChildInfo/list',
        page: true,
        height: 460,
        cellMinWidth: 100,
        where: queryData,
        cols: ProductBomChildInfo.initColumn()
    });
 
    $("#scanCode").keydown(function(event) {
        if (event.keyCode === 13) {
            // 执行您想要的代码
            var ajax = new $ax(Feng.ctxPath + "/kb/formulaView/addFormulaState?formulaCode="+msg.recipeCode);
            var result = ajax.start();
            table.reload("formulaChildInfoTable")
            return false; // 阻止默认行为
        }
    });
 
    $("#clear").click(function() {
        var ajax = new $ax(Feng.ctxPath + "/kb/formulaView/clear?formulaCode="+msg.recipeCode);
        var result = ajax.start();
        table.reload("formulaChildInfoTable")
    });
 
});