zhao
2021-07-19 8347f2fbddbd25369359dcb2da1233ac48a19fdc
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
@{
    Layout = "~/Views/Shared/_LayoutVue.cshtml";
    ViewBag.Title = "EditLogistics";
}
 
<div id="editLogistics" v-cloak>
    <el-card class="box-card">
        <el-form label-width="90px" v-bind:model="formData" class="demo-ruleForm" v-bind:inline="true">
            <el-form-item label="物流公司:">
                <hh-select-url v-model="formData.logisticsFlag"
                               url="/Basic/Common/GetLogisticsCompany"
                               valuefield="CN_S_LOGISTICS_FLAG"
                               textfield="CN_S_LOGISTICS_NAME"
                               datafield="Data"></hh-select-url>
            </el-form-item>
            <el-button v-if="false" size="mini" type="primary" v-on:click="createLogistics">一键生成物流单</el-button>
            <el-button style="float:right" size="mini" type="primary" v-on:click="saveLogistics">保 存</el-button>
        </el-form>
    </el-card>
    <el-table class="tb-edit" v-bind:data="logisticsData" style="width: 100%;" border
              highlight-current-row
              size="mini">
        <el-table-column type="index" width="45" align="center" label="行号">
        </el-table-column>
        <el-table-column label="发货通知单" prop="CN_S_OP_NO"></el-table-column>
        <el-table-column label="物流单号" prop="CN_S_WAYBILL_NO">
            <template scope="scope">
                <el-input v-model="scope.row.CN_S_WAYBILL_NO"
                          size="mini"></el-input>
                <span>{{scope.row.CN_S_WAYBILL_NO}}</span>
            </template>
        </el-table-column>
    </el-table>
</div>
@section scripts{
    <script>
        new Vue({
            data: {
                formData: {
                    logisticsFlag: "",
                },
                logisticsData: [],
                opNos: ""
            },
            watch: {
                deep: true,
                "formData.logisticsFlag": function (val) {
                    //alert(val);
                }
            },
            methods: {
                validate: function () {
                    var $this = this;
                    if (!$this.formData.logisticsFlag) {
                        wms.warning("请选择物流公司!");
                        return false;
                    }
                    var failedMsg = "";
                    $.each($this.logisticsData, function (i, n) {
                        if (!n.CN_S_WAYBILL_NO) {
                            failedMsg = "物流单号不可为空!";
                            return false;
                        }
                    });
                    if (failedMsg) {
                        wms.warning(failedMsg);
                        return false;
                    }
                    return true;
                },
                saveLogistics: function () {
                    var $this = this;
                    if (!this.validate()) return;
                    var updateLogistics = [];
                    $this.logisticsData.forEach(function (n) {
                        updateLogistics.push({
                            CN_S_LOGISTICS_FLAG: $this.formData.logisticsFlag,
                            CN_S_WAYBILL_NO: n.CN_S_WAYBILL_NO,
                            CN_S_OP_NO: n.CN_S_OP_NO
                        });
                    });
                    ajaxManage({
                        url: "@Url.Action("SaveWayBill")",
                        data: JSON.stringify(updateLogistics),
                        success: function (data) {
                            wms.showMsg(data);
                            wms.dialogFrame.cb();
                        }
                    });
                },
                loadLogistics: function () {
                    var $this = this;
                    ajaxManage({
                        url: "@Url.Action("GetOutMstRange")?opNos=" + $this.opNos,
                        success: function (data) {
                            wms.showMsg(data, function () {
                                $this.logisticsData = data.Data;
                            });
                        }
                    });
                },
                createLogistics: function () {
                    var $this = this;
                    var opNo = [];
                    $this.logisticsData.forEach(function (n) {
                        opNo.push(n.CN_S_OP_NO);
                    });
                    //
                    ajaxManage({
                        url: "@Url.Action("CreateLogistics")?outNos=" + opNo.join(','),
                        success: function (data) {
                            wms.showMsg(data, function () {
                                console.log(data.Data);
                                data.Data.forEach(function (n) {
                                    if (n.Success) {
                                        wms.$notify({
                                            title: '生成成功',
                                            message: 'hh',
                                            type: 'success'
                                        });
                                    } else {
                                        wms.$notify.error({
                                            title: '生成失败',
                                            message: n.Reason
                                        });
                                    }
                                });
                            });
                        }
                    });
                }
            },
            mounted: function () {
                this.opNos = GetUrlParam("opNos");
                this.loadLogistics();
                if (this.logisticsData[0].CN_S_LOGISTICS_FLAG)
                    this.formData.logisticsFlag = this.logisticsData[0].CN_S_LOGISTICS_FLAG;
            },
            el: '#editLogistics'
        });
    </script>
}