zhao
2021-06-04 c7ec496f9e41c2227103b3ef776e4a3f91bce6b2
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
@{
    Layout = "~/Views/Shared/_LayoutVue.cshtml";
    ViewBag.Title = "PrintBill";
}
@section head{
    <style type="text/css">
        .clearfix {
            height: 25px;
        }
 
        .header_left_span {
            float: left;
            height: 25px;
            line-height: 25px;
        }
 
        .header_right_span {
            float: right;
            height: 25px;
            line-height: 25px;
        }
 
        .el-card__header {
            padding: 2px 10px 5px 10px;
            font-size: 13px;
            font-weight: bold;
        }
    </style>
}
<div id="printBill" v-cloak>
    <el-card class="box-card" style="height:70px;" shadow="hover" v-if="printType=='fjd'">
        <div slot="header" class="clearfix">
            <span class="header_left_span">分拣单</span>
            <el-checkbox style="float: right; " v-model="enablePrintFjd">是否启用</el-checkbox>
        </div>
        <el-form label-width="60px" v-bind:model="formData" class="demo-ruleForm"
                 v-bind:inline="true">
            <el-form-item label="打印机:">
                <hh-select-url v-model="formData.printer"
                               v-bind:url="printUrl"
                               v-bind:disabled="!enablePrintFjd"
                               valuefield="CN_S_PRINTER"
                               textfield="CN_S_PRINTER"
                               datafield="Data"></hh-select-url>
            </el-form-item>
            <el-form-item label="模板:">
                <hh-select-url v-model="formData.printTemplet"
                               v-bind:url="printTempletUrl"
                               v-bind:disabled="!enablePrintFjd"
                               valuefield="CN_S_TEMPLET_NAME"
                               textfield="CN_S_TEMPLET_NAME"
                               datafield="Data"></hh-select-url>
            </el-form-item>
        </el-form>
    </el-card>
    <el-card class="box-card" style="height:70px;" shadow="hover" v-if="printType=='wld'">
        <div slot="header" class="clearfix">
            <span class="header_left_span">物流单</span>
        </div>
        <el-form label-width="60px" v-bind:model="formData" class="demo-ruleForm"
                 v-bind:inline="true">
            <el-form-item label="打印机:">
                <hh-select-url v-model="formData.printer"
                               v-bind:url="printUrl"
                               valuefield="CN_S_PRINTER"
                               textfield="CN_S_PRINTER"
                               datafield="Data"></hh-select-url>
            </el-form-item>
            <el-form-item label="模板:">
                <hh-select-url v-model="formData.printTemplet"
                               v-bind:url="printTempletUrl"
                               valuefield="CN_S_TEMPLET_NAME"
                               textfield="CN_S_TEMPLET_NAME"
                               datafield="Data"></hh-select-url>
            </el-form-item>
        </el-form>
    </el-card>
    <el-card class="box-card" style="height:70px;" shadow="hover" v-if="printType=='zxm'">
        <div slot="header" class="clearfix">
            <span class="header_left_span">装箱码</span>
            <span class="header_right_span">
                份数:
                <el-input-number v-model="packNum"
                                 v-bind:min="1"
                                 size="mini"></el-input-number>
            </span>
        </div>
        <el-form label-width="60px" v-bind:model="formData" class="demo-ruleForm"
                 v-bind:inline="true">
            <el-form-item label="打印机:">
                <hh-select-url v-model="formData.printer"
                               v-bind:url="printUrl"
                               valuefield="CN_S_PRINTER"
                               textfield="CN_S_PRINTER"
                               datafield="Data"></hh-select-url>
            </el-form-item>
            <el-form-item label="模板:">
                <hh-select-url v-model="formData.printTemplet"
                               v-bind:url="printTempletUrl"
                               valuefield="CN_S_TEMPLET_NAME"
                               textfield="CN_S_TEMPLET_NAME"
                               datafield="Data"></hh-select-url>
            </el-form-item>
        </el-form>
    </el-card>
    <el-footer style="padding:10px 15px;text-align:center">
        <el-button size="mini" type="primary" v-on:click="createBill">打 单</el-button>
        <el-button size="mini" type="primary" v-on:click="close">关 闭</el-button>
    </el-footer>
</div>
@section scripts{
    <script>
        new Vue({
            watch: {
                enablePrintFjd: function (val) {
                    if (!this.enablePrintFjd) {
                        this.formData.printer = "";
                        this.formData.printTemplet = "";
                    }
                }
            },
            computed: {
                printTempletUrl: function () {
                    if (this.formData.printer) {
                        this.formData.printTemplet = "";
                        return '/Basic/Common/GetPrintTemplet?stockCode=' + this.stockCode + '&templetType=' + this.templetType + '&printer=' + this.formData.printer + "&logistics=" + this.logistics;
                    }
                    return '';
                },
                printUrl: function () {
                    return '/Basic/Common/GetPrintTemplet?stockCode=' + this.stockCode + '&templetType=' + this.templetType;
                }
            },
            data: {
                formData: {
                    printer: "",
                    printTemplet: ""
                },
                templetType: "",
                packNum: 1,
                opNos: "",
                enablePrintFjd: false,
                showAll: false,
                printType: "",
                stockCode: "",
                logistics:""
            },
            methods: {
                close: function () {
                    wms.dialogFrame.show = false
                },
                createBill: function () {
                    var $this = this;
                    var ajaxData = null;
                    if (($this.printType == 'fjd' && $this.enablePrintFjd) || $this.printType != 'fjd') {
                        if (!$this.formData.printer) {
                            wms.warning("请选择打印机!");
                            return;
                        }
                        if (!$this.formData.printTemplet) {
                            wms.warning("请选择打印机模板!");
                            return;
                        }
                    }
                    switch (this.printType) {
                        case 'fjd':
                            if ($this.enablePrintFjd) {
                                if (!$this.printer.printer) {
                                    wms.warning("请选择打印机!");
                                    return;
                                }
                                if (!$this.printer.printTemplet) {
                                    wms.warning("请选择打印机模板!");
                                    return;
                                }
                            }
                            ajaxManage({
                                url: "@Url.Action("CreateBill")",
                                data: { opNos: $this.opNos, printer: $this.formData.printer, printTemplet: $this.formData.printTemplet },
                                success: function (data) {
                                    wms.showMsg(data, function () {
                                        wms.success("打单成功");
                                        wms.dialogFrame.cb();
                                    });
                                }
                            });
                            break;
                        case 'zxm':
                            ajaxData = { opNos: $this.opNos, printer: $this.formData.printer, printTemplet: $this.formData.printTemplet, stockCode: $this.stockCode, printType: 3, packNum: $this.packNum };
                            break;
                        case 'wld':
                            ajaxData = { opNos: $this.opNos, printer: $this.formData.printer, printTemplet: $this.formData.printTemplet, stockCode: $this.stockCode, printType: 0 };
                            break;
                    }
                    if (ajaxData) {
                        ajaxManage({
                            url: "@Url.Action("SavePrinter")",
                            data: ajaxData,
                            success: function (data) {
                                wms.showMsg(data, function () {
                                    wms.success("打单成功");
                                    wms.dialogFrame.cb();
                                });
                            }
                        });
                    }
                }
            },
            mounted: function () {
                this.opNos = GetUrlParam("opNos");
                this.printType = GetUrlParam("printType");
                switch (this.printType) {
                    case 'wld':
                        this.templetType = '物流单';
                        break;
                    case 'zxm':
                        this.templetType = '装箱标签';
                        break;
                }
                this.stockCode = GetUrlParam("stockCode");
                this.logistics = GetUrlParam("logistics");
                
                if (!this.printType) this.showAll = true;
            },
            el: '#printBill'
        });
    </script>
}