feat(testing): 增加质检报告独立编辑与详情页面,不再使用弹窗
这个提交包含在:
@@ -1,9 +1,10 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/granary-site'], function ($, undefined, Backend, Table, Form, SiteMixin) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
let vue = new Vue({
|
||||
el: '#vue',
|
||||
mixins: [SiteMixin],
|
||||
data: {
|
||||
typeName: '',
|
||||
detail: {
|
||||
@@ -62,6 +63,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
listLoading: false,
|
||||
// 搜索字段
|
||||
search: {
|
||||
site: '',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
keyword: '',
|
||||
@@ -115,9 +117,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
this.loadData(this.search.keyword, this.currentPage, this.pageSize, this.search.sort);
|
||||
},
|
||||
methods: {
|
||||
isRuleNumber(value) {
|
||||
return (typeof value === 'string' || typeof value === 'number')
|
||||
&& /^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/.test(String(value).trim())
|
||||
&& Number.isFinite(Number(value));
|
||||
},
|
||||
isNumericRule(item) {
|
||||
return [item.warning, item.alert].every(value =>
|
||||
value !== null && value !== undefined && String(value).trim() !== '' && Number.isFinite(Number(value)));
|
||||
return [item.warning, item.alert].every(value => this.isRuleNumber(value));
|
||||
},
|
||||
ruleDirection(item) {
|
||||
return item.direction === 'upper' || item.direction === 'lower' ? item.direction
|
||||
@@ -140,7 +146,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
: [`当前值 ≥ ${w}`, `${a} ≤ 当前值 < ${w}`, `当前值 < ${a}`];
|
||||
},
|
||||
ruleError(item) {
|
||||
const expectsNumeric = item.rule_numeric === true || Number(item.is_number) === 1
|
||||
|| this.isRuleNumber(item.warning) || this.isRuleNumber(item.alert);
|
||||
if (expectsNumeric && !this.isNumericRule(item)) return '预警值和警告值必须都是有限数字';
|
||||
if (!this.isNumericRule(item)) return '';
|
||||
if (!this.isRuleNumber(item.val)
|
||||
&& !/^(?:\/|--?|未检测|未提供|暂无|未检出|未检出\s*ND|ND)$/i.test(String(item.val ?? '').trim())) {
|
||||
return '检测值必须是有限数字,缺测可填 /';
|
||||
}
|
||||
const upper = this.ruleDirection(item) === 'upper';
|
||||
return (upper && Number(item.warning) > Number(item.alert)) || (!upper && Number(item.warning) < Number(item.alert))
|
||||
? (upper ? '越小越好指标要求:预警值 ≤ 警告值(高值预警)' : '越大越好指标要求:预警值 ≥ 警告值(低值预警)') : '';
|
||||
@@ -148,6 +161,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
// 刷新页面
|
||||
refreshPage() {
|
||||
this.search = {
|
||||
site: '',
|
||||
startTime: '',
|
||||
endTime: '',
|
||||
keyword: '',
|
||||
@@ -164,15 +178,37 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
let list = this.granaryList;
|
||||
let item = list.find(v => v.id === e);
|
||||
|
||||
if (!item) return;
|
||||
this.typeName = item.varieties;
|
||||
this.formData.type = item.type;
|
||||
},
|
||||
handelIsNumber(index, val) {
|
||||
this.typeList[this.formData.type]['content'][index].is_number = val;
|
||||
},
|
||||
openPage(url, title) {
|
||||
if (typeof top !== 'undefined' && top && top.Backend && top.Backend.api && typeof top.Backend.api.addtabs === 'function') {
|
||||
top.Backend.api.addtabs(url, title);
|
||||
} else if (typeof Backend !== 'undefined' && Backend && Backend.api && typeof Backend.api.addtabs === 'function') {
|
||||
Backend.api.addtabs(url, title);
|
||||
} else if (typeof window !== 'undefined' && window.location) {
|
||||
window.location.href = url;
|
||||
}
|
||||
},
|
||||
openAddPage() {
|
||||
this.openPage('testing/add', '添加检测报告');
|
||||
},
|
||||
openEditPage(item) {
|
||||
var id = typeof item === 'object' ? item.id : item;
|
||||
var name = (item && item.granary && item.granary.name) ? ' - ' + item.granary.name : '';
|
||||
this.openPage('testing/edit?ids=' + id, '编辑检测报告' + name);
|
||||
},
|
||||
openDetailPage(item) {
|
||||
var id = typeof item === 'object' ? item.id : item;
|
||||
var name = (item && item.granary && item.granary.name) ? ' - ' + item.granary.name : '';
|
||||
this.openPage('testing/detail?ids=' + id, '检测报告详情' + name);
|
||||
},
|
||||
openDialogDetail(detail) {
|
||||
this.detail = detail;
|
||||
this.detailDialog = true;
|
||||
this.openDetailPage(detail);
|
||||
},
|
||||
handleClearSelect(field) {
|
||||
// 重新加载
|
||||
@@ -261,13 +297,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
})
|
||||
});
|
||||
},
|
||||
// 添加/编辑
|
||||
// 添加/编辑(兼容原有状态准备)
|
||||
openAddDialog(type, item) {
|
||||
this.addDialog = true;
|
||||
this.typeList = JSON.parse(JSON.stringify(this.newTypeList));
|
||||
|
||||
if (type === 'add') {
|
||||
this.title = '添加';
|
||||
this.formSite = this.search.site || (this.siteOptions[0] || {}).id || '';
|
||||
this.formData = {
|
||||
id: 0,
|
||||
gid: '',
|
||||
@@ -279,6 +316,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
};
|
||||
} else {
|
||||
this.title = '编辑';
|
||||
this.formSite = item.granary.site;
|
||||
this.formData = {
|
||||
id: item.id,
|
||||
gid: item.gid,
|
||||
@@ -292,6 +330,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
this.typeName = item.granary.varieties;
|
||||
this.typeList[item.type]['content'] = JSON.parse(JSON.stringify(item.testing_params));
|
||||
}
|
||||
for (const group of Object.values(this.typeList)) {
|
||||
for (const row of group.content || []) {
|
||||
this.$set(row, 'rule_numeric', this.isNumericRule(row));
|
||||
}
|
||||
}
|
||||
},
|
||||
handleSort(item) {
|
||||
// 提交
|
||||
@@ -325,6 +368,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
||||
this.listLoading = true;
|
||||
$.getJSON('testing/index', {
|
||||
keyword: key,
|
||||
site: this.search.site,
|
||||
type: this.search.type,
|
||||
gid: this.search.gid,
|
||||
date: this.search.date,
|
||||
|
||||
在新工单中引用
屏蔽一个用户