|
@@ -28,13 +28,15 @@ const OnlineFormMixins = {
|
|
|
}
|
|
|
},
|
|
|
mixins: [uploadMixin],
|
|
|
- data () {
|
|
|
+ data() {
|
|
|
return {
|
|
|
isLoading: true,
|
|
|
formData: {},
|
|
|
rules: {},
|
|
|
- components_json:{},
|
|
|
- component_movementjson:{},
|
|
|
+ components_json: {},
|
|
|
+ blueunit:[],
|
|
|
+ redunit:[],
|
|
|
+ component_movementjson: {},
|
|
|
formConfig: {
|
|
|
formType: undefined,
|
|
|
formKind: undefined,
|
|
@@ -60,13 +62,13 @@ const OnlineFormMixins = {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- getFormData () {
|
|
|
+ getFormData() {
|
|
|
return this.formData;
|
|
|
},
|
|
|
- getPermCode (widget, operation) {
|
|
|
+ getPermCode(widget, operation) {
|
|
|
return getOperationPermCode(widget, operation);
|
|
|
},
|
|
|
- loadOnlineFormData () {
|
|
|
+ loadOnlineFormData() {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
OnlineFormController.render(this, {
|
|
|
formId: this.formId
|
|
@@ -176,7 +178,7 @@ const OnlineFormMixins = {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- initWidget (widget, formConfig) {
|
|
|
+ initWidget(widget, formConfig) {
|
|
|
if (widget != null) {
|
|
|
if (widget.datasourceId) widget.datasource = this.datasourceMap.get(widget.datasourceId);
|
|
|
if (widget.relationId) {
|
|
@@ -260,7 +262,7 @@ const OnlineFormMixins = {
|
|
|
param.table = this.tableMap.get(param.tableId);
|
|
|
param.column = this.columnMap.get(param.columnId);
|
|
|
param.relation = this.relationMap.get(param.relationId);
|
|
|
-
|
|
|
+
|
|
|
if (param.table == null || param.column == null) {
|
|
|
this.errorMessage.push({
|
|
|
widget: widget,
|
|
@@ -337,7 +339,7 @@ const OnlineFormMixins = {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- initFormWidgetList (formConfig) {
|
|
|
+ initFormWidgetList(formConfig) {
|
|
|
this.errorMessage = [];
|
|
|
if (Array.isArray(formConfig.formWidgetList)) {
|
|
|
formConfig.formWidgetList.forEach(widget => {
|
|
@@ -351,7 +353,7 @@ const OnlineFormMixins = {
|
|
|
console.error(this.errorMessage);
|
|
|
}
|
|
|
},
|
|
|
- buildRuleItem (widget, rule) {
|
|
|
+ buildRuleItem(widget, rule) {
|
|
|
if (rule.propDataJson) rule.data = JSON.parse(rule.propDataJson);
|
|
|
if (widget != null && rule != null) {
|
|
|
switch (rule.onlineRule.ruleType) {
|
|
@@ -376,7 +378,7 @@ const OnlineFormMixins = {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- buildWidgetRule (widget, rules) {
|
|
|
+ buildWidgetRule(widget, rules) {
|
|
|
if (widget != null && widget.column != null) {
|
|
|
let widgetRuleKey = (widget.relation ? widget.relation.variableName + '__' : '') + widget.column.columnName;
|
|
|
// 必填字段以及设置了验证规则的字段
|
|
@@ -398,7 +400,7 @@ const OnlineFormMixins = {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- initWidgetRule (formConfig) {
|
|
|
+ initWidgetRule(formConfig) {
|
|
|
if (Array.isArray(formConfig.formWidgetList)) {
|
|
|
let rules = {};
|
|
|
formConfig.formWidgetList.forEach(widget => {
|
|
@@ -410,9 +412,9 @@ const OnlineFormMixins = {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- initFormDatasourceData (formConfig) {
|
|
|
+ initFormDatasourceData(formConfig) {
|
|
|
let that = this;
|
|
|
- function addFormDataByColumn (retObj, column, relation) {
|
|
|
+ function addFormDataByColumn(retObj, column, relation) {
|
|
|
let fieldName = (relation ? relation.variableName + '__' : '') + column.columnName;
|
|
|
if (retObj == null) retObj = {};
|
|
|
if (formConfig.formType === that.SysOnlineFormType.QUERY) {
|
|
@@ -453,7 +455,7 @@ const OnlineFormMixins = {
|
|
|
}
|
|
|
this.$set(this, 'formData', datasourceFormData);
|
|
|
},
|
|
|
- initWidgetLinkage (formConfig) {
|
|
|
+ initWidgetLinkage(formConfig) {
|
|
|
this.linkageMap.forEach((widgetList, key) => {
|
|
|
let column = this.columnMap.get(key);
|
|
|
let watchKey = null;
|
|
@@ -477,7 +479,7 @@ const OnlineFormMixins = {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- initFormData (formConfig) {
|
|
|
+ initFormData(formConfig) {
|
|
|
this.masterTable = this.tableMap.get(formConfig.masterTableId);
|
|
|
// 初始化表单数据
|
|
|
this.initFormDatasourceData(formConfig);
|
|
@@ -487,32 +489,32 @@ const OnlineFormMixins = {
|
|
|
// 初始化校验信息
|
|
|
this.initWidgetRule(formConfig);
|
|
|
},
|
|
|
- getParamValue (valueType, valueData) {
|
|
|
+ getParamValue(valueType, valueData) {
|
|
|
switch (valueType) {
|
|
|
case this.SysOnlineParamValueType.FORM_PARAM:
|
|
|
return this.params ? this.params[valueData] : undefined;
|
|
|
case this.SysOnlineParamValueType.TABLE_COLUMN:
|
|
|
- {
|
|
|
- let column = this.columnMap.get(valueData);
|
|
|
- let columnValue = null;
|
|
|
- if (this.formConfig.formType === this.SysOnlineFormType.QUERY) {
|
|
|
- columnValue = this.formData.formFilterCopy[column.columnName];
|
|
|
- } else {
|
|
|
- columnValue = this.formData[column.columnName];
|
|
|
- }
|
|
|
- if (column == null || columnValue == null || columnValue === '') {
|
|
|
- return null;
|
|
|
- } else {
|
|
|
- return columnValue;
|
|
|
+ {
|
|
|
+ let column = this.columnMap.get(valueData);
|
|
|
+ let columnValue = null;
|
|
|
+ if (this.formConfig.formType === this.SysOnlineFormType.QUERY) {
|
|
|
+ columnValue = this.formData.formFilterCopy[column.columnName];
|
|
|
+ } else {
|
|
|
+ columnValue = this.formData[column.columnName];
|
|
|
+ }
|
|
|
+ if (column == null || columnValue == null || columnValue === '') {
|
|
|
+ return null;
|
|
|
+ } else {
|
|
|
+ return columnValue;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
case this.SysOnlineParamValueType.STATIC_DICT:
|
|
|
return Array.isArray(valueData) ? valueData[1] : undefined;
|
|
|
case this.SysOnlineParamValueType.INPUT_VALUE:
|
|
|
return valueData;
|
|
|
}
|
|
|
},
|
|
|
- getParamValueObj (paramName, valueType, valueData, retObj) {
|
|
|
+ getParamValueObj(paramName, valueType, valueData, retObj) {
|
|
|
try {
|
|
|
if (retObj == null) retObj = {};
|
|
|
retObj[paramName] = this.getParamValue(valueType, valueData);
|
|
@@ -522,14 +524,14 @@ const OnlineFormMixins = {
|
|
|
console.log(e);
|
|
|
}
|
|
|
},
|
|
|
- clean () {
|
|
|
+ clean() {
|
|
|
this.datasourceMap = null;
|
|
|
this.relationMap = null;
|
|
|
this.tableMap = null;
|
|
|
this.columnMap = null;
|
|
|
this.dictMap = null;
|
|
|
},
|
|
|
- loadAllDropdownData () {
|
|
|
+ loadAllDropdownData() {
|
|
|
if (Array.isArray(this.dropdownWidgetList)) {
|
|
|
this.dropdownWidgetList.forEach(dropdownWidget => {
|
|
|
let dropdownWidgetImpl = this.$refs[dropdownWidget.variableName][0];
|
|
@@ -539,12 +541,12 @@ const OnlineFormMixins = {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- reload () {
|
|
|
+ reload() {
|
|
|
this.loadOnlineFormData().then(res => {
|
|
|
this.isLoading = false;
|
|
|
if (this.formConfig.formType === this.SysOnlineFormType.FORM) {
|
|
|
if (Number.parseInt(this.operationType) === this.SysCustomWidgetOperationType.EDIT && this.saveOnClose === '1') {
|
|
|
-
|
|
|
+
|
|
|
// 编辑操作页面,初始化页面数据
|
|
|
let httpCall = null;
|
|
|
if (this.saveOnClose === '0') {
|
|
@@ -578,7 +580,7 @@ const OnlineFormMixins = {
|
|
|
this.loadAllDropdownData();
|
|
|
// 初始化组件联动
|
|
|
this.initWidgetLinkage(this.formConfig);
|
|
|
- }).catch(e => {});
|
|
|
+ }).catch(e => { });
|
|
|
return;
|
|
|
} else {
|
|
|
if (this.rowData != null) {
|
|
@@ -602,8 +604,8 @@ const OnlineFormMixins = {
|
|
|
console.log(e);
|
|
|
});
|
|
|
},
|
|
|
- onResume () {},
|
|
|
- getPrimaryKeyColumnParam (table, row) {
|
|
|
+ onResume() { },
|
|
|
+ getPrimaryKeyColumnParam(table, row) {
|
|
|
if (table && Array.isArray(table.columnList)) {
|
|
|
return table.columnList.reduce((retObj, column) => {
|
|
|
let fieldName = (table.relation ? table.relation.variableName + '__' : '') + column.columnName;
|
|
@@ -616,7 +618,7 @@ const OnlineFormMixins = {
|
|
|
|
|
|
return null;
|
|
|
},
|
|
|
- buildSubFormParams (operation, subFormInfo, row) {
|
|
|
+ buildSubFormParams(operation, subFormInfo, row) {
|
|
|
let subFormMasterTable = this.tableMap.get(subFormInfo.masterTableId);
|
|
|
if (subFormMasterTable == null) return null;
|
|
|
if (subFormMasterTable.relation == null) {
|
|
@@ -651,7 +653,7 @@ const OnlineFormMixins = {
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
- async handlerOperation (operation, row, widget) {
|
|
|
+ async handlerOperation(operation, row, widget) {
|
|
|
if (this.preview()) return;
|
|
|
if (operation.formId != null) {
|
|
|
OnlineFormController.view(this, {
|
|
@@ -728,7 +730,7 @@ const OnlineFormMixins = {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
- }).catch(e => {});
|
|
|
+ }).catch(e => { });
|
|
|
} else {
|
|
|
if (operation.type === this.SysCustomWidgetOperationType.DELETE) {
|
|
|
this.$confirm('是否删除当前数据?').then(res => {
|
|
@@ -775,86 +777,174 @@ const OnlineFormMixins = {
|
|
|
widgetObj.refresh(row, operation.type);
|
|
|
}
|
|
|
}
|
|
|
- }).catch(e => {});
|
|
|
+ }).catch(e => { });
|
|
|
} else if (operation.type === this.SysCustomWidgetOperationType.EXPORT) {
|
|
|
- console.log('row :>> ', row);
|
|
|
- let fileInfoStr = row.component_movementjson;
|
|
|
- let fileInfoArr = JSON.parse(fileInfoStr);
|
|
|
- let fileInfo = fileInfoArr[0]; // 假设只有一个文件
|
|
|
- await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/mainUnit',{
|
|
|
- params:{
|
|
|
- datasourceId: '1657931215497334784',
|
|
|
- fieldName: 'component_movementjson',
|
|
|
- asImage: false,
|
|
|
- dataId: '1657943277879431168',
|
|
|
- filename: 'db512fe1891042219ec61641625354da.json',
|
|
|
- Authorization: getToken(),
|
|
|
- MenuId: '1657932967709773824'
|
|
|
- }
|
|
|
- })
|
|
|
- .then(response => {
|
|
|
- // 处理成功的响应
|
|
|
- this.component_movementjson = response.data;
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- // 处理错误
|
|
|
- console.error(error);
|
|
|
- });
|
|
|
+ if (this.formId == 1657932361767063552) {
|
|
|
|
|
|
- fileInfoStr = row.components_json ;
|
|
|
- fileInfoArr = JSON.parse(fileInfoStr);
|
|
|
- fileInfo = fileInfoArr[0]; // 假设只有一个文件
|
|
|
- await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/mainUnit',{
|
|
|
- params:{
|
|
|
- datasourceId: '1657931215497334784',
|
|
|
- fieldName: 'components_json',
|
|
|
- asImage: false,
|
|
|
- dataId: '1657943277879431168',
|
|
|
- filename: fileInfo.filename,
|
|
|
- Authorization: getToken(),
|
|
|
- MenuId: '1657932967709773824'
|
|
|
- }
|
|
|
- })
|
|
|
+ let fileInfoStr = row.component_movementjson;
|
|
|
+ let fileInfoArr = JSON.parse(fileInfoStr);
|
|
|
+ let fileInfo = fileInfoArr[0]; // 假设只有一个文件
|
|
|
+ console.log('row[id] :>> ', row);
|
|
|
+ await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/mainUnit', {
|
|
|
+ params: {
|
|
|
+ datasourceId: '1657931215497334784',
|
|
|
+ fieldName: 'component_movementjson',
|
|
|
+ asImage: false,
|
|
|
+ dataId: row.id,
|
|
|
+ filename: fileInfo.filename,
|
|
|
+ Authorization: getToken(),
|
|
|
+ MenuId: '1657932967709773824'
|
|
|
+ }
|
|
|
+ })
|
|
|
.then(response => {
|
|
|
- // 处理成功的响应
|
|
|
+ // 处理成功的响应
|
|
|
+ this.component_movementjson = response.data;
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ // 处理错误
|
|
|
+ console.error(error);
|
|
|
+ });
|
|
|
+
|
|
|
+ fileInfoStr = row.components_json;
|
|
|
+ fileInfoArr = JSON.parse(fileInfoStr);
|
|
|
+ fileInfo = fileInfoArr[0]; // 假设只有一个文件
|
|
|
+ await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/mainUnit', {
|
|
|
+ params: {
|
|
|
+ datasourceId: '1657931215497334784',
|
|
|
+ fieldName: 'components_json',
|
|
|
+ asImage: false,
|
|
|
+ dataId: row.id,
|
|
|
+ filename: fileInfo.filename,
|
|
|
+ Authorization: getToken(),
|
|
|
+ MenuId: '1657932967709773824'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(response => {
|
|
|
+ // 处理成功的响应
|
|
|
this.components_json = response.data;
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- // 处理错误
|
|
|
- console.error(error);
|
|
|
- });
|
|
|
- console.log('components_json :>> ', this.components_json);
|
|
|
- console.log('component_movementjson :>> ', this.component_movementjson);
|
|
|
- const data = {
|
|
|
- id: row.id,
|
|
|
- name: row.name,
|
|
|
- type: row.type,
|
|
|
- creator: row.creator,
|
|
|
- createtime: row.createtime,
|
|
|
- belong: row.belong,
|
|
|
- health: row.health,
|
|
|
- target: row.target,
|
|
|
- team: row.team,
|
|
|
- task: row.task,
|
|
|
- component_movementid: row.component_movementid,
|
|
|
- component_movementjson: this.component_movementjson,
|
|
|
- components_cnt: row.components_cnt,
|
|
|
- components_ids:row.components_ids,
|
|
|
- components_json:this.components_json
|
|
|
- };
|
|
|
- const jsonData = JSON.stringify(data);
|
|
|
- const blob = new Blob([jsonData], { type: 'application/json' });
|
|
|
- const url = URL.createObjectURL(blob);
|
|
|
-
|
|
|
- const link = document.createElement('a');
|
|
|
- link.href = url;
|
|
|
- link.download = data.name+'.json';
|
|
|
- document.body.appendChild(link);
|
|
|
- link.click();
|
|
|
- document.body.removeChild(link);
|
|
|
-
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ // 处理错误
|
|
|
+ console.error(error);
|
|
|
+ });
|
|
|
+ const data = {
|
|
|
+ id: row.id,
|
|
|
+ name: row.name,
|
|
|
+ type: row.type,
|
|
|
+ creator: row.creator,
|
|
|
+ createtime: row.createtime,
|
|
|
+ belong: row.belong,
|
|
|
+ health: row.health,
|
|
|
+ target: row.target,
|
|
|
+ team: row.team,
|
|
|
+ task: row.task,
|
|
|
+ pos:{
|
|
|
+ lat: row.lat,
|
|
|
+ lon: row.lon,
|
|
|
+ height: row.height
|
|
|
+ },
|
|
|
+ component_movementid: row.component_movementid,
|
|
|
+ component_movementjson: this.component_movementjson,
|
|
|
+ components_cnt: row.components_cnt,
|
|
|
+ components_ids: row.components_ids,
|
|
|
+ components_json: this.components_json
|
|
|
+ };
|
|
|
+ const jsonData = JSON.stringify(data);
|
|
|
+ const blob = new Blob([jsonData], { type: 'application/json' });
|
|
|
+ const url = URL.createObjectURL(blob);
|
|
|
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.href = url;
|
|
|
+ link.download = data.name + '.json';
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //todo 场景想定json导出
|
|
|
+ console.log('row :>> ', row);
|
|
|
+ let fileInfoStr = row.blueunit;
|
|
|
+ let fileInfoArr = JSON.parse(fileInfoStr);
|
|
|
+ console.log('fileInfoArr :>> ', fileInfoArr);
|
|
|
+ let fileInfo = fileInfoArr[0]; // 假设只有一个文件
|
|
|
+ for(let i = 0;i<fileInfoArr.length;i++){
|
|
|
+ await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/main', {
|
|
|
+ params: {
|
|
|
+ datasourceId: '1656243335922192384',
|
|
|
+ fieldName: 'blueunit',
|
|
|
+ asImage: false,
|
|
|
+ dataId: row.id,
|
|
|
+ filename: fileInfoArr[i].filename,
|
|
|
+ Authorization: getToken(),
|
|
|
+ MenuId: '1656244747347431424'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(response => {
|
|
|
+ // 处理成功的响应
|
|
|
+ this.blueunit.push(response.data) ;
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ // 处理错误
|
|
|
+ console.error(error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ console.log('this.blueunit :>> ', this.blueunit);
|
|
|
+ fileInfoStr = row.redunit;
|
|
|
+ fileInfoArr = JSON.parse(fileInfoStr);
|
|
|
+ console.log('fileInfoArr :>> ', fileInfoArr);
|
|
|
+
|
|
|
+ for(let i = 0;i<fileInfoArr.length;i++){
|
|
|
+ await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/main', {
|
|
|
+ params: {
|
|
|
+ datasourceId: '1656243335922192384',
|
|
|
+ fieldName: 'redunit',
|
|
|
+ asImage: false,
|
|
|
+ dataId: row.id,
|
|
|
+ filename: fileInfoArr[i].filename,
|
|
|
+ Authorization: getToken(),
|
|
|
+ MenuId: '1656244747347431424'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .then(response => {
|
|
|
+ // 处理成功的响应
|
|
|
+ this.redunit.push(response.data) ;
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ // 处理错误
|
|
|
+ console.error(error);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ console.log('this.redunit :>> ', this.redunit);
|
|
|
+ const data = {
|
|
|
+ id: row.id,
|
|
|
+ xdname: row.xdname,
|
|
|
+ type: row.type,
|
|
|
+ creator: row.creator,
|
|
|
+ createtime: row.createtime,
|
|
|
+ redcnt: row.redcnt,
|
|
|
+ bluecnt: row.bluecnt,
|
|
|
+ target: row.target,
|
|
|
+ starttime: row.starttime,
|
|
|
+ steptime: row.steptime ,
|
|
|
+ blueunit: this.blueunit,
|
|
|
+ redunit: this.redunit,
|
|
|
+ };
|
|
|
+ const jsonData = JSON.stringify(data);
|
|
|
+ const blob = new Blob([jsonData], { type: 'application/json' });
|
|
|
+ const url = URL.createObjectURL(blob);
|
|
|
+
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.href = url;
|
|
|
+ link.download = data.xdname + '.json';
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link);
|
|
|
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
httpCall.then(res => {
|
|
@@ -865,8 +955,8 @@ const OnlineFormMixins = {
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
- getRelationTableData (tableWidget) {
|
|
|
+
|
|
|
+ getRelationTableData(tableWidget) {
|
|
|
if (tableWidget.widgetType === this.SysCustomWidgetType.Table) {
|
|
|
let table = tableWidget.table;
|
|
|
let temp = this.$refs[tableWidget.variableName];
|
|
@@ -883,7 +973,7 @@ const OnlineFormMixins = {
|
|
|
}
|
|
|
return null;
|
|
|
},
|
|
|
- getWidgetPrimaryColumnId (widget) {
|
|
|
+ getWidgetPrimaryColumnId(widget) {
|
|
|
let columnList = null;
|
|
|
if (widget.relationId == null) {
|
|
|
columnList = widget.datasource.masterTable.columnList;
|
|
@@ -904,16 +994,16 @@ const OnlineFormMixins = {
|
|
|
},
|
|
|
...mapMutations(['addOnlineFormCache'])
|
|
|
},
|
|
|
- created () {
|
|
|
+ created() {
|
|
|
this.reload();
|
|
|
|
|
|
},
|
|
|
- destoryed () {
|
|
|
+ destoryed() {
|
|
|
this.clean();
|
|
|
},
|
|
|
watch: {
|
|
|
formId: {
|
|
|
- handler (newValue) {
|
|
|
+ handler(newValue) {
|
|
|
this.reload();
|
|
|
}
|
|
|
}
|