zet-lib 1.0.49 → 1.0.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Util.js +869 -859
- package/lib/zRoute.js +30 -11
- package/package.json +2 -2
package/lib/zRoute.js
CHANGED
|
@@ -1078,7 +1078,7 @@ zRoute.excelQuery = async (req, res, MYMODEL) => {
|
|
|
1078
1078
|
let result = results[0]
|
|
1079
1079
|
body = result.filter
|
|
1080
1080
|
fields = body.fields.filter((item) => item != 'no' && item != 'actionColumn')
|
|
1081
|
-
select = Util.
|
|
1081
|
+
select = Util.selectParser(fields, MYMODEL)
|
|
1082
1082
|
if (zall) {
|
|
1083
1083
|
let difference = allfields.filter((x) => !fields.includes(x))
|
|
1084
1084
|
arr = [...fields, ...difference]
|
|
@@ -1115,7 +1115,7 @@ zRoute.excelQuery = async (req, res, MYMODEL) => {
|
|
|
1115
1115
|
rows = await connection.results(obj)
|
|
1116
1116
|
} else {
|
|
1117
1117
|
rows = await connection.results({
|
|
1118
|
-
select: Util.
|
|
1118
|
+
select: Util.selectParser(fields, MYMODEL),
|
|
1119
1119
|
table: MYMODEL.table,
|
|
1120
1120
|
limit: reqQuery.pageSize,
|
|
1121
1121
|
offset: parseInt(reqQuery.pageSize) - 1,
|
|
@@ -1524,7 +1524,7 @@ zRoute.listDataTable = async (req, res, objData = {}) => {
|
|
|
1524
1524
|
const MYMODEL = objData.MYMODEL || {}
|
|
1525
1525
|
const fields = Object.prototype.hasOwnProperty.call(objData, 'fields') ? objData.fields : req.body.fields
|
|
1526
1526
|
const relations = await zRoute.relations(req, res, MYMODEL.table)
|
|
1527
|
-
const select = Object.prototype.hasOwnProperty.call(objData, 'select') ? objData.select : Util.
|
|
1527
|
+
const select = Object.prototype.hasOwnProperty.call(objData, 'select') ? objData.select : Util.selectParser(fields, MYMODEL)
|
|
1528
1528
|
const columns = Object.prototype.hasOwnProperty.call(objData, 'columns') ? objData.columns : body.columns
|
|
1529
1529
|
let whereArray = []
|
|
1530
1530
|
if (objData.hasOwnProperty('whereArray')) {
|
|
@@ -1604,7 +1604,7 @@ zRoute.listData = async (req, res, MYMODEL, zRole, actionButtonsFn) => {
|
|
|
1604
1604
|
const relations = await zRoute.relations(req, res, MYMODEL.table)
|
|
1605
1605
|
const body = req.body
|
|
1606
1606
|
const fields = body.fields
|
|
1607
|
-
const select = Util.
|
|
1607
|
+
const select = Util.selectParser(fields, MYMODEL)
|
|
1608
1608
|
let whereArray = []
|
|
1609
1609
|
const columns = body.columns
|
|
1610
1610
|
whereArray.push({
|
|
@@ -3036,8 +3036,8 @@ zRoute.import = async (req, res, MYMODEL) => {
|
|
|
3036
3036
|
}
|
|
3037
3037
|
//convert to table header
|
|
3038
3038
|
let hd = '<tr>'
|
|
3039
|
+
let i = 0
|
|
3039
3040
|
for (let prop in result[1]) {
|
|
3040
|
-
let i = 0
|
|
3041
3041
|
keys[prop] = result[1][prop]
|
|
3042
3042
|
hd += `<th>${result[0][prop]}</th>`
|
|
3043
3043
|
headers.push({ i: i, prop: prop, value: result[0][prop] })
|
|
@@ -3045,20 +3045,38 @@ zRoute.import = async (req, res, MYMODEL) => {
|
|
|
3045
3045
|
}
|
|
3046
3046
|
hd += `<th>${LANGUAGE['noted']}</th>`
|
|
3047
3047
|
hd += `</tr>`
|
|
3048
|
+
|
|
3049
|
+
let isCut = false;
|
|
3050
|
+
if(i > 20 && result.length > 2000) {
|
|
3051
|
+
io.to(room).emit('message', 'short display data!');
|
|
3052
|
+
isCut = true;
|
|
3053
|
+
}
|
|
3048
3054
|
//convert to table header
|
|
3049
3055
|
io.to(room).emit('import', hd)
|
|
3050
|
-
let isInsert = true
|
|
3051
|
-
|
|
3056
|
+
let isInsert = true;
|
|
3057
|
+
|
|
3052
3058
|
for (let i = 3; i < result.length; i++) {
|
|
3059
|
+
hd = '';
|
|
3060
|
+
hd += `<tr>`
|
|
3053
3061
|
const data = {}
|
|
3054
3062
|
hd += `${i - 2}`
|
|
3063
|
+
//column cut tidak penting hanya jika kebanyakan dipotong
|
|
3064
|
+
let columnCut = 0;
|
|
3055
3065
|
for (var prop in keys) {
|
|
3056
3066
|
let value = result[i][prop]
|
|
3057
3067
|
if (value) {
|
|
3058
3068
|
data[keys[prop]] = value
|
|
3059
3069
|
}
|
|
3060
|
-
|
|
3070
|
+
if(isCut) {
|
|
3071
|
+
console.log('cut and column cut')
|
|
3072
|
+
if(columnCut < 10) {
|
|
3073
|
+
hd += `<td>${value || ''}</td>`
|
|
3074
|
+
}
|
|
3075
|
+
} else {
|
|
3076
|
+
hd += `<td>${value || ''}</td>`
|
|
3077
|
+
}
|
|
3061
3078
|
if (keys[prop] == 'id') isInsert = false
|
|
3079
|
+
columnCut++;
|
|
3062
3080
|
}
|
|
3063
3081
|
try {
|
|
3064
3082
|
if (isInsert) {
|
|
@@ -3081,13 +3099,14 @@ zRoute.import = async (req, res, MYMODEL) => {
|
|
|
3081
3099
|
}
|
|
3082
3100
|
hd += `<td class='text text-success'>${LANGUAGE['success']}</td>`
|
|
3083
3101
|
} catch (err) {
|
|
3084
|
-
hd += `<td class='text text-danger'>${err
|
|
3102
|
+
hd += `<td class='text text-danger'>${err+''}</td>`
|
|
3103
|
+
io.to(room).emit('error', err + '' + ' ')
|
|
3085
3104
|
}
|
|
3086
3105
|
hd += '</tr>'
|
|
3087
3106
|
io.to(room).emit('import', hd)
|
|
3088
3107
|
}
|
|
3089
|
-
|
|
3090
|
-
|
|
3108
|
+
|
|
3109
|
+
|
|
3091
3110
|
fs.removeSync(filename)
|
|
3092
3111
|
//cache for uploading excel
|
|
3093
3112
|
zRoute.modelsCacheRenew(MYMODEL.table, res.locals.companyId)
|
package/package.json
CHANGED