feat: 完善仓库建筑绑定、质检预警规则与大屏展示
这个提交包含在:
@@ -115,6 +115,36 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
|
||||
},
|
||||
methods: {
|
||||
isNumericRule(item) {
|
||||
return [item.warning, item.alert].every(value =>
|
||||
value !== null && value !== undefined && String(value).trim() !== '' && Number.isFinite(Number(value)));
|
||||
},
|
||||
ruleDirection(item) {
|
||||
return item.direction === 'upper' || item.direction === 'lower' ? item.direction
|
||||
: (this.isNumericRule(item) && Number(item.warning) > Number(item.alert) ? 'lower' : 'upper');
|
||||
},
|
||||
rulePreference(item) {
|
||||
return this.ruleDirection(item) === 'lower' ? 'higher' : 'lower';
|
||||
},
|
||||
setRuleDirection(item, direction) {
|
||||
if (direction !== 'upper' && direction !== 'lower') return;
|
||||
this.$set(item, 'direction', direction);
|
||||
},
|
||||
toggleRule(item) {
|
||||
this.setRuleDirection(item, this.ruleDirection(item) === 'upper' ? 'lower' : 'upper');
|
||||
},
|
||||
ruleRanges(item) {
|
||||
const w = item.warning, a = item.alert;
|
||||
return this.ruleDirection(item) === 'upper'
|
||||
? [`当前值 ≤ ${w}`, `${w} < 当前值 ≤ ${a}`, `当前值 > ${a}`]
|
||||
: [`当前值 ≥ ${w}`, `${a} ≤ 当前值 < ${w}`, `当前值 < ${a}`];
|
||||
},
|
||||
ruleError(item) {
|
||||
if (!this.isNumericRule(item)) return '';
|
||||
const upper = this.ruleDirection(item) === 'upper';
|
||||
return (upper && Number(item.warning) > Number(item.alert)) || (!upper && Number(item.warning) < Number(item.alert))
|
||||
? (upper ? '越小越好指标要求:预警值 ≤ 警告值(高值预警)' : '越大越好指标要求:预警值 ≥ 警告值(低值预警)') : '';
|
||||
},
|
||||
// 刷新页面
|
||||
refreshPage() {
|
||||
this.search = {
|
||||
@@ -175,7 +205,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
// 参数验证
|
||||
for (let item of content) {
|
||||
name = item.name;
|
||||
if (!item.val) {
|
||||
const error = this.ruleError(item);
|
||||
if (error) {
|
||||
this._sweetMsg({ type: 'warning', content: `${name}:${error}` });
|
||||
return false;
|
||||
}
|
||||
this.$set(item, 'direction', this.ruleDirection(item));
|
||||
if (item.val === '' || item.val === null || item.val === undefined) {
|
||||
this._sweetMsg({
|
||||
type: 'warning',
|
||||
content: `请您输入${name}值`
|
||||
@@ -192,7 +228,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
if (item.alert === '') {
|
||||
this._sweetMsg({
|
||||
type: 'warning',
|
||||
content: `请您输入${name}警戒值`
|
||||
content: `请您输入${name}警告值`
|
||||
});
|
||||
return false;
|
||||
}
|
||||
@@ -254,7 +290,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
};
|
||||
|
||||
this.typeName = item.granary.varieties;
|
||||
this.typeList[item.type]['content'] = item.testing_params;
|
||||
this.typeList[item.type]['content'] = JSON.parse(JSON.stringify(item.testing_params));
|
||||
}
|
||||
},
|
||||
handleSort(item) {
|
||||
|
||||
在新工单中引用
屏蔽一个用户