Refactor
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
dee7e844ad
commit
f17e9058b3
|
@ -93,10 +93,11 @@ class Component {
|
|||
|
||||
const component = this.build();
|
||||
const i18n = new VueI18n(config.i18n);
|
||||
const props = {tplPath: this.path, ...this.args};
|
||||
this._component = new Vue({
|
||||
i18n: i18n,
|
||||
render: h => h(component, {
|
||||
props: this.args
|
||||
props: props
|
||||
})
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const mysql = require('mysql2/promise');
|
||||
const config = require('./config.js');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
init() {
|
||||
|
@ -34,9 +33,8 @@ module.exports = {
|
|||
*
|
||||
* @return {Object} - Result promise
|
||||
*/
|
||||
rawSqlFromDef(queryName, params, dirname = '.') {
|
||||
const sqlPath = path.join(dirname, 'sql', `${queryName}.sql`);
|
||||
const query = fs.readFileSync(sqlPath, 'utf8');
|
||||
rawSqlFromDef(queryName, params) {
|
||||
const query = fs.readFileSync(`${queryName}.sql`, 'utf8');
|
||||
|
||||
return this.rawSql(query, params);
|
||||
},
|
||||
|
@ -90,29 +88,5 @@ module.exports = {
|
|||
return this.findOneFromDef(queryName, params, dirname).then(row => {
|
||||
return Object.values(row)[0];
|
||||
});
|
||||
},
|
||||
|
||||
getCaller() {
|
||||
let originalFunc = Error.prepareStackTrace;
|
||||
let callerfile;
|
||||
try {
|
||||
const err = new Error();
|
||||
|
||||
Error.prepareStackTrace = function(err, stack) {
|
||||
return stack;
|
||||
};
|
||||
|
||||
const currentfile = err.stack.shift().getFileName();
|
||||
|
||||
while (err.stack.length) {
|
||||
callerfile = err.stack.shift().getFileName();
|
||||
|
||||
if (currentfile !== callerfile) break;
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
Error.prepareStackTrace = originalFunc;
|
||||
|
||||
return path.dirname(callerfile);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
const Vue = require('vue');
|
||||
const path = require('path');
|
||||
const db = require('../database');
|
||||
|
||||
const dbHelper = {
|
||||
methods: {
|
||||
/**
|
||||
* Makes a query from a raw sql
|
||||
* @param {String} query - The raw SQL query
|
||||
* @param {Object} params - Parameterized values
|
||||
*
|
||||
* @return {Object} - Result promise
|
||||
*/
|
||||
rawSql: db.rawSql,
|
||||
|
||||
/**
|
||||
* Makes a query from a SQL file
|
||||
* @param {String} queryName - The SQL file name
|
||||
* @param {Object} params - Parameterized values
|
||||
*
|
||||
* @return {Object} - Result promise
|
||||
*/
|
||||
rawSqlFromDef(queryName, params) {
|
||||
const absolutePath = path.join(__dirname, '../', this.tplPath, 'sql', queryName);
|
||||
return db.rawSqlFromDef(absolutePath, params);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the first row from a given raw sql
|
||||
* @param {String} query - The raw SQL query
|
||||
* @param {Object} params - Parameterized values
|
||||
*
|
||||
* @return {Object} - Result promise
|
||||
*/
|
||||
findOne: db.findOne,
|
||||
|
||||
/**
|
||||
* Returns the first row from a given SQL file
|
||||
* @param {String} queryName - The SQL file name
|
||||
* @param {Object} params - Parameterized values
|
||||
*
|
||||
* @return {Object} - Result promise
|
||||
*/
|
||||
findOneFromDef(queryName, params) {
|
||||
return this.rawSqlFromDef(queryName, params)
|
||||
.then(([row]) => row);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the first property from a given raw sql
|
||||
* @param {String} query - The raw SQL query
|
||||
* @param {Object} params - Parameterized values
|
||||
*
|
||||
* @return {Object} - Result promise
|
||||
*/
|
||||
findValue: db.findValue,
|
||||
|
||||
/**
|
||||
* Returns the first property from a given SQL file
|
||||
* @param {String} queryName - The SQL file name
|
||||
* @param {Object} params - Parameterized values
|
||||
*
|
||||
* @return {Object} - Result promise
|
||||
*/
|
||||
findValueFromDef(queryName, params) {
|
||||
return this.findOneFromDef(queryName, params).then(row => {
|
||||
return Object.values(row)[0];
|
||||
});
|
||||
}
|
||||
},
|
||||
props: ['tplPath']
|
||||
};
|
||||
|
||||
Vue.mixin(dbHelper);
|
|
@ -2,3 +2,4 @@
|
|||
require('./image-src');
|
||||
require('./user-locale');
|
||||
require('./prop-validator');
|
||||
require('./db-helper');
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const emailHeader = new Component('email-header');
|
||||
const emailFooter = new Component('email-footer');
|
||||
|
||||
|
@ -10,7 +9,7 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchClient(clientId) {
|
||||
return db.findOneFromDef('client', [clientId], __dirname);
|
||||
return this.findOneFromDef('client', [clientId]);
|
||||
},
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const emailHeader = new Component('email-header');
|
||||
const emailFooter = new Component('email-footer');
|
||||
const attachment = new Component('attachment');
|
||||
|
@ -18,7 +17,7 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchDebtor(clientId, companyId) {
|
||||
return db.findOneFromDef('client', [clientId, companyId], __dirname);
|
||||
return this.findOneFromDef('client', [clientId, companyId]);
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -18,7 +18,7 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchDebtor(clientId, companyId) {
|
||||
return db.findOneFromDef('client', [clientId, companyId], __dirname);
|
||||
return this.findOneFromDef('client', [clientId, companyId]);
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const emailHeader = new Component('email-header');
|
||||
const emailFooter = new Component('email-footer');
|
||||
|
||||
|
@ -18,7 +17,7 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchPayMethod(clientId) {
|
||||
return db.findOneFromDef('payMethod', {clientId: clientId}, __dirname);
|
||||
return this.findOneFromDef('payMethod', {clientId: clientId});
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const emailHeader = new Component('email-header');
|
||||
const emailFooter = new Component('email-footer');
|
||||
const attachment = new Component('attachment');
|
||||
|
@ -15,7 +14,7 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchClient(clientId) {
|
||||
return db.findOneFromDef('client', [clientId], __dirname);
|
||||
return this.findOneFromDef('client', [clientId]);
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const reportHeader = new Component('report-header');
|
||||
const reportFooter = new Component('report-footer');
|
||||
|
||||
|
@ -14,10 +13,10 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchClient(clientId) {
|
||||
return db.findOneFromDef('client', [clientId], __dirname);
|
||||
return this.findOneFromDef('client', [clientId]);
|
||||
},
|
||||
fetchSales(clientId, from, to) {
|
||||
return db.rawSqlFromDef('sales', [clientId, from, to], __dirname);
|
||||
return this.rawSqlFromDef('sales', [clientId, from, to]);
|
||||
},
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const reportHeader = new Component('report-header');
|
||||
const reportFooter = new Component('report-footer');
|
||||
|
||||
|
@ -21,10 +20,10 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchClient(claimId) {
|
||||
return db.findOneFromDef('client', [claimId], __dirname);
|
||||
return this.findOneFromDef('client', [claimId]);
|
||||
},
|
||||
fetchSales(claimId) {
|
||||
return db.rawSqlFromDef('sales', [claimId], __dirname);
|
||||
return this.rawSqlFromDef('sales', [claimId]);
|
||||
},
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const config = require(`${appPath}/core/config`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const Component = require(`${appPath}/core/component`);
|
||||
const reportHeader = new Component('report-header');
|
||||
const reportFooter = new Component('report-footer');
|
||||
|
@ -42,28 +41,28 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchClient(ticketId) {
|
||||
return db.findOneFromDef('getClient', [ticketId], __dirname);
|
||||
return this.findOneFromDef('client', [ticketId]);
|
||||
},
|
||||
fetchTicket(ticketId) {
|
||||
return db.findOneFromDef('getTicket', [ticketId], __dirname);
|
||||
return this.findOneFromDef('ticket', [ticketId]);
|
||||
},
|
||||
fetchAddress(ticketId) {
|
||||
return db.findOneFromDef(`getAddress`, [ticketId], __dirname);
|
||||
return this.findOneFromDef(`address`, [ticketId]);
|
||||
},
|
||||
fetchSignature(ticketId) {
|
||||
return db.findOneFromDef('getSignature', [ticketId], __dirname);
|
||||
return this.findOneFromDef('signature', [ticketId]);
|
||||
},
|
||||
fetchTaxes(ticketId) {
|
||||
return db.findOneFromDef(`getTaxes`, [ticketId], __dirname);
|
||||
return this.findOneFromDef(`taxes`, [ticketId]);
|
||||
},
|
||||
fetchSales(ticketId) {
|
||||
return db.rawSqlFromDef('getSales', [ticketId], __dirname);
|
||||
return this.rawSqlFromDef('sales', [ticketId]);
|
||||
},
|
||||
fetchPackagings(ticketId) {
|
||||
return db.rawSqlFromDef('getPackagings', [ticketId], __dirname);
|
||||
return this.rawSqlFromDef('packagings', [ticketId]);
|
||||
},
|
||||
fetchServices(ticketId) {
|
||||
return db.rawSqlFromDef('getServices', [ticketId], __dirname);
|
||||
return this.rawSqlFromDef('services', [ticketId]);
|
||||
},
|
||||
|
||||
getSubTotal() {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const reportHeader = new Component('report-header');
|
||||
const reportFooter = new Component('report-footer');
|
||||
|
||||
|
@ -28,10 +27,10 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchRoutes(routesId) {
|
||||
return db.rawSqlFromDef('routes', {routesId}, __dirname);
|
||||
return this.rawSqlFromDef('routes', {routesId});
|
||||
},
|
||||
fetchTickets(routesId) {
|
||||
return db.rawSqlFromDef('tickets', {routesId}, __dirname);
|
||||
return this.rawSqlFromDef('tickets', {routesId});
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const db = require(`${appPath}/core/database`);
|
||||
const Component = require(`${appPath}/core/component`);
|
||||
const reportHeader = new Component('report-header');
|
||||
const reportFooter = new Component('report-footer');
|
||||
|
@ -18,13 +17,13 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchSupplier(entryId) {
|
||||
return db.findOneFromDef('supplier', [entryId], __dirname);
|
||||
return this.findOneFromDef('supplier', [entryId]);
|
||||
},
|
||||
fetchEntry(entryId) {
|
||||
return db.findOneFromDef('entry', [entryId], __dirname);
|
||||
return this.findOneFromDef('entry', [entryId]);
|
||||
},
|
||||
fetchBuys(entryId) {
|
||||
return db.rawSqlFromDef('buys', [entryId], __dirname);
|
||||
return this.rawSqlFromDef('buys', [entryId]);
|
||||
},
|
||||
getTotal() {
|
||||
let total = 0.00;
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const reportHeader = new Component('report-header');
|
||||
const reportFooter = new Component('report-footer');
|
||||
const qrcode = require('qrcode');
|
||||
|
@ -30,10 +29,10 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchItem(id, warehouseId) {
|
||||
return db.findOneFromDef('item', [id, warehouseId], __dirname);
|
||||
return this.findOneFromDef('item', [id, warehouseId]);
|
||||
},
|
||||
fetchItemTags(itemId) {
|
||||
return db.rawSqlFromDef('itemTags', [itemId], __dirname).then(rows => {
|
||||
return this.rawSqlFromDef('itemTags', [itemId]).then(rows => {
|
||||
const tags = {};
|
||||
rows.forEach(row => tags[row.code] = row.value);
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const reportHeader = new Component('report-header');
|
||||
const reportFooter = new Component('report-footer');
|
||||
|
||||
|
@ -24,13 +23,13 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchClient(clientId) {
|
||||
return db.findOneFromDef('client', [clientId], __dirname);
|
||||
return this.findOneFromDef('client', [clientId]);
|
||||
},
|
||||
fetchSales(clientId, companyId) {
|
||||
return db.findOneFromDef('sales', {
|
||||
return this.findOneFromDef('sales', {
|
||||
clientId: clientId,
|
||||
companyId: companyId,
|
||||
}, __dirname);
|
||||
});
|
||||
},
|
||||
getBalance(sale) {
|
||||
if (sale.debtOut)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const reportHeader = new Component('report-header');
|
||||
const reportFooter = new Component('report-footer');
|
||||
|
||||
|
@ -14,10 +13,10 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchClient(receiptId) {
|
||||
return db.findOneFromDef('client', [receiptId], __dirname);
|
||||
return this.findOneFromDef('client', [receiptId]);
|
||||
},
|
||||
fetchReceipt(receiptId) {
|
||||
return db.findOneFromDef('receipt', [receiptId], __dirname);
|
||||
return this.findOneFromDef('receipt', [receiptId]);
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const Component = require(`${appPath}/core/component`);
|
||||
const db = require(`${appPath}/core/database`);
|
||||
const reportHeader = new Component('report-header');
|
||||
const reportFooter = new Component('report-footer');
|
||||
|
||||
|
@ -21,10 +20,10 @@ const rptSepaCore = {
|
|||
},
|
||||
methods: {
|
||||
fetchClient(clientId, companyId) {
|
||||
return db.findOneFromDef('client', {companyId, clientId}, __dirname);
|
||||
return this.findOneFromDef('client', {companyId, clientId});
|
||||
},
|
||||
fetchSupplier(clientId, companyId) {
|
||||
return db.findOneFromDef('supplier', {companyId, clientId}, __dirname);
|
||||
return this.findOneFromDef('supplier', {companyId, clientId});
|
||||
}
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -2,8 +2,9 @@ div.text {
|
|||
font-family: Tahoma;
|
||||
font-weight: bold;
|
||||
color: white;
|
||||
font-size: 7.5em;
|
||||
font-size: 12em;
|
||||
text-align: center;
|
||||
background-color: black;
|
||||
margin-bottom: 0.2em
|
||||
margin: 0.30em;
|
||||
padding: 30px 0
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"landscape": true,
|
||||
"format": "A4"
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
const db = require(`${appPath}/core/database`);
|
||||
|
||||
module.exports = {
|
||||
name: 'zone',
|
||||
async serverPrefetch() {
|
||||
|
@ -10,7 +8,7 @@ module.exports = {
|
|||
},
|
||||
methods: {
|
||||
fetchZone(routeId) {
|
||||
return db.findOneFromDef('zone', {routeId}, __dirname);
|
||||
return this.findOneFromDef('zone', {routeId});
|
||||
}
|
||||
},
|
||||
props: {
|
||||
|
|
Loading…
Reference in New Issue