zet-lib 3.1.0 → 3.1.1
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/zMenuRouter.js +37 -31
- package/package.json +1 -1
package/lib/zMenuRouter.js
CHANGED
|
@@ -53,6 +53,7 @@ router.get('/', async function (req, res, next) {
|
|
|
53
53
|
}
|
|
54
54
|
})
|
|
55
55
|
if(copyMenu){
|
|
56
|
+
copyMenu.json = JSON.stringify(copyMenu.json);
|
|
56
57
|
copyMenu.updated_by = res.locals.userId;
|
|
57
58
|
copyMenu.created_by = res.locals.userId;
|
|
58
59
|
copyMenu.created_at = Util.now();
|
|
@@ -64,45 +65,50 @@ router.get('/', async function (req, res, next) {
|
|
|
64
65
|
data : copyMenu
|
|
65
66
|
});
|
|
66
67
|
}
|
|
68
|
+
rows= await connection.results({
|
|
69
|
+
table: "zmenu",
|
|
70
|
+
where : {
|
|
71
|
+
company_id : companyId
|
|
72
|
+
}
|
|
73
|
+
});
|
|
67
74
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
name = selected.name;
|
|
97
|
-
}
|
|
75
|
+
hasAccessMenu = true;
|
|
76
|
+
//check id changes
|
|
77
|
+
let rowsChanges = rows.filter((item) => item.active == 1);
|
|
78
|
+
idChanges = rowsChanges.length > 0 ? rowsChanges[0].id : null;
|
|
79
|
+
if (id) {
|
|
80
|
+
await connection.update({
|
|
81
|
+
table : "zmenu",
|
|
82
|
+
data: {
|
|
83
|
+
active:0
|
|
84
|
+
},
|
|
85
|
+
where : {
|
|
86
|
+
company_id: companyId
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
await connection.update({
|
|
90
|
+
table : "zmenu",
|
|
91
|
+
data : {
|
|
92
|
+
active : 1,
|
|
93
|
+
},
|
|
94
|
+
where : {
|
|
95
|
+
id: id
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
} else {
|
|
99
|
+
id =1;
|
|
100
|
+
let selected = rows.filter(item=>item.active == 1)[0] || {}
|
|
101
|
+
id = selected.id;
|
|
102
|
+
name = selected.name;
|
|
98
103
|
}
|
|
104
|
+
|
|
99
105
|
findArr = await connection.results({
|
|
100
106
|
table:"zmenu",
|
|
101
107
|
where: {
|
|
102
108
|
id:id
|
|
103
109
|
}
|
|
104
110
|
});
|
|
105
|
-
arr = findArr[0].json;
|
|
111
|
+
arr = findArr && findArr.length > 0 && findArr[0].json ? findArr[0].json : arr;
|
|
106
112
|
let refresh = 0;
|
|
107
113
|
if (id != idChanges) {
|
|
108
114
|
refresh = 1;
|