diff --git a/src/assets/images/doc@2x.png b/src/assets/images/doc@2x.png
new file mode 100644
index 0000000..19a8c15
Binary files /dev/null and b/src/assets/images/doc@2x.png differ
diff --git a/src/assets/images/excel@2x.png b/src/assets/images/excel@2x.png
new file mode 100644
index 0000000..e21d6ac
Binary files /dev/null and b/src/assets/images/excel@2x.png differ
diff --git a/src/assets/images/file@2x.png b/src/assets/images/file@2x.png
new file mode 100644
index 0000000..c3364d3
Binary files /dev/null and b/src/assets/images/file@2x.png differ
diff --git a/src/assets/images/pdf@2x.png b/src/assets/images/pdf@2x.png
new file mode 100644
index 0000000..ff9fa20
Binary files /dev/null and b/src/assets/images/pdf@2x.png differ
diff --git a/src/assets/images/ppt@2x.png b/src/assets/images/ppt@2x.png
new file mode 100644
index 0000000..e4d8ffa
Binary files /dev/null and b/src/assets/images/ppt@2x.png differ
diff --git a/src/assets/images/text@2x.png b/src/assets/images/text@2x.png
new file mode 100644
index 0000000..ddd6746
Binary files /dev/null and b/src/assets/images/text@2x.png differ
diff --git a/src/components/FileUpload/index.vue b/src/components/FileUpload/index.vue
index 6c583cf..cd7cb46 100644
--- a/src/components/FileUpload/index.vue
+++ b/src/components/FileUpload/index.vue
@@ -19,20 +19,38 @@
请上传
- 大小不超过 {{ fileSize }}MB
- 格式为 {{ fileType.join("/") }}
+
+ 大小不超过 {{ fileSize }}MB
+
+
+ 格式为 {{ fileType.join("/") }}
+
的文件
-
-
-
+
+
+
{{ getFileName(file.name) }}
- 删除
+ 删除
@@ -57,23 +75,28 @@ export default {
type: Number,
default: 5,
},
+ // 是否返回文件名称以及url
+ isReturnFileAll: {
+ type: Boolean,
+ default: true,
+ },
// 文件类型, 例如['png', 'jpg', 'jpeg']
fileType: {
type: Array,
- default: () => ["doc", "xls", "ppt", "txt", "pdf"],
+ default: () => ["doc", "docx", "xls", "xlsx", "ppt", "txt", "pdf"],
},
// 是否显示提示
isShowTip: {
type: Boolean,
- default: true
- }
+ default: true,
+ },
},
data() {
return {
number: 0,
uploadList: [],
baseUrl: process.env.VUE_APP_BASE_API,
- uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传文件服务器地址
+ uploadFileUrl: process.env.VUE_APP_BASE_API + "/zongzhi/common/upload", // 上传文件服务器地址
headers: {
Authorization: "Bearer " + getToken(),
},
@@ -86,11 +109,13 @@ export default {
if (val) {
let temp = 1;
// 首先将值转为数组
- const list = Array.isArray(val) ? val : this.value.split(',');
+ const list = Array.isArray(val) ? val : this.value.split(",");
// 然后将数组转为对象数组
- this.fileList = list.map(item => {
+ this.fileList = list.map((item) => {
if (typeof item === "string") {
item = { name: item, url: item };
+ } else if (typeof item === "object") {
+ item = { name: item.name, url: item.url };
}
item.uid = item.uid || new Date().getTime() + temp++;
return item;
@@ -101,8 +126,8 @@ export default {
}
},
deep: true,
- immediate: true
- }
+ immediate: true,
+ },
},
computed: {
// 是否显示提示
@@ -115,11 +140,13 @@ export default {
handleBeforeUpload(file) {
// 校检文件类型
if (this.fileType) {
- const fileName = file.name.split('.');
+ const fileName = file.name.split(".");
const fileExt = fileName[fileName.length - 1];
const isTypeOk = this.fileType.indexOf(fileExt) >= 0;
if (!isTypeOk) {
- this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
+ this.$modal.msgError(
+ `文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`
+ );
return false;
}
}
@@ -142,12 +169,20 @@ export default {
// 上传失败
handleUploadError(err) {
this.$modal.msgError("上传文件失败,请重试");
- this.$modal.closeLoading()
+ this.$modal.closeLoading();
},
// 上传成功回调
handleUploadSuccess(res, file) {
if (res.code === 200) {
- this.uploadList.push({ name: res.fileName, url: res.fileName });
+ if (this.isReturnFileAll) {
+ this.uploadList.push({
+ name: res.originalFilename,
+ url: res.fileName,
+ });
+ } else {
+ this.uploadList.push({ name: res.fileName, url: res.fileName });
+ }
+
this.uploadedSuccessfully();
} else {
this.number--;
@@ -160,7 +195,11 @@ export default {
// 删除文件
handleDelete(index) {
this.fileList.splice(index, 1);
- this.$emit("input", this.listToString(this.fileList));
+ if (this.isReturnFileAll) {
+ this.$emit("input", this.fileList);
+ } else {
+ this.$emit("input", this.listToString(this.fileList));
+ }
},
// 上传结束处理
uploadedSuccessfully() {
@@ -168,12 +207,20 @@ export default {
this.fileList = this.fileList.concat(this.uploadList);
this.uploadList = [];
this.number = 0;
- this.$emit("input", this.listToString(this.fileList));
+ if (this.isReturnFileAll) {
+ this.$emit("input", this.fileList);
+ } else {
+ this.$emit("input", this.listToString(this.fileList));
+ }
+
this.$modal.closeLoading();
}
},
// 获取文件名称
getFileName(name) {
+ if (this.isReturnFileAll) {
+ return name;
+ }
if (name.lastIndexOf("/") > -1) {
return name.slice(name.lastIndexOf("/") + 1);
} else {
@@ -187,9 +234,9 @@ export default {
for (let i in list) {
strs += list[i].url + separator;
}
- return strs != '' ? strs.substr(0, strs.length - 1) : '';
- }
- }
+ return strs != "" ? strs.substr(0, strs.length - 1) : "";
+ },
+ },
};
diff --git a/src/components/FileView/index.vue b/src/components/FileView/index.vue
new file mode 100644
index 0000000..a1c89b0
--- /dev/null
+++ b/src/components/FileView/index.vue
@@ -0,0 +1,89 @@
+
+
+
{{ title }}
+
+
+
![]()
+
{{ item.name }}
+
+
+
+
+
+
+
+
diff --git a/src/main.js b/src/main.js
index ec18500..47febf4 100644
--- a/src/main.js
+++ b/src/main.js
@@ -61,6 +61,8 @@ import DictTag from "@/components/DictTag";
import VueMeta from "vue-meta";
// 字典数据组件
import DictData from "@/components/DictData";
+// 文件列表
+import FileView from "@/components/FileView";
// 全局方法挂载
Vue.prototype.getDicts = getDicts;
@@ -81,6 +83,7 @@ Vue.component("Editor", Editor);
Vue.component("FileUpload", FileUpload);
Vue.component("ImageUpload", ImageUpload);
Vue.component("ImagePreview", ImagePreview);
+Vue.component("FileView", FileView);
Vue.use(directive);
Vue.use(plugins);
diff --git a/src/views/netSecurity/SafetyYh/index.vue b/src/views/netSecurity/SafetyYh/index.vue
index a8ffcf5..3aa9109 100644
--- a/src/views/netSecurity/SafetyYh/index.vue
+++ b/src/views/netSecurity/SafetyYh/index.vue
@@ -230,12 +230,14 @@
>
-
-
+
+
+
-
+
@@ -319,13 +321,13 @@
- {{
+
{{
form.depName
@@ -339,6 +341,7 @@
form.endTime
}}
+
@@ -362,6 +365,7 @@ export default {
dicts: ["tc_yh_level", "tc_yh_cz_state", "tc_yh_source", "tc_yh_type"],
data() {
return {
+ fileList: [],
tableHeigth: 0,
//查看详情
infoOpen: false,
@@ -472,6 +476,7 @@ export default {
remark: null,
};
+ this.fileList = [];
this.resetForm("form");
},
/** 搜索按钮操作 */
@@ -495,6 +500,7 @@ export default {
this.reset();
const id = row.id || this.ids;
getDanger(id).then((response) => {
+ this.filterFile(2, response.data.fileName, response.data.fileUrl);
this.form = response.data;
this.infoOpen = true;
this.infoTitle = "查看安全隐患详情";
@@ -511,15 +517,50 @@ export default {
this.reset();
const id = row.id || this.ids;
getDanger(id).then((response) => {
+ this.filterFile(2, response.data.fileName, response.data.fileUrl);
this.form = response.data;
+ console.log(this.fileList);
this.open = true;
this.title = "修改安全隐患";
});
},
+
+ filterFile(state, fileName, fileUrl) {
+ //1.提交 else 查看
+ if (state == 1) {
+ let fileName = [];
+ let fileUrl = [];
+ if (this.fileList.length > 0) {
+ this.fileList.forEach((item) => {
+ fileName.push(item.name);
+ fileUrl.push(item.url);
+ });
+ this.form.fileName = fileName.join(",");
+ this.form.fileUrl = fileUrl.join(",");
+ } else {
+ this.form.fileName = "";
+ this.form.fileUrl = "";
+ }
+ } else {
+ if (fileName != "" || fileUrl != "") {
+ fileName = fileName.split(",");
+ fileUrl = fileUrl.split(",");
+ fileName.forEach((item, index) => {
+ this.fileList.push({
+ name: item,
+ url: fileUrl[index],
+ });
+ });
+ } else {
+ this.fileList = [];
+ }
+ }
+ },
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate((valid) => {
if (valid) {
+ this.filterFile(1);
if (this.form.id != null) {
updateDanger(this.form).then((response) => {
this.$modal.msgSuccess("修改成功");