13693261870
2025-07-02 009f9edb9391da3a3f2084f592ea118893b62f76
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
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
<template>
  <div class="app-container">
    <el-row :gutter="24">
      <!--部门数据-->
      <!-- <el-col :span="4" :xs="24">
        <div class="head-container">
          <el-input
            v-model="deptName"
            placeholder="请输入部门名称"
            clearable
            size="small"
            prefix-icon="el-icon-search"
            style="margin-bottom: 20px"
          />
        </div>
        <div class="head-container">
          <el-tree
            :data="deptOptions"
            :props="defaultProps"
            :expand-on-click-node="false"
            :filter-node-method="filterNode"
            ref="tree"
            node-key="id"
            default-expand-all
            highlight-current
            @node-click="handleNodeClick"
          />
        </div>
      </el-col> -->
      <!--港口数据-->
      <el-col :span="24" :xs="24">
        <el-form
          :model="queryParams"
          ref="queryForm"
          size="small"
          :inline="true"
          v-show="showSearch"
          label-width="68px"
        >
          <el-form-item label="文件名称" prop="name">
            <el-input
              v-model="queryParams.name"
              placeholder="请输入文件名称"
              clearable
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="文件类型" prop="type">
            <el-input
              v-model="queryParams.type"
              placeholder="请输入文件类型"
              clearable
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
            <!-- <el-select
              v-model="queryParams.type"
              placeholder="文件类型"
              clearable
              style="width: 240px"
            >
              <el-option
                v-for="item in TypeList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select> -->
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQuery"
              >搜索</el-button
            >
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
              >重置</el-button
            >
          </el-form-item>
        </el-form>
 
        <el-row :gutter="10" class="mb8">
     
          <el-col :span="1.5">
            <el-button
              type="info"
              plain
              icon="el-icon-upload2"
              size="mini"
              @click="handleImport"
              >导入</el-button
            >
          </el-col>
          <!-- <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              >导出</el-button
            >
          </el-col> -->
          <right-toolbar
            :showSearch.sync="showSearch"
            @queryTable="getList"
            :columns="columns"
          ></right-toolbar>
        </el-row>
 
        <el-table
          v-loading="loading"
          :data="userList.slice((queryParams.pageNum - 1) * queryParams.pageSize, queryParams.pageNum * queryParams.pageSize)"
        >
          
          <el-table-column
            label="文件编号"
            align="center"
            key="id"
            prop="id"
            v-if="columns[0].visible"
          />
          <el-table-column
            label="文件名称"
            align="center"
            key="name"
            prop="name"
            v-if="columns[1].visible"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="文件说明"
            align="center"
            key="remark"
            prop="remark"
            v-if="columns[2].visible"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="文件类型"
            align="center"
            key="type"
            prop="type"
            v-if="columns[3].visible"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="文件大小"
            align="center"
            key="size"
            prop="size"
            v-if="columns[4].visible"
            width="120"
          />
          <el-table-column
            label="上传时间"
            align="center"
            prop="createTime"
            v-if="columns[5].visible"
            width="160"
          >
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="操作"
            align="center"
            width="160"
            class-name="small-padding fixed-width"
          >
            <template slot-scope="scope" v-if="scope.row.id !== 1">
              <!-- <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                >修改</el-button
              > -->
              <el-button
                size="mini"
                type="text"
                icon="el-icon-download"
                @click="downloadFile(scope.row)"
                >下载</el-button
              >
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
 
        <pagination
          v-show="total > 0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </el-col>
    </el-row>
    <!-- 文件导入对话框 -->
    <el-dialog
      :title="upload.title"
      :visible.sync="upload.open"
      width="400px"
      append-to-body
    >
      <el-upload
        ref="upload"
        :limit="1"
        :headers="upload.headers"
        :action="upload.url"
        :data="uploadData"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        :before-upload="handleBeforeUpload"
        drag
      >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        <div class="el-upload__tip text-center" slot="tip">
          <!-- <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
          </div> -->
          <!-- <span>仅允许导入xls、xlsx格式文件。</span> -->
          <!-- <el-link
            type="primary"
            :underline="false"
            style="font-size: 12px; vertical-align: baseline"
            @click="importTemplate"
            >下载模板</el-link
          > -->
        </div>
      </el-upload>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import {
  listFile,
  deleteBatch,
  SearchlistFile,
} from "@/api/system/gkInformation/gkInfo";
//文件管理、
 
import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { number } from "echarts";
 
export default {
  name: "User",
  dicts: ["sys_normal_disable", "sys_user_sex"],
  components: { Treeselect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      rowid:[],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户表格数据
      userList: null,
      // 弹出层标题
      title: "",
      // 部门树选项
      deptOptions: undefined,
      // 是否显示弹出层
      open: false,
      // 部门名称
      deptName: undefined,
      // 默认密码
      initPassword: undefined,
      // 日期范围
      // dateRange: [],
      // 岗位选项
      postOptions: [],
      // 角色选项
      roleOptions: [],
      // 表单参数
      form: {},
      defaultProps: {
        children: "children",
        label: "label",
      },
      // 用户导入参数
      upload: {
        // 是否显示弹出层(用户导入)
        open: false,
        // 弹出层标题(用户导入)
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        // url: process.env.VUE_APP_BASE_API + "/system/user/importData",
        url: process.env.VUE_APP_BASE_API + "dp/sysFile/uploadFile",
      },
      //文件类型
      fileType: [
        "bmp",
        "gif",
        "jpg",
        "jpeg",
        "png",
        "doc",
        "docx",
        "xls",
        "xlsx",
        "ppt",
        "pptx",
        "html",
        "htm",
        "txt",
        "rar",
        "zip",
        "gz",
        "bz2",
        "swf",
        "flv",
        "mp4",
        "avi",
        "rmvb",
        "swf",
        "flv",
        "mp3",
        "wav",
        "wma",
        "wmv",
        "mid",
        "avi",
        "mpg",
        "asf",
        "rm",
        "rmvb",
        "pdf",
        "glb",
        "gltf"
      ],
      number: 0,
      uploadData: {
        type: "",
        name: "",
        remark: "",
      },
      //大小限制(MB)
      fileSize: 1024,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        // phonenumber: undefined,
        type: null,
        // deptId: undefined,
        offset: 0,
      },
      TypeList: [
        { value: "视频", label: "视频" },
        { value: "音频", label: "音频" },
        { value: "图片", label: "图片" },
        { value: "文档", label: "文档" },
      ],
      // 列信息
      columns: [
        { key: 0, label: `文件编号`, visible: true },
        { key: 1, label: `文件名称`, visible: true },
        { key: 2, label: `文件说明`, visible: true },
        { key: 3, label: `文件类型`, visible: true },
        { key: 4, label: `文件大小`, visible: true },
        { key: 5, label: `上传时间`, visible: true },
      ],
      // 表单校验
      rules: {
        name: [
          { required: true, message: "文件名称不能为空", trigger: "blur" },
          {
            min: 2,
            max: 20,
            message: "文件名称长度必须介于 2 和 20 之间",
            trigger: "blur",
          },
        ],
        remark: [{ required: true, message: "文件说明不能为空", trigger: "blur" }],
      },
      //
      TreeList: [
        {
          id: 101,
          label: "港口资料",
          disabled: false,
        },
        {
          id: 4000,
          label: "报表分析",
          disabled: false,
          children: [
            {
              id: 4002,
              label: "水深",
              disabled: false,
            },
            {
              id: 4003,
              label: "油表",
              disabled: false,
            },
            {
              id: 4004,
              label: "水表",
              disabled: false,
            },
            {
              id: 4005,
              label: "电表",
              disabled: false,
            },
          ],
        },
      ],
    };
  },
  watch: {
    // 根据名称筛选部门树
    deptName(val) {
      this.$refs.tree.filter(val);
    },
  },
  created() {
    this.getList();
    this.getDeptTree();
  },
  methods: {
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listFile(this.addDateRange(this.queryParams)).then((response) => {
        this.userList = response.data;
        this.total = response.data.length;
        this.loading = false;
      });
    },
    //搜索查询
    getSearchList() {
      this.loading = true;
      SearchlistFile(this.queryParams).then((response) => {
        this.userList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 查询部门下拉树结构 */
    getDeptTree() {
      this.deptOptions = this.TreeList;
    },
    // 筛选节点
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    // 节点单击事件
    handleNodeClick(data) {
      this.queryParams.deptId = data.id;
      this.handleQuery();
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        deptId: undefined,
        name: undefined,
        remark: undefined,
        size: undefined,
        type: "0",
        postIds: [],
        roleIds: [],
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      // this.getList();
      this.getSearchList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      // this.dateRange = [];
      this.resetForm("queryForm");
      this.queryParams.id = undefined;
      this.$refs.tree.setCurrentKey(null);
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      debugger
      this.ids = selection.map((item) => item.id);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      this.rowid.push(row.id)
      const fileIds = this.rowid || this.ids;
      this.$modal
        .confirm('是否确认删除文件编号为"' + fileIds + '"的数据项?')
        .then(function () {
          return deleteBatch(fileIds);
        })
        .then(() => {
          this.getList();
          this.rowid = [];
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    // /** 导出按钮操作 */
    // handleExport() {
    //   this.download(
    //     "system/user/export",
    //     {
    //       ...this.queryParams,
    //     },
    //     `user_${new Date().getTime()}.xlsx`
    //   );
    // },
    //下载
    downloadFile(row) {
      this.downloadFiles(
        "dp/sysFile/download",
        {
          id: row.id,
        },
        `${row.filePath.substring(row.filePath.lastIndexOf("/") + 1)}`
      );
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "文件导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    // importTemplate() {
    //   this.download(
    //     "system/user/importTemplate",
    //     {},
    //     `user_template_${new Date().getTime()}.xlsx`
    //   );
    // },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      if (response.code === 200) {
        this.$modal.closeLoading();
        this.upload.open = false;
        this.upload.isUploading = false;
        this.$refs.upload.clearFiles();
        this.$modal.msgSuccess("上传成功!");
        // this.$alert(
        //   "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
        //     response.msg +
        //     "</div>",
        //   "导入结果",
        //   { dangerouslyUseHTMLString: true }
        // );
        this.getList();
      } else {
        this.number--;
        this.$modal.closeLoading();
        this.$modal.msgError("上传失败,请重新上传!");
      }
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    //校验文件类型
    handleBeforeUpload(file) {
      //校验文件类型
      if (this.fileType) {
        const fileName = file.name.split(".");
        const fileExt = fileName[fileName.length - 1];
        this.uploadData.name = fileName[0];
        this.uploadData.type = fileExt;
        const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
        if (!isTypeOk) {
          this.$modal.msgError(
            `文件格式不正确,请上传${this.fileType.join("/")}格式文件!`
          );
          return false;
        }
      }
      //校验文件大小
      if (this.fileSize) {
        const isLt = file.size / 1024 / 1024 < this.fileSize;
        if (!isLt) {
          this.$modal.msgError(`上传文件大小不能超过${this.fileSize}MB!`);
          return false;
        }
      }
      this.$modal.loading(`正在上传文件,请稍候。。。。。`);
      this.number++;
      return true;
    },
  },
};
</script>