Helius
2022-05-27 4351e71d782741143a98f86f6648acd16689165f
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" xmlns:matrix="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <LINK rel="Bookmark" href="../images/favicon.ico">
    <!-- 本框架基本脚本和样式 -->
    <script type="text/javascript" th:src="@{/js/systools/MBaseVue.js}"></script>
    <link rel="stylesheet" th:href="@{/plugin/element-ui/index.css}">
    <link th:href="@{/css/styleOne/style.min.css}" rel="stylesheet" type="text/css"/>
    <title></title>
    <style>
        .panel-body {
            overflow: hidden;
        }
 
        .buttonPanel {
            background: #ffffff;
            padding: 10px 10px;
            margin: 0px 0px 10px 0px;
        }
 
        .rowPanel {
            background: #ffffff;
            padding: 0px 10px;
            padding-top: 10px;
            margin: 0px 0px 10px 0px;
        }
 
        .paginationStyle {
            background: #ffffff;
            padding: 10px 10px;
            margin: 0px 0px 10px 0px;
            text-align: right;
        }
    </style>
</head>
<body>
<div class="panel-body" id="app">
 
    <el-row class="buttonPanel">
        <el-button @click="openForm('add')" type="primary">新增</el-button>
    </el-row>
 
    <el-row class="rowPanel">
        <el-form ref="form" :model="form" inline>
            <el-form-item label="规则名称" prop="queryKey">
                <el-input v-model="form.keyword" placeholder="请输入规则名称"></el-input>
            </el-form-item>
            <el-button type="primary" @click="search">搜索</el-button>
            <el-button @click="resetForm('form')">重置</el-button>
        </el-form>
    </el-row>
 
    <el-row class="table-style">
 
        <el-table id="proj" :data="table.rows" :height="height" stripe @sort-change="sortChange">
            <el-table-column
                    prop="name"
                    label="规则名称">
            </el-table-column>
            <el-table-column
                    prop="updateTime"
                    sortable="custom"
                    label="修改时间"
                    show-overflow-tooltip
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="updateBy"
                    label="修改人">
            </el-table-column>
 
            <el-table-column
                    prop="createTime"
                    sortable="custom"
                    label="创建时间"
                    show-overflow-tooltip
                    width="180">
            </el-table-column>
            <el-table-column
                    prop="createBy"
                    label="创建人"
                    width="180">
            </el-table-column>
 
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button type="text" @click="openForm('modify', scope.row)" size="small">修改</el-button>
                    <el-button type="text" @click="remove(scope.$index, scope.row)" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
    </el-row>
    <el-row class="paginationStyle">
        <el-pagination background
                       @size-change="changePageSize"
                       @current-change="changeCurrentPage"
                       :current-page="table.currentPage"
                       :page-sizes="[10, 20, 30, 50]"
                       :page-size="table.pageSize"
                       layout="total, sizes, prev, pager, next, jumper"
                       :total="table.total">
        </el-pagination>
    </el-row>
 
    <el-dialog
            :title="title"
            :visible.sync="dialogVisible"
            width="60%"
            :before-close="handleClose">
 
        <el-form :model="formData" ref="ruleForm" label-width="100px" class="demo-ruleForm">
 
            <el-form-item label="规则名称"  >
                <el-input style="width: 200px" v-model="formData.name"></el-input>
                <el-button type="primary" @click="addRuleItem()" size="small">添加规则</el-button>
            </el-form-item>
 
            <el-form-item label="绩效方案" >
                <el-table
                        :data="formData.ruleItemList"
                        style="width: 100%">
                    <el-table-column
                            label="业绩类型"
                    >
                        <template slot-scope="scope">
                            <el-select v-model="scope.row.achieveType" placeholder="请选择业绩类型">
                                <el-option label="本金消耗" :value="1"></el-option>
                                <el-option label="赠送消耗" :value="2"></el-option>
                            </el-select>
                        </template>
                    </el-table-column>
                    <el-table-column
                            label="计算方式"
                    >
                        <template slot-scope="scope">
                            <el-select v-model="scope.row.calculationType" placeholder="请选择计算方式">
                                <el-option label="固定金额" :value="1"></el-option>
                                <el-option label="百分比(%)" :value="2"></el-option>
                            </el-select>
                        </template>
                    </el-table-column>
                    <el-table-column
                            label="区间"
                            width="240">
                        <template slot-scope="scope">
                            <el-input style="width: 100px" v-model="scope.row.lower"></el-input>
                            -
                            <el-input style="width: 100px" v-model="scope.row.upper"></el-input>
                        </template>
                    </el-table-column>
                    <el-table-column
                            label="业绩">
                        <template slot-scope="scope">
                            <el-input v-model="scope.row.achieve"></el-input>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作">
                        <template slot-scope="scope">
                            <el-button  type="text" @click="removeRuleItem(scope.$index, scope.row)" size="small">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </el-form-item>
 
 
 
        </el-form>
        <span slot="footer" class="dialog-footer">
                <el-button @click="dialogVisible = false">取 消</el-button>
                <el-button type="primary" @click="submitForm">确 定</el-button>
            </span>
</el-dialog>
 
 
</div>
</body>
<script type="text/javascript" th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script>
<script type="text/javascript" th:src="@{/js/plugin/jquery.query.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layer/layer.js}"></script>
<script type="text/javascript" th:src="@{/js/systools/AjaxProxyVue.js}"></script>
<script type="text/javascript" th:src="@{/js/plugin/vue.js}"></script>
<script type="text/javascript" th:src="@{/plugin/element-ui/index.js}"></script>
<script type="text/javascript" th:src="@{/plugin/moment.min.js}"></script>
<script type="text/javascript" th:inline="javascript">
 
    var vue = new Vue({
        el: '#app',
        data: {
            table: {
                rows: [],
                total: 0,
                pageSize: 10,
                currentPage: 1,
            },
            form: {
                queryKey: null,
            },
 
            height: 'calc(100vh - 240px)',
            dialogVisible: false,
            title: '',
            formData: {
                name: '',
                ruleItemList: [
                    {
                        achieveType: 1,
                        calculationType: 1,
                        lower: '',
                        upper: '',
                        achieve: '',
                    }
                ]
            },
 
            type: '',
 
        },
        created: function () {
            this.loadData();
            window.addEventListener("keydown", this.keydown);
        },
        methods: {
            changePageSize(val) {
                this.table.pageSize = val;
                this.loadData();
            },
            changeCurrentPage(val) {
                this.table.currentPage = val;
                this.loadData();
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            },
            sortChange: function (column) {
                if (column.order) {
                    if (column.order.indexOf("desc")) {
                        this.form.order = "desc";
                    } else {
                        this.form.order = "asc";
                    }
                    this.form.sort = column.prop;
                    this.loadData();
                }
            },
            loadData: function () {
                let _this = this;
                let data = _this.getRequestParam();
                data.pageSize = _this.table.pageSize;
                data.pageNum = _this.table.currentPage;
                AjaxProxy.requst({
                    app: _this,
                    data: data,
                    url: basePath + '/admin/achieveRule/selectList',
                    callback: function (data) {
                        _this.table.rows = data.rows;
                        _this.table.total = data.total;
                    }
                });
            },
            getRequestParam() {
                let _this = this;
                return {
                    queryKey: _this.form.queryKey,
                }
            },
            search: function () {
                this.table.currentPage = 1;
                this.loadData();
            },
            keydown(evt) {
                if (evt.keyCode == 13) {
                    this.search();
                }
            },
 
            remove(index, row) {
                let _this = this;
                this.$confirm('确认删除该规则吗?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    AjaxProxy.requst({
                        app: _this,
                        type: 'GET',
                        url: basePath + "/admin/achieveRule/removeById/" + row.id,
                        callback: function (data) {
                            _this.loadData();
                            _this.$message({
                                type: 'success',
                                message: data.info,
                            });
                        }
                    });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            //开启表单弹窗
            openForm(type, data) {
 
                if (type == 'add') {
                    this.title = '新增规则';
                    //this.$refs['formName'].resetFields();
 
                } else {
                    this.title = '修改规则';
                    this.formData = data;
                }
                this.type = type;
                this.dialogVisible = true;
            },
            //提交表单
            submitForm() {
                let url = basePath + "/admin/achieveRule/add";
                if (this.type == 'modify') {
                    url = basePath + "/admin/achieveRule/update";
                }
                let data=this.formData;
 
                if(MTools.isBlank(data.name)){this.$message.error("请输入规则名称");return;}
 
                if(data.ruleItemList.length<1){
                    this.$message.error("最少需要一个计算规则");;return;}
                let flag=true;
                data.ruleItemList.forEach(item=>{
                    if(MTools.isBlank(item.lower)){
                        this.$message.error("请输入业绩下限");flag=false;}
                    else if(MTools.isBlank(item.upper)){
                        this.$message.error("请输入业绩上限");flag=false;}
                    else if(MTools.isBlank(item.achieve)){
                        this.$message.error("请输入业绩金额或者比例");flag=false;}
                })
                if(flag){
                    var _this=this;
                    AjaxProxy.requst({
                        app: _this,
                        data:data,
                        url:url,
                        callback: function (data) {
                            _this.$message.success(data.info);
                            _this.loadData();
                            _this.dialogVisible = false;
                            _this.formData={
                                name: '',
                                ruleItemList: [
                                    {
                                        achieveType: 1,
                                        calculationType: 1,
                                        lower: '',
                                        upper: '',
                                        achieve: '',
                                    }
                                ]
                            };
                        }
                    });
 
                }
            },
            handleClose(done) {
                this.$confirm('确认关闭?')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {
                    });
            },
            addRuleItem(){
                this.formData.ruleItemList.push(
                    {
                        achieveType: 1,
                        calculationType: 1,
                        lower: '',
                        upper: '',
                        achieve: '',
                    }
                );
            },
            removeRuleItem(index,row){
                this.formData.ruleItemList.splice(index, 1);
            },
 
 
        }
 
    });
 
 
</script>
</body>
</html>