Commit c844c7ef19c7378514065fc7f23b8f425f823239

Authored by YunaiV
1 parent b267b2c3

v3.6.0 FileUpload组件支持多文件上传

yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/vue/views/index.vue.vm
... ... @@ -74,7 +74,7 @@
74 74 #elseif("" != $column.dictType)## 数据字典
75 75 <el-table-column label="${comment}" align="center" prop="${javaField}">
76 76 <template slot-scope="scope">
77   - <span>{{ getDictDataLabel(DICT_TYPE.$dictType.toUpperCase(), scope.row.${column.javaField}) }}</span>
  77 + <dict-type :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" />
78 78 </template>
79 79 </el-table-column>
80 80 #else
... ...
yudao-ui-admin/src/api/bpm/processInstance.js
... ... @@ -33,3 +33,18 @@ export function getProcessInstance(id) {
33 33 method: 'get',
34 34 })
35 35 }
  36 +
  37 +export class createProcessInstanceExt {
  38 +}
  39 +
  40 +export class exportProcessInstanceExtExcel {
  41 +}
  42 +
  43 +export class getProcessInstanceExtPage {
  44 +}
  45 +
  46 +export class deleteProcessInstanceExt {
  47 +}
  48 +
  49 +export class deleteProcessInstanceExt {
  50 +}
... ...
yudao-ui-admin/src/components/FileUpload/index.vue
... ... @@ -4,9 +4,7 @@
4 4 :action="uploadFileUrl"
5 5 :before-upload="handleBeforeUpload"
6 6 :file-list="fileList"
7   - :limit="1"
8 7 :on-error="handleUploadError"
9   - :on-exceed="handleExceed"
10 8 :on-success="handleUploadSuccess"
11 9 :show-file-list="false"
12 10 :headers="headers"
... ... @@ -26,8 +24,8 @@
26 24  
27 25 <!-- 文件列表 -->
28 26 <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
29   - <li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in list">
30   - <el-link :href="file.url" :underline="false" target="_blank">
  27 + <li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
  28 + <el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank">
31 29 <span class="el-icon-document"> {{ getFileName(file.name) }} </span>
32 30 </el-link>
33 31 <div class="ele-upload-list__item-content-action">
... ... @@ -42,6 +40,7 @@
42 40 import { getToken } from "@/utils/auth";
43 41  
44 42 export default {
  43 + name: "FileUpload",
45 44 props: {
46 45 // 值
47 46 value: [String, Object, Array],
... ... @@ -63,6 +62,7 @@ export default {
63 62 },
64 63 data() {
65 64 return {
  65 + baseUrl: process.env.VUE_APP_BASE_API,
66 66 uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传的图片服务器地址
67 67 headers: {
68 68 Authorization: "Bearer " + getToken(),
... ... @@ -70,30 +70,35 @@ export default {
70 70 fileList: [],
71 71 };
72 72 },
  73 + watch: {
  74 + value: {
  75 + handler(val) {
  76 + if (val) {
  77 + let temp = 1;
  78 + // 首先将值转为数组
  79 + const list = Array.isArray(val) ? val : this.value.split(',');
  80 + // 然后将数组转为对象数组
  81 + this.fileList = list.map(item => {
  82 + if (typeof item === "string") {
  83 + item = { name: item, url: item };
  84 + }
  85 + item.uid = item.uid || new Date().getTime() + temp++;
  86 + return item;
  87 + });
  88 + } else {
  89 + this.fileList = [];
  90 + return [];
  91 + }
  92 + },
  93 + deep: true,
  94 + immediate: true
  95 + }
  96 + },
73 97 computed: {
74 98 // 是否显示提示
75 99 showTip() {
76 100 return this.isShowTip && (this.fileType || this.fileSize);
77 101 },
78   - // 列表
79   - list() {
80   - let temp = 1;
81   - if (this.value) {
82   - // 首先将值转为数组
83   - const list = Array.isArray(this.value) ? this.value : [this.value];
84   - // 然后将数组转为对象数组
85   - return list.map((item) => {
86   - if (typeof item === "string") {
87   - item = { name: item, url: item };
88   - }
89   - item.uid = item.uid || new Date().getTime() + temp++;
90   - return item;
91   - });
92   - } else {
93   - this.fileList = [];
94   - return [];
95   - }
96   - },
97 102 },
98 103 methods: {
99 104 // 上传前校检格式和大小
... ... @@ -124,10 +129,6 @@ export default {
124 129 }
125 130 return true;
126 131 },
127   - // 文件个数超出
128   - handleExceed() {
129   - this.$message.error(`只允许上传单个文件`);
130   - },
131 132 // 上传失败
132 133 handleUploadError(err) {
133 134 this.$message.error("上传失败, 请重试");
... ... @@ -135,12 +136,13 @@ export default {
135 136 // 上传成功回调
136 137 handleUploadSuccess(res, file) {
137 138 this.$message.success("上传成功");
138   - this.$emit("input", res.url);
  139 + this.fileList.push({ name: res.fileName, url: res.fileName });
  140 + this.$emit("input", this.listToString(this.fileList));
139 141 },
140 142 // 删除文件
141 143 handleDelete(index) {
142 144 this.fileList.splice(index, 1);
143   - this.$emit("input", '');
  145 + this.$emit("input", this.listToString(this.fileList));
144 146 },
145 147 // 获取文件名称
146 148 getFileName(name) {
... ... @@ -149,11 +151,16 @@ export default {
149 151 } else {
150 152 return "";
151 153 }
  154 + },
  155 + // 对象转成分隔字符串
  156 + listToString(list) {
  157 + let files = "";
  158 + for (let key in list) {
  159 + files += list[key].url + ",";
  160 + }
  161 + return files.substr(0, files.length - 1);
152 162 }
153   - },
154   - created() {
155   - this.fileList = this.list;
156   - },
  163 + }
157 164 };
158 165 </script>
159 166  
... ... @@ -176,4 +183,4 @@ export default {
176 183 .ele-upload-list__item-content-action .el-link {
177 184 margin-right: 10px;
178 185 }
179   -</style>
180 186 \ No newline at end of file
  187 +</style>
... ...
yudao-ui-admin/src/views/bpm/definition/index.vue
... ... @@ -12,7 +12,7 @@
12 12 </el-table-column>
13 13 <el-table-column label="定义分类" align="center" prop="category" width="100">
14 14 <template slot-scope="scope">
15   - <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
  15 + <dict-tag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="scope.row.category" />
16 16 </template>
17 17 </el-table-column>
18 18 <el-table-column label="表单信息" align="center" prop="formType" width="200">
... ...
yudao-ui-admin/src/views/bpm/model/index.vue
... ... @@ -47,7 +47,7 @@
47 47 </el-table-column>
48 48 <el-table-column label="流程分类" align="center" prop="category" width="100">
49 49 <template slot-scope="scope">
50   - <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
  50 + <dict-tag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="scope.row.category" />
51 51 </template>
52 52 </el-table-column>
53 53 <el-table-column label="表单信息" align="center" prop="formType" width="200">
... ... @@ -291,7 +291,7 @@ export default {
291 291 // 设置上传的请求头部
292 292 headers: getBaseHeader(),
293 293 // 上传的地址
294   - url: process.env.VUE_APP_BASE_API + '/api/' + "/bpm/model/import",
  294 + url: process.env.VUE_APP_BASE_API + '/admin-api/' + "/bpm/model/import",
295 295 // 表单
296 296 form: {},
297 297 // 校验规则
... ...
yudao-ui-admin/src/views/bpm/oa/leave/index.vue
... ... @@ -84,7 +84,7 @@
84 84  
85 85 <script>
86 86 import { getLeavePage } from "@/api/bpm/leave"
87   -import { getDictDataLabel, getDictDatas, DICT_TYPE } from '@/utils/dict'
  87 +import { getDictDatas, DICT_TYPE } from '@/utils/dict'
88 88 import {cancelProcessInstance} from "@/api/bpm/processInstance";
89 89  
90 90 export default {
... ... @@ -171,13 +171,7 @@ export default {
171 171 this.getList();
172 172 this.msgSuccess("取消成功");
173 173 })
174   - },
175   - resultFormat(row, column) {
176   - return getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, row.result)
177   - },
178   - typeFormat(row, column) {
179   - return getDictDataLabel(DICT_TYPE.BPM_OA_LEAVE_TYPE, row.type)
180   - },
  174 + }
181 175 }
182 176 };
183 177 </script>
... ...
yudao-ui-admin/src/views/bpm/processInstance/create.vue
... ... @@ -12,7 +12,7 @@
12 12 </el-table-column>
13 13 <el-table-column label="流程分类" align="center" prop="category" width="100">
14 14 <template slot-scope="scope">
15   - <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
  15 + <dict-tag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="scope.row.category" />
16 16 </template>
17 17 </el-table-column>
18 18 <el-table-column label="流程版本" align="center" prop="processDefinition.version" width="80">
... ...
yudao-ui-admin/src/views/bpm/processInstance/index.vue
... ... @@ -52,7 +52,7 @@
52 52 <el-table-column label="流程名" align="center" prop="name" />
53 53 <el-table-column label="流程分类" align="center" prop="category">
54 54 <template slot-scope="scope">
55   - <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
  55 + <dict-tag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="scope.row.category" />
56 56 </template>
57 57 </el-table-column>
58 58 <el-table-column label="当前审批任务" align="center" prop="tasks">
... ... @@ -64,14 +64,7 @@
64 64 </el-table-column>
65 65 <el-table-column label="状态" align="center" prop="status">
66 66 <template slot-scope="scope">
67   - <span>
68   - <el-tag type="primary" v-if="scope.row.status === 1"> <!-- 进行中 -->
69   - {{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS, scope.row.status) }}
70   - </el-tag>
71   - <el-tag type="success" v-if="scope.row.status === 2"> <!-- 已结束 -->
72   - {{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS, scope.row.status) }}
73   - </el-tag>
74   - </span>
  67 + <dict-tag :type="DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS" :value="scope.row.status" />
75 68 </template>
76 69 </el-table-column>
77 70 <el-table-column label="结果" align="center" prop="result">
... ... @@ -106,16 +99,7 @@
106 99 </template>
107 100  
108 101 <script>
109   -import {
110   - getMyProcessInstancePage,
111   - createProcessInstanceExt,
112   - updateProcessInstanceExt,
113   - deleteProcessInstanceExt,
114   - getProcessInstanceExt,
115   - getProcessInstanceExtPage,
116   - exportProcessInstanceExtExcel, cancelProcessInstance
117   -} from "@/api/bpm/processInstance";
118   -import {deleteErrorCode} from "@/api/system/errorCode";
  102 +import { getMyProcessInstancePage, cancelProcessInstance } from "@/api/bpm/processInstance";
119 103  
120 104 export default {
121 105 name: "ProcessInstance",
... ...
yudao-ui-admin/src/views/bpm/taskAssignRule/taskAssignRuleDialog.vue
... ... @@ -7,7 +7,7 @@
7 7 <el-table-column label="任务标识" align="center" prop="taskDefinitionKey" width="120" show-tooltip-when-overflow />
8 8 <el-table-column label="规则类型" align="center" prop="type" width="120">
9 9 <template slot-scope="scope">
10   - <span>{{ getDictDataLabel(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE, scope.row.type) }}</span>
  10 + <dict-tag :type="DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE" :value="scope.row.type" />
11 11 </template>
12 12 </el-table-column>
13 13 <el-table-column label="规则范围" align="center" prop="options" width="440px">
... ...
yudao-ui-admin/src/views/infra/apiErrorLog/index.vue
... ... @@ -63,7 +63,7 @@
63 63 <el-table-column label="异常名" align="center" prop="exceptionName" width="250" />
64 64 <el-table-column label="处理状态" align="center" prop="processStatus">
65 65 <template slot-scope="scope">
66   - <span>{{ getDictDataLabel(DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS, scope.row.processStatus) }}</span>
  66 + <dict-tag :type="DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS" :value="scope.row.processStatus" />
67 67 </template>
68 68 </el-table-column>
69 69 <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
... ... @@ -93,7 +93,7 @@
93 93 <el-form-item label="链路追踪:">{{ form.traceId }}</el-form-item>
94 94 <el-form-item label="应用名:">{{ form.applicationName }}</el-form-item>
95 95 <el-form-item label="用户信息:">
96   - {{ form.userId }} | {{ getDictDataLabel(DICT_TYPE.USER_TYPE, form.userType) }} | {{ form.userIp }} | {{ form.userAgent}}
  96 + {{ form.userId }} <dict-tag :type="DICT_TYPE.USER_TYPE" :value="form.userType" /> | {{ form.userIp }} | {{ form.userAgent}}
97 97 </el-form-item>
98 98 <el-form-item label="请求信息:">{{ form.requestMethod }} | {{ form.requestUrl }} </el-form-item>
99 99 <el-form-item label="请求参数:">{{ form.requestParams }}</el-form-item>
... ... @@ -103,7 +103,7 @@
103 103 <el-input type="textarea" :readonly="true" :autosize="{ maxRows: 20}" v-model="form.exceptionStackTrace"></el-input>
104 104 </el-form-item>
105 105 <el-form-item label="处理状态">
106   - {{ getDictDataLabel(DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS, form.processStatus) }}
  106 + <dict-tag :type="DICT_TYPE.INFRA_API_ERROR_LOG_PROCESS_STATUS" :value="form.processStatus" />
107 107 </el-form-item>
108 108 <el-form-item label="处理人">{{ form.processUserId }}</el-form-item>
109 109 <el-form-item label="处理时间">{{ parseTime(form.processTime) }}</el-form-item>
... ...
yudao-ui-admin/src/views/system/user/index.vue
... ... @@ -172,18 +172,9 @@
172 172  
173 173 <!-- 用户导入对话框 -->
174 174 <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
175   - <el-upload
176   - ref="upload"
177   - :limit="1"
178   - accept=".xlsx, .xls"
179   - :headers="upload.headers"
180   - :action="upload.url + '?updateSupport=' + upload.updateSupport"
181   - :disabled="upload.isUploading"
182   - :on-progress="handleFileUploadProgress"
183   - :on-success="handleFileSuccess"
184   - :auto-upload="false"
185   - drag
186   - >
  175 + <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers"
  176 + :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading"
  177 + :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
187 178 <i class="el-icon-upload"></i>
188 179 <div class="el-upload__text">
189 180 将文件拖到此处,或
... ... @@ -253,6 +244,7 @@ import {CommonStatusEnum} from &quot;@/utils/constants&quot;;
253 244 import {DICT_TYPE, getDictDatas} from "@/utils/dict";
254 245 import {assignUserRole, listUserRoles} from "@/api/system/permission";
255 246 import {listSimpleRoles} from "@/api/system/role";
  247 +import {getBaseHeader} from "@/utils/request";
256 248  
257 249 export default {
258 250 name: "User",
... ... @@ -306,9 +298,9 @@ export default {
306 298 // 是否更新已经存在的用户数据
307 299 updateSupport: 0,
308 300 // 设置上传的请求头部
309   - headers: { Authorization: "Bearer " + getToken() },
  301 + headers: getBaseHeader(),
310 302 // 上传的地址
311   - url: process.env.VUE_APP_BASE_API + '/api/' + "/system/user/import"
  303 + url: process.env.VUE_APP_BASE_API + '/admin-api/' + "/system/user/import"
312 304 },
313 305 // 查询参数
314 306 queryParams: {
... ... @@ -626,6 +618,10 @@ export default {
626 618 },
627 619 // 文件上传成功处理
628 620 handleFileSuccess(response, file, fileList) {
  621 + if (response.code !== 0) {
  622 + this.msgError(response.msg)
  623 + return;
  624 + }
629 625 this.upload.open = false;
630 626 this.upload.isUploading = false;
631 627 this.$refs.upload.clearFiles();
... ...