From 1a3f0ed6b7f6d4112069a3c8679e7192365d5eef Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 31 三月 2026 12:38:44 +0800
Subject: [PATCH] #电视机退回时入库站点也显示信息
---
src/main/webapp/static/js/config/config.js | 89 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 87 insertions(+), 2 deletions(-)
diff --git a/src/main/webapp/static/js/config/config.js b/src/main/webapp/static/js/config/config.js
index a3e61fe..d4594da 100644
--- a/src/main/webapp/static/js/config/config.js
+++ b/src/main/webapp/static/js/config/config.js
@@ -991,12 +991,44 @@
textarea: false,
minWidth: 140,
dialogSpan: 24,
+ suggestInput: true,
enumOptions: [],
foreignQuery: '',
checkboxActiveRaw: 'Y',
checkboxInactiveRaw: 'N'
}
];
+
+ function applySelectTypeOptions(options) {
+ var normalizedOptions = [];
+ (options || []).forEach(function (item) {
+ var rawValue = '';
+ var label = '';
+ if (item && typeof item === 'object') {
+ rawValue = item.value !== undefined ? item.value : (item.rawValue !== undefined ? item.rawValue : (item.label !== undefined ? item.label : ''));
+ label = item.label !== undefined ? item.label : rawValue;
+ } else {
+ rawValue = item;
+ label = item;
+ }
+ rawValue = isEmptyValue(rawValue) ? '' : String(rawValue);
+ label = isEmptyValue(label) ? rawValue : String(label);
+ if (!rawValue) {
+ return;
+ }
+ normalizedOptions.push({
+ rawValue: rawValue,
+ label: label
+ });
+ });
+ fieldMeta.forEach(function (field) {
+ if (field.field !== 'selectType') {
+ return;
+ }
+ field.kind = 'enum';
+ field.enumOptions = normalizedOptions;
+ });
+ }
function isEmptyValue(value) {
return value === null || value === undefined || value === '';
@@ -1058,6 +1090,9 @@
if (field.kind === 'date') {
return [];
}
+ if (field.kind === 'enum' && field.suggestInput) {
+ return '';
+ }
if (field.kind === 'enum' || field.kind === 'checkbox') {
return null;
}
@@ -1114,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;
@@ -1295,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([]);
@@ -1325,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 : '');
@@ -1436,6 +1499,7 @@
}
},
created: function () {
+ this.fetchSelectTypeOptions();
this.loadTable();
},
mounted: function () {
@@ -1583,6 +1647,27 @@
}
});
},
+ fetchSelectTypeOptions: function () {
+ var self = this;
+ $.ajax({
+ url: baseUrl + '/config/getSelectTypes',
+ method: 'POST',
+ headers: self.authHeaders(),
+ success: function (res) {
+ if (self.handleForbidden(res)) {
+ return;
+ }
+ if (!res || res.code !== 200) {
+ return;
+ }
+ applySelectTypeOptions(Array.isArray(res.data) ? res.data : []);
+ self.fieldMeta = fieldMeta.slice();
+ self.allColumns = fieldMeta.slice();
+ self.dialogRules = createFormRules();
+ self.requestTableLayout(80);
+ }
+ });
+ },
handleSearch: function () {
this.page.curr = 1;
this.loadTable();
--
Gitblit v1.9.1