Blame view

juvenile-prosecution-vue/src/components/jeecg/minipop/JFilePop.vue 2.3 KB
6c637641   wxy   no message
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
  <template>
    <div>
      <a-modal
        :title="fileType === 'image' ? '图片上传' : '文件上传'"
        :width="width"
        :visible="visible"
        @ok="ok"
        cancelText="取消"
        @cancel="close">
        <!--style="top: 20px;"-->
        <j-upload :file-type="fileType" :value="filePath" @change="handleChange" :disabled="disabled" :number="number"></j-upload>
      </a-modal>
    </div>
  </template>
  
  <script>
    import { getFileAccessHttpUrl } from '@/api/manage';
  
    const getFileName=(path)=>{
      if(path.lastIndexOf("\\")>=0){
        let reg=new RegExp("\\\\","g");
        path = path.replace(reg,"/");
      }
      return path.substring(path.lastIndexOf("/")+1);
    }
  
    export default {
      name: 'JFilePop',
      components: { },
      props:{
        title:{
          type:String,
          default:'',
          required:false
        },
        position:{
          type:String,
          default:'right',
          required:false
        },
        height:{
          type:Number,
          default:200,
          required:false
        },
        width:{
          type:Number,
          default:520,
          required:false
        },
  
        popContainer:{
          type:String,
          default:'',
          required:false
        },
        disabled:{
          type:Boolean,
          default:false,
          required:false
        },
        number:{
          type:Number,
          required:false,
          default: 0
        }
      },
      data(){
        return {
          visible:false,
          filePath:'',
          id:'',
          fileType:'file'
  
        }
      },
      methods:{
        handleChange(value){
          this.filePath = value;
        },
        show(id,value,flag){
          this.id = id;
          this.filePath = value;
          this.visible=true
          if(flag === 'img'){
            this.fileType = 'image'
          }else{
            this.fileType = 'file'
          }
  
        },
        ok(){
          if(!this.filePath){
            this.$message.error("未上传任何文件")
            return false;
          }
          let arr = this.filePath.split(",")
          let obj = {
            name:getFileName(arr[0]),
            url:getFileAccessHttpUrl(arr[0]),
            path:this.filePath,
            status: 'done',
            id:this.id
          }
          this.$emit('ok',obj)
          this.visible=false
        },
        close(){
          this.visible=false
        }
      }
    }
  </script>
  
  <style scoped>
  
  </style>