From b2df37c5f99379db0f17b67ee376ea27e6fa23cc Mon Sep 17 00:00:00 2001
From: Apcallover <1503963513@qq.com>
Date: Tue, 12 Mar 2024 21:25:10 +0800
Subject: [PATCH] flat: zanc
---
src/api/tenant/policy.js | 20 ++++++
src/views/tenant/main/policy/index.vue | 86 ++++++++++++++++++++------
2 files changed, 86 insertions(+), 20 deletions(-)
diff --git a/src/api/tenant/policy.js b/src/api/tenant/policy.js
index c6350f5..8d4fe03 100644
--- a/src/api/tenant/policy.js
+++ b/src/api/tenant/policy.js
@@ -1,4 +1,5 @@
import request from '@/router/axios';
+import { Message } from 'element-ui';
/*获取人才列表*/
export const getList =
(current, size, params, groupId) => {
@@ -104,3 +105,22 @@ export const transferDept =
export const upload = () => {
return `/api/jobslink-api/policy/group/import?isCovered=1`
}
+
+
+export const uploadFilePolicy = (formData) => {
+ return new Promise((resolve, reject) => {
+ request({
+ url: '/api/jobslink-api/resource/file/save',
+ method: 'post',
+ data: formData,
+ headers: {
+ 'Content-Type': 'multipart/form-data;'
+ }
+ })
+ .then((res) => {
+ resolve(res)
+ }).catch(err => {
+ Message.error('上传失败' + err.data.message || '上传失败');
+ })
+ })
+}
diff --git a/src/views/tenant/main/policy/index.vue b/src/views/tenant/main/policy/index.vue
index 5eb1df7..9852459 100644
--- a/src/views/tenant/main/policy/index.vue
+++ b/src/views/tenant/main/policy/index.vue
@@ -72,7 +72,7 @@
:permission="permissionList" :before-open="beforeOpen" @row-del="rowDel" @row-update="rowUpdate"
@row-save="rowSave" @search-change="searchChange" @search-reset="searchReset"
@selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
- @refresh-change="refreshChange" class="customPage">
+ @refresh-change="refreshChange" class="customPage" @upload-after="uploadSearchAfter">
@@ -96,15 +96,31 @@
@@ -169,6 +185,7 @@ import {
getDept,
removeDept,
upload,
+ uploadFilePolicy
} from "@/api/tenant/policy";
import { getWorkTypes, getLabelList } from "@/api/tenant/common";
import { mapGetters } from "vuex";
@@ -195,6 +212,8 @@ export default {
name: "tenant_policy",
data() {
return {
+ policyFileUrl: '',
+ guidelineFileUrl: '',
activeNames: "1",
isIndeterminate: false,
checkAll: false,
@@ -571,17 +590,20 @@ export default {
label: "政策文件地址",
prop: "policyFileUrl",
hide: true,
- type: "upload",
- // accept:["png", "jpg", "jpeg"],
- showFileList: true,
- action: "https://api.avuejs.com/imgupload",
- headers: [],
- data: "",
- span: 24,
- propsHttp: {
- res: "data",
- url: "link",
- },
+ // type: "upload",
+ // // accept:["png", "jpg", "jpeg"],
+ // showFileList: true,
+ // action: "/api/jobslink-api/resource/file/save",
+ // headers: [],
+ // data: "",
+ // span: 24,
+ // propsHttp: {
+ // // res: "data",
+ // url: "msg",
+ // name: "msg", // 解析responseJSON中的data.fileName为文件名
+ // // "fileName": "attach" // 指定
+ // },
+ // tip: '上传政策文件',
slot: true,
formslot: true,
showWordLimit: true,
@@ -688,6 +710,22 @@ export default {
this.getLabelList();
},
methods: {
+ async allUpload(file) {
+ const formData = new FormData();
+ formData.append('file', file.file);
+ let resData = await uploadFilePolicy(formData)
+ if(resData.data.code === 200) {
+ this.policyFileUrl = resData.data.msg
+ }
+ },
+ async allUploadGuideline(file) {
+ const formData = new FormData();
+ formData.append('file', file.file);
+ let resData = await uploadFilePolicy(formData)
+ if(resData.data.code === 200) {
+ this.guidelineFileUrl = resData.data.msg
+ }
+ },
getWorkTypes() {
getWorkTypes().then((res) => {
@@ -847,6 +885,8 @@ export default {
this.tempWorkType = this.obj.labelName ? this.obj.labelName.split(",") : [];
this.guidelineContent = this.obj.guidelineContent
this.policyContent = this.obj.policyContent
+ this.guidelineFileUrl = this.obj.guidelineFileUrl
+ this.policyFileUrl = this.obj.policyFileUrl
done();
},
(error) => {
@@ -862,7 +902,6 @@ export default {
},
/*新增人才*/
rowSave(row, done) {
- console.log(this.form);
debugger
add({
// groupId: row.groupId,
@@ -882,8 +921,8 @@ export default {
// status: row.status,
// issuingNumber: row.issuingNumber,
...row,
- guidelineFileUrl: row.guidelineFileUrl.join(','),
- policyFileUrl: row.policyFileUrl.join(','),
+ guidelineFileUrl: this.guidelineFileUrl,
+ policyFileUrl: this.policyFileUrl,
labelName: this.selectedWorkTypes.map((item) => item.name).join(','),
policyContent: this.policyContent,
guidelineContent: this.guidelineContent
@@ -894,6 +933,8 @@ export default {
message: "操作成功!",
});
done();
+ this.guidelineFileUrl = ''
+ this.policyFileUrl = ''
this.refresh();
},
(error) => {
@@ -916,7 +957,9 @@ export default {
// remarks: row.remarks,
...copyRow,
guidelineContent: this.guidelineContent,
- policyContent: this.policyContent
+ policyContent: this.policyContent,
+ guidelineFileUrl: this.guidelineFileUrl,
+ policyFileUrl: this.policyFileUrl,
}).then(
() => {
done();
@@ -924,6 +967,8 @@ export default {
type: "success",
message: "操作成功!",
});
+ this.guidelineFileUrl = ''
+ this.policyFileUrl = ''
this.refresh();
},
(error) => {
@@ -1054,6 +1099,7 @@ export default {
}
},
uploadAfter(res, done) {
+ console.log(res)
if (!(res instanceof Error) && !res.data) {
this.excelBox = false;
} else if (res.data && res.data.code === 900) {