arrange.js 5.7 KB
Newer Older
1 2 3 4 5 6

layui.config({
    base: basePath,
    version: skyeyeVersion
}).extend({
    window: 'js/winui.window'
doc_wei's avatar
doc_wei 已提交
7
}).define(['window', 'jquery', 'winui', 'form', 'laydate'], function (exports) {
8 9 10 11
    winui.renderColor();
    var index = parent.layer.getFrameIndex(window.name);
    var $ = layui.$,
        form = layui.form,
doc_wei's avatar
doc_wei 已提交
12 13 14
        laydate = layui.laydate;
    var selTemplate = getFileContent('tpl/template/select-option.tpl');
    var id = GetUrlParam("id");
15

doc_wei's avatar
doc_wei 已提交
16 17
    AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryMachinProcedureById", params: {id: id}, type: 'json', method: 'GET', callback: function (json) {
        $("#showForm").html(getDataUseHandlebars($("#beanTemplate").html(), json));
18

doc_wei's avatar
doc_wei 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
        let par = {
            workProcedureId: json.bean.procedureId
        };
        let farmModelHtml = '';
        // 根据工序id查询可以执行该工序的车间
        AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryExecuteFarmByWorkProcedureId", params: par, type: 'json', method: 'GET', callback: function (json) {
            farmModelHtml = getDataUseHandlebars(selTemplate, json);
        }, async: false});

        initTableChooseUtil.initTable({
            id: "arrangeList",
            cols: [
                {id: 'farmId', title: '安排车间', formType: 'select', width: '200', verify: 'required', modelHtml: farmModelHtml },
                {id: 'targetNum', title: '安排任务数量', formType: 'input', width: '140', verify: 'required|number' },
                {id: 'stateName', title: '状态', formType: 'detail', width: '140' }
            ],
            deleteRowCallback: function (trcusid) {},
            addRowCallback: function (trcusid) {},
            form: form,
            minData: 1
39
        });
40

doc_wei's avatar
doc_wei 已提交
41 42 43 44 45 46 47 48 49 50 51 52 53
        initTableChooseUtil.deleteAllRow('arrangeList');
        $.each(json.bean.machinProcedureFarmList, function(i, item) {
            item.stateName = skyeyeClassEnumUtil.getEnumDataNameByCodeAndKey("machinProcedureFarmState", 'id', item.state, 'name');
            var trcusid = initTableChooseUtil.resetData('arrangeList', item);
            var thisRowKey = trcusid.replace("tr", "");
            if (item.state != 'waitReceive') {
                // 只有【待接收】的任务可以删除
                let itemBox = $('input[type="checkbox"][rowId="row' + thisRowKey + '"]');
                itemBox.prop('disabled', true);
                itemBox.addClass('layui-btn-disabled');
                itemBox.next().css("cursor", "not-allowed");
            }
        });
54

doc_wei's avatar
doc_wei 已提交
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
        var planStartTime = laydate.render({
            elem: '#planStartTime', //指定元素
            format: 'yyyy-MM-dd',
            theme: 'grid',
            done:function(value, date){
                planEndTime.config.min = {
                    year: date.year,
                    month: date.month - 1,//关键
                    date: date.date,
                    hours: date.hours,
                    minutes: date.minutes,
                    seconds: date.seconds
                };
            }
        });
70

doc_wei's avatar
doc_wei 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
        var planEndTime = laydate.render({
            elem: '#planEndTime', //指定元素
            format: 'yyyy-MM-dd',
            theme: 'grid',
            done:function(value, date){
                planStartTime.config.max = {
                    year: date.year,
                    month: date.month - 1,//关键
                    date: date.date,
                    hours: date.hours,
                    minutes: date.minutes,
                    seconds: date.seconds
                }
            }
        });
86

doc_wei's avatar
doc_wei 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99
        var actualStartTime = laydate.render({
            elem: '#actualStartTime', //指定元素
            format: 'yyyy-MM-dd',
            theme: 'grid',
            done:function(value, date){
                actualEndTime.config.min = {
                    year: date.year,
                    month: date.month - 1,//关键
                    date: date.date,
                    hours: date.hours,
                    minutes: date.minutes,
                    seconds: date.seconds
                };
100
            }
doc_wei's avatar
doc_wei 已提交
101 102 103 104 105 106 107 108 109 110 111 112 113 114
        });

        var actualEndTime = laydate.render({
            elem: '#actualEndTime', //指定元素
            format: 'yyyy-MM-dd',
            theme: 'grid',
            done:function(value, date){
                actualStartTime.config.max = {
                    year: date.year,
                    month: date.month - 1,//关键
                    date: date.date,
                    hours: date.hours,
                    minutes: date.minutes,
                    seconds: date.seconds
115
                }
doc_wei's avatar
doc_wei 已提交
116 117 118 119 120 121 122 123 124
            }
        });

        matchingLanguage();
        form.render();
        form.on('submit(formAddBean)', function (data) {
            if (winui.verifyForm(data.elem)) {
                var result = initTableChooseUtil.getDataList('arrangeList');
                if (!result.checkResult) {
125 126 127
                    return false;
                }

doc_wei's avatar
doc_wei 已提交
128 129 130 131 132 133 134 135 136
                var params = {
                    id: id,
                    planStartTime: $("#planStartTime").val(),
                    planEndTime: $("#planEndTime").val(),
                    actualStartTime: $("#actualStartTime").val(),
                    actualEndTime: $("#actualEndTime").val(),
                    machinProcedureFarmList: JSON.stringify(result.dataList),
                };
                AjaxPostUtil.request({url: sysMainMation.erpBasePath + "setMachinProcedureById", params: params, type: 'json', method: 'POST', callback: function (json) {
137 138 139 140
                    parent.layer.close(index);
                    parent.refreshCode = '0';
                }});
            }
doc_wei's avatar
doc_wei 已提交
141
            return false;
142
        });
doc_wei's avatar
doc_wei 已提交
143
    }});
144

doc_wei's avatar
doc_wei 已提交
145
    // 取消
146 147 148 149 150
    $("body").on("click", "#cancle", function() {
        parent.layer.close(index);
    });

});