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
@{
    ViewBag.Title = "StoreRel";
    Layout = "~/Views/Shared/_LayoutVue.cshtml";
}
@section head{
    <style>
        .el-transfer-panel {
            width: 170px;
            height: 240px;
        }
        .el-transfer {
            padding:5px 0 0 10px;
        }
        .el-transfer-panel__list {
            height: 170px;
        }
    </style>
}
 
<div id="strategyAdd" v-cloak>
    <el-card class="box-card">
        <el-form label-width="70px" v-bind:inline="true">
            <el-form-item label="业务名称:">
                <el-input style="width:150px" v-model="op.opName" size="mini" v-bind:disabled="true"></el-input>
            </el-form-item>
            <el-form-item label="仓库名:">
                <el-input style="width:150px" v-model="stockCode" size="mini" v-bind:disabled="true"></el-input>
                @*<hh-select-url v-model="stockCode"
                               url="/Basic/Common/StockList"
                               valuefield="CN_S_STOCK_CODE"
                               textfield="CN_S_STOCK_NAME"
                               datafield="Data">
                </hh-select-url>*@
            </el-form-item>
        </el-form>
        <div style="padding:5px 0 15px 0">
            <template>
                <el-transfer v-bind:data="strategyData" v-model="selectValue" v-bind:titles="['可关联库区', '已选库区']"></el-transfer>
            </template>
        </div>
        <div><el-button size="mini" type="success" v-on:click="add" style="float:right; margin:0 10px 10px 0px">保存关联</el-button></div>
    </el-card>
</div>
@section scripts{
    <script>
        new Vue({
            mixins: [useAutoHeight],
            computed: {},
            data: {
                strategyData: [],
                selectValue: [],
                stockCode: '@ViewData["stockName"]',
                op: {
                    opCode: '@ViewData["opCode"]',
                    opName: '@ViewData["opName"]',
                }
            },
            methods: {
                add: function () {
                    var $this = this;
                    ajaxManage({
                        url: "@Url.Action("SaveAreaRel")",
                        data: {
                            stockCode: $this.stockCode, opCode: $this.op.opCode, selectValue: $this.selectValue.join(',')
                        },
                        success: function (data) {
                            if (data.Success) {
                                wms.success("关联成功!");
                                wms.dialogFrame.cb();
                            } else {
                                wms.error(data.Msg);
                            }
                        }
                    });
                },
                GetSelectedArea: function () {
                    var $this = this;
                    ajaxManage({
                        url: "@Url.Action("AbleAreas")?stockCode=" + $this.stockCode + "&opCode=" + $this.op.opCode,
                        success: function (data) {
                            $.each(data.Data, function (i, r) {
                                $this.selectValue.push(r.CN_S_AREA_CODE);
                            });
                        }
                    });
                },
                GetAllArea: function () {
                    var $this = this;
                    ajaxManage({
                        url: "/Basic/Common/AreaList?stockCode=" + $this.stockCode + "&include=1",
                        success: function (result) {
                            if (result.Success) {
                                console.log(result.Data);
                                $.each(result.Data, function (i, r) {
                                    $this.strategyData.push({
                                        key: r.CN_S_AREA_CODE,
                                        label: r.CN_S_AREA_NAME
                                    });
                                });
                                $this.GetSelectedArea();
                            }
                            else {
                                wms.error(data.Msg);
                            }
                        }
                    });
                }
            },
            mounted: function () {
                var $this = this;
                $this.GetAllArea();
            },
            el: '#strategyAdd'
        });
    </script>
}