diff --git a/components/admin/TheSidebar.vue b/components/admin/TheSidebar.vue index 61bc26f..dc1f107 100644 --- a/components/admin/TheSidebar.vue +++ b/components/admin/TheSidebar.vue @@ -76,7 +76,7 @@ @@ -89,9 +89,6 @@ font-icon="fas fa-folder" @update:show="val => setDropdownState('adminS_CustomerM_Dropdown', val)" > - - - @@ -321,7 +318,7 @@ v-if="hasPermission('gps')" :show="getDropdownState('adminS_GpsM_Dropdown')" name="مدیریت پنل جی پی اس" - :font-icon="getDropdownState('adminS_GpsM_Dropdown') ? `fas fa-folder-open`:`fas fa-folder` " + :font-icon="getDropdownState('adminS_GpsM_Dropdown') ? `fas fa-folder-open` : `fas fa-folder`" @update:show="val => setDropdownState('adminS_GpsM_Dropdown', val)" > - - diff --git a/server/controllers/serialsExelController.js b/server/controllers/serialsExelController.js index 286224b..5b4741e 100644 --- a/server/controllers/serialsExelController.js +++ b/server/controllers/serialsExelController.js @@ -25,11 +25,12 @@ module.exports.addExel = [ checkValidations(validationResult), async (req, res) => { if (!req.files?.file) return res.status(422).json({ validation: { file: { msg: 'فایل را اضافه کنید' } } }) - if (!req.files?.file.name.split('.').some(item => ['xlsx', 'xltx', 'xlsm', 'xlsb'].includes(item))) return res.status(422).json({ validation: { file: { msg: 'فرمت فایل درست نمیباشد' } } }) + if (!req.files?.file.name.split('.').some(item => ['xlsx', 'xltx', 'xlsm', 'xlsb'].includes(item))) + return res.status(422).json({ validation: { file: { msg: 'فرمت فایل درست نمیباشد' } } }) const file = req.files.file const { type, g } = req.body try { - const exelFile = await readXlsxFile(Buffer.from(file.data)); + const exelFile = await readXlsxFile(Buffer.from(file.data)) const data = await creator(exelFile, type, g, file.name) const path = (type === 'guaranteeSerial' ? guaranteeSerialsPath : productSerialsPath) + `/${g}` @@ -42,8 +43,6 @@ module.exports.addExel = [ // res.status(201).json({ msg: _sr.fa.response.success_save, data }) res.status(201).json(data) - - } catch (err) { return res500(res, err) } @@ -72,7 +71,6 @@ module.exports.getAllExels = [ } ] - module.exports.removeExel = [ async (req, res) => { const type = req.query?.type @@ -82,7 +80,7 @@ module.exports.removeExel = [ const validValues = ['guaranteeSerial', 'orginality'] if (!validValues.includes(type)) return res500(res, 'choose type') const path = (type === 'guaranteeSerial' ? guaranteeSerialsPath : productSerialsPath) + `/${g}` - await Serial.deleteMany({ fileName: req.params.name }) + await Serial.deleteMany({ fileName: req.params.name }) fs.unlink(`${path}/${req.params.name}`, err => { if (err) return res404(res, _faSr.not_found.item_id) @@ -110,18 +108,19 @@ module.exports.checkSerial = [ try { const { serial, type, g } = req.body const code = serial.toString().trim().toLowerCase() + console.log(code) const serialStatus = await Serial.findOne({ code, type, kind: g }) + console.log(serialStatus) if (!serialStatus) { res404(res, 'این کد در سامانه وجود ندارد') } else { res.status(200).json({ message: serialStatus.message }) } - } catch (e) { console.log(e) return res500(res, e) @@ -135,9 +134,9 @@ const creator = (exel, type, g, name) => { for (const row of exel) { // eslint-disable-next-line no-constant-condition const code = row[1].toString().trim().toLowerCase() - const serial = await Serial.findOne({ code }) + const serial = await Serial.findOne({ code, type, kind: g }) if (serial) { - console.info("Repeated serial ", row[1]) + console.info('Repeated serial => ', row[1]) serial.model = row[0] serial.message = row[2] @@ -146,24 +145,22 @@ const creator = (exel, type, g, name) => { serial.fileName = name serial.save() } else { - await Serial.create( - { - code, - model: row[0], - message: row[2], - type, - fileName: name, - kind: g - } - ) + console.log('inserting new =>', row[1]) + await Serial.create({ + code, + model: row[0], + message: row[2], + type, + fileName: name, + kind: g + }) } - } - resolve("end") + resolve('end') } catch (error) { - console.log(error); + console.log(error) reject(error.message) } }) -} \ No newline at end of file +} diff --git a/server/controllers/transactionController.js b/server/controllers/transactionController.js index a496d12..bce5398 100644 --- a/server/controllers/transactionController.js +++ b/server/controllers/transactionController.js @@ -73,7 +73,7 @@ module.exports.add_transaction = [ ] return msgArray.join(' ') } - + // TODO: here arpa service if (agent === 'main') { const ArpaResponse = await saveTransactionToArpa(data, items, db_name) await TransactionDraft.findByIdAndRemove(draftId) @@ -107,7 +107,7 @@ module.exports.add_transaction = [ }) } } catch (e) { - console.log('there is an error in (Post Transaction to Arpa)', e, data) + console.log('there is an error in (Post Transaction to Arpa)', e, data) return res500(res, e) } } @@ -140,7 +140,7 @@ module.exports.get_all_transactions_for_agent = [ async (req, res) => { try { const { agent_id } = req - const transactions = await Transaction.find({ agent_id }).sort({created_at:-1}) + const transactions = await Transaction.find({ agent_id }).sort({ created_at: -1 }) return res.json(transactions) } catch (e) { return res500(res, e) @@ -291,7 +291,8 @@ module.exports.change_transaction_status_by_agent = [ module.exports.get_all_agents_inbox_for_admin = [ async (req, res) => { try { - const transactions = await Transaction.find().sort({created_at:-1}) + const transactions = await Transaction.find() + .sort({ created_at: -1 }) .populate('agent_id', 'agent_code full_name') .populate('user_id', 'province_id province_name city_id city_name') return res.json(transactions) diff --git a/static/uploads/serials/1/code-guaranty-dahua-512gb.xlsx b/static/uploads/serials/1/code-guaranty-dahua-512gb.xlsx new file mode 100644 index 0000000..448ed8f Binary files /dev/null and b/static/uploads/serials/1/code-guaranty-dahua-512gb.xlsx differ diff --git a/static/uploads/serials_products/1/esalat-dahua-512G.xlsx b/static/uploads/serials_products/1/esalat-dahua-512G.xlsx new file mode 100644 index 0000000..cb32c9e Binary files /dev/null and b/static/uploads/serials_products/1/esalat-dahua-512G.xlsx differ