明树Git Lab

Commit f05c3f87 authored by zfp1's avatar zfp1

update

parent a3623380
Pipeline #104409 passed with stage
in 3 seconds
const { buildTree, disTree } = require("../utils"); const { buildTree, disTree } = require("../utils");
const errorMessage = require("../utils/errorMessage"); const errorMessage = require("../utils/errorMessage");
const { Op } = require('sequelize'); const { Op } = require('sequelize');
const _ = require('lodash')
/** /**
* 资源库controller * 资源库controller
...@@ -230,6 +230,7 @@ async function listResourceAll(req, res, next) { ...@@ -230,6 +230,7 @@ async function listResourceAll(req, res, next) {
model: DB.ResourcesInfo, model: DB.ResourcesInfo,
as: 'resourcesInfos', as: 'resourcesInfos',
// raw: true, // raw: true,
// order: [['order', 'ASC']],
} }
], ],
} }
...@@ -238,11 +239,11 @@ async function listResourceAll(req, res, next) { ...@@ -238,11 +239,11 @@ async function listResourceAll(req, res, next) {
for (let index = 0; index < datas.length; index++) { for (let index = 0; index < datas.length; index++) {
let element = datas[index]; let element = datas[index];
element = element.toJSON() element = element.toJSON()
console.log(element.resourceInfos, "==") console.log(element.resourcesInfos, "==")
if (element.type == 2) { if (element.type == 2) {
element.resourcesInfos = utils.buildTree2(element.resourcesInfos, 'code', 'parentCode'); element.resourcesInfos = utils.buildTree2(element.resourcesInfos, 'code', 'parentCode');
} }
obj[element.key] = element.resourcesInfos || []; obj[element.key] = _.orderBy(element.resourcesInfos || [], 'order', 'asc');
} }
return res.sendData(obj) return res.sendData(obj)
} catch (error) { } catch (error) {
......
...@@ -45,7 +45,7 @@ const Project = sequelize.define('Project', { ...@@ -45,7 +45,7 @@ const Project = sequelize.define('Project', {
sfzjc: { type: DataTypes.INTEGER, allowNull: true, comment: "是否再决策", zjType: 'danxuan', zjKey: 'sf', _mark: "lixiang" }, // 1是 2 否 sfzjc: { type: DataTypes.INTEGER, allowNull: true, comment: "是否再决策", zjType: 'danxuan', zjKey: 'sf', _mark: "lixiang" }, // 1是 2 否
projectForeignName: { type: DataTypes.STRING, allowNull: true, comment: "项目外文名称", _mark: "lixiang" }, projectForeignName: { type: DataTypes.STRING, allowNull: true, comment: "项目外文名称", _mark: "lixiang" },
sfnjlhtxm: { type: DataTypes.INTEGER, allowNull: true, comment: "是否能建联合体项目", zjType: 'danxuan', zjKey: 'sf', _mark: "lixiang" }, // 1是 2 否 sfnjlhtxm: { type: DataTypes.INTEGER, allowNull: true, comment: "是否能建联合体项目", zjType: 'danxuan', zjKey: 'sf', _mark: "lixiang" }, // 1是 2 否
tzzt: { type: DataTypes.INTEGER, allowNull: true, comment: "投资主体", zjType: 'danxuan', _mark: "lixiang" }, tzzt: { type: DataTypes.STRING, allowNull: true, comment: "投资主体", zjType: 'danxuan', _mark: "lixiang" },
zyfzy: { type: DataTypes.INTEGER, allowNull: true, comment: "主业/非主业", zjType: 'danxuan', _mark: "lixiang" }, zyfzy: { type: DataTypes.INTEGER, allowNull: true, comment: "主业/非主业", zjType: 'danxuan', _mark: "lixiang" },
zsqy: { type: DataTypes.INTEGER, allowNull: true, comment: "直属企业", zjType: 'danxuan', _mark: "lixiang" }, zsqy: { type: DataTypes.INTEGER, allowNull: true, comment: "直属企业", zjType: 'danxuan', _mark: "lixiang" },
sfnjzdhzytz: { type: DataTypes.INTEGER, allowNull: true, comment: "是否能建重大或重要投资", zjType: 'danxuan', zjKey: 'sf', _mark: "lixiang" }, sfnjzdhzytz: { type: DataTypes.INTEGER, allowNull: true, comment: "是否能建重大或重要投资", zjType: 'danxuan', zjKey: 'sf', _mark: "lixiang" },
...@@ -132,7 +132,7 @@ const Project = sequelize.define('Project', { ...@@ -132,7 +132,7 @@ const Project = sequelize.define('Project', {
sbdwqygg: { type: DataTypes.INTEGER, allowNull: true, comment: "申报单位企业规格", _mark: 'juece', zjType: 'danxuan' }, sbdwqygg: { type: DataTypes.INTEGER, allowNull: true, comment: "申报单位企业规格", _mark: 'juece', zjType: 'danxuan' },
xmztz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "项目总投资", _mark: 'juece' }, xmztz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "项目总投资", _mark: 'juece' },
// zsqy: { type: DataTypes.STRING, allowNull: true, comment: "直属企业", }, // zsqy: { type: DataTypes.STRING, allowNull: true, comment: "直属企业", },
glzt: { type: DataTypes.INTEGER, allowNull: true, comment: "管理主体", _mark: 'juece', zjType: 'danxuan' }, glzt: { type: DataTypes.STRING, allowNull: true, comment: "管理主体", _mark: 'juece', zjType: 'danxuan' },
// xmqy: { type: DataTypes.STRING, allowNull: true, comment: "项目区域", zjType: 'danxuan' }, // xmqy: { type: DataTypes.STRING, allowNull: true, comment: "项目区域", zjType: 'danxuan' },
// jnw: { type: DataTypes.STRING, allowNull: true, comment: "境内/外", zjType: 'danxuan' }, // jnw: { type: DataTypes.STRING, allowNull: true, comment: "境内/外", zjType: 'danxuan' },
// sjnzjjw: { type: DataTypes.STRING, allowNull: true, comment: "省(境内)/洲际(境外)", zjType: 'danxuan' }, // sjnzjjw: { type: DataTypes.STRING, allowNull: true, comment: "省(境内)/洲际(境外)", zjType: 'danxuan' },
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"production": "cross-env NODE_ENV=production node server.js", "production": "cross-env NODE_ENV=production nodemon server.js",
"dev": "cross-env NODE_ENV=dev nodemon server.js", "dev": "cross-env NODE_ENV=dev nodemon server.js",
"local": "cross-env NODE_ENV=local nodemon server.js", "local": "cross-env NODE_ENV=local nodemon server.js",
"lint": "eslint .", "lint": "eslint .",
......
...@@ -142,13 +142,13 @@ function buildTree2(nodes, keyid = 'id', keyParentId = 'parentId') { ...@@ -142,13 +142,13 @@ function buildTree2(nodes, keyid = 'id', keyParentId = 'parentId') {
if (nodeMap.has(parentId)) { if (nodeMap.has(parentId)) {
// 将当前节点添加到父节点的children数组中 // 将当前节点添加到父节点的children数组中
nodeMap.get(parentId).children.push(nodeMap.get(String(node[keyid]))); nodeMap.get(parentId).children.push(nodeMap.get(String(node[keyid])));
nodeMap.get(parentId).children = _.orderBy(nodeMap.get(parentId).children, 'order') nodeMap.get(parentId).children = _.orderBy(nodeMap.get(parentId).children, ['order', 'code'])
} }
} }
}); });
// 从映射中提取顶级节点(parentId为null) // 从映射中提取顶级节点(parentId为null)
return _.orderBy(Array.from(nodeMap.values()).filter(node => node[keyParentId] == null), 'order'); return _.orderBy(Array.from(nodeMap.values()).filter(node => node[keyParentId] == null), ['order', 'code']);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment