TTaskClose.js 8.75 KB
layui.config({
    base: "/js/"
}).use(['form', 'I18nPage', 'element', 'vue', 'layer', 'table', 'jquery', 'hhweb', 'Universal'], function () {
    var form = layui.form,
        layer = layui.layer,
        element = layui.element,
        $ = layui.jquery,
        table = layui.table,
        hhweb = layui.hhweb,
        Universal = layui.Universal,
        I18nPage = layui.I18nPage;

    var AreaName = 'task';
    var TableName = 'TTaskAssign';

    var MessageContainer = {};
    I18nPage.GetI18nMessage({
        Type: "PM",
        Code: "TTaskClose",
        Container: MessageContainer,
    });

    var cols_arr = I18nPage.GetI18nTable(
        {
            TableNo: AreaName + "-" + TableName + "-Close",
            TableName: TableName,
            Qel: "#qFields",
        }
    );

    var vmq = new Vue({
        el: '#panelSearch',
        data: {
        }
    });

    hhweb.Config = {
        'qCreateTime': vmq,
    };
    hhweb.InitUIClass();

    LoadStatus();
    function LoadStatus() {
        $("[name='qStatus']").append('<option value="" selected = "selected">' + MessageContainer["QStatus_None"] + '</option>');
        $("[name='qStatus']").append('<option value="0">' + MessageContainer["QStatus_0"] + '</option>');
        $("[name='qStatus']").append('<option value="1">' + MessageContainer["QStatus_1"] + '</option>');
        //$("[name='qStatus']").append('<option value="98">' + MessageContainer["QStatus_98"] + '</option>');
        //$("[name='qStatus']").append('<option value="99">' + MessageContainer["QStatus_99"] + '</option>');
        //$("[name='qStatus']").append('<option value="100">' + MessageContainer["QStatus_100"] + '</option>');
    }

    var mainList = {
        Render: function () {
            mainList.Table = table.render({
                elem: '#mainList'
                , url: "/" + AreaName + "/" + TableName + "/LoadClose"
                , method: "post"
                , even: true
                , page: true //开启分页
                , cols: hhweb.ColumnSetting('mainList1', cols_arr)
                , id: 'mainList'
                , limit: 10
                , limits: [10, 20, 50]
                , defaultToolbar: ['filter']
                , toolbar: '#toolbarTable'
                , height: 'full-20'
                , size: 'lg'
                , done: function (res) { }
            });

            return mainList.Table;
        },
        Load: function () {
            if (mainList.Table == undefined) {
                mainList.Table = this.Render();
                return;
            }
            table.reload('mainList', {});
        }
    };

    var selfbtn = {
        //自定义按钮
        btnRefreshClose: function () {
            mainList.Table = table.render({
                elem: '#mainList'
                , url: "/" + AreaName + "/" + TableName + "/LoadClose"
                , method: "post"
                , even: true
                , page: true //开启分页
                , cols: hhweb.ColumnSetting('mainList1', cols_arr)
                , id: 'mainList'
                , limit: 10
                , limits: [10, 20, 50]
                , defaultToolbar: ['filter']
                , toolbar: '#toolbarTable'
                , height: 'full-20'
                , size: 'lg'
                , done: function (res) { }
            });
        },
        CloseTask: function () {
            var checkStatus = table.checkStatus('mainList');
            var count = checkStatus.data.length;//选中的行数

            if (count == 1) {
                var data = checkStatus.data; //获取选中行的数据
                $.ajax({
                    type: 'POST',
                    url: "/" + AreaName + "/" + TableName + "/GetTaskInfo",
                    data: { taskNo: data[0].Taskno },
                    dataType: 'json',
                    success: function (result) {
                        if (result.count == 1) {
                            var taskInfo = result.data;

                            var content = '<label style="font-size:28px;font-weight:bold;color:rgb(72,156,156)">' + MessageContainer.CloseTask + '</label><br/><br/>'
                                + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="font-size:28px;font-weight:bold;">' + MessageContainer.TaskNo + ':' + data[0].Taskno + '</label><br/>'
                                + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="font-size:28px;;font-weight:bold;">' + MessageContainer.TaskId + ':' + data[0].Taskid + '</label><br/>'
                                + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="font-size:28px;;font-weight:bold;">' + MessageContainer.AssignAgv + ':' + taskInfo.StrTaskAgv + '</label><br/>'
                                + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="font-size:28px;;font-weight:bold;">' + MessageContainer.AgvState + ':' + taskInfo.StrTaskState + '</label><br/>'
                                + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="font-size:28px;;font-weight:bold;">' + MessageContainer.ErrorCode + ':' + (taskInfo.AgvErrorCode == null ? "" : taskInfo.AgvErrorCode) + '</label><br/>'
                                + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<label style="font-size:28px;;font-weight:bold;">' + MessageContainer.ErrorMsg + ':' + ((taskInfo.TaskErrMsg == 0 || taskInfo.TaskErrMsg == null) ? "" : taskInfo.TaskErrMsg) + '</label>';

                            layer.open({
                                type: 0
                                , title: false
                                , closeBtn: 0
                                , area: ['590px', '320px']
                                , shade: 0.1
                                , shadeClose: true
                                , maxmin: false
                                , content: content
                                , btn: [MessageContainer.CancelBtn, MessageContainer.ConfirmBtn]
                                , yes: function () {
                                    layer.closeAll();
                                }
                                , btn2: function () {
                                    var index = layer.load();
                                    $.ajax({
                                        type: "POST",
                                        url: "/" + AreaName + "/" + TableName + "/CloseTask",
                                        async: true,
                                        data: { id: data[0].Id, taskInfo: JSON.stringify(taskInfo) },
                                        dataType: "json",
                                        success: function (data) {
                                            layer.close(index);
                                            if (data.Status) {
                                                layer.msg(MessageContainer.SuccessMsg, { icon: 6, shade: 0.4, time: 1000 });
                                                mainList.Load();
                                            } else {
                                                layer.alert(data.Message, { icon: 2, shadeClose: true, title: MessageContainer.ErrorInfo });
                                            }
                                        },
                                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                                            layer.close(index);
                                            layer.alert(errorThrown, { icon: 2, shadeClose: true, title: MessageContainer.ErrorInfo });
                                        }
                                    });
                                }
                            });
                        }
                        else {
                            layer.alert(result.data.AgvErrorMsg, { icon: 5, shadeClose: true, title: MessageContainer.ErrorInfo });
                        }
                    }
                });
            }
            else
                layer.alert(MessageContainer.SelectSome, { icon: 5, shadeClose: true, title: MessageContainer.ErrorInfo });
        },
    };

    form.on('select(qGroupname)', function (data) {
        vmq.$set('Groupname', data.value);
    });

    form.on('select(qStatus)', function (data) {
        vmq.$set('Status', data.value);
    });

    var selector = {
        'Groupname': {
            SelType: "FromUrl",
            SelFrom: "/task/TTaskGroup/GetTaskGroup",
            SelModel: "Groupname",
            SelLabel: "Groupname",
            SelValue: "Groupname",
            Dom: [$("[name='qGroupname']")]
        },
    };

    var vml = new Array({
        vmq: vmq,
    });

    Universal.BindSelector(vml, selector);
    Universal.mmain(AreaName, TableName, null, vmq, null, selfbtn, mainList);
});