|
@@ -18,6 +18,9 @@ import Common from '../common/Common.js';
|
|
|
import { CssUtil,Notify } from 'pc-component-v3';
|
|
import { CssUtil,Notify } from 'pc-component-v3';
|
|
|
import JsUtil from '../common/JsUtil';
|
|
import JsUtil from '../common/JsUtil';
|
|
|
|
|
|
|
|
|
|
+import { useRoleStateSingleton } from '../client/RoleState.js';
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
|
name: 'DashboardPage',
|
|
name: 'DashboardPage',
|
|
|
|
|
|
|
@@ -26,9 +29,17 @@ export default defineComponent({
|
|
|
return {
|
|
return {
|
|
|
dashboardArray: [],
|
|
dashboardArray: [],
|
|
|
moduleDtos: [],
|
|
moduleDtos: [],
|
|
|
|
|
+ roleStateInstance: useRoleStateSingleton,
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ 'roleStateInstance.userRoleOrTemplate': function(newValue, oldVal){
|
|
|
|
|
+ console.log(newValue);
|
|
|
|
|
+ this.loadData();
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
mounted: function () {
|
|
mounted: function () {
|
|
|
this.loadData();
|
|
this.loadData();
|
|
|
},
|
|
},
|
|
@@ -46,13 +57,19 @@ export default defineComponent({
|
|
|
var _self = this;
|
|
var _self = this;
|
|
|
$.ajax({
|
|
$.ajax({
|
|
|
url: Common.getApiURL('dashboardResource/listDashBoard'),
|
|
url: Common.getApiURL('dashboardResource/listDashBoard'),
|
|
|
- type: 'get',
|
|
|
|
|
|
|
+ type: 'POST',
|
|
|
|
|
+ data: _self.roleStateInstance.userRoleOrTemplate == null ? null : JSON.stringify(_self.roleStateInstance.userRoleOrTemplate),
|
|
|
dataType: 'json',
|
|
dataType: 'json',
|
|
|
|
|
+ contentType: 'application/json',
|
|
|
beforeSend: function (request) {
|
|
beforeSend: function (request) {
|
|
|
Common.addTokenToRequest(request);
|
|
Common.addTokenToRequest(request);
|
|
|
},
|
|
},
|
|
|
success: function (data) {
|
|
success: function (data) {
|
|
|
- _self.dynamicInit(data);
|
|
|
|
|
|
|
+ if(data.errorCode == 0){
|
|
|
|
|
+ _self.dynamicInit(data.datas);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Notify.error('仪表盘数据获取错误', data.errorMessage, false);
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
|
|
Common.processException(XMLHttpRequest, textStatus, errorThrown);
|
|
Common.processException(XMLHttpRequest, textStatus, errorThrown);
|
|
@@ -75,6 +92,7 @@ export default defineComponent({
|
|
|
*/
|
|
*/
|
|
|
dynamicInit: function (dashboards) {
|
|
dynamicInit: function (dashboards) {
|
|
|
let _self = this;
|
|
let _self = this;
|
|
|
|
|
+ _self.dashboardArray.splice(0, _self.dashboardArray.length);
|
|
|
|
|
|
|
|
if (dashboards != null && dashboards.length > 0) {
|
|
if (dashboards != null && dashboards.length > 0) {
|
|
|
dashboards.forEach(function (item) {
|
|
dashboards.forEach(function (item) {
|
|
@@ -113,10 +131,12 @@ export default defineComponent({
|
|
|
sortNo: sortNo,
|
|
sortNo: sortNo,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- console.log(_self.dashboardArray);
|
|
|
|
|
- _self.dashboardArray.push(item1);
|
|
|
|
|
- // add by jack 2024-05-22 增加排序
|
|
|
|
|
- _self.dashboardArray.sort((a, b) => a.sortNo - b.sortNo);
|
|
|
|
|
|
|
+ // console.log(_self.dashboardArray);
|
|
|
|
|
+ if(!_self.isExistDashboardComponent(item1)){
|
|
|
|
|
+ _self.dashboardArray.push(item1);
|
|
|
|
|
+ // add by jack 2024-05-22 增加排序
|
|
|
|
|
+ _self.dashboardArray.sort((a, b) => a.sortNo - b.sortNo);
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
errorData => {
|
|
errorData => {
|
|
|
console.error(errorData);
|
|
console.error(errorData);
|
|
@@ -126,6 +146,21 @@ export default defineComponent({
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 是否是现有的看板项
|
|
|
|
|
+ * @param dashboardItem 看板项
|
|
|
|
|
+ */
|
|
|
|
|
+ isExistDashboardComponent(dashboardItem){
|
|
|
|
|
+ let _self = this;
|
|
|
|
|
+ for(let i = 0; i < _self.dashboardArray.length; i ++){
|
|
|
|
|
+ let dashboardItemExist = _self.dashboardArray[i];
|
|
|
|
|
+ if(dashboardItemExist.no == dashboardItem.no){
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return false;
|
|
|
|
|
+ },
|
|
|
},
|
|
},
|
|
|
});
|
|
});
|
|
|
</script>
|
|
</script>
|