Merge branch 'projects/mes-test' of git.picaiba.com:mt-fe-group/yudao-dev into projects/mes-test

This commit is contained in:
gtz
2023-11-28 09:03:13 +08:00
47 changed files with 1207 additions and 1608 deletions

View File

@@ -76,6 +76,7 @@
class="upload-area"
:class="uploadOpen ? '' : 'height-48'"
ref="uploadArea"
:key="col.prop"
v-if="col.upload">
<span class="close-icon" :class="uploadOpen ? 'open' : ''">
<el-button
@@ -87,13 +88,18 @@
<el-upload
class="upload-in-dialog"
v-if="col.upload"
:key="col.prop + '__el-upload'"
:action="uploadUrl"
:headers="uploadHeaders"
:show-file-list="false"
icon="el-icon-upload2"
:disabled="disabled"
:before-upload="beforeUpload"
:on-success="handleUploadSuccess"
:on-success="
(response, file, fileList) => {
handleUploadSuccess(response, file, col.prop);
}
"
v-bind="col.bind">
<el-button size="mini" :disabled="col.bind?.disabled || false">
<svg-icon
@@ -108,10 +114,10 @@
<uploadedFile
class="file"
v-for="file in form[col.prop] || []"
v-for="file in form[col.prop]"
:file="file"
:key="file.fileUrl"
@delete="!disabled && handleDeleteFile(file)" />
@delete="!disabled && handleDeleteFile(file, col.prop)" />
</div>
</el-form-item>
</el-col>
@@ -152,12 +158,30 @@ const uploadedFile = {
handleDelete() {
this.$emit('delete', this.file);
},
async handleDownload() {
const data = await this.$axios({
url: this.file.fileUrl,
method: 'get',
responseType: 'blob',
});
await this.$message.success('开始下载');
// create download link
const url = window.URL.createObjectURL(data);
const link = document.createElement('a');
link.href = url;
link.download = this.file.fileName;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
},
},
mounted() {},
render: function (h) {
return (
<div
title={this.file.fileName}
onClick={this.handleDownload}
style={{
background: `url(${tupleImg}) no-repeat`,
backgroundSize: '14px',
@@ -205,7 +229,7 @@ export default {
default: false,
},
hasFiles: {
type: Boolean,
type: Boolean | Array,
default: false,
},
labelPosition: {
@@ -251,7 +275,13 @@ export default {
handler(val) {
this.form = JSON.parse(JSON.stringify(val));
if (this.hasFiles) {
this.form.files = this.form.files ?? [];
if (typeof this.hasFiles == 'boolean' && this.hasFiles) {
this.form.files = this.form.files ?? [];
} else if (Array.isArray(this.hasFiles)) {
this.hasFiles.forEach((prop) => {
this.form[prop] = this.form[prop] ?? [];
});
}
}
},
deep: true,
@@ -348,7 +378,7 @@ export default {
// 处理输入框数据
this.form[opt.prop] = response.data;
// 更新下外部的 dataForm防止code字段有数据也报空的bug
this.$emit('update', this.form)
this.$emit('update', this.form);
}
});
}
@@ -377,11 +407,12 @@ export default {
// 上传成功的特殊处理
beforeUpload() {},
// 上传前的验证规则可通过 bind 属性传入
handleUploadSuccess(response, file, fileList) {
this.form.files.push({
handleUploadSuccess(response, file, prop) {
console.log('[handleUploadSuccess]', response, file, prop);
this.form[prop].push({
fileName: file.name,
fileUrl: response.data,
fileType: 2,
fileType: prop == 'files' ? 2 : 1,
});
this.$modal.msgSuccess('上传成功');
this.$emit('update', this.form);
@@ -395,8 +426,8 @@ export default {
this.uploadOpen = !this.uploadOpen;
},
handleDeleteFile(file) {
this.form.files = this.form.files.filter(
handleDeleteFile(file, prop) {
this.form[prop] = this.form[prop].filter(
(item) => item.fileUrl != file.fileUrl
);
this.$emit('update', this.form);

View File

@@ -124,9 +124,9 @@ export default {
this.Quill = new Quill(editor, this.options);
// 取消自动聚焦 start
this.$nextTick(() => {
this.Quill.blur();
this.Quill?.blur();
if (!this.readOnly) {
this.Quill.enable();
this.Quill?.enable();
}
});
// 如果设置了上传地址则自定义图片上传事件

View File

@@ -29,10 +29,10 @@
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
<el-link :href="`${file.url}`" :underline="false" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
<span class="el-icon-document"> {{ fileName }} </span>
</el-link>
<div class="ele-upload-list__item-content-action">
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
<el-link :underline="false" @click="handleDelete(index)" :disabled="disabled" type="danger">删除</el-link>
</div>
</li>
</transition-group>
@@ -71,6 +71,11 @@ export default {
disabled: {
type: Boolean,
default: false
},
//文件名称
fName: {
type: String,
default: ''
}
},
data() {
@@ -81,6 +86,7 @@ export default {
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/upload", // 请求地址
headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部
fileList: [],
fileName: ''
};
},
watch: {
@@ -105,6 +111,14 @@ export default {
},
deep: true,
immediate: true
},
fName: {
handler(val) {
if (val) {
console.log('11', val)
this.fileName = val
}
}
}
},
computed: {
@@ -117,6 +131,7 @@ export default {
// 上传前校检格式和大小
handleBeforeUpload(file) {
// 校检文件类型
this.fileName = file.name
if (this.fileType) {
let fileExtension = "";
if (file.name.lastIndexOf(".") > -1) {
@@ -150,7 +165,7 @@ export default {
},
// 上传失败
handleUploadError(err) {
this.$modal.msgError("上传图片失败,请重试");
this.$modal.msgError("上传文件失败,请重试");
this.$modal.closeLoading()
},
// 上传成功回调
@@ -180,8 +195,12 @@ export default {
this.number = 0;
this.$emit("input", this.listToString(this.fileList));
this.$modal.closeLoading();
this.returnFileName()
}
},
returnFileName() {
this.$emit('name', this.fileName)
},
// 获取文件名称
getFileName(name) {
console.log('你好', name)