diff --git a/api/app/lib/controllers/resourceRepository/index.js b/api/app/lib/controllers/resourceRepository/index.js
index 53edb19..0f61642 100644
--- a/api/app/lib/controllers/resourceRepository/index.js
+++ b/api/app/lib/controllers/resourceRepository/index.js
@@ -136,24 +136,27 @@ async function getResourceFileList(ctx, next) {
findObj.limit = Number(limit);
findObj.offset = Number(offset);
}
- if (departmentName) {
- const where = {
- departmentName: departmentName
+
+ if ("公司培训资料" == type) {
+ findObj.where = { fileName: { $not: null } };
+ if (departmentName) {
+ findObj.where.departmentName = departmentName;
}
if (trainDate) {
- //todo
- // where.trainDate = trainDate
- }
- findObj.where = where;
- }
- if ("公司培训资料" == type) {
- if (findObj.where) {
- findObj.where.fileName = { $not: null };
- } else {
- findObj.where = { fileName: { $not: null } };
+ findObj.where.trainDate = trainDate;
}
rlst = await models.TrainingInformation.findAndCountAll(findObj);
} else {
+ if (departmentName) {
+ const where = {
+ departmentName: departmentName
+ }
+ if (trainDate) {
+ //todo
+ where.trainDate = trainDate
+ }
+ findObj.where = where;
+ }
rlst = await models.DeptTraining.findAndCountAll(findObj);
}
} else {
@@ -246,11 +249,62 @@ async function delResourceClassify(ctx) {
ctx.body = { message: err.message || '新增培训资源储备库文件夹失败' }
}
}
+//新增公司培训资料文件
+async function postResourceFile(ctx) {
+ const transaction = await ctx.fs.dc.orm.transaction();
+ try {
+ const { fileList, currentSelect } = ctx.request.body;
+ const { models } = ctx.fs.dc;
+
+ const files = fileList && fileList.length && fileList.filter(f => f.fileName && f.fileType && f.fileSize && f.attachPath);
+ const splitArr = currentSelect.split("/");
+ if (files.length && splitArr.length == 3 && "公司培训资料" == splitArr[0]) {
+ const dataToSave = files.map(r => {
+ return {
+ ...r,
+ departmentName: splitArr[1],
+ trainDate: splitArr[2],
+ updateDate: moment()
+ }
+ });
+ await models.TrainingInformation.bulkCreate(dataToSave, { transaction });
+ } else {
+ ctx.throw("新增公司培训资料文件内容不合法,请检查");
+ }
+
+ await transaction.commit();
+ ctx.status = 204;
+ } catch (err) {
+ await transaction.rollback();
+ ctx.status = 400;
+ ctx.body = { message: err.message || '新增公司培训资料文件失败' }
+ }
+}
+//删除公司培训资料文件
+async function delResourceFile(ctx) {
+ const transaction = await ctx.fs.dc.orm.transaction();
+ try {
+ const { id } = ctx.params;
+ const { models } = ctx.fs.dc;
+ const old = await models.TrainingInformation.findOne({ where: { id: id } });
+ if (old) {
+ await models.TrainingInformation.destroy({ where: { id: id }, transaction });
+ }
+ await transaction.commit();
+ ctx.status = 204;
+ } catch (err) {
+ await transaction.rollback();
+ ctx.status = 400;
+ ctx.body = { message: err.message || '删除培训资源储备库文件夹失败' }
+ }
+}
module.exports = {
getResourceClassify,
getResourceFileList,
postResourceClassify,
putResourceClassify,
- delResourceClassify
+ delResourceClassify,
+ postResourceFile,
+ delResourceFile
}
\ No newline at end of file
diff --git a/api/app/lib/routes/resourceRepository/index.js b/api/app/lib/routes/resourceRepository/index.js
index 61716a7..3e4a960 100644
--- a/api/app/lib/routes/resourceRepository/index.js
+++ b/api/app/lib/routes/resourceRepository/index.js
@@ -15,8 +15,15 @@ module.exports = function (app, router, opts) {
app.fs.api.logAttr['PUT/train/trainFiles/resourceRepository/classify'] = { content: '编辑培训资源储备库文件夹', visible: true };
router.put('/train/trainFiles/resourceRepository/classify', resourceRepository.putResourceClassify);
-
+
app.fs.api.logAttr['DELETE/train/trainFiles/resourceRepository/classify'] = { content: '删除培训资源储备库文件夹', visible: true };
router.delete('/train/trainFiles/resourceRepository/classify', resourceRepository.delResourceClassify);
-
+
+ app.fs.api.logAttr['POST/train/trainFiles/resourceRepository/file'] = { content: '新增公司培训资料文件', visible: true };
+ router.post('/train/trainFiles/resourceRepository/file', resourceRepository.postResourceFile);
+
+ app.fs.api.logAttr['DELETE/train/trainFiles/resourceRepository/file/:id'] = { content: '删除公司培训资料文件', visible: true };
+ router.delete('/train/trainFiles/resourceRepository/file/:id', resourceRepository.delResourceFile);
+
+
};
\ No newline at end of file
diff --git a/web/client/src/sections/humanAffairs/actions/resourceRepository.js b/web/client/src/sections/humanAffairs/actions/resourceRepository.js
index 1ecdd42..4d97d2b 100644
--- a/web/client/src/sections/humanAffairs/actions/resourceRepository.js
+++ b/web/client/src/sections/humanAffairs/actions/resourceRepository.js
@@ -58,4 +58,26 @@ export function delResourceClassify(query) {
url: `${ApiTable.delResourceClassify}`,
msg: { option: "删除" },
});
-}
\ No newline at end of file
+}
+
+export function postResourceFile(data) {
+ return (dispatch) =>
+ basicAction({
+ type: "post",
+ dispatch: dispatch,
+ data,
+ actionType: "POST_RESOURCE_FILE",
+ url: `${ApiTable.postResourceFile}`,
+ msg: { option: "上传" },
+ });
+}
+export function delResourceFile(id) {
+ return (dispatch) =>
+ basicAction({
+ type: "del",
+ dispatch: dispatch,
+ actionType: "DEL_RESOURCE_FILE",
+ url: ApiTable.delResourceFile.replace("{id}", id),
+ msg: { option: "删除" },
+ });
+}
diff --git a/web/client/src/sections/humanAffairs/components/resourceRepository/folder-model.jsx b/web/client/src/sections/humanAffairs/components/resourceRepository/folder-model.jsx
index eaa7178..67e0e3a 100644
--- a/web/client/src/sections/humanAffairs/components/resourceRepository/folder-model.jsx
+++ b/web/client/src/sections/humanAffairs/components/resourceRepository/folder-model.jsx
@@ -11,7 +11,10 @@ const FolderModal = (props) => {
if (val && '' == val.trim()) {
return '不可以为空';
} else
- if (val.length > 20) {
+ if (RegExp(/\//).exec(val)) {
+ return '不可以包含"/"特殊字符';
+ }
+ else if (val.length > 20) {
return '最大20字符';
} else {
if (oldData.children) {
@@ -43,7 +46,6 @@ const FolderModal = (props) => {
return '';
}
const handleOk = () => {
-
form.current.validate().then((values) => {
if (!add) {
values.oldDepName = departmentName;
diff --git a/web/client/src/sections/humanAffairs/components/resourceRepository/upload-modal.jsx b/web/client/src/sections/humanAffairs/components/resourceRepository/upload-modal.jsx
new file mode 100644
index 0000000..4638049
--- /dev/null
+++ b/web/client/src/sections/humanAffairs/components/resourceRepository/upload-modal.jsx
@@ -0,0 +1,51 @@
+import React, { useRef, useState } from 'react';
+import { Modal, Form, Button, Toast } from '@douyinfe/semi-ui';
+import { IconUpload } from '@douyinfe/semi-icons';
+
+const ResourceUploadModal = (props) => {
+ const { apiRoot, user, onCancel, onOk } = props;
+
+ const form = useRef();
+ const handleOk = () => {
+ form.current.validate().then((values) => {
+ onOk(values);
+ });
+ }
+ return ( 支持文件类型:.doc,.docx,.xls,.xlsx,.pdf,.pptx,
+ 支持压缩包类型:zip、rar、7z,
+ 文件大小一个不能超过200M,一次最多上传5个文件。
+