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
@{
    Layout = "~/Views/Shared/_LayoutVue.cshtml";
    ViewBag.Title = "算法策略";
}
 
@section head{
 
    <style>
        .el-input__inner {
            text-align: center;
        }
    </style>
}
<div id="strategyList" 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="库区名称:">
                <el-input v-model="formData.areaName" size="mini"></el-input>
            </el-form-item>
            <el-button style="margin-top:2px;" size="mini" type="primary" v-on:click="search">查 询</el-button>
 
            @*<el-button size="mini" type="warning" v-on:click="setpriority" style="float:right">设置优先级</el-button>*@
        </el-form>
    </el-card>
    <el-row>
        <el-col v-bind:span="9">
            <hh-table v-bind:coloptions="areaCols" style="margin-right:10px"
                      v-bind:paging="true"
                      v-bind:single="true"
                      v-bind:check="true"
                      v-bind:where="where"
                      v-on:clickrow="clickRow"
                      url="/Basic/Common/GetStockAndAreaList"
                      ref="areaList"
                      dh="100">
            </hh-table>
        </el-col>
        <el-col v-bind:span="15" style="float:right">
            <el-button size="mini" type="success" v-on:click="add" style="margin:10px 0px 5px 0px">新增关联</el-button>
            <el-button size="mini" type="danger" v-on:click="del" style="margin:10px 0px 5px 5px">删除关联</el-button>
            @*<hh-table v-bind:coloptions="strategyCols"
                          v-bind:single="true"
                          v-bind:url="itemUrl"
                          ref="strategyList"
                          dh="100">
                </hh-table>*@
            <el-table v-bind:data="tableData" ref="singleTable" class="tb-edit" style="width: 100%;height:365px"
                      border highlight-current-row v-on:row-click="clickStrategyRow" size="mini">
                <el-table-column type="selection" width="35"></el-table-column>
                <el-table-column label="策略编码" prop="CN_S_CODE" width="150" align="center"></el-table-column>
                <el-table-column label="策略名称" prop="CN_S_NAME" width="120" align="center"></el-table-column>
                <el-table-column label="策略类型" prop="CN_S_TYPE" width="70" align="center"></el-table-column>
                <el-table-column label="是否使用" prop="CN_C_IS_USE" width="70" align="center"></el-table-column>
                <el-table-column label="条件" prop="CN_S_WHERE" width="90" align="center"></el-table-column>
                <el-table-column label="优先级" prop="CN_N_PRIORITY" width="80" align="center">
                    <template scope="scope">
                        <el-input size="mini" type="text" maxlength="3" v-model.number="scope.row.CN_N_PRIORITY" v-on:keyup.native="checkNum(scope.row,scope.$index)" v-on:change.native="updatePriority(scope.row,scope.$index)" placeholder=""></el-input>
                        <span>{{scope.row.CN_N_PRIORITY}}</span>
                    </template>
                </el-table-column>
 
                <el-table-column label="备注" prop="CN_S_NOTE" width="110" align="center">
            </el-table>
        </el-col>
    </el-row>
</div>
@section scripts{
    <script>
        new Vue({
            mixins: [useAutoHeight],
            computed: {},
            data: {
                areaCode: "",
                stockCode: "",
                itemUrl: "",
                formData: {
                    areaName: ""
                },
                where: {},
                areaCols: [
                    { f: "CN_S_STOCK_CODE", n: "仓库编码", w: "70" },
                    { f: "CN_S_STOCK_NAME", n: "仓库名称", w: "90" },
                    { f: "CN_S_AREA_CODE", n: "库区编码", w: "103" },
                    { f: "CN_S_AREA_NAME", n: "库区名称", w: "125" }
                ],
                tableData: [],
            },
            methods: {
                checkNum: function (row, index) {
                    var oldvalue = row.CN_N_PRIORITY.toString();
                    row.CN_N_PRIORITY = oldvalue.replace(/[^\d]/g, '').replace('.', '');
                    if (row.CN_N_PRIORITY == "" || row.CN_N_PRIORITY == "0") {
                        row.CN_N_PRIORITY = "1";
                    }
                    var $this = this;
                    $this.$set($this.tableData, index, row);
                },
                updatePriority: function (row, index) {
                    var priority = row.CN_N_PRIORITY.toString();
                    var $this = this;
 
                    ajaxManage({
                        url: "/Sys/Strategy/UpdatePriority?areaCode=" + $this.areaCode + "&stockCode=" + $this.stockCode + "&strategyGuid=" + row.CN_GUID + "&priority=" + priority,
                        success: function (data) {
                            if (data.Success) {
                                wms.success("更新优先级成功!");
                            }
                            else {
                                wms.warning("优先级更新失败!" + data.Msg);
                            }
                            return;
                        }
                    });
 
                },
                search: function () {
                    var $this = this;
                    $this.areaCode = "";
                    $this.stockCode = "";
                    this.$refs.areaList.loadData(this.formData);
                    $this.tableData = [];
                },
                add: function () {
                    var $this = this;
                    var areaCode = $this.areaCode;
                    var stockCode = $this.stockCode;
                    if (areaCode == "" && stockCode == "") {
                        wms.warning("请先选择左侧仓库或者库区!");
                        return;
                    }
                    wms.showDialogFrame({
                        title: '新增策略',
                        dh: 220,
                        width: "720px",
                        btn: false,
                        callBack: function (frame) {
                            ajaxManage({
                                url: "/Sys/Strategy/GetStrategyList?areaCode=" + areaCode + "&stockCode=" + stockCode,
                                success: function (data) {
                                    console.log(data.Data);
                                    $this.tableData = data.Data;
                                }
                            });
                        },
                        url: "@Url.Action("Add")?areaCode=" + areaCode + "&stockCode=" + stockCode
                    });
 
 
                },
                del: function () {
                    var $this = this;
                    var areaCode = $this.areaCode;
                    var stockCode = $this.stockCode;
 
                    var selectRow = this.$refs.singleTable.selection;
                    if (selectRow.length <= 0) {
                        wms.warning("请先选择右侧策略行!");
                        return;
                    }
                    wms.confirm("确认删除?", function () {
                        ajaxManage({
                            url: "/Sys/Strategy/DeleteAreaStrategy?areaCode=" + areaCode + "&stockCode=" + stockCode + "&strategyGuid=" + selectRow[0].CN_GUID,
                            success: function (data) {
                                wms.showMsg(data, function () {
                                    wms.success("策略删除成功!");
                                    ajaxManage({
                                        url: "/Sys/Strategy/GetStrategyList?areaCode=" + areaCode + "&stockCode=" + stockCode,
                                        success: function (data) {
                                            $this.tableData = data.Data;
                                        }
                                    });
                                });
                            }
                        });
                    });
 
                },
                clickRow: function (row, event, column) {
                    var $this = this;
                    var areaCode = row.CN_S_AREA_CODE;
                    var stockCode = row.CN_S_STOCK_CODE;
 
                    $this.areaCode = areaCode;
                    $this.stockCode = stockCode;
 
                    ajaxManage({
                        url: "/Sys/Strategy/GetStrategyList?areaCode=" + areaCode + "&stockCode=" + stockCode,
                        success: function (data) {
                            console.log(data.Data);
                            $this.tableData = data.Data;
                        }
                    });
                },
                clickStrategyRow: function (row, event, column) {
                    var selectrow = row;
                    this.$refs.singleTable.clearSelection();
                    this.$refs.singleTable.toggleRowSelection(selectrow);
                }
            },
            el: '#strategyList'
        });
    </script>
}