zhuguifei
2025-04-28 442928123f63ee497d766f9a7a14f0a6ee067e25
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
<template>
  <j-modal
    ref='modal'
    :width='600'
    :visible='visible'
    @ok='handleOk'
    @cancel='handleCancel'
    :footer='null'
    :maskClosable='false'
    :closable='false'
    cancelText='关闭'>
    <div class='container'>
      <div class='panel-tool'>
        <a class='panel-tool-close' @click='handleCancel'></a>
      </div>
      <div class='content'>
        <a-spin :spinning='confirmLoading'>
          <a-form-model ref='form' :label-col='labelCol' :wrapper-col='wrapperCol' :model='model'
                        :rules='validatorRules'>
            <a-row class='form-row' :gutter='16'>
              <!--              <a-col :lg='24'>
                              <a-form-model-item label='文件夹名称' prop='pid'>
                                <a-input v-model='model.pid' placeholder='请输入项目名称' />
                              </a-form-model-item>
                            </a-col>-->
              <a-col :lg='24'>
                <a-form-model-item label='上传路径' prop='pid'>
                  <a-tree-select
                    show-search
                    @select='treeSelect'
                    tree-node-filter-prop='title'
                    v-model='model.pid'
                    style='width: 100%'
                    :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                    :tree-data='treeData'
                    placeholder='请选择上传路径'
                  >
                  </a-tree-select>
                </a-form-model-item>
              </a-col>
              <a-col :lg='24'>
                <a-form-model-item label='上传路径' prop='pid'>
                  <j-upload :biz-path='getPath' list-type='picture' v-model='model.fileList'></j-upload>
                </a-form-model-item>
              </a-col>
 
            </a-row>
          </a-form-model>
        </a-spin>
        <div class='confirm-box'>
          <a-button style='width: 100px' type='primary' :loading='loading' @click='handleOk'>
            保存
          </a-button>
        </div>
 
      </div>
 
    </div>
 
  </j-modal>
</template>
 
<script>
import { getAction, postAction } from '@api/manage'
 
export default {
  name: 'UploadModal',
  data() {
    return {
      title: '新建文件夹',
      model: {
        pid: undefined,
        fileList: undefined
      },
      visible: false,
      loading: false,
      value: '',
      treeData: [],
      uploadPath: undefined,
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      confirmLoading: false,
      validatorRules: {
        pid: [{ message: '上传路径不能为空', trigger: 'blur' }]
      },
      url: {
        add: 'desk/file/add',
        queryTreeList: 'desk/file/queryTreeList',
        uploadAction: window._CONFIG['domianURL'] + '/sys/common/upload'
      }
    }
  },
  methods: {
    add() {
      this.treeData = []
      this.loading = false
      this.uploadPath = undefined
      this.edit({
        pid: undefined,
        fileList: undefined
      })
      this.onLoadData()
    },
    edit(record) {
      this.visible = true
      //默认类型为市场型
      this.model = Object.assign({}, record)
    },
 
    close() {
      this.$emit('close')
      this.visible = false
    },
    previewFile(file) {
 
    }
    ,
    handleOk() {
      if (!this.model.pid) {
        this.$message.error('请先选择上传路径!')
        return false
      }
      if (!this.model.fileList) {
        this.$message.error('最少上传一个文件')
        return false
      }
      this.model.type = 1
      console.info(this.model)
      this.handleAdd(this.model)
 
    },
    handleAdd(param){
      console.info(param)
      this.loading = true
      postAction(this.url.add, param)
        .then((res) => {
          this.confirmLoading = false
          this.loading = false
          if (res.success) {
            this.close()
            this.$message.success(res.message)
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.confirmLoading = false
          this.loading = false
        })
    },
    handleCancel() {
      this.close()
    },
 
 
    onLoadData() {
      getAction(this.url.queryTreeList).then((res) => {
        if (res.success) {
          this.treeData = res.result.filter(c => c.id != '1') // 去除常用文件夹
          console.info(this.treeData)
        }
      })
 
    },
    treeSelect(value, node, extra) {
      console.info(node)
      this.uploadPath = node.$options.propsData.dataRef.path
    }
 
  },
  computed: {
    getPath() {
      if (this.uploadPath) {
        //选择了路径传到路径下
        return 'desk/' + this.uploadPath
      } else {
        return 'desk/temp'
      }
 
    }
  }
}
</script>
 
<style lang='less' scoped>
 
/deep/ .ant-modal .ant-modal-content .ant-modal-body {
  padding: 0px;
}
 
.container {
  width: 100%;
  height: 600px;
  position: relative;
  background: linear-gradient(to bottom, #EFF5FF 0, #E0ECFF 20%);
  box-sizing: border-box;
  border: 1px solid #95B8E7;
  border-radius: 5px;
  display: flex;
 
  .panel-tool {
    width: 100%;
    height: 25px;
    padding: 0px 10px;
    position: absolute;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-end;
    align-items: center;
 
    a {
      display: inline-block;
      width: 16px;
      height: 16px;
      opacity: .6;
      margin: 0 0 0 2px;
      vertical-align: top;
    }
 
    a:hover {
      opacity: 1;
    }
 
    .panel-tool-close {
      background: url(../../../assets/desk/panel_tools.png) no-repeat -16px 0px;
    }
 
    .panel-tool-max {
      background: url(../../../assets/desk/panel_tools.png) no-repeat 0px -16px;
    }
 
    .panel-tool-min {
      background: url(../../../assets/desk/panel_tools.png) no-repeat 0px 0px;
    }
  }
 
  .content {
    width: 100%;
    flex-grow: 1;
    margin: 25px 5px 5px 5px;
    padding-top: 20px;
    background: white;
    box-sizing: border-box;
    border: 1px solid #95B8E7;
    overflow: auto;
 
    .confirm-box {
      width: 100%;
      height: 40px;
      margin-top: 20px;
      text-align: center;
    }
  }
 
 
}
 
</style>