zet-lib 1.2.80 → 1.2.81
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/zAppRouter.js +30 -27
- package/lib/zRoute.js +22 -4
- package/package.json +1 -1
package/lib/zAppRouter.js
CHANGED
|
@@ -1370,14 +1370,6 @@ router.post('/zapproval-update/:table', async (req, res) => {
|
|
|
1370
1370
|
canUpdate = false
|
|
1371
1371
|
}
|
|
1372
1372
|
}
|
|
1373
|
-
/*if (approval_history.length > 0) {
|
|
1374
|
-
let lastStatus = +approval_history[approval_history.length - 1].status
|
|
1375
|
-
canUpdate = lastStatus > +value ? false : true
|
|
1376
|
-
let history = approval_history.filter((item) => item.status == value && item.user_id == res.locals.userId)
|
|
1377
|
-
if (history.length > 0) {
|
|
1378
|
-
canUpdate = false
|
|
1379
|
-
}
|
|
1380
|
-
}*/
|
|
1381
1373
|
if (canUpdate) {
|
|
1382
1374
|
approval_history.push({
|
|
1383
1375
|
status: value,
|
|
@@ -1514,32 +1506,42 @@ router.get('/addapproval-models', async (req, res) => {
|
|
|
1514
1506
|
|
|
1515
1507
|
//post dropzone widget
|
|
1516
1508
|
router.post('/zdropzone', async (req, res) => {
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
})
|
|
1524
|
-
let filename = req.files.file.name
|
|
1525
|
-
req.files.file.mv(dir + '/' + filename, function (err) {
|
|
1526
|
-
if (err) {
|
|
1527
|
-
//console.log('fileempty move',err); // => null
|
|
1528
|
-
return res.status(500).send(err)
|
|
1509
|
+
try {
|
|
1510
|
+
let userId = res.locals.userId
|
|
1511
|
+
if (userId) {
|
|
1512
|
+
let dir = `${dirRoot}/public/zdropzone/${userId}`
|
|
1513
|
+
if (!fs.existsSync(dir)){
|
|
1514
|
+
fs.mkdirSync(dir,{ recursive: true });
|
|
1529
1515
|
}
|
|
1530
|
-
|
|
1516
|
+
let filename = req.files.file.name
|
|
1517
|
+
req.files.file.mv(dir + '/' + filename, function (err) {
|
|
1518
|
+
if (err) {
|
|
1519
|
+
//console.log('fileempty move',err); // => null
|
|
1520
|
+
return res.status(500).send(err+'')
|
|
1521
|
+
}
|
|
1522
|
+
})
|
|
1523
|
+
}
|
|
1524
|
+
res.json('ok')
|
|
1525
|
+
} catch (e) {
|
|
1526
|
+
console.log(e)
|
|
1527
|
+
res.status(500)
|
|
1528
|
+
res.send(e+'')
|
|
1531
1529
|
}
|
|
1532
|
-
res.json('ok')
|
|
1533
1530
|
})
|
|
1534
1531
|
|
|
1535
1532
|
router.post('/zdropzone-remove', async (req, res) => {
|
|
1536
1533
|
try {
|
|
1537
1534
|
let userId = res.locals.userId
|
|
1538
|
-
console.log(req.body)
|
|
1535
|
+
//console.log(req.body)
|
|
1539
1536
|
let filename = `${dirRoot}/public/zdropzone/${userId}/${req.body.file}`
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1537
|
+
if(Util.fileExist(filename)) {
|
|
1538
|
+
await fs.unlink(filename)
|
|
1539
|
+
}
|
|
1540
|
+
res.json('ok')
|
|
1541
|
+
} catch (e) {
|
|
1542
|
+
console.log(e)
|
|
1543
|
+
res.status(500).send(e+'')
|
|
1544
|
+
}
|
|
1543
1545
|
})
|
|
1544
1546
|
router.post('/zdropzone-attributes', async (req, res) => {
|
|
1545
1547
|
try {
|
|
@@ -1557,10 +1559,11 @@ router.post('/zdropzone-attributes', async (req, res) => {
|
|
|
1557
1559
|
Util.arrayDelete(arr, body.file)
|
|
1558
1560
|
}
|
|
1559
1561
|
myCache.set(name, arr)
|
|
1562
|
+
res.json('ok')
|
|
1560
1563
|
} catch (e) {
|
|
1561
1564
|
console.log(e)
|
|
1565
|
+
res.status(500).send(e+'')
|
|
1562
1566
|
}
|
|
1563
|
-
res.json('ok')
|
|
1564
1567
|
})
|
|
1565
1568
|
|
|
1566
1569
|
module.exports = router
|
package/lib/zRoute.js
CHANGED
|
@@ -2310,6 +2310,11 @@ zRoute.forms = (req, res, MYMODEL, relations, data = {}) => {
|
|
|
2310
2310
|
obj.type = 'email'
|
|
2311
2311
|
break
|
|
2312
2312
|
case 'dropzone':
|
|
2313
|
+
if(obj.value.length > 0){
|
|
2314
|
+
myCache.set(`dropzone__${res.locals.userId}__${MYMODEL.table}__${key}__${data.id}`, obj.value)
|
|
2315
|
+
}
|
|
2316
|
+
let dropzoneValue = obj.value.length > 0 ? JSON.stringify(obj.value) : '[]'
|
|
2317
|
+
script += `let dropzone_${key}_data = ${dropzoneValue};`
|
|
2313
2318
|
obj.type = 'dropzone'
|
|
2314
2319
|
obj.class = 'dropzone boxy-tiny d-block'
|
|
2315
2320
|
break
|
|
@@ -3197,13 +3202,26 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
3197
3202
|
})
|
|
3198
3203
|
},
|
|
3199
3204
|
init: function() {
|
|
3200
|
-
let
|
|
3201
|
-
|
|
3205
|
+
let dz = this;
|
|
3206
|
+
const type = window.location.href.split("/").pop();
|
|
3207
|
+
dz.on("addedfile", function(file) {
|
|
3202
3208
|
ajaxPost("/zdropzone-attributes",{file:file.name,'category':'add',field:"${item}",table:"${MYMODEL.table}", type:type},() => {})
|
|
3203
3209
|
});
|
|
3204
|
-
|
|
3210
|
+
dz.on("removedfile", function(file) {
|
|
3205
3211
|
ajaxPost("/zdropzone-attributes",{file:file.name,'category':'remove',field:"${item}",table:"${MYMODEL.table}", type:type},() => {})
|
|
3206
3212
|
});
|
|
3213
|
+
if(dropzone_${item}_data.length > 0) {
|
|
3214
|
+
dropzone_${item}_data.map((item) => {
|
|
3215
|
+
const mockFile = {
|
|
3216
|
+
name: item,
|
|
3217
|
+
id: item,
|
|
3218
|
+
size: 12345,
|
|
3219
|
+
accepted:true
|
|
3220
|
+
};
|
|
3221
|
+
dz.options.addedfile.call(dz, mockFile);
|
|
3222
|
+
dz.options.thumbnail.call(dz, mockFile, "${process.env.APP_URL}/uploads/${MYMODEL.table}/${item}/"+item);
|
|
3223
|
+
})
|
|
3224
|
+
};
|
|
3207
3225
|
}
|
|
3208
3226
|
}); `
|
|
3209
3227
|
})
|
|
@@ -3517,7 +3535,7 @@ zRoute.insertSQL = async (req, res, table, data) => {
|
|
|
3517
3535
|
let hasDropzone = false
|
|
3518
3536
|
for (let key in MYMODEL.widgets) {
|
|
3519
3537
|
if (MYMODEL.widgets[key].name === 'dropzone') {
|
|
3520
|
-
console.log('has dropzone')
|
|
3538
|
+
//console.log('has dropzone')
|
|
3521
3539
|
let path_src = dirRoot + '/public/zdropzone/' + userId + '/'
|
|
3522
3540
|
let path_dest = dirRoot + '/public/uploads/' + MYMODEL.routeName + '/' + key + '/'
|
|
3523
3541
|
fs.ensureDir(path_dest, (err) => {
|