From f80c453745a44c7fb67a8769886b0dd99e84cb48 Mon Sep 17 00:00:00 2001 From: zhouxin Date: Sat, 17 Dec 2022 17:06:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E8=B5=84=E6=BA=90=E5=BA=93?= =?UTF-8?q?=EF=BC=9A=E5=B7=A6=E4=BE=A7=E5=BC=95=E5=85=A5=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/resourceRepository/index.js | 28 ++++++---- .../sections/humanAffairs/actions/index.js | 5 +- .../actions/resourceRepository.js | 54 +++++++++++++++++++ .../containers/resourceRepository.jsx | 28 ++++++++-- web/client/src/utils/webapi.js | 7 ++- 5 files changed, 105 insertions(+), 17 deletions(-) create mode 100644 web/client/src/sections/humanAffairs/actions/resourceRepository.js diff --git a/api/app/lib/controllers/resourceRepository/index.js b/api/app/lib/controllers/resourceRepository/index.js index f50c666..a9bd824 100644 --- a/api/app/lib/controllers/resourceRepository/index.js +++ b/api/app/lib/controllers/resourceRepository/index.js @@ -6,7 +6,7 @@ async function getResourceClassify(ctx) { const { models } = ctx.fs.dc; const { limit, offset } = ctx.query; let rlst = []; - const findObj = { plain: false, group: ["type", "id"] } + const findObj = {} if (Number(limit) > 0 && Number(offset) >= 0) { findObj.limit = Number(limit); findObj.offset = Number(offset); @@ -14,14 +14,15 @@ async function getResourceClassify(ctx) { const trainingInformationLevel = await models.TrainingInformationLevel.findAll(findObj); if (trainingInformationLevel.length) { rlst = [{ - label: "公司培训资料", value: "company", operation: true, - }, { label: "部门培训资料", value: 'dept', operation: false }]; + label: "公司培训资料", value: "company", key: "company", operation: true, + }, { label: "部门培训资料", value: 'dept', key: 'dept', operation: false }]; for (let level of trainingInformationLevel) { - const { id, type, departmentname, traindate } = level; + const { id, type, departmentname, traindate, origin } = level; /**type:1级, departmentname:2级,traindate:3级 */ const arrIndex = rlst.findIndex(item => item.label == type) if (arrIndex > -1) {//一级分类名称正确 + const operation = "import" == origin ? true : false; if (departmentname) { if (traindate) { //区分2级是否记录 @@ -33,22 +34,25 @@ async function getResourceClassify(ctx) { label: moment(traindate).format('YYYY-MM'), value: id, key: id, + operation }) } else { rlst[arrIndex].children[depIndex].children = [{ label: moment(traindate).format('YYYY-MM'), value: id, - key: id + key: id, + operation }] } } else { rlst[arrIndex].children.push({ label: departmentname, - children: { + children: [{ label: moment(traindate).format('YYYY-MM'), value: id, - key: id - } + key: id, + operation + }] }); } } else { @@ -58,6 +62,7 @@ async function getResourceClassify(ctx) { label: moment(traindate).format('YYYY-MM'), value: id, key: id, + operation }] }] } @@ -68,19 +73,22 @@ async function getResourceClassify(ctx) { if (!rlst[arrIndex].children[depIndex].value) { rlst[arrIndex].children[depIndex].value = id; rlst[arrIndex].children[depIndex].key = id; + rlst[arrIndex].children[depIndex].operation = operation; } } else { rlst[arrIndex].children.push({ label: departmentname, value: id, - key: id + key: id, + operation }) } } else { rlst[arrIndex].children = [{ label: departmentname, value: id, - key: id + key: id, + operation }] } } diff --git a/web/client/src/sections/humanAffairs/actions/index.js b/web/client/src/sections/humanAffairs/actions/index.js index f75ecde..9ce29bf 100644 --- a/web/client/src/sections/humanAffairs/actions/index.js +++ b/web/client/src/sections/humanAffairs/actions/index.js @@ -4,9 +4,12 @@ import * as personnelFiles from './personnelFiles' import * as employeeInformation from './employeeInformation' import * as salesDistribution from './salesDistribution' import * as departmentTrain from './departmentTrain' +import * as resourceRepository from './resourceRepository' + export default { ...personnelFiles, ...employeeInformation, ...salesDistribution, - ...departmentTrain + ...departmentTrain, + ...resourceRepository } \ 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 new file mode 100644 index 0000000..2982643 --- /dev/null +++ b/web/client/src/sections/humanAffairs/actions/resourceRepository.js @@ -0,0 +1,54 @@ +'use strict'; + +import { ApiTable, basicAction } from '$utils' + +export function getResourceClassify() {//查询籍贯列表 + return (dispatch) => basicAction({ + type: "get", + dispatch: dispatch, + actionType: "GET_RESOURCE_CLASSIFY", + // query: query, + url: `${ApiTable.getResourceClassify}`, + msg: { option: "查询培训资料库目录" }, + reducer: { name: "resourceClassify" }, + }); +} + +export function postResourceClassify(data) { + return (dispatch) => + basicAction({ + type: "post", + dispatch: dispatch, + data, + actionType: "POST_RESOURCE_CLASSIFY", + url: `${ApiTable.postResourceClassify}`, + msg: { option: "新增" }, + reducer: { name: "" }, + }); +} + +export function putResourceClassify(data) { + return (dispatch) => + basicAction({ + type: "put", + dispatch: dispatch, + data, + actionType: "PUT_RESOURCE_CLASSIFY", + url: `${ApiTable.putResourceClassify}`, + msg: { option: "修改" }, + reducer: {}, + }); +} + +export function delResourceClassify(data) { + return (dispatch) => + basicAction({ + type: "del", + query: data, + dispatch: dispatch, + actionType: "DEL_RESOURCE_CLASSIFY", + url: `${ApiTable.delResourceClassify}`, + msg: { option: "删除" }, //删除 + reducer: {}, + }); +} \ No newline at end of file diff --git a/web/client/src/sections/humanAffairs/containers/resourceRepository.jsx b/web/client/src/sections/humanAffairs/containers/resourceRepository.jsx index 6b549db..80d4a99 100644 --- a/web/client/src/sections/humanAffairs/containers/resourceRepository.jsx +++ b/web/client/src/sections/humanAffairs/containers/resourceRepository.jsx @@ -1,13 +1,19 @@ -import React, { useEffect, useState ,useRef} from 'react'; +import React, { useEffect, useState, useRef } from 'react'; import { connect } from 'react-redux'; -import { Button, Col, Row, Input, Tree, Table, Space } from '@douyinfe/semi-ui'; +import { Button, Col, Row, Input, Tree, Table, Space, Tooltip } from '@douyinfe/semi-ui'; import { IconSearch, IconEditStroked, IconMinusCircleStroked, IconPlusCircleStroked } from '@douyinfe/semi-icons'; +import { getResourceClassify } from '../actions/resourceRepository'; import '../style.less' const ResourceRepository = (props) => { - const { dispatch, actions, clientHeight } = props; + const { dispatch, actions, clientHeight, resourceClassify } = props; + const ref = useRef(); + useEffect(() => { + dispatch(getResourceClassify()); + }, []) + const treeData = [ { label: (
@@ -185,6 +191,16 @@ const ResourceRepository = (props) => { avatarBg: 'light-blue', } ]; + const renderLabel = (label, data) => (
+ {label.length > 8 ? label.substring(0, 8) + '...' : label} + {true == data.operation ? + + alert("bianji")} /> + alert("sahnchu")} /> + alert("+")} /> + : ''} +
+ ) return ( <> @@ -212,13 +228,14 @@ const ResourceRepository = (props) => { } showClear onChange={v => ref.current.search(v)} placeholder="请输入"> {/* 右侧内容 */} @@ -244,11 +261,12 @@ const ResourceRepository = (props) => { } function mapStateToProps(state) { - const { auth, global } = state; + const { auth, global, resourceClassify } = state; return { user: auth.user, actions: global.actions, clientHeight: global.clientHeight, + resourceClassify: resourceClassify.data || [] }; } diff --git a/web/client/src/utils/webapi.js b/web/client/src/utils/webapi.js index 0c29fa0..39dfb81 100644 --- a/web/client/src/utils/webapi.js +++ b/web/client/src/utils/webapi.js @@ -37,11 +37,16 @@ export const ApiTable = { editSalesMember: 'sales/member/modify', delSalesMember: 'sales/member/del', addSalesMemberBulk: 'add/sales/members/bulk', - + //部门培训记录 getDepartmentTrainRecord: 'department/train/record/list', importDepartmentTrainRecord: 'department/train/record/bulk', modifyDepartmentTrainRecord: 'department/train/record/modify', + //-培训资料库 + getResourceClassify: 'train/trainFiles/resourceRepository/classify', + postResourceClassify: 'train/trainFiles/resourceRepository/classify', + putResourceClassify: 'train/trainFiles/resourceRepository/classify/{id}', + delResourceClassify: 'train/trainFiles/resourceRepository/classify/{id}', }; export const RouteTable = { apiRoot: "/api/root",