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
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
@{
    ViewBag.Title = "页面配置";
    Layout = "~/Views/Shared/_LayoutVue.cshtml";
}
<div id="pageSet" v-cloak>
    <el-card class="box-card">
        <el-form label-width="90px" v-bind:model="formData" v-bind:rules="formRules" class="demo-ruleForm" v-bind:inline="true" ref="formData">
            <el-form-item label="功能模块:" prop="power">
                <hh-select-url v-model="formData.power"
                               url="@Url.Action("GetPowerType")"
                               valuefield="CN_GUID"
                               textfield="CN_S_POWER"
                               datafield="Data">
                </hh-select-url>
            </el-form-item>
            <el-form-item label="编码:">
                <el-input v-model="formData.code" size="mini"></el-input>
            </el-form-item>
            <el-form-item label="名称:">
                <el-input v-model="formData.name" 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="primary" v-on:click="add">新增</el-button>
        </el-form>
    </el-card>
    <el-table v-bind:data="pageSetData"
              class="tb-edit"
              style="width: 100%;"
              border
              highlight-current-row
              size="mini"
              v-bind:height="tabHeight"
              v-on:row-click="pageSetRowClick"
              ref="list">
        <el-table-column label="功能模块" prop="CN_S_POWER" width="130" align="center"></el-table-column>
        <el-table-column label="编码" prop="CN_S_POWER_CODE" width="190"></el-table-column>
        <el-table-column label="名称" prop="CN_S_POWER_NAME" width="130"></el-table-column>
        <el-table-column label="是否启用" prop="CN_B_ENABLED" width="70" align="center">
            <template scope="scope">
                <el-switch v-model="scope.row.CN_B_ENABLED" size="mini" v-on:change="changeRowData(scope.row)">
                </el-switch>
            </template>
        </el-table-column>
        <el-table-column label="宽度" prop="CN_F_WIDTH" width="50" align="center"></el-table-column>
        <el-table-column label="对齐" prop="CN_S_ALIGN" width="60" align="center"></el-table-column>
        <el-table-column label="方法" prop="CN_S_METHOD_NAME" width="90" align="center"></el-table-column>
        <el-table-column label="备注" prop="CN_S_REMARK">
            <template scope="scope">
                <el-input size="mini"
                          v-model="scope.row.CN_S_REMARK"
                          v-on:blur="remarkInputBlur">
                </el-input>
                <span>{{scope.row.CN_S_REMARK}}</span>
            </template>
        </el-table-column>
        <el-table-column label="排序" prop="CN_N_ORDER" width="150" align="center">
            <template scope="scope">
                <el-input-number v-model="scope.row.CN_N_ORDER"
                                 v-bind:min="0"
                                 size="mini"
                                 v-on:change="changeRowData(scope.row)"></el-input-number>
                <span>{{scope.row.CN_N_ORDER}}</span>
            </template>
        </el-table-column>
        <el-table-column fixed="right"
                         label="操作"
                         width="100"
                         align="center">
            <template slot-scope="scope">
                <a href="javascript:void(0)" style="color:#409EFF" v-on:click="edit(scope.row)">编辑</a>
                <a href="javascript:void(0)" style="color:#409EFF" v-on:click="remove(scope.row)">删除</a>
            </template>
        </el-table-column>
    </el-table>
</div>
@section scripts{
    <script>
        new Vue({
            el: "#pageSet",
            mixins: [useAutoHeight],
            computed: {
                tabHeight: function () {
                    return this.autoHeight - 40;
                },
            },
            data: {
                pageSetData: [],
                currentRow: null,
                formData: {
                    power: '',
                    code: '',
                    name: ''
                },
                formRules: {
                    power: [
                        { required: true, message: ' ', trigger: 'change' }
                    ]
                }
            },
            methods: {
                selectSingleRowEvent: function (callBack) {
                    var selectRow = this.$refs.list.selections;
                    if (selectRow.length != 1) {
                        wms.warning("请选择一条记录");
                        return;
                    }
                    if (callBack)
                        callBack(selectRow[0]);
                },
                add: function () {
                    var $this = this;
                    wms.showDialogFrame({
                        title: '新增',
                        dh: 320,
                        width: "400px",
                        btn: false,
                        callBack: function (frame) {
                            $this.loadPageSet();
                        },
                        url: "@Url.Action("Edit")?power=" + $this.formData.power
                    });
                },
                edit: function (row) {
                    var $this = this;
                    wms.showDialogFrame({
                        title: '修改',
                        dh: 320,
                        width: "400px",
                        btn: false,
                        callBack: function (frame) {
                            $this.loadPageSet();
                        },
                        url: "@Url.Action("Edit")?id=" + row.CN_GUID
                    });
                },
                remove: function (row) {
                    var $this = this;
                    wms.confirm("请谨慎操作,是否确认删除?", function () {
                        ajaxManage({
                            url: "@Url.Action("Delete")?id=" + row.CN_GUID,
                            success: function (data) {
                                wms.showMsg(data, function () {
                                    wms.success("已删除");
                                    $this.loadPageSet();
                                });
                            }
                        });
                    });
                },
                remarkInputBlur: function () {
                    if (this.currentRow)
                        this.changeRowData(this.currentRow);
                },
                pageSetRowClick: function (row, event, column) {
                    this.currentRow = row;
                },
                changeRowData: function (row) {
                    ajaxManage({
                        url: "@Url.Action("SetEnabled")",
                        data: row,
                        success: function (data) {
                            wms.showMsg(data, function () {
                                wms.success("已修改");
                            });
                        }
                    });
                },
                loadPageSet: function () {
                    var $this = this;
                    if (!$this.formData.power) return false;
                    ajaxManage({
                        url: "@Url.Action("GetPowerEnabled")",
                        data: { power: $this.formData.power, code: $this.formData.code, name: $this.formData.name },
                        success: function (data) {
                            wms.showMsg(data, function () {
                                $this.pageSetData = [];
                                var _data = data.Data;
                                $this.pageSetData = _data;
                            });
                        }
                    });
                },
                search: function () {
                    var $this = this;
                    this.$refs["formData"].validate(function (valid) {
                        if (valid) {
                            $this.loadPageSet();
                        } else {
                            wms.warning("请选择功能模块查询");
                            return false;
                        }
                    });
                }
            },
            mounted: function () {
                this.loadPageSet();
            }
        });
    </script>
}