From 59a5e337400b25862b744df4ea2078788bc93eba Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 02 四月 2026 18:36:00 +0800
Subject: [PATCH] #预调度堆垛机
---
src/main/webapp/static/js/config/config.js | 195 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 192 insertions(+), 3 deletions(-)
diff --git a/src/main/webapp/static/js/config/config.js b/src/main/webapp/static/js/config/config.js
index 55aedab..05688ee 100644
--- a/src/main/webapp/static/js/config/config.js
+++ b/src/main/webapp/static/js/config/config.js
@@ -991,6 +991,7 @@
textarea: false,
minWidth: 140,
dialogSpan: 24,
+ suggestInput: true,
enumOptions: [],
foreignQuery: '',
checkboxActiveRaw: 'Y',
@@ -1089,6 +1090,9 @@
if (field.kind === 'date') {
return [];
}
+ if (field.kind === 'enum' && field.suggestInput) {
+ return '';
+ }
if (field.kind === 'enum' || field.kind === 'checkbox') {
return null;
}
@@ -1145,13 +1149,14 @@
function createFormRules() {
var rules = {};
fieldMeta.forEach(function (field) {
+ var useInputRule = field.kind === 'enum' && field.suggestInput;
if (field.primaryKey || !field.required) {
return;
}
rules[field.field] = [{
required: true,
- message: (field.kind === 'date' || field.kind === 'enum' ? '璇烽�夋嫨' : '璇疯緭鍏�') + field.label,
- trigger: (field.kind === 'date' || field.kind === 'enum') ? 'change' : 'blur'
+ message: (field.kind === 'date' || (field.kind === 'enum' && !useInputRule) ? '璇烽�夋嫨' : '璇疯緭鍏�') + field.label,
+ trigger: (field.kind === 'date' || (field.kind === 'enum' && !useInputRule)) ? 'change' : 'blur'
}];
});
return rules;
@@ -1326,6 +1331,12 @@
self.fetchForeignSuggestions(field, queryString, callback);
};
},
+ getEnumSuggestionFetcher: function (field) {
+ var self = this;
+ return function (queryString, callback) {
+ self.fetchEnumSuggestions(field, queryString, callback);
+ };
+ },
fetchForeignSuggestions: function (field, queryString, callback) {
if (!field.foreignQuery || !queryString) {
callback([]);
@@ -1356,6 +1367,27 @@
callback([]);
}
});
+ },
+ fetchEnumSuggestions: function (field, queryString, callback) {
+ var keyword = String(queryString || '').toLowerCase();
+ var result = [];
+ var seen = {};
+ (field && field.enumOptions ? field.enumOptions : []).forEach(function (option) {
+ var rawValue = option && option.rawValue !== undefined ? String(option.rawValue) : '';
+ var label = option && option.label !== undefined ? String(option.label) : rawValue;
+ var haystack = (label + ' ' + rawValue).toLowerCase();
+ if (keyword && haystack.indexOf(keyword) === -1) {
+ return;
+ }
+ if (!rawValue || seen[rawValue]) {
+ return;
+ }
+ seen[rawValue] = true;
+ result.push({
+ value: rawValue
+ });
+ });
+ callback(result);
},
handleForeignSelect: function (field, item) {
this.$set(this.displayTarget, field.field, item && item.value ? item.value : '');
@@ -1405,9 +1437,31 @@
tableHeight: 420,
layoutTimer: null,
tableResizeHandler: null,
+ grantTimer: null,
dialogForm: createFormDefaults(),
dialogDisplay: createDisplayDefaults(),
- dialogRules: createFormRules()
+ dialogRules: createFormRules(),
+ grantStatus: {
+ granted: false,
+ remainingSeconds: 0,
+ expireAt: null
+ },
+ grantDialog: {
+ visible: false,
+ submitting: false,
+ form: {
+ account: '',
+ password: ''
+ },
+ rules: {
+ account: [
+ { required: true, message: '璇疯緭鍏ョ鐞嗗憳璐﹀彿', trigger: 'blur' }
+ ],
+ password: [
+ { required: true, message: '璇疯緭鍏ュ瘑鐮�', trigger: 'blur' }
+ ]
+ }
+ }
};
},
computed: {
@@ -1464,11 +1518,18 @@
},
isDialogReadonly: function () {
return this.dialog.mode === 'detail';
+ },
+ grantStatusText: function () {
+ if (!this.grantStatus.granted) {
+ return '褰撳墠鏃犳渶楂樻潈闄愭巿鏉�';
+ }
+ return '鍓╀綑 ' + this.formatRemainingSeconds(this.grantStatus.remainingSeconds);
}
},
created: function () {
this.fetchSelectTypeOptions();
this.loadTable();
+ this.loadGrantStatus();
},
mounted: function () {
var self = this;
@@ -1487,8 +1548,135 @@
window.removeEventListener('resize', this.tableResizeHandler);
this.tableResizeHandler = null;
}
+ this.stopGrantCountdown();
},
methods: $.extend({}, sharedMethods, {
+ formatRemainingSeconds: function (seconds) {
+ var total = Number(seconds || 0);
+ var minutes;
+ var remainSeconds;
+ if (total <= 0) {
+ return '0绉�';
+ }
+ minutes = Math.floor(total / 60);
+ remainSeconds = total % 60;
+ if (minutes <= 0) {
+ return remainSeconds + '绉�';
+ }
+ if (remainSeconds === 0) {
+ return minutes + '鍒嗛挓';
+ }
+ return minutes + '鍒�' + remainSeconds + '绉�';
+ },
+ stopGrantCountdown: function () {
+ if (this.grantTimer) {
+ clearInterval(this.grantTimer);
+ this.grantTimer = null;
+ }
+ },
+ startGrantCountdown: function () {
+ var self = this;
+ self.stopGrantCountdown();
+ if (!self.grantStatus.granted || Number(self.grantStatus.remainingSeconds) <= 0) {
+ return;
+ }
+ self.grantTimer = setInterval(function () {
+ if (!self.grantStatus.granted) {
+ self.stopGrantCountdown();
+ return;
+ }
+ if (self.grantStatus.remainingSeconds <= 1) {
+ self.grantStatus = {
+ granted: false,
+ remainingSeconds: 0,
+ expireAt: null
+ };
+ self.stopGrantCountdown();
+ return;
+ }
+ self.grantStatus.remainingSeconds -= 1;
+ }, 1000);
+ },
+ applyGrantStatus: function (payload) {
+ var status = payload || {};
+ this.grantStatus = {
+ granted: !!status.granted,
+ remainingSeconds: Number(status.remainingSeconds || 0),
+ expireAt: status.expireAt || null
+ };
+ this.startGrantCountdown();
+ },
+ loadGrantStatus: function () {
+ var self = this;
+ $.ajax({
+ url: baseUrl + '/highPrivilege/status/auth',
+ method: 'GET',
+ headers: self.authHeaders(),
+ success: function (res) {
+ if (self.handleForbidden(res)) {
+ return;
+ }
+ if (!res || res.code !== 200) {
+ return;
+ }
+ self.applyGrantStatus(res.data || {});
+ }
+ });
+ },
+ resetGrantDialog: function () {
+ this.grantDialog.submitting = false;
+ this.grantDialog.form = {
+ account: '',
+ password: ''
+ };
+ if (this.$refs.grantForm) {
+ this.$refs.grantForm.clearValidate();
+ }
+ },
+ openGrantDialog: function () {
+ this.grantDialog.visible = true;
+ this.$nextTick(this.resetGrantDialog);
+ },
+ submitGrant: function () {
+ var self = this;
+ if (!self.$refs.grantForm) {
+ return;
+ }
+ self.$refs.grantForm.validate(function (valid) {
+ if (!valid) {
+ return false;
+ }
+ self.grantDialog.submitting = true;
+ $.ajax({
+ url: baseUrl + '/highPrivilege/grant/auth',
+ method: 'POST',
+ contentType: 'application/json;charset=UTF-8',
+ headers: self.authHeaders(),
+ data: JSON.stringify({
+ account: self.grantDialog.form.account,
+ password: hex_md5(self.grantDialog.form.password || '')
+ }),
+ success: function (res) {
+ self.grantDialog.submitting = false;
+ if (self.handleForbidden(res)) {
+ return;
+ }
+ if (!res || res.code !== 200) {
+ self.$message.error((res && res.msg) ? res.msg : '鎺堟潈澶辫触');
+ return;
+ }
+ self.$message.success('鎺堟潈鎴愬姛');
+ self.grantDialog.visible = false;
+ self.applyGrantStatus(res.data || {});
+ },
+ error: function () {
+ self.grantDialog.submitting = false;
+ self.$message.error('鎺堟潈澶辫触');
+ }
+ });
+ return true;
+ });
+ },
calculateTableHeight: function () {
var viewportHeight = window.innerHeight || document.documentElement.clientHeight || 860;
var tableWrap = this.$refs.tableWrap;
@@ -1631,6 +1819,7 @@
applySelectTypeOptions(Array.isArray(res.data) ? res.data : []);
self.fieldMeta = fieldMeta.slice();
self.allColumns = fieldMeta.slice();
+ self.dialogRules = createFormRules();
self.requestTableLayout(80);
}
});
--
Gitblit v1.9.1