zjf
2023-02-24 2126cd24b8a0174ac0597340917c0a4595f72254
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
<template>
  <flexbox class="cell">
    <img
      class="cell-head"
      src="@/assets/img/relevance_file.png"
      alt>
    <div
      :class="{'cursor-pointer' :cursorPointer}"
      class="cell-body">
      <span>{{ data.name.length > 20 ? data.name.substring(0, 20) + '...' : data.name }}</span>
      <span class="size">({{ data.size }})</span>
    </div>
    <div class="cell-foot">
      <el-button
        type="primary"
        icon="el-icon-download"
        @click="downloadClick">下载</el-button>
      <i
        v-if="showDelete"
        class="el-icon-delete"
        @click="deleteClick"/>
    </div>
  </flexbox>
</template>
 
<script type="text/javascript">
import { downloadFile } from '@/utils'
// import { crmFileDelete } from '@/api/common'
 
export default {
  name: 'FileCell',
  props: {
    cellIndex: Number,
    data: Object,
    showFoot: {
      type: Boolean,
      default: true
    },
    cursorPointer: {
      type: Boolean,
      default: false
    },
    showDelete: {
      type: Boolean,
      default: false
    },
    module_id: [String, Number]
  },
  data () {
    return {}
  }, // 附件展示效果
  computed: {},
  watch: {},
  mounted () {},
 
  beforeDestroy () {},
  methods: {
    downloadClick () {
      downloadFile({ path: this.data.filePath, name: this.data.name })
    },
    deleteClick () {
      this.$confirm('确定删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          // crmFileDelete({
          //   id: this.data.fileId
          // })
          //   .then(res => {
          //     this.$message.success('操作成功')
          //     this.$emit('delete', this.cellIndex, this.data)
          //   })
          //   .catch(() => {})
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    }
  }
}
</script>
<style lang="scss" scoped>
.cell {
  padding: 8px;
  background-color: #f5f7fa;
  border-radius: 2px;
  position: relative;
  margin-bottom: 5px;
 
  .cell-head {
    display: block;
    width: 16px;
    height: 16px;
    margin-right: 5px;
  }
 
  .cell-body {
    flex: 1;
    color: #4D88FF;
    font-size: 13px;
    .size {
      color: #ccc;
    }
  }
 
  .cell-foot {
    margin-right: 8px;
    cursor: pointer;
    i {
      color: #ccc;
      padding: 0 2px;
    }
  }
}
 
.cursor-pointer {
  cursor: pointer;
}
</style>