明树Git Lab

Commit 74edf28a authored by zfp1's avatar zfp1

update

parent 1a47eb90
Pipeline #104419 passed with stage
in 3 seconds
......@@ -895,7 +895,7 @@ async function listProject(req, res, next) {
console.log(search)
search.raw = true
let ret = await DB.Project.findAndCountAll(search);
// ret = await projectModule.handleProjectData(ret, search.attributes);
ret = await projectModule.handleProjectData(ret, search.attributes);
return res.sendData(ret);
} catch (error) {
next(error);
......
......@@ -13,7 +13,7 @@ const moment = require('moment');
async function handleProjectData(ret, queryAttrs) {
let rawAttributes = _.cloneDeep(DB.Project.rawAttributes);
// console.log(ret, "====")
// console.log(rawAttributes, "====")
// let queryRawAtr = [], resourceKeys = [];
// for (let index = 0; index < queryAttrs.length; index++) {
// const element = queryAttrs[index];
......@@ -34,26 +34,32 @@ async function handleProjectData(ret, queryAttrs) {
const element = ret.rows[index];
// console.log(element);
for (const key in element) {
console.log(key)
if (!_.isEmpty(element[key]) && rawAttributes[key].zjType) {
if (rawAttributes[element].zjType == "danxuan") {
console.log(rawAttributes[key].zjType, element[key],"=======", !_.isNumber(element[key]))
if ((_.isNumber(element[key])) && rawAttributes[key].zjType) {
if (rawAttributes[key].zjType == "danxuan") {
console.log(rawAttributes[key].zjType, element[key],"===111====")
resouInfoIds.push(element[key]);
} else if (rawAttributes[element].zjType == "duoxuan") {
}
else if ((!_.isEmpty(element[key])) && rawAttributes[element].zjType == "duoxuan") {
resouInfoIds = resouInfoIds.concat(element[key])
}
}
}
}
console.log(resouInfoIds, ",,,,,")
let resMap = await getResourceInfoByIds(resouInfoIds);
console.log(resMap)
for (let index = 0; index < ret.rows.length; index++) {
const element = ret.rows[index];
// console.log(element);
for (const key in element) {
if (!_.isEmpty(element[key]) && rawAttributes[element].zjType) {
if (rawAttributes[element].zjType == "danxuan") {
element[key] = resMap[element[key]];
} else if (rawAttributes[element].zjType == "duoxuan") {
console.log(element, element[key], rawAttributes[key].zjType);
if (_.isNumber(element[key]) && rawAttributes[key].zjType) {
if (rawAttributes[key].zjType == "danxuan") {
console.log(resMap[String(element[key])], String(element[key]), "=========================")
element[key] = resMap[String(element[key])];
} else if (rawAttributes[key].zjType == "duoxuan") {
if(_.isArray(element[key]) && element[key].length > 0) {
element[key].map(o => {return resMap[o]});
element[key] = element[key].join(',')
......@@ -72,14 +78,14 @@ async function handleProjectData(ret, queryAttrs) {
async function getResourceInfoByIds(resouInfoIds) {
let ris = await DB.ResourcesInfo.findAll({
where: {id: {[Op.in]: resouInfoIds}},
raw: true,
// raw: true,
});
let risMap = {};
for (let index = 0; index < ris.length; index++) {
const element = ris[index];
risMap[element.id] = element.value;
risMap[String(element.id)] = element.value;
}
console.log(risMap)
return risMap;
}
......
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