李林
2024-01-09 0dc1e26569ab570259fef29cd5cde70cb96d7f2c
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
<style scoped>
    .title {
        height: 60px;
        line-height: 60px;
    }
 
    .search {
        background-color: #fff;
        height: 80px;
        display: flex;
        align-items: center;
    }
 
    .search_thing {
        width: 350px;
        display: flex;
        align-items: center;
    }
 
    .search_label {
        width: 110px;
        font-size: 14px;
        text-align: right;
    }
 
    .search_input {
        width: calc(100% - 110px);
    }
 
    .table {
        margin-top: 10px;
        background-color: #fff;
        width: calc(100% - 40px);
        height: calc(100% - 60px - 80px - 10px - 40px);
        padding: 20px;
    }
</style>
<style>
    .data_reporting .data_reporting_dia .el-dialog__body {
        padding: 15px 0;
    }
 
    .data_reporting .el-upload {
        width: 100%;
    }
 
    .data_reporting .el-upload-dragger {
        width: 100%;
    }
</style>
 
<template>
    <div class="data_reporting" v-loading="uploading">
        <div>
            <el-row class="title">
                <el-col :span="12" style="padding-left: 20px;">数据上报</el-col>
                <el-col :span="12" style="text-align: right;padding-right: 8px;">
                    <el-button size="medium" @click="openUpload()" v-if="inPower">
                        <i class="el-icon-upload2" style="color: #3A7BFA;"></i>
                        <span style="color: #3A7BFA;">导入</span>
                    </el-button>
                    <el-button size="medium" @click="$refs.ValueTable.openDownDia()" v-if="outPower">
                        <i class="el-icon-download" style="color: #3A7BFA;"></i>
                        <span style="color: #3A7BFA;">导出</span>
                    </el-button>
                    <el-button size="medium" type="primary" @click="opeaAdd" v-if="addPower">新增</el-button>
                </el-col>
            </el-row>
        </div>
        <div class="search">
            <div class="search_thing">
                <div class="search_label">系统日期:</div>
                <div class="search_input">
                    <el-date-picker size="small" v-model="componentData.entity.createTime" type="date" placeholder="选择日期"
                        value-format="yyyy-MM-dd HH:mm:ss" clearable></el-date-picker>
                </div>
            </div>
            <div class="search_thing">
                <div class="search_label">登记人:</div>
                <div class="search_input">
                    <el-input size="small" v-model="componentData.entity.registrant" clearable placeholder="登记人"
                        @keyup.enter.native="refreshTable()"></el-input>
                </div>
            </div>
            <div class="search_thing">
                <div class="search_label">项目:</div>
                <div class="search_input">
                    <el-select size="small" style="width: 100%;" placeholder="请选择" v-model="componentData.entity.product">
                        <el-option :value="null" label="全部"></el-option>
                        <el-option v-for="(a, ai) in product" :key="ai" :label="a.product" :value="a.product"></el-option>
                    </el-select>
                </div>
            </div>
            <div class="search_thing" style="padding-left: 30px;">
                <el-button size="small" @click="refresh()">重 置</el-button>
                <el-button size="small" type="primary" @click="refreshTable()">查 询</el-button>
            </div>
        </div>
        <div class="table">
            <ValueTable ref="ValueTable" :url="$api.dataReporting.selectDataReportingList"
                :delUrl="$api.dataReporting.delDataReporting" :componentData="componentData" :key="upIndex" @upRole="upRole" :downUrl="$api.dataReporting.downDataReportingFile"/>
        </div>
        <el-dialog title="上报修改" :visible.sync="upDia" width="700px" class="data_reporting_dia">
            <div class="body" v-if="upDia">
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">系统日期</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.updateTime" size="small" disabled></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">登记人</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.registrant" size="small" disabled></el-input>
                    </el-col>
                </el-row>
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">部门</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.department" size="small" disabled></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">账户名</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.name" size="small" disabled></el-input>
                    </el-col>
                </el-row>
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">渠道</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.channel" size="small" disabled></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">项目</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.product" size="small" disabled></el-input>
                    </el-col>
                </el-row>
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">姓名</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.name2" size="small" disabled></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">代理</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.agent" size="small" disabled></el-input>
                    </el-col>
                </el-row>
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">展现量</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.showNum" size="small" disabled></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">点击量</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.click" size="small" disabled></el-input>
                    </el-col>
                </el-row>
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">账户消费</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.accountConsumption" size="small" disabled></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">客户返点消费</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.rebateConsumption" size="small" disabled></el-input>
                    </el-col>
                </el-row>
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">消费</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.consumption" size="small" disabled></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">折后消费</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.discountedConsumption" size="small" disabled></el-input>
                    </el-col>
                </el-row>
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">进粉</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.fansAdd" size="small" disabled></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">实际成本</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.actualCost" size="small" disabled></el-input>
                    </el-col>
                </el-row>
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">利润</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.profit" size="small" disabled></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">员工代理返点</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.agentRebate" size="small" disabled></el-input>
                    </el-col>
                </el-row>
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">内部成本</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.internalCosts" size="small"></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">客户成本</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.customerCosts" size="small"></el-input>
                    </el-col>
                </el-row>
                <el-row style="line-height: 50px;">
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">客户返点</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.customerRebate" size="small"></el-input>
                    </el-col>
                    <el-col :span="4" style="text-align: right;padding-right: 8px;">做进来</el-col>
                    <el-col :span="7">
                        <el-input v-model="upData.remark" size="small"></el-input>
                    </el-col>
                </el-row>
            </div>
            <span slot="footer" class="dialog-footer" style="margin-right: 18px;">
                <el-button type="primary" @click="saveUpData" :loading="upLoad">确 定</el-button>
                <el-button @click="upDia = false">取 消</el-button>
            </span>
        </el-dialog>
        <el-dialog title="数据导入" :visible.sync="uploadDia" width="500px">
            <div style="margin: 0 auto;">
                <el-upload ref="upload" drag :action="javaApi + $api.dataReporting.inputCsv" :headers="token"
                    :file-list="fileList" name="file" :auto-upload="false" accept=".csv" :limit="1" :on-change="beforeUpload"
                    :on-success="onSuccess" :on-error="onError">
                    <i class="el-icon-upload"></i>
                    <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
                </el-upload>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button @click="uploadDia = false">取 消</el-button>
                <el-button type="primary" @click="submitUpload()">上 传</el-button>
            </span>
        </el-dialog>
    </div>
</template>
 
<script>
    import ValueTable from '../tool/value-table.vue'
    export default {
        components: {
            ValueTable
        },
        data() {
            return {
                componentData: {
                    entity: {
                        createTime: null,
                        registrant: null,
                        product: null,
                        orderBy: {
                            field: 'id',
                            order: 'desc'
                        }
                    },
                    isIndex: true,
                    showSelect: true,
                    select: true,
                    do: [{
                        id: 'update',
                        font: '编辑',
                        type: 'text',
                        method: 'upRole',
                        field: ['createUserName', 'updateUserName', 'registrant', 'department', 'consumption',
                            'rebateConsumption', 'discountedConsumption', 'profit', 'remark', 'actualCost', 'fansAdd', 'agentRebate'
                        ]
                    }, {
                        id: 'delete',
                        font: '删除',
                        type: 'text',
                        method: 'doDiy'
                    }],
                    tagField: {},
                    selectField: {},
                    requiredAdd:['name2','agent','channel','product','showNum','click','accountConsumption'],
                },
                entityCopy: {},
                upIndex: 0,
                addDia: false,
                upDia: false,
                upLoad: false,
                upData: {},
                product: [],
                uploadDia: false,
                fileList: [],
                uploading: false,
                addPower: true,
                token: null,
                inPower: true,
                outPower: true
            }
        },
        created() {
            var today = new Date();
            var yesterday = new Date(today);
            yesterday.setDate(today.getDate() - 1);
            var yyyy = yesterday.getFullYear();
            var mm = yesterday.getMonth() + 1;
            var dd = yesterday.getDate()
            if (dd < 10) {
                dd = "0" + dd;
            }
            if (mm < 10) {
                mm = "0" + mm;
            }
            this.componentData.entity.createTime = this.HaveJson(`${yyyy}-${mm}-${dd} 00:00:00`)
        },
        mounted() {
            this.entityCopy = this.HaveJson(this.componentData.entity)
            this.selectProductEnumList()
            this.getPower()
            this.token = {
                'token': sessionStorage.getItem('token')
            }
        },
        methods: {
            refreshTable() {
                this.$refs['ValueTable'].selectList()
            },
            refresh() {
                this.componentData.entity = this.HaveJson(this.entityCopy)
                this.upIndex++
            },
            upRole(row) {
                this.upData = this.HaveJson(row)
                this.upDia = true
            },
            saveUpData() {
                this.upLoad = true
                delete this.upData.createTime
                delete this.upData.updateTime
                delete this.upData.createUser
                delete this.upData.updateUser
                this.$axios.post(this.$api.dataReporting.upDataReporting, this.upData, {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                }).then(res => {
                    this.upLoad = false
                    if (res.code == 201) {
                        return
                    }
                    this.$message.success('修改成功')
                    this.upDia = false
                    this.refreshTable()
                })
            },
            selectProductEnumList() {
                this.$axios.get(this.$api.enums.selectProductEnumList).then(res => {
                    this.product = res.data
                })
            },
            // 权限分配
            getPower() {
                let power = JSON.parse(sessionStorage.getItem('power'))
                let up = false
                let del = false
                let add = false
                let inPower = false
                let outPower = false
                for (var i = 0; i < power.length; i++) {
                    if (power[i].menuMethod == 'upDataReporting') {
                        up = true
                    }
                    if (power[i].menuMethod == 'delDataReporting') {
                        del = true
                    }
                    if (power[i].menuMethod == 'addDataReporting') {
                        add = true
                    }
                    if (power[i].menuMethod == 'inputCsv') {
                        inPower = true
                    }
                    if (power[i].menuMethod == 'downDataReportingFile') {
                        outPower = true
                    }
                }
                if (!del) {
                    this.componentData.do.splice(1, 1)
                }
                if (!up) {
                    this.componentData.do.splice(0, 1)
                }
                this.addPower = add
                this.inPower = inPower
                this.outPower = outPower
            },
            openUpload() {
                this.uploadDia = true
            },
            beforeUpload(file, fileList) {
                if (file.raw.type != 'text/csv') {
                    this.$message.error('上传文件格式不正确');
                    this.$refs.upload.clearFiles()
                    return false;
                }
            },
            submitUpload() {
                if (this.$refs.upload.uploadFiles.length == 0) {
                    this.$message.error('未选择文件')
                    return
                }
                this.uploading = true
                this.$refs.upload.submit();
            },
            onSuccess(response, file, fileList) {
                this.$refs.upload.clearFiles()
                this.uploadDia = false
                this.uploading = false
                if(response.code==201){
                    this.$message.error(response.message)
                    return
                }
                this.$message.success('上传成功')
                this.refreshTable()
            },
            onError(err, file, fileList) {
                this.$message.error('上传失败')
                this.$refs.upload.clearFiles()
                this.uploading = false
            },
            opeaAdd() {
                this.$refs.ValueTable.openAddDia(this.$api.dataReporting.addDataReporting);
            }
        }
    }
</script>