zhao
2021-06-11 98186752629a7bd38965418af84db382d90b9c07
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
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_LayoutVue.cshtml";
}
 
<div id="owner" 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.owner" size="mini"></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="add" v-has="'Add'">新增</el-button>
            <el-button size="mini" type="primary" v-on:click="edit" v-has="'Edit'">修 改</el-button>
            <el-button size="mini" type="danger" v-on:click="remove" v-has="'Delete'">删 除</el-button>
        </el-row>
    </el-card>
    <hh-table v-bind:coloptions="cols"
              v-bind:single="true"
              v-bind:paging="true"
              v-bind:check="true"
              dh="115"
              url="@Url.Action("OwnerList")"
              ref="list">
    </hh-table>
</div>
@section scripts{
    <script>
        var owner = new Vue({
            data: {
                formData: {
                    owner: "",
                },
                cols: [
                    { f: "CN_S_OWNER", n: "货主" },
                    {
                        f: "CN_B_DEFAULT", n: "是否默认", format: function (row, column, cellValue, index) {
                            if (cellValue) return 'Y';
                            return 'N';
                        }
                    },
                    { f: "CN_S_REMARK", n: "备注" }
                ]
            },
            methods: {
                search: function () {
                    this.$refs.list.loadData(this.formData);
                },
                add: function () {
                    var $this = this;
                    wms.showDialogFrame({
                        title: '新增',
                        dh: 380,
                        width: "400px",
                        btn: false,
                        callBack: function (frame) {
                            $this.$refs.list.loadData();
                        },
                        url: "@Url.Action("Edit")"
                    });
                },
                edit: function () {
                    var $this = this;
                    this.selectSingleRowEvent(function (row) {
                        wms.showDialogFrame({
                            title: '修改',
                            dh: 380,
                            width: "400px",
                            btn: false,
                            callBack: function (frame) {
                                $this.$refs.list.loadData();
                            },
                            url: "@Url.Action("Edit")?guid=" + row.CN_GUID
                        });
                    });
                },
                remove: function () {
                    var $this = this;
                    this.selectMultiRowEvent(function (rows) {
                        wms.confirm("确认删除?", function () {
                            var guid = "";
                            rows.forEach(function (value, index, array) {
                                if (index != 0)
                                    guid += ",";
                                guid += value.CN_GUID;
                            });
                            ajaxManage({
                                url: "@Url.Action("Delete")?guid=" + guid,
                                type: "Get",
                                success: function (data) {
                                    if (data.Success) {
                                        $this.$refs.list.loadData();
                                        wms.success("删除成功");
                                    } else {
                                        wms.error(data.Msg);
                                    }
                                }
                            });
                        });
                    });
                },
                selectMultiRowEvent: function (callBack) {
                    var selectRow = this.$refs.list.selections;
                    if (selectRow.length <= 0) {
                        wms.warning("最少选择一条记录");
                        return;
                    }
                    if (callBack)
                        callBack(selectRow);
                },
                selectSingleRowEvent: function (callBack) {
                    var selectRow = this.$refs.list.selections;
                    if (selectRow.length != 1) {
                        wms.warning("请选择一条记录");
                        return;
                    }
                    if (callBack)
                        callBack(selectRow[0]);
                }
            },
            el: '#owner'
        });
    </script>
}