328 lines
8.5 KiB
JavaScript
328 lines
8.5 KiB
JavaScript
const { sequelize,Workingnotes} = require('../models')
|
|
const { logMsg } = require('../services/logger.js');
|
|
|
|
exports.createNotes = async (req, res) =>
|
|
{
|
|
try
|
|
{
|
|
|
|
|
|
for (const value of req.body.notes)
|
|
{
|
|
notes = JSON.stringify(value);
|
|
data = {
|
|
losid: req.body.losid,
|
|
module_name: req.body.module_name,
|
|
entity_reference: req.body.entity_reference,
|
|
notes: notes,
|
|
sheet_no : value.name,
|
|
user_id: req.body.user_id,
|
|
createdby: req.body.createdby
|
|
};
|
|
// insert working notes data
|
|
await Workingnotes.create(data)
|
|
.then(data=>{ logMsg.info("Notes insert Success");})
|
|
.catch(err=>{ logMsg.info("Notes insert Failed");});
|
|
}
|
|
|
|
|
|
res.send({'status':200 , message:"Success." ,'data': "no data"});
|
|
|
|
} catch(err) {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
|
}); } //end of try catch
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.updateNotes = async (req, res) =>
|
|
{
|
|
try
|
|
{
|
|
|
|
|
|
for (const value of req.body.notes)
|
|
{
|
|
notesData = await Workingnotes.findOne({where :{losid : req.body.losid , module_name : req.body.module_name, sheet_no : value.name , is_active:1}});
|
|
id = notesData.dataValues.id;
|
|
notes = JSON.stringify(value);
|
|
|
|
// update working notes data
|
|
await Workingnotes.update({notes: notes , updatedby: req.body.updatedby} , { where: { id: id } })
|
|
.then(data=>{ logMsg.info("Notes update Success");})
|
|
.catch(err=>{ logMsg.info("Notes update Failed");});
|
|
|
|
}
|
|
|
|
|
|
res.send({'status':200 , message:"Success." ,'data': "no data"});
|
|
|
|
} catch(err) {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
|
}); } //end of try catch
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.notesList = async (req, res) =>
|
|
{
|
|
try
|
|
{
|
|
|
|
|
|
if(req.query.entity_reference == undefined)
|
|
{
|
|
notesData = await Workingnotes.findAll({where :{losid : req.query.losid , module_name : req.query.module_name , is_active:1}});
|
|
console.log(JSON.parse(notesData[2].notes))
|
|
res.send({'status':200 , message:"Success." ,'data': notesData});
|
|
}else{
|
|
notesData = await Workingnotes.findAll({where :{losid : req.query.losid , module_name : req.query.module_name , entity_reference : req.query.entity_reference, is_active:1}});
|
|
res.send({'status':200 , message:"Success." ,'data': notesData});
|
|
}
|
|
|
|
|
|
} catch(err) {
|
|
res.status(500).send({'status':404,
|
|
message: err.message || "Some error occurred while inserting statements." ,'data': "No data"
|
|
}); } //end of try catch
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const myData = [ {
|
|
"name": "sheet1",
|
|
"freeze": "A1",
|
|
"styles": [
|
|
{
|
|
"font": {
|
|
"italic": true
|
|
}
|
|
},
|
|
{
|
|
"color": "#f7ccac"
|
|
},
|
|
{
|
|
"color": "#f7ccac",
|
|
"bgcolor": "#93d051"
|
|
},
|
|
{
|
|
"color": "#7030a0",
|
|
"bgcolor": "#93d051"
|
|
}
|
|
],
|
|
"merges": [],
|
|
"rows": {
|
|
"0": {
|
|
"cells": {
|
|
"0": {
|
|
"text": "ddsd"
|
|
},
|
|
"1": {
|
|
"text": "fdfdf",
|
|
"style": 0
|
|
},
|
|
"2": {
|
|
"text": "ddd"
|
|
}
|
|
}
|
|
},
|
|
"1": {
|
|
"cells": {
|
|
"6": {
|
|
"text": "dfdfd"
|
|
}
|
|
}
|
|
},
|
|
"2": {
|
|
"cells": {
|
|
"4": {
|
|
"text": "dfdf"
|
|
}
|
|
}
|
|
},
|
|
"4": {
|
|
"cells": {
|
|
"6": {
|
|
"text": "dfd"
|
|
}
|
|
}
|
|
},
|
|
"5": {
|
|
"cells": {
|
|
"3": {
|
|
"text": "dfddf"
|
|
},
|
|
"5": {
|
|
"text": "df"
|
|
}
|
|
}
|
|
},
|
|
"6": {
|
|
"cells": {
|
|
"8": {
|
|
"text": "dfdf"
|
|
}
|
|
}
|
|
},
|
|
"9": {
|
|
"cells": {
|
|
"2": {
|
|
"text": "dfdf"
|
|
},
|
|
"6": {
|
|
"text": "dfdf",
|
|
"style": 3
|
|
}
|
|
}
|
|
},
|
|
"10": {
|
|
"cells": {
|
|
"4": {
|
|
"text": "ddsd"
|
|
}
|
|
}
|
|
},
|
|
"11": {
|
|
"cells": {
|
|
"3": {
|
|
"text": "fff"
|
|
}
|
|
}
|
|
},
|
|
"12": {
|
|
"cells": {
|
|
"1": {
|
|
"text": "dfdf"
|
|
}
|
|
}
|
|
},
|
|
"len": 100
|
|
},
|
|
"cols": {
|
|
"len": 26
|
|
},
|
|
"validations": [],
|
|
"autofilter": {}
|
|
},{
|
|
"name": "sheet2",
|
|
"freeze": "A1",
|
|
"styles": [
|
|
{
|
|
"font": {
|
|
"italic": true
|
|
}
|
|
},
|
|
{
|
|
"color": "#f7ccac"
|
|
},
|
|
{
|
|
"color": "#f7ccac",
|
|
"bgcolor": "#93d051"
|
|
},
|
|
{
|
|
"color": "#7030a0",
|
|
"bgcolor": "#93d051"
|
|
}
|
|
],
|
|
"merges": [],
|
|
"rows": {
|
|
"0": {
|
|
"cells": {
|
|
"0": {
|
|
"text": "123"
|
|
},
|
|
"1": {
|
|
"text": "123",
|
|
"style": 0
|
|
},
|
|
"2": {
|
|
"text": "123"
|
|
}
|
|
}
|
|
},
|
|
"1": {
|
|
"cells": {
|
|
"6": {
|
|
"text": "dfdfd"
|
|
}
|
|
}
|
|
},
|
|
"2": {
|
|
"cells": {
|
|
"4": {
|
|
"text": "dfdf"
|
|
}
|
|
}
|
|
},
|
|
"4": {
|
|
"cells": {
|
|
"6": {
|
|
"text": "dfd"
|
|
}
|
|
}
|
|
},
|
|
"5": {
|
|
"cells": {
|
|
"3": {
|
|
"text": "dfddf"
|
|
},
|
|
"5": {
|
|
"text": "df"
|
|
}
|
|
}
|
|
},
|
|
"6": {
|
|
"cells": {
|
|
"8": {
|
|
"text": "dfdf"
|
|
}
|
|
}
|
|
},
|
|
"9": {
|
|
"cells": {
|
|
"2": {
|
|
"text": "dfdf"
|
|
},
|
|
"6": {
|
|
"text": "dfdf",
|
|
"style": 3
|
|
}
|
|
}
|
|
},
|
|
"10": {
|
|
"cells": {
|
|
"4": {
|
|
"text": "ddsd"
|
|
}
|
|
}
|
|
},
|
|
"11": {
|
|
"cells": {
|
|
"3": {
|
|
"text": "fff"
|
|
}
|
|
}
|
|
},
|
|
"12": {
|
|
"cells": {
|
|
"1": {
|
|
"text": "dfdf"
|
|
}
|
|
}
|
|
},
|
|
"len": 100
|
|
},
|
|
"cols": {
|
|
"len": 26
|
|
},
|
|
"validations": [],
|
|
"autofilter": {}
|
|
}
|
|
] |