zhao
2021-06-24 02ca96debc6056275d58e55d97f7885a195542d0
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
@{
    ViewBag.Title = "盘点新增";
    Layout = "~/Views/Shared/_LayoutVue.cshtml";
}
@section head
    {
    <style type="text/css">
        .block {
            text-align: right;
        }
    </style>
}
 
<div id="inList" v-cloak>
    <el-card class="box-card">
        <el-form v-bind:model="formData" style="margin-top:5px;" label-width="85px" class="demo-ruleForm" v-bind:inline="true">
            <el-form-item label="盘点类型:">
                <hh-select-url v-model="formData.checkType"
                               url="/Basic/Common/GetDictionary?dictName=盘点类型"
                               v-bind:disabled="readOnly"
                               valuefield="NAME"
                               textfield="NAME"
                               v-bind:usedefault="false"
                               v-on:change="changeType"></hh-select-url>
            </el-form-item>
            <el-form-item label="仓  库:">
                <hh-select-url v-model="formData.stockCode"
                               url="/Basic/Common/StockList"
                               valuefield="CN_S_STOCK_CODE"
                               textfield="CN_S_STOCK_NAME"
                               datafield="Data"
                               v-on:success="stockSuccess"
                               v-bind:usedefault="false"></hh-select-url>
            </el-form-item>
            <el-form-item label="库  区:">
                <hh-select-url v-model="formData.stockArea"
                               v-bind:url="areaUrl"
                               valuefield="CN_S_AREA_CODE"
                               textfield="CN_S_AREA_NAME"
                               datafield="Data"></hh-select-url>
            </el-form-item>
            <el-form-item label="货  位:" v-if="showlocation">
                <el-input v-model="formData.locationCode" size="mini" onkeyup="this.value = this.value.replace(/\'|’|‘/g, '')"></el-input>
            </el-form-item>
 
            <el-form-item label="货  主:" v-if="showOwner">
                <el-input v-model="formData.owner" size="mini" onkeyup="this.value = this.value.replace(/\'|’|‘/g, '')"></el-input>
            </el-form-item>
            <el-form-item label="物料编码:" v-if="showItemCode" prop="CN_S_ITEM_CODE">
                <el-input v-model="formData.itemCode" onkeyup="this.value = this.value.replace(/\'|’|‘/g, '')" size="mini">
                    <i class="el-icon-more el-input__icon"
                       slot="suffix"
                       v-on:click="selectItem">
                    </i>
                </el-input>
            </el-form-item>
            <el-button style="margin-top:2px;" size="mini" type="primary" v-on:click="search">查 询</el-button>
        </el-form>
        <el-row style="padding-left:10px;margin-top:7px;">
            <el-button size="mini" type="primary" v-on:click="save">保 存</el-button>
            @*<el-button size="mini" type="primary" v-on:click="reset">重 置</el-button>
                <el-button size="mini" type="primary" v-on:click="diy" v-show="readonlydiy">自定义盘点</el-button>*@
 
        </el-row>
    </el-card>
    <hh-table v-bind:coloptions="checkListCols"
              v-bind:paging="true"
              v-bind:notfirstload="true"
              v-bind:url="'@Url.Action("GetTrayLocation")'"
              v-bind:check="true"
              v-on:clickrow="clickRow"
              v-on:loaded="loaded"
              v-on:selectall="selectall"
              ref="CheckMstList"
              v-bind:rowno="true"
              v-bind:dh="tableHeight"></hh-table>
 
    <el-tabs type="border-card" tab-position="left">
        <hh-table v-bind:coloptions="checkDtlCols"
                  v-bind:single="true"
                  v-bind:data="checkdtlDate"
                  ref="CheckDtlList"
                  v-bind:dh="tabTableHeight"
                  v-bind:rowno="true"
                  v-on:dbclickrow="doubleRowclick"></hh-table>
    </el-tabs>
</div>
@section scripts{
    <script src="~/Content/js/linq.js_ver2.2.0.2/linq.js"></script>
    <script>
        new Vue({
            mixins: [useAutoHeight],
            data: {//数据
                formData: {
                    checkType: "",
                    stockCode: "",
                    itemCode: "",
                    stockArea: "",
                    locationCode: "",
                    owner: ""
                },
                showlocation: true,
                showOwner: false,
                showItemCode: false,
                readOnly: false,
                readonlydiy: true,
                checkListCols: [],
                checkDtlCols: [],
                dtlUrl: "",
                cklistUrl: "",
                itemCols: [
                      { f: 'CN_S_ITEM_CODE', n: '物料编码' },
                      { f: 'CN_S_ITEM_NAME', n: '物料名称' },
                      { f: 'CN_S_MODEL', n: '规格型号' },
                      { f: 'CN_S_FIGURE_NO', n: '图号' },
                      { f: 'CN_C_IS_WARRNTY_PARTS', n: '是否质保件' },
                      { f: 'CN_F_WARRNTY_PARTS', n: '质保期' },
                      { f: 'CN_S_MEASURE_UNIT', n: '计量单位' }
                ],
                locationCheckCols: [
                                { f: 'CN_S_STOCK_CODE', n: '仓库名称' },
                                { f: 'CN_S_AREA_CODE', n: '库区名称' },
                                { f: 'CN_S_LOCATION_CODE', n: '货位' }
                ],
                itemCheckCols: [
                                { f: 'CN_S_ITEM_CODE', n: '物料编码' },
                                { f: 'CN_S_ITEM_NAME', n: '物料名称' },
                                { f: 'CN_S_ITEM_STATE', n: '物料状态' },
                                { f: 'CN_S_MODEL', n: '物料规格' },
                                { f: 'CN_S_FIGURE_NO', n: '物料图号' },
                                { f: 'CN_S_OWNER', n: '货主' },
                                { f: 'CN_F_QUANTITY', n: '库存量' },
                                { f: 'CN_S_MEASURE_UNIT', n: '计量单位' }
                ],
                checkdtlDate: [], //盘点单子表行记录
                currentTitle: parent.$(".layui-tab-title li[class='layui-this'] cite").text(),
 
                opNo: ""
            },
 
            methods: {
                search: function () {
                    var $this = this;
                    $this.$refs.CheckMstList.loadData($this.formData);
                },
                selectall: function () {
                    $this = this;
                    if ($this.$refs.CheckMstList.selections.length > 0) {
                        //全选
                        $.each($this.$refs.CheckMstList.selections, function (i, row) {
                            var selected = ($this.checkdtlDate.indexOf(row) < 0);
                            if (selected) {
                                //选中
                                $this.checkdtlDate.push(row);
                            }
                        });
                    }
                    else {
                        //取消全选
                        $.each($this.$refs.CheckMstList.datas, function (i, row) {
                            var index = $this.checkdtlDate.indexOf(row);
                            $this.checkdtlDate.splice(index, 1);
                        });
                    }
                },
                stockSuccess: function (data) {
                    if (data.length == 1 && !this.formData.stockCode) {
                        this.formData.stockCode = data[0];
                    }
                },
                save: function () {
                    //提交
                    var $this = this;
                    var errorMsg = null;
 
                    var type = $this.formData.checkType;
                    var stockCode = $this.formData.stockCode;
                    var obj = "";
                    var urls = "";
                    if ($this.checkdtlDate.length == 0) {
                        wms.warning("请选择盘点信息");
                        return false;
                    }
 
                    if ($this.formData.checkType == "") {
                        wms.warning("请选择盘点类型");
                        return false;
                    }
                    if ($this.formData.stockCode == "") {
                        wms.warning("请选择仓库");
                        return false;
                    }
 
                    $.each($this.checkdtlDate, function (i, r) {
                        r.CN_S_STOCK_AREA = r.CN_S_AREA_CODE;
                    });
                    //新增
                    if (GetUrlParam("opNo") == "") {
                        obj = { "type": type, "rows": $this.checkdtlDate, stockcode: stockCode, state: "新建" };
                        urls = "@Url.Action("add")";
                    }
                    else  //修改
                    {
                        obj = { opNo: GetUrlParam("opNo"), "rows": $this.checkdtlDate };
                        urls = "@Url.Action("Update")";
                    }
                    //保存数据
                    ajaxManage({
                        url: urls,
                        data: JSON.stringify(obj),
                        traditional: true,
                        success: function (data) {
                            wms.showMsg(data, function () {
                                if (data.Success) {
                                    wms.success("保存成功");
                                    parent.tab.tabDeleteRefresh($this.currentTitle, GetUrlParam("currentTitle"));
                                } else {
                                    wms.error(data.Msg);
                                }
                            });
                        }
                    });
                },
                reset: function ()//重置
                {
                    var $this = this;
                    $this.checkdtlDate = [];
                },
                loaded: function () {
                    $this = this;
                    $this.checkdtlDate
                    $.each($this.checkdtlDate, function (index, row) {
                        $.each($this.$refs.CheckMstList.datas, function (i, r) {
                            if ($this.formData.checkType == "货位盘点") {
                                if (r.CN_S_LOCATION_CODE == row.CN_S_LOCATION_CODE) {
                                    $this.$nextTick(function () {
                                        $this.$refs.CheckMstList.toggleRowSelection($this.$refs.CheckMstList.datas[i]);
                                    });
                                }
                            }
                            else if (($this.formData.checkType == "物料盘点"))
                            {
                                if (r.CN_S_ITEM_CODE == row.CN_S_ITEM_CODE
                                    && r.CN_S_ITEM_STATE == row.CN_S_ITEM_STATE
                                    && r.CN_S_OWNER == row.CN_S_OWNER)
                                {
                                    $this.$nextTick(function () {
                                        $this.$refs.CheckMstList.toggleRowSelection($this.$refs.CheckMstList.datas[i]);
                                    });
                                }
                            }
                        });
                    });
                },
                clickRow: function (row, event, column) {
                    $this = this;
                    var selected = (this.$refs.CheckMstList.selections.length && this.$refs.CheckMstList.selections.indexOf(row) !== -1);
                    if (selected) {
                        //选中
                        $this.checkdtlDate.push(row);
                    }
                    else {
                        //取消选中
                        var type = $this.formData.checkType;
                        if (type == "物料盘点") {
                            $.each($this.checkdtlDate, function (i, r) {
                                if (r.CN_S_ITEM_CODE == row.CN_S_ITEM_CODE
                                        && r.CN_S_ITEM_STATE == row.CN_S_ITEM_STATE
                                        && r.CN_S_OWNER == row.CN_S_OWNER) {
                                    $this.checkdtlDate.splice(i, 1);
                                }
                            });
                        }
                        else if (type == "货位盘点") {
                            $.each($this.checkdtlDate, function (i, r) {
                                if (r.CN_S_LOCATION_CODE == row.CN_S_LOCATION_CODE) {
                                    $this.checkdtlDate.splice(i, 1);
                                }
                            });
                        }
                    }
                },
                doubleRowcheckMst: function (row, event) {
                    var $this = this;
                    var checkInfo =
                   {
                       //CN_S_STOCK_NAME: row.CN_S_STOCK_NAME,
                       CN_S_AREA_NAME: row.CN_S_AREA_NAME,
                       CN_S_STOCK_CODE: $.trim(row.CN_S_STOCK_CODE),
                       CN_S_STOCK_AREA: $.trim(row.CN_S_STOCK_AREA),
                       CN_S_ITEM_CODE: row.CN_S_ITEM_CODE,
                       CN_S_ITEM_NAME: row.CN_S_ITEM_NAME,
                       CN_S_ITEM_STATE: row.CN_S_ITEM_STATE,
                       CN_S_MODEL: row.CN_S_MODEL,
                       CN_S_FIGURE_NO: row.CN_S_FIGURE_NO,
                       CN_S_OWNER: row.CN_S_OWNER,
                       CN_S_LOT_NO: row.CN_S_LOT_NO,
                       CN_S_LOCATION_CODE: row.CN_S_LOCATION_CODE,
                       CN_F_QUANTITY: row.CN_F_QUANTITY,
                       CN_S_MEASURE_UNIT: row.CN_S_MEASURE_UNIT,
                   }
                    //删除选中行
                    $this.checkdtlDate.splice($this.checkdtlDate.indexOf(checkInfo), 1);
                },
                //双击行删除
                doubleRowclick: function (row, event) {
                    var $this = this;
                    for (var i = 0; i < $this.checkdtlDate.length; i++) {//判断是否重复 选择物料
                        if ($this.checkdtlDate[i].CN_S_STOCK_CODE == $.trim(row.CN_S_STOCK_CODE)
                            //&& $this.checkdtlDate[i].CN_S_STOCK_AREA == $.trim(row.CN_S_STOCK_AREA)
                            && $this.checkdtlDate[i].CN_S_ITEM_CODE == row.CN_S_ITEM_CODE
                            && $this.checkdtlDate[i].CN_S_ITEM_NAME == row.CN_S_ITEM_NAME
                            && $this.checkdtlDate[i].CN_S_ITEM_STATE == row.CN_S_ITEM_STATE
                            && $this.checkdtlDate[i].CN_S_MODEL == row.CN_S_MODEL
                            && $this.checkdtlDate[i].CN_S_FIGURE_NO == row.CN_S_FIGURE_NO
                            && $this.checkdtlDate[i].CN_S_OWNER == row.CN_S_OWNER
                            && $this.checkdtlDate[i].CN_S_LOCATION_CODE == row.CN_S_LOCATION_CODE
                            && $this.checkdtlDate[i].CN_F_QUANTITY == row.CN_F_QUANTITY
                            && $this.checkdtlDate[i].CN_S_MEASURE_UNIT == row.CN_S_MEASURE_UNIT
                            && $this.checkdtlDate[i].CN_S_LOT_NO == row.CN_S_LOT_NO) {
 
                            //删除选中行
                            $this.checkdtlDate.splice(i, 1);
                            return false;
                        }
                    }
                },
                selectSingleRowEvent: function (callBack) {
                    var selectRow = this.$refs.increaselist.selections;
                    if (selectRow.length <= 0) {
                        wms.warning("请选择一条记录");
                        return;
                    }
                    if (callBack)
                        callBack(selectRow[0]);
                },
                selectItem: function () {
                    var $this = this;
                    wms.showDialogList({
                        title: '选择物料',
                        show: true,
                        itemCols: $this.itemCols,
                        condition: 'item',
                        url: '/Basic/Common/ItemList',
                        btnSure: function (checkedItems) {
                            $this.formData.itemCode = checkedItems[0].CN_S_ITEM_CODE;
                        }
                    });
                },
                diy: function () {
                    wms.showDialogFrame({
                        title: '自定义新增',
                        dh: 380,
                        width: "400px",
                        btn: false,
                        callBack: function (frame) {
                            $this.$refs.CheckMstList.loadData();
                        },
                        url: "@Url.Action("Batch")"
                    });
                },
                changeType: function () {
                    var $this = this;
                    wms.confirm("确认重新选择?", function () {
                        $this.checkdtlDate = [];
                        type = $this.formData.checkType;
 
                        if (type == "货位盘点") {
                            $this.showlocation = true;
                            $this.showOwner = false,
                            $this.showItemCode = false,
 
                            $this.formData.locationCode = "";
                            $this.checkListCols = $this.locationCheckCols;
                            $this.checkDtlCols = $this.locationCheckCols;
                        }
                        else {
                            $this.showlocation = false;
                            $this.showOwner = true,
                            $this.showItemCode = true,
                            $this.checkListCols = $this.itemCheckCols;
                            $this.checkDtlCols = $this.itemCheckCols;
                        }
                    });
                }
            },
            mounted: function () {
                var $this = this;
                var opNo = GetUrlParam("opNo");
                if (opNo == "") {
                    $this.formData.checkType = "货位盘点";
                        $this.checkListCols = $this.locationCheckCols
                        $this.checkDtlCols = $this.locationCheckCols;
                }
                else {
                    //修改
                    $this.readOnly = true;
                    $this.readonlydiy = false;
 
                    ajaxManage({
                        url: "@Url.Action("GetModel")?opNo=" + opNo,
                        type: "GET",
                        success: function (data) {
                            if (data.Success) {
                                $this.formData.checkType = data.Data.CN_S_TYPE;
 
                                if (data.Data.CN_S_TYPE == "货位盘点") {
                                    $this.checkListCols = $this.locationCheckCols
                                    $this.checkDtlCols = $this.locationCheckCols;
                                }
                                else if (data.Data.CN_S_TYPE == "物料盘点") {
                                    $this.checkListCols = $this.itemCheckCols;
                                    $this.checkDtlCols = $this.itemCheckCols;
                                }
 
                                $.each(data.Data.dtls, function (i, r) {
                                    r.CN_S_STOCK_CODE = data.Data.CN_S_STOCK_CODE;
                                    r.CN_S_AREA_CODE = r.CN_S_STOCK_AREA;
                                });
                                $this.checkdtlDate = data.Data.dtls;
                                $this.formData.stockcode = data.Data.CN_S_STOCK_CODE;
                            }
                            else {
                                wms.error(data.Msg);
                            }
                        }
                    });
                }
            },
            computed: {
                tableHeight: function () {
                    return (this.autoHeight + 100) / 2;
                },
                tabHeight: function () {
                    return (this.autoHeight - 200) / 2;
                },
                tabTableHeight: function () {
                    return (this.autoHeight + 80) / 2;
                },
                areaUrl: function () {
                    if (this.formData.stockCode) {
                        this.formData.stockArea = "";
                        return '/Basic/Common/AreaList?stockCode=' + this.formData.stockCode + '&include=1';
                    } else {
                        this.formData.stockArea = "";
                    }
                    return '';
                }
            },
            el: '#inList'
        });
 
    </script>
}