LocationChoice.js
5.81 KB
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
let action = null;
layui.config({
    base: "/js/",
    version: 2
}).use(['system'], function () {
    var form = layui.form,
        $ = layui.jquery,
        element = layui.element,
        table = layui.table,
        system = layui.system,
        sysU = new system.u(),
        sendData = null,
        areaName = "Distribution",
        controllerName = "BaseLocation",
        app = null,
        completState = 90;
    action = {
        queryOptions: function () {
            var options = {
                resetFrom: "form[lay-filter=listForm]",
                fromId: "listForm",
                urlExport: `/${areaName}/${controllerName}/Export`,
                urlQuery: `/${areaName}/${controllerName}/Load`,
                mainTable: app.data.tableIns
            }
            return options;
        },
        rowClickOptions: function () {
            var options = {
                isDefault: false,
                customFn: function (obj) {
                    var stationData = obj.data;
                    //通知主页面 返回code给工序缓存
                    sysU.initParentEvent(stationData);
                }
            }
            return options;
        },
        checkboxMethod: function (obj) {
            var page = "".GetUrlParam("page")
            var locationCode = "".GetUrlParam("locationCode")
            if (page == "LocationChoice") {
                var checkBoxData = {
                    stationCode: null,
                    endPositionCode: locationCode,
                    checkeds: obj.checked,
                }
                if (obj.type == "all") {
                    checkBoxData.stationCode = sysU.getTableAllData(app.data.tableElem).GetArrValue("locationCode");
                } else {
                    checkBoxData.stationCode = obj.data.locationCode;
                }
                var ajaxConfig = {
                    data: checkBoxData,
                    url: `/distribution/BaseLocation/OperateLocationStation`,
                    success: function (result) {
                        if (sysU.successBefore(result)) return false;
                        layer.msg(result.Message);
                    }
                };
                sysU.ajax(ajaxConfig);
            }
        },
        //所有动作成功之后
        actionSuccess: (falg) => {
            app.data.tableIns.config.where = {};
            app.data.tableIns.config.page.curr = 1;
            app.data.tableIns.reload(app.data.tableElem, {});
        }
    }
    app = {
        data: {
            cols: [[
                { checkbox: true, fixed: true },
                { field: "id", width: 80, hide: true, title: "Id" },
                { field: "keys", width: 80, hide: true, title: "Keys" },
                { field: "locationCode", width: 250, title: "料点编码" },
                { field: "locationName", width: 300, title: "料点名称" },
                { field: "stationCode", width: 250, title: "工位编码" },
                {
                    field: "zoneCode", width: 100, title: "区域编码", templet: function (obj) {
                        return "".GetState(window.top.EnumLocationZoneCode, obj.zoneCode);
                    }
                }
            ]],
            tableIns: null,
            tableElem: "mainList",
            //下拉框配置
            selectOption: {
                //station: {
                //    SelType: "FromUrl",
                //    SelFrom: `/${areaName}/${controllerName}/StationLineSelect`,
                //    SelLabel: "workStationName",
                //    SelValue: "workStationCode",
                //    OptGroup: true,
                //    Dom: [$("[name='stationCode']")]
                //},
                //返回的数据 用于后续操作
                selectData: {
                }
            }
        },
        methods: {
            initTable: function () {
                var locationCode = "".GetUrlParam("locationCode");
                var config = { "locationCode": locationCode };
                let options = {
                    elem: "#" + app.data.tableElem,
                    url: `/${areaName}/${controllerName}/LoadData`,
                    cols: sysU.columnRecord(app.data.tableElem, app.data.cols),
                    toolbar: '#toolbarTable',
                    where: config,
                    doneExtend: function (res, obj) {
                        var page = "".GetUrlParam("page");
                        //刷新选中
                        if (page == "LocationChoice") {
                            let ajaxConfig = {
                                data: { locationCode: locationCode },
                                url: `/distribution/BaseLocation/GetLocationChoiceByLocationCode`,
                                success: function (result) {
                                    if (sysU.successBefore(result)) return false;
                                    var targetArrValue = result.Result.map(function (e) { return e.startPositionCode; });
                                    var selectColKey = "".GetUrlParam("selectColKeyCustom");
                                    sysU.SetTableCheck(targetArrValue, res, selectColKey, app.data.tableElem);
                                }
                            };
                            sysU.ajax(ajaxConfig);
                        }
                    }
                }
                app.data.tableIns = sysU.initTable(options);
            },
            initSelectTable: function () {
            },
            initFrom() {
                sysU.initSelect(app.data.selectOption);
            }
        },
        registerEvent: function () {
        },
        init: function () {
            app.methods.initTable();
            app.methods.initFrom();
            app.registerEvent();
        }
    };
    app.init();
});