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: (