|
|
@ -6,22 +6,42 @@ var path = require('path'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.post('/add', function (req, res) { |
|
|
|
router.post('/add', function (req, res) { |
|
|
|
|
|
|
|
let flag = false; |
|
|
|
|
|
|
|
let emptyFieldsArray =[] |
|
|
|
const userInfo = { |
|
|
|
const userInfo = { |
|
|
|
firstName: req.body.firstName, |
|
|
|
firstName: req.body.firstName.trim(), |
|
|
|
lastName: req.body.lastName, |
|
|
|
lastName: req.body.lastName.trim(), |
|
|
|
fatherName: req.body.fatherName, |
|
|
|
fatherName: req.body.fatherName.trim(), |
|
|
|
codeMelli: req.body.codeMelli, |
|
|
|
codeMelli: req.body.codeMelli.trim(), |
|
|
|
workUnit: req.body.workUnit, |
|
|
|
workUnit: req.body.workUnit.trim(), |
|
|
|
workUnitCode: req.body.workUnitCode, |
|
|
|
workUnitCode: req.body.workUnitCode.trim(), |
|
|
|
address: req.body.address, |
|
|
|
address: req.body.address.trim(), |
|
|
|
obligationNumber: req.body.obligationNumber, |
|
|
|
obligationNumber: req.body.obligationNumber.trim(), |
|
|
|
obligationDate: req.body.obligationDate, |
|
|
|
obligationDate: req.body.obligationDate.trim(), |
|
|
|
requestNumber: req.body.requestNumber, |
|
|
|
requestNumber: req.body.requestNumber.trim(), |
|
|
|
requestDate: req.body.requestDate, |
|
|
|
requestDate: req.body.requestDate.trim(), |
|
|
|
writtenOrderNumber: req.body.writtenOrderNumber, |
|
|
|
writtenOrderNumber: req.body.writtenOrderNumber.trim(), |
|
|
|
writtenOrderDate: req.body.writtenOrderDate, |
|
|
|
writtenOrderDate: req.body.writtenOrderDate.trim(), |
|
|
|
deadline: req.body.deadline |
|
|
|
deadline: req.body.deadline.trim(), |
|
|
|
|
|
|
|
deadlineUnit: req.body.deadlineUnit.trim(), |
|
|
|
|
|
|
|
healthCenter: req.body.healthCenter.trim(), |
|
|
|
|
|
|
|
healthCenterCity: req.body.healthCenterCity.trim() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (const key in userInfo) { |
|
|
|
|
|
|
|
if (!userInfo[key] || !userInfo[key].trim()) { |
|
|
|
|
|
|
|
emptyFieldsArray.push(key) |
|
|
|
|
|
|
|
flag = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(flag){ |
|
|
|
|
|
|
|
res.status(406).send({ |
|
|
|
|
|
|
|
success: false, |
|
|
|
|
|
|
|
emptyFields : emptyFieldsArray, |
|
|
|
|
|
|
|
error: `پر کردن همه فیلدها الزامی است` |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}else { |
|
|
|
userServeice.addUser(userInfo) |
|
|
|
userServeice.addUser(userInfo) |
|
|
|
.then((result) => { |
|
|
|
.then((result) => { |
|
|
|
res.status(200).send({ |
|
|
|
res.status(200).send({ |
|
|
@ -46,6 +66,8 @@ router.post('/add', function (req, res) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
router.post('/complete/form', function (req, res) { |
|
|
|
router.post('/complete/form', function (req, res) { |
|
|
@ -57,6 +79,7 @@ router.post('/complete/form', function (req, res) { |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
.catch(err => { |
|
|
|
|
|
|
|
console.log(err); |
|
|
|
if (err.eText) { |
|
|
|
if (err.eText) { |
|
|
|
if (typeof err.eText !== 'string') { |
|
|
|
if (typeof err.eText !== 'string') { |
|
|
|
err.eText = err.eText.toString() |
|
|
|
err.eText = err.eText.toString() |
|
|
|