onlineFormMixins.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317
  1. import { mapMutations } from 'vuex';
  2. import * as StaticDict from '@/staticDict';
  3. import { getToken } from '@/utils';
  4. import rules from '@/utils/validate.js';
  5. import { getOperationPermCode } from '../utils/index.js';
  6. import OnlineForm from '@/views/onlineForm/index.vue';
  7. import {
  8. OnlineFormController
  9. } from '@/api/onlineController.js';
  10. import axios from 'axios';
  11. import { uploadMixin } from '@/core/mixins';
  12. const OnlineFormMixins = {
  13. props: {
  14. formId: {
  15. type: String,
  16. required: true
  17. },
  18. readOnly: {
  19. type: Boolean,
  20. default: false
  21. },
  22. closeVisible: {
  23. type: String,
  24. default: '0'
  25. },
  26. params: {
  27. type: Object
  28. }
  29. },
  30. mixins: [uploadMixin],
  31. data () {
  32. return {
  33. isLoading: true,
  34. formData: {},
  35. rules: {},
  36. components_json: {},
  37. blueunit: [],
  38. redunit: [],
  39. center: [],
  40. satellite: [],
  41. toll_json: {},
  42. component_movementjson: {},
  43. formConfig: {
  44. formType: undefined,
  45. formKind: undefined,
  46. gutter: 20,
  47. labelPosition: 'right',
  48. labelWidth: 120,
  49. width: undefined,
  50. height: undefined,
  51. formWidgetList: [],
  52. formQueryTable: undefined
  53. },
  54. masterTable: undefined,
  55. errorMessage: [],
  56. tableWidgetList: [],
  57. dropdownWidgetList: [],
  58. richEditWidgetList: [],
  59. datasourceMap: new Map(),
  60. relationMap: new Map(),
  61. tableMap: new Map(),
  62. columnMap: new Map(),
  63. dictMap: new Map(),
  64. linkageMap: new Map()
  65. }
  66. },
  67. methods: {
  68. getFormData () {
  69. return this.formData;
  70. },
  71. getPermCode (widget, operation) {
  72. return getOperationPermCode(widget, operation);
  73. },
  74. loadOnlineFormData () {
  75. return new Promise((resolve, reject) => {
  76. OnlineFormController.render(this, {
  77. formId: this.formId
  78. }).then(res => {
  79. let onlineForm = res.data.onlineForm;
  80. let formConfigData = JSON.parse(onlineForm.widgetJson);
  81. let formConfig = {
  82. formName: onlineForm.formName,
  83. formType: onlineForm.formType,
  84. formKind: onlineForm.formKind,
  85. masterTableId: onlineForm.masterTableId,
  86. labelWidth: formConfigData.formConfig.labelWidth,
  87. labelPosition: formConfigData.formConfig.labelPosition,
  88. gutter: formConfigData.formConfig.gutter,
  89. height: formConfigData.formConfig.height,
  90. width: formConfigData.formConfig.width,
  91. formWidgetList: formConfigData.widgetList,
  92. formQueryTable: formConfigData.formConfig.tableWidget
  93. }
  94. onlineForm = null;
  95. res.data.onlineForm = null;
  96. // 字典
  97. if (Array.isArray(res.data.onlineDictList)) {
  98. res.data.onlineDictList.forEach(dict => {
  99. this.dictMap.set(dict.dictId, dict);
  100. });
  101. }
  102. res.data.onlineDictList = null;
  103. // 数据表
  104. if (Array.isArray(res.data.onlineTableList)) {
  105. res.data.onlineTableList.forEach(table => {
  106. this.tableMap.set(table.tableId, table);
  107. });
  108. }
  109. res.data.onlineTableList = null;
  110. // 字段
  111. if (Array.isArray(res.data.onlineColumnList)) {
  112. res.data.onlineColumnList.forEach(column => {
  113. if (column.dictId != null) {
  114. column.dictInfo = this.dictMap.get(column.dictId);
  115. }
  116. let table = this.tableMap.get(column.tableId);
  117. if (table) {
  118. if (!Array.isArray(table.columnList)) table.columnList = [];
  119. table.columnList.push(column);
  120. }
  121. this.columnMap.set(column.columnId, column);
  122. });
  123. }
  124. res.data.onlineColumnList = null;
  125. // 虚拟字段
  126. if (Array.isArray(res.data.onlineVirtualColumnList)) {
  127. res.data.onlineVirtualColumnList.forEach(column => {
  128. column.columnId = column.virtualColumnId;
  129. column.columnComment = column.columnPrompt;
  130. column.columnName = column.objectFieldName;
  131. column.primaryKey = false;
  132. column.isVirtualColumn = true;
  133. this.columnMap.set(column.columnId, column);
  134. });
  135. }
  136. res.data.onlineVirtualColumnList = null;
  137. // 数据源
  138. if (Array.isArray(res.data.onlineDatasourceList)) {
  139. res.data.onlineDatasourceList.forEach(datasource => {
  140. datasource.masterTable = this.tableMap.get(datasource.masterTableId);
  141. if (datasource.masterTable) datasource.masterTable.datasource = datasource;
  142. this.datasourceMap.set(datasource.datasourceId, datasource);
  143. });
  144. }
  145. res.data.onlineDatasourceList = null;
  146. // 关联
  147. if (Array.isArray(res.data.onlineDatasourceRelationList)) {
  148. res.data.onlineDatasourceRelationList.forEach(relation => {
  149. let datasource = this.datasourceMap.get(relation.datasourceId);
  150. if (datasource) {
  151. if (!Array.isArray(datasource.relationList)) datasource.relationList = [];
  152. datasource.relationList.push(relation);
  153. }
  154. relation.masterColumn = this.columnMap.get(relation.masterColumnId);
  155. relation.slaveTable = this.tableMap.get(relation.slaveTableId);
  156. if (relation.slaveTable) {
  157. relation.slaveTable.relation = relation;
  158. relation.slaveTable.datasource = datasource;
  159. }
  160. relation.slaveColumn = this.columnMap.get(relation.slaveColumnId);
  161. this.relationMap.set(relation.relationId, relation);
  162. });
  163. }
  164. res.data.onlineDatasourceRelationList = null;
  165. // 校验规则
  166. if (Array.isArray(res.data.onlineColumnRuleList)) {
  167. res.data.onlineColumnRuleList.forEach(rule => {
  168. let column = this.columnMap.get(rule.columnId);
  169. if (column) {
  170. if (!Array.isArray(column.ruleList)) column.ruleList = [];
  171. column.ruleList.push(rule);
  172. }
  173. });
  174. }
  175. res.data.onlineColumnRuleList = null;
  176. this.initFormData(formConfig);
  177. this.formConfig = formConfig;
  178. resolve();
  179. }).catch(e => {
  180. reject(e);
  181. });
  182. });
  183. },
  184. initWidget (widget, formConfig) {
  185. if (widget != null) {
  186. if (widget.datasourceId) widget.datasource = this.datasourceMap.get(widget.datasourceId);
  187. if (widget.relationId) {
  188. widget.relation = this.relationMap.get(widget.relationId);
  189. if (widget.datasource == null && widget.relation != null) {
  190. widget.datasource = this.datasourceMap.get(widget.relation.datasourceId);
  191. }
  192. }
  193. if (widget.datasource == null) {
  194. widget.datasource = {
  195. masterTable: {}
  196. }
  197. widget.column = {}
  198. }
  199. if (widget.tableId) widget.table = this.tableMap.get(widget.tableId);
  200. if (widget.columnId) widget.column = this.columnMap.get(widget.columnId);
  201. if (widget.widgetType === this.SysCustomWidgetType.RichEditor) {
  202. this.richEditWidgetList.push(widget);
  203. }
  204. // 初始化组件下拉字典参数
  205. if (Array.isArray(widget.dictParamList)) {
  206. widget.dictParamList.forEach(param => {
  207. if (param.dictValueType === this.SysOnlineParamValueType.STATIC_DICT) {
  208. let errorItem = null;
  209. if (Array.isArray(param.dictValue) && param.dictValue.length === 2) {
  210. let staticDict = StaticDict[param.dictValue[0]];
  211. if (staticDict == null) {
  212. errorItem = {
  213. widget: widget,
  214. message: '组件字典参数' + param.dictParamName + '绑定的静态字典 [' + param.dictValue[0] + '] 并不存在!'
  215. }
  216. } else {
  217. if (staticDict.getValue(param.dictValue[1]) == null) {
  218. errorItem = {
  219. widget: widget,
  220. message: '组件字典参数' + param.dictParamName + '绑定的静态字典值并不属于静态字段 [' + param.dictValue[0] + '] !'
  221. }
  222. }
  223. }
  224. } else {
  225. errorItem = {
  226. widget: widget,
  227. message: '组件字典参数' + param.dictParamName + '绑定的静态字典错误!'
  228. }
  229. }
  230. if (errorItem != null) this.errorMessage.push(errorItem);
  231. }
  232. });
  233. }
  234. if (widget.column && widget.column.dictInfo != null) {
  235. this.dropdownWidgetList.push(widget);
  236. }
  237. // 初始化表格列
  238. if (widget.widgetType === this.SysCustomWidgetType.Table) {
  239. // 寻找表格主键
  240. widget.primaryColumnName = undefined;
  241. if (widget.table && Array.isArray(widget.table.columnList)) {
  242. for (let i = 0; i < widget.table.columnList.length; i++) {
  243. if (widget.table.columnList[i].primaryKey) {
  244. widget.primaryColumnName = widget.table.columnList[i].columnName;
  245. break;
  246. }
  247. }
  248. }
  249. if (Array.isArray(widget.tableColumnList)) {
  250. widget.tableColumnList.forEach(tableColumn => {
  251. tableColumn.table = this.tableMap.get(tableColumn.tableId);
  252. tableColumn.column = this.columnMap.get(tableColumn.columnId);
  253. tableColumn.relation = this.relationMap.get(tableColumn.relationId);
  254. if (tableColumn.table == null || tableColumn.column == null) {
  255. this.errorMessage.push({
  256. widget: widget,
  257. message: '表格列 [' + tableColumn.showName + '] 绑定的字段不存在!'
  258. });
  259. }
  260. });
  261. }
  262. if (Array.isArray(widget.queryParamList)) {
  263. widget.queryParamList.forEach(param => {
  264. param.table = this.tableMap.get(param.tableId);
  265. param.column = this.columnMap.get(param.columnId);
  266. param.relation = this.relationMap.get(param.relationId);
  267. if (param.table == null || param.column == null) {
  268. this.errorMessage.push({
  269. widget: widget,
  270. message: '表格查询参数不存在!'
  271. });
  272. }
  273. });
  274. }
  275. this.tableWidgetList.push(widget);
  276. }
  277. while (widget.datasourceId != null || widget.relationId != null) {
  278. if (widget.datasourceId == null && widget.relation == null) {
  279. let errorItem = {
  280. widget: widget,
  281. message: '组件绑定字段所属' + (widget.datasourceId ? '数据源' : '关联') + '不存在!'
  282. }
  283. this.errorMessage.push(errorItem);
  284. break;
  285. }
  286. if (widget.table == null) {
  287. let errorItem = {
  288. widget: widget,
  289. messagre: '组件绑定字段所属数据表不存在!'
  290. }
  291. this.errorMessage.push(errorItem);
  292. break;
  293. }
  294. if (widget.column == null && widget.columnId != null) {
  295. let errorItem = {
  296. widget: widget,
  297. messagre: '组件绑定字段不存在!'
  298. }
  299. this.errorMessage.push(errorItem);
  300. break;
  301. }
  302. if (widget.column) {
  303. let table = this.tableMap.get(widget.tableId);
  304. if (table.tableId !== widget.table.tableId) {
  305. let errorItem = {
  306. widget: widget,
  307. messagre: '组件绑定字段不属于选张的数据表!'
  308. }
  309. this.errorMessage.push(errorItem);
  310. break;
  311. }
  312. }
  313. break;
  314. }
  315. if (Array.isArray(widget.childWidgetList)) {
  316. widget.childWidgetList.forEach(subWidget => {
  317. if (formConfig.formType === this.SysOnlineFormType.FLOW && this.formReadOnly) {
  318. subWidget.readOnly = true;
  319. }
  320. this.initWidget(subWidget, formConfig);
  321. })
  322. }
  323. if (widget.column && widget.column.dictInfo) {
  324. if (Array.isArray(widget.dictParamList)) {
  325. widget.dictParamList.forEach(dictParam => {
  326. if (dictParam.dictValueType === this.SysOnlineParamValueType.TABLE_COLUMN) {
  327. let linkageItem = this.linkageMap.get(dictParam.dictValue);
  328. if (linkageItem == null) {
  329. linkageItem = [];
  330. this.linkageMap.set(dictParam.dictValue, linkageItem);
  331. }
  332. linkageItem.push(widget);
  333. }
  334. });
  335. }
  336. }
  337. }
  338. },
  339. initFormWidgetList (formConfig) {
  340. this.errorMessage = [];
  341. if (Array.isArray(formConfig.formWidgetList)) {
  342. formConfig.formWidgetList.forEach(widget => {
  343. if (formConfig.formType === this.SysOnlineFormType.FLOW && this.formReadOnly) {
  344. widget.readOnly = true;
  345. }
  346. this.initWidget(widget, formConfig);
  347. });
  348. }
  349. if (this.errorMessage.length > 0) {
  350. console.error(this.errorMessage);
  351. }
  352. },
  353. buildRuleItem (widget, rule) {
  354. if (rule.propDataJson) rule.data = JSON.parse(rule.propDataJson);
  355. if (widget != null && rule != null) {
  356. switch (rule.onlineRule.ruleType) {
  357. case this.SysOnlineRuleType.INTEGER_ONLY:
  358. return { type: 'integer', message: rule.data.message, trigger: 'blur', transform: (value) => Number(value) };
  359. case this.SysOnlineRuleType.DIGITAL_ONLY:
  360. return { type: 'number', message: rule.data.message, trigger: 'blur', transform: (value) => Number(value) };
  361. case this.SysOnlineRuleType.LETTER_ONLY:
  362. return { type: 'string', pattern: rules.pattern.english, message: rule.data.message, trigger: 'blur' };
  363. case this.SysOnlineRuleType.EMAIL:
  364. return { type: 'email', message: rule.data.message, trigger: 'blur' };
  365. case this.SysOnlineRuleType.MOBILE:
  366. return { type: 'string', pattern: rules.pattern.mobie, message: rule.data.message, trigger: 'blur' };
  367. case this.SysOnlineRuleType.RANGE:
  368. if (widget.column) {
  369. let isNumber = ['Boolean', 'Date', 'String'].indexOf(widget.column.objectFieldType) === -1;
  370. return { type: isNumber ? 'number' : 'string', min: rule.data.min, max: rule.data.max, message: rule.data.message, trigger: 'blur' };
  371. }
  372. break;
  373. case this.SysOnlineRuleType.CUSTOM:
  374. return { type: 'string', pattern: new RegExp(rule.data.pattern), message: rule.data.message, trigger: 'blur' };
  375. }
  376. }
  377. },
  378. buildWidgetRule (widget, rules) {
  379. if (widget != null && widget.column != null) {
  380. let widgetRuleKey = (widget.relation ? widget.relation.variableName + '__' : '') + widget.column.columnName;
  381. // 必填字段以及设置了验证规则的字段
  382. if (!widget.column.nullable || Array.isArray(widget.column.ruleList)) {
  383. rules[widgetRuleKey] = [];
  384. // 必填验证
  385. if (!widget.column.nullable) {
  386. rules[widgetRuleKey].push(
  387. { required: true, message: widget.showName + '不能为空!', trigger: 'true' }
  388. )
  389. }
  390. // 其他验证
  391. if (Array.isArray(widget.column.ruleList)) {
  392. widget.column.ruleList.forEach(rule => {
  393. let ruleItem = this.buildRuleItem(widget, rule);
  394. if (ruleItem) rules[widgetRuleKey].push(ruleItem);
  395. });
  396. }
  397. }
  398. }
  399. },
  400. initWidgetRule (formConfig) {
  401. if (Array.isArray(formConfig.formWidgetList)) {
  402. let rules = {};
  403. formConfig.formWidgetList.forEach(widget => {
  404. this.buildWidgetRule(widget, rules);
  405. });
  406. this.$set(this, 'rules', rules);
  407. this.$nextTick(() => {
  408. if (this.$refs.form) this.$refs.form.clearValidate();
  409. });
  410. }
  411. },
  412. initFormDatasourceData (formConfig) {
  413. let that = this;
  414. function addFormDataByColumn (retObj, column, relation) {
  415. let fieldName = (relation ? relation.variableName + '__' : '') + column.columnName;
  416. if (retObj == null) retObj = {};
  417. if (formConfig.formType === that.SysOnlineFormType.QUERY) {
  418. if (retObj.formFilter == null) retObj.formFilter = {};
  419. if (retObj.formFilterCopy == null) retObj.formFilterCopy = {};
  420. retObj.formFilter[fieldName] = column.objectFieldType === 'Boolean' ? false : undefined;
  421. retObj.formFilterCopy[fieldName] = column.objectFieldType === 'Boolean' ? false : undefined;
  422. } else {
  423. retObj[fieldName] = column.objectFieldType === 'Boolean' ? false : undefined;
  424. }
  425. return retObj;
  426. }
  427. // 设置数据源数据
  428. let datasourceFormData = {};
  429. if (this.masterTable) {
  430. // 添加表单主表的数据
  431. this.masterTable.columnList.forEach(column => {
  432. datasourceFormData = addFormDataByColumn(datasourceFormData, column, this.masterTable.relation);
  433. });
  434. // 如果表单主表是数据源主表,添加关联数据
  435. if (this.masterTable.relation == null) {
  436. let datasource = this.masterTable.datasource;
  437. if (datasource != null && Array.isArray(datasource.relationList)) {
  438. datasource.relationList.forEach(relation => {
  439. // 一对一关联从表数据
  440. if (relation.relationType === this.SysOnlineRelationType.ONE_TO_ONE) {
  441. let slaveTable = this.tableMap.get(relation.slaveTableId);
  442. if (slaveTable && Array.isArray(slaveTable.columnList)) {
  443. slaveTable.columnList.forEach(column => {
  444. datasourceFormData = addFormDataByColumn(datasourceFormData, column, relation);
  445. });
  446. }
  447. }
  448. });
  449. }
  450. }
  451. }
  452. this.$set(this, 'formData', datasourceFormData);
  453. },
  454. initWidgetLinkage (formConfig) {
  455. this.linkageMap.forEach((widgetList, key) => {
  456. let column = this.columnMap.get(key);
  457. let watchKey = null;
  458. if (formConfig.formType === this.SysOnlineFormType.QUERY) {
  459. watchKey = 'formData.formFilter.' + column.columnName;
  460. } else {
  461. watchKey = 'formData.' + column.columnName;
  462. }
  463. this.$watch(watchKey, (newValue) => {
  464. if (Array.isArray(widgetList)) {
  465. widgetList.forEach(widget => {
  466. if (Array.isArray(this.$refs[widget.variableName])) {
  467. this.$refs[widget.variableName].forEach(ref => {
  468. ref.reset();
  469. });
  470. } else {
  471. this.$refs[widget.variableName].reset();
  472. }
  473. });
  474. }
  475. });
  476. });
  477. },
  478. initFormData (formConfig) {
  479. this.masterTable = this.tableMap.get(formConfig.masterTableId);
  480. // 初始化表单数据
  481. this.initFormDatasourceData(formConfig);
  482. // 初始化表单组件
  483. this.initWidget(formConfig.formQueryTable, formConfig);
  484. this.initFormWidgetList(formConfig);
  485. // 初始化校验信息
  486. this.initWidgetRule(formConfig);
  487. },
  488. getParamValue (valueType, valueData) {
  489. switch (valueType) {
  490. case this.SysOnlineParamValueType.FORM_PARAM:
  491. return this.params ? this.params[valueData] : undefined;
  492. case this.SysOnlineParamValueType.TABLE_COLUMN:
  493. {
  494. let column = this.columnMap.get(valueData);
  495. let columnValue = null;
  496. if (this.formConfig.formType === this.SysOnlineFormType.QUERY) {
  497. columnValue = this.formData.formFilterCopy[column.columnName];
  498. } else {
  499. columnValue = this.formData[column.columnName];
  500. }
  501. if (column == null || columnValue == null || columnValue === '') {
  502. return null;
  503. } else {
  504. return columnValue;
  505. }
  506. }
  507. case this.SysOnlineParamValueType.STATIC_DICT:
  508. return Array.isArray(valueData) ? valueData[1] : undefined;
  509. case this.SysOnlineParamValueType.INPUT_VALUE:
  510. return valueData;
  511. }
  512. },
  513. getParamValueObj (paramName, valueType, valueData, retObj) {
  514. try {
  515. if (retObj == null) retObj = {};
  516. retObj[paramName] = this.getParamValue(valueType, valueData);
  517. if (retObj[paramName] == null) return null;
  518. return retObj;
  519. } catch (e) {
  520. console.log(e);
  521. }
  522. },
  523. clean () {
  524. this.datasourceMap = null;
  525. this.relationMap = null;
  526. this.tableMap = null;
  527. this.columnMap = null;
  528. this.dictMap = null;
  529. },
  530. loadAllDropdownData () {
  531. if (Array.isArray(this.dropdownWidgetList)) {
  532. this.dropdownWidgetList.forEach(dropdownWidget => {
  533. let dropdownWidgetImpl = this.$refs[dropdownWidget.variableName][0];
  534. if (dropdownWidgetImpl) {
  535. dropdownWidgetImpl.onVisibleChange();
  536. }
  537. });
  538. }
  539. },
  540. reload () {
  541. this.loadOnlineFormData().then(res => {
  542. this.isLoading = false;
  543. if (this.formConfig.formType === this.SysOnlineFormType.FORM) {
  544. if (Number.parseInt(this.operationType) === this.SysCustomWidgetOperationType.EDIT && this.saveOnClose === '1') {
  545. // 编辑操作页面,初始化页面数据
  546. let httpCall = null;
  547. if (this.saveOnClose === '0') {
  548. httpCall = Promise.resolve({
  549. data: this.params
  550. });
  551. } else {
  552. let params = {
  553. datasourceId: (this.masterTable.datasource || {}).datasourceId,
  554. relationId: (this.masterTable.relation || {}).relationId
  555. }
  556. for (let i = 0; i < this.masterTable.columnList.length; i++) {
  557. let column = this.masterTable.columnList[i];
  558. if (column.primaryKey) {
  559. params.dataId = this.params[column.columnName];
  560. break;
  561. }
  562. }
  563. if (params.relationId) {
  564. httpCall = this.doUrl('/admin/online/onlineOperation/viewByOneToManyRelationId/' + (this.masterTable.datasource || {}).variableName, 'get', params);
  565. } else {
  566. httpCall = this.doUrl('/admin/online/onlineOperation/viewByDatasourceId/' + (this.masterTable.datasource || {}).variableName, 'get', params);
  567. }
  568. }
  569. httpCall.then(res => {
  570. this.formData = {
  571. ...this.formData,
  572. ...res.data
  573. }
  574. this.loadAllDropdownData();
  575. // 初始化组件联动
  576. this.initWidgetLinkage(this.formConfig);
  577. }).catch(e => { });
  578. return;
  579. } else {
  580. if (this.rowData != null) {
  581. this.formData = {
  582. ...this.rowData
  583. }
  584. }
  585. }
  586. this.loadAllDropdownData();
  587. }
  588. setTimeout(() => {
  589. if (this.formConfig.formType === this.SysOnlineFormType.FLOW) {
  590. this.loadAllDropdownData();
  591. }
  592. // 初始化组件联动
  593. this.initWidgetLinkage(this.formConfig);
  594. this.onResume();
  595. this.$emit('ready');
  596. }, 30);
  597. }).catch(e => {
  598. console.log(e);
  599. });
  600. },
  601. onResume () { },
  602. getPrimaryKeyColumnParam (table, row) {
  603. if (table && Array.isArray(table.columnList)) {
  604. return table.columnList.reduce((retObj, column) => {
  605. let fieldName = (table.relation ? table.relation.variableName + '__' : '') + column.columnName;
  606. if (column.primaryKey) {
  607. retObj[column.columnName] = row ? row[fieldName] : undefined;
  608. }
  609. return retObj;
  610. }, {});
  611. }
  612. return null;
  613. },
  614. buildSubFormParams (operation, subFormInfo, row) {
  615. let subFormMasterTable = this.tableMap.get(subFormInfo.masterTableId);
  616. if (subFormMasterTable == null) return null;
  617. if (subFormMasterTable.relation == null) {
  618. // 下级表单操作的是主表数据的编辑
  619. if (operation.type === this.SysCustomWidgetOperationType.EDIT) {
  620. return this.getPrimaryKeyColumnParam(this.masterTable, row);
  621. } else {
  622. return null;
  623. }
  624. } else {
  625. // 下级表单操作的是从表
  626. if (subFormInfo.formType === this.SysOnlineFormType.QUERY) {
  627. // 从表的查询页面,参数为主表主键
  628. return this.getPrimaryKeyColumnParam(this.masterTable, row);
  629. } else {
  630. if (operation.type === this.SysCustomWidgetOperationType.EDIT) {
  631. // 从表的编辑页面
  632. if (this.formConfig.formType === this.SysOnlineFormType.FORM &&
  633. Number.parseInt(this.operationType) === this.SysCustomWidgetOperationType.ADD) {
  634. return {
  635. ...row
  636. }
  637. } else {
  638. return this.getPrimaryKeyColumnParam(subFormMasterTable, row);
  639. }
  640. } else {
  641. // 从表的添加页面
  642. return {
  643. ...this.params
  644. }
  645. }
  646. }
  647. }
  648. },
  649. async handlerOperation (operation, row, widget) {
  650. if (this.preview()) return;
  651. if (operation.formId != null) {
  652. OnlineFormController.view(this, {
  653. formId: operation.formId
  654. }).then(res => {
  655. let formInfo = res.data;
  656. if (formInfo != null) {
  657. let params = this.buildSubFormParams(operation, formInfo, row);
  658. if (formInfo.formKind === this.SysOnlineFormKind.DIALOG) {
  659. let formJsonData = JSON.parse(formInfo.widgetJson);
  660. let area = (formInfo.height != null) ? [(formJsonData.formConfig.width || 800) + 'px', formJsonData.formConfig.height + 'px'] : (formJsonData.formConfig.width || 800) + 'px';
  661. this.$dialog.show(operation.name, OnlineForm, {
  662. area: area,
  663. offset: '100px'
  664. }, {
  665. flowData: this.flowData,
  666. formId: formInfo.formId,
  667. formType: formInfo.formType,
  668. operationType: operation.type,
  669. params,
  670. saveOnClose: (
  671. formInfo.formType === this.SysOnlineFormType.FLOW || this.formConfig.formType === this.SysOnlineFormType.FLOW ||
  672. (
  673. formInfo.formType === this.SysOnlineFormType.FORM &&
  674. Number.parseInt(this.operationType) === this.SysCustomWidgetOperationType.ADD
  675. )
  676. ) ? '0' : '1',
  677. rowData: row
  678. }).then(res => {
  679. let widgetObj = this.$refs[widget.variableName];
  680. if (Array.isArray(widgetObj)) {
  681. widgetObj.forEach(item => {
  682. item.refresh(res, operation.type);
  683. });
  684. } else {
  685. widgetObj.refresh(res, operation.type);
  686. }
  687. }).catch(e => {
  688. });
  689. } else {
  690. if (this.formConfig.formType === this.SysOnlineFormType.QUERY) {
  691. let tableWidget = this.$refs[this.formConfig.formQueryTable.variableName].getTableWidget();
  692. this.addOnlineFormCache({
  693. key: this.$route.fullPath,
  694. value: {
  695. formFilter: { ...this.formData.formFilter },
  696. formFilterCopy: { ...this.formData.formFilterCopy },
  697. tableImpl: {
  698. totalCount: tableWidget.totalCount,
  699. currentPage: tableWidget.currentPage,
  700. pageSize: tableWidget.pageSize
  701. }
  702. }
  703. });
  704. }
  705. this.$router.push({
  706. name: 'onlineForm',
  707. query: {
  708. flowData: this.flowData,
  709. formId: formInfo.formId,
  710. formType: formInfo.formType,
  711. closeVisible: '1',
  712. operationType: operation.type,
  713. params,
  714. saveOnClose: (
  715. formInfo.formType === this.SysOnlineFormType.FLOW || this.formConfig.formType === this.SysOnlineFormType.FLOW ||
  716. (
  717. formInfo.formType === this.SysOnlineFormType.FORM &&
  718. Number.parseInt(this.operationType) === this.SysCustomWidgetOperationType.ADD
  719. )
  720. ) ? '0' : '1',
  721. rowData: row
  722. }
  723. })
  724. }
  725. }
  726. }).catch(e => { });
  727. } else {
  728. if (operation.type === this.SysCustomWidgetOperationType.DELETE) {
  729. this.$confirm('是否删除当前数据?').then(res => {
  730. if (this.formConfig.formType !== this.SysOnlineFormType.FLOW &&
  731. (this.formConfig.formType !== this.SysOnlineFormType.FORM || Number.parseInt(this.operationType) !== this.SysCustomWidgetOperationType.ADD)) {
  732. let params = {
  733. datasourceId: (widget.table.datasource || {}).datasourceId,
  734. relationId: (widget.table.relation || {}).relationId
  735. }
  736. for (let i = 0; i < widget.table.columnList.length; i++) {
  737. let column = widget.table.columnList[i];
  738. if (column.primaryKey) {
  739. let fieldName = (widget.table.relation ? widget.table.relation.variableName + '__' : '') + column.columnName;
  740. params.dataId = row[fieldName];
  741. break;
  742. }
  743. }
  744. let httpCall = null;
  745. if (params.relationId) {
  746. httpCall = this.doUrl('/admin/online/onlineOperation/deleteOneToManyRelation/' + widget.datasource.variableName, 'post', params);
  747. } else {
  748. httpCall = this.doUrl('/admin/online/onlineOperation/deleteDatasource/' + widget.datasource.variableName, 'post', params);
  749. }
  750. httpCall.then(res => {
  751. this.$message.success('删除成功!');
  752. let widgetObj = this.$refs[widget.variableName];
  753. if (Array.isArray(widgetObj)) {
  754. widgetObj.forEach(item => {
  755. item.refresh(res, operation.type);
  756. });
  757. } else {
  758. widgetObj.refresh(res, operation.type);
  759. }
  760. }).catch(e => {
  761. });
  762. } else {
  763. let widgetObj = this.$refs[widget.variableName];
  764. if (Array.isArray(widgetObj)) {
  765. widgetObj.forEach(item => {
  766. item.refresh(row, operation.type);
  767. });
  768. } else {
  769. widgetObj.refresh(row, operation.type);
  770. }
  771. }
  772. }).catch(e => { });
  773. } else if (operation.type === this.SysCustomWidgetOperationType.EXPORT) {
  774. console.log('this.formId :>> ', this.formId);
  775. if (this.formId == 1657932361767063552) {
  776. let fileInfoStr = row.component_movementjson;
  777. if (fileInfoStr != undefined) {
  778. let fileInfoArr = JSON.parse(fileInfoStr);
  779. let fileInfo = fileInfoArr[0]; // 假设只有一个文件
  780. await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/mainUnit', {
  781. params: {
  782. datasourceId: '1657931215497334784',
  783. fieldName: 'component_movementjson',
  784. asImage: false,
  785. dataId: row.id,
  786. filename: fileInfo.filename,
  787. Authorization: getToken(),
  788. MenuId: '1657932967709773824'
  789. }
  790. })
  791. .then(response => {
  792. // 处理成功的响应
  793. this.component_movementjson = response.data;
  794. })
  795. .catch(error => {
  796. // 处理错误
  797. console.error(error);
  798. });
  799. }
  800. fileInfoStr = row.components_json;
  801. let fileInfoArr1 = JSON.parse(fileInfoStr);
  802. let fileInfo1 = fileInfoArr1[0]; // 假设只有一个文件
  803. await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/mainUnit', {
  804. params: {
  805. datasourceId: '1657931215497334784',
  806. fieldName: 'components_json',
  807. asImage: false,
  808. dataId: row.id,
  809. filename: fileInfo1.filename,
  810. Authorization: getToken(),
  811. MenuId: '1657932967709773824'
  812. }
  813. })
  814. .then(response => {
  815. // 处理成功的响应
  816. this.components_json = response.data;
  817. })
  818. .catch(error => {
  819. // 处理错误
  820. console.error(error);
  821. });
  822. fileInfoStr = row.toll_json;
  823. let fileInfoArr2 = JSON.parse(fileInfoStr);
  824. let fileInfo2 = fileInfoArr2[0]; // 假设只有一个文件
  825. await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/mainUnit', {
  826. params: {
  827. datasourceId: '1657931215497334784',
  828. fieldName: 'toll_json',
  829. asImage: false,
  830. dataId: row.id,
  831. filename: fileInfo2.filename,
  832. Authorization: getToken(),
  833. MenuId: '1657932967709773824'
  834. }
  835. })
  836. .then(response => {
  837. // 处理成功的响应
  838. this.toll_json.push(response.data);
  839. })
  840. .catch(error => {
  841. // 处理错误
  842. console.error(error);
  843. });
  844. const data = {
  845. id: row.id,
  846. name: row.name,
  847. type: row.type,
  848. creator: row.creator,
  849. createtime: row.createtime,
  850. belong: row.belong,
  851. health: row.health,
  852. target: row.target,
  853. team: row.team,
  854. task: row.task,
  855. pos: {
  856. lat: row.lat,
  857. lon: row.lon,
  858. height: row.height
  859. },
  860. toll_json: this.toll_json,
  861. component_movementid: row.component_movementid,
  862. component_movementjson: this.component_movementjson,
  863. components_cnt: row.components_cnt,
  864. components_ids: row.components_ids,
  865. components_json: this.components_json
  866. };
  867. const jsonData = JSON.stringify(data);
  868. const blob = new Blob([jsonData], { type: 'application/json' });
  869. const url = URL.createObjectURL(blob);
  870. const link = document.createElement('a');
  871. link.href = url;
  872. link.download = data.name + '.json';
  873. document.body.appendChild(link);
  874. link.click();
  875. document.body.removeChild(link);
  876. } else if (this.formId == 1675055217952952320) {
  877. console.log('row :>> ', row);
  878. let number = row.number
  879. const data = {};
  880. data[number] = {
  881. type: row.type,
  882. properties: {
  883. id: row.id,
  884. lon: row.lon,
  885. lat: row.lat,
  886. h: row.h,
  887. picture: row.picture
  888. }
  889. }
  890. data['name'] = row.number
  891. const jsonData = JSON.stringify(data);
  892. const blob = new Blob([jsonData], { type: 'application/json' });
  893. const url = URL.createObjectURL(blob);
  894. const link = document.createElement('a');
  895. link.href = url;
  896. link.download = '指挥中心-' + row.number + '.json';
  897. document.body.appendChild(link);
  898. link.click();
  899. document.body.removeChild(link);
  900. }
  901. else if (this.formId == 1705138897635250176){
  902. let name = row.name
  903. const data = {};
  904. data[name] = {
  905. id: row.id,
  906. name: row.name,
  907. type: row.type,
  908. height: row.height,
  909. range: row.range,
  910. number: row.number
  911. }
  912. data['name'] = row.name
  913. const jsonData = JSON.stringify(data);
  914. const blob = new Blob([jsonData], { type: 'application/json' });
  915. const url = URL.createObjectURL(blob);
  916. const link = document.createElement('a');
  917. link.href = url;
  918. link.download = '拦截导弹-' + row.name + '.json';
  919. document.body.appendChild(link);
  920. link.click();
  921. document.body.removeChild(link);
  922. }
  923. else if (this.formId == 1675055674104483840) {
  924. let fileInfoStr = row.missile;
  925. let fileInfoArr = JSON.parse(fileInfoStr);
  926. let missile = [];
  927. let fileInfo = fileInfoArr[0]; // 假设只有一个文件
  928. for (let i = 0; i < fileInfoArr.length; i++) {
  929. await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/thaad', {
  930. params: {
  931. datasourceId: '1654422305075367936',
  932. fieldName: 'missile',
  933. asImage: false,
  934. dataId: row.id,
  935. filename: fileInfoArr[i].filename,
  936. Authorization: getToken(),
  937. MenuId: '1683649747904106496'
  938. }
  939. })
  940. .then(response => {
  941. // 处理成功的响应
  942. missile.push(response.data);
  943. })
  944. .catch(error => {
  945. // 处理错误
  946. console.error(error);
  947. });
  948. }
  949. let name = row.name
  950. const data = {};
  951. data[name] = {
  952. id: row.id,
  953. name: row.name,
  954. BW: row.BW,
  955. PW: row.PW,
  956. fc: row.fc,
  957. fs: row.fs,
  958. h: row.h,
  959. lat: row.lat,
  960. lon: row.lon,
  961. fire_number: row.fire_number,
  962. modulation: row.modulation,
  963. prf: row.prf,
  964. prf_mode: row.prf_mode,
  965. type: row.type,
  966. style: row.style,
  967. url: row.url,
  968. missile: missile
  969. }
  970. data['name'] = row.name
  971. const jsonData = JSON.stringify(data);
  972. const blob = new Blob([jsonData], { type: 'application/json' });
  973. const url = URL.createObjectURL(blob);
  974. const link = document.createElement('a');
  975. link.href = url;
  976. link.download = '末端拦截-' + row.name + '.json';
  977. document.body.appendChild(link);
  978. link.click();
  979. document.body.removeChild(link);
  980. } else if (this.formId == 1675056214280507392) {
  981. let number = row.number
  982. const data = {};
  983. data['name'] = number
  984. data[number] = {
  985. name: number,
  986. type: row.type,
  987. properties: {
  988. id: row.id,
  989. CSV_starttime: row.CSV_starttime,
  990. CSV_endtime: row.CSV_endtime,
  991. CSV_path: row.CSV_path,
  992. CSV_sampletime: row.CSV_sampletime,
  993. TLE_Propagator: row.TLE_Propagator,
  994. common_RAAN: row.common_RAAN,
  995. common_argofperiapsis: row.common_argofperiapsis,
  996. common_eccentricity: row.common_eccentricity,
  997. common_inclination: row.common_inclination,
  998. common_semiMajorAxis: row.common_semiMajorAxis,
  999. common_trueanomaly: row.common_trueanomaly,
  1000. config_type: row.config_type,
  1001. mark: row.mark,
  1002. TLE_LINE0: row.TLE_LINE0,
  1003. TLE_LINE1: row.TLE_LINE1,
  1004. TLE_LINE2: row.TLE_LINE2,
  1005. picture: row.picture
  1006. }
  1007. }
  1008. const jsonData = JSON.stringify(data);
  1009. const blob = new Blob([jsonData], { type: 'application/json' });
  1010. const url = URL.createObjectURL(blob);
  1011. const link = document.createElement('a');
  1012. link.href = url;
  1013. link.download = '预警卫星-' + row.number + '.json';
  1014. document.body.appendChild(link);
  1015. link.click();
  1016. document.body.removeChild(link);
  1017. } else if (this.formId == 1675048581024714752) {
  1018. console.log('row :>> ', row);
  1019. let number = row.number
  1020. const data = {};
  1021. data['name'] = row.number
  1022. data[number] = {
  1023. type: row.type,
  1024. properties: {
  1025. id: row.id,
  1026. launch_lon: row.launch_lon,
  1027. launch_lat: row.launch_lat,
  1028. launch_h: row.launch_h,
  1029. target_lon: row.target_lon,
  1030. target_lat: row.target_lat,
  1031. target_h: row.target_h,
  1032. apogee_height: row.apogee_height,
  1033. fly_time: row.fly_time,
  1034. filepath: row.filepath,
  1035. acceleration: row.acceleration
  1036. }
  1037. }
  1038. const jsonData = JSON.stringify(data);
  1039. const blob = new Blob([jsonData], { type: 'application/json' });
  1040. const url = URL.createObjectURL(blob);
  1041. const link = document.createElement('a');
  1042. link.href = url;
  1043. link.download = '弹道导弹-' + row.number + '.json';
  1044. document.body.appendChild(link);
  1045. link.click();
  1046. document.body.removeChild(link);
  1047. } else if (this.formId == 1674960384441716736) {
  1048. let number = row.number
  1049. const data = {};
  1050. data[number] = {
  1051. type: row.type,
  1052. properties: {
  1053. id: row.id,
  1054. N: row.N,
  1055. f0: row.fo,
  1056. number: row.number,
  1057. tau: row.tau,
  1058. tr: row.tr,
  1059. ts: row.ts,
  1060. url: row.url,
  1061. method: row.method
  1062. }
  1063. }
  1064. const jsonData = JSON.stringify(data);
  1065. const blob = new Blob([jsonData], { type: 'application/json' });
  1066. const url = URL.createObjectURL(blob);
  1067. const link = document.createElement('a');
  1068. link.href = url;
  1069. link.download = '干扰雷达-' + row.number + '.json';
  1070. document.body.appendChild(link);
  1071. link.click();
  1072. document.body.removeChild(link);
  1073. } else if (this.formId == 1674971627114205184) {
  1074. console.log('row :>> ', row);
  1075. let number = row.number
  1076. const data = {};
  1077. data['name'] = number
  1078. data[number] = {
  1079. type: row.type,
  1080. creator: row.creator,
  1081. properties: {
  1082. id: row.id,
  1083. f0: row.fo,
  1084. number: row.number,
  1085. tau: row.tau,
  1086. k: row.k,
  1087. time: row.time,
  1088. tr: row.tr,
  1089. t_r: row.t_r,
  1090. ts: row.ts,
  1091. url: row.url,
  1092. method: row.method
  1093. }
  1094. }
  1095. const jsonData = JSON.stringify(data);
  1096. const blob = new Blob([jsonData], { type: 'application/json' });
  1097. const url = URL.createObjectURL(blob);
  1098. const link = document.createElement('a');
  1099. link.href = url;
  1100. link.download = '诱饵雷达-' + row.number + '.json';
  1101. document.body.appendChild(link);
  1102. link.click();
  1103. document.body.removeChild(link);
  1104. } else {
  1105. // todo 场景想定json导出
  1106. let fileInfoStr = row.blueunit;
  1107. let fileInfoArr = JSON.parse(fileInfoStr);
  1108. let fileInfo = fileInfoArr[0]; // 假设只有一个文件
  1109. for (let i = 0; i < fileInfoArr.length; i++) {
  1110. await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/main', {
  1111. params: {
  1112. datasourceId: '1656243335922192384',
  1113. fieldName: 'blueunit',
  1114. asImage: false,
  1115. dataId: row.id,
  1116. filename: fileInfoArr[i].filename,
  1117. Authorization: getToken(),
  1118. MenuId: '1656244747347431424'
  1119. }
  1120. })
  1121. .then(response => {
  1122. // 处理成功的响应
  1123. this.blueunit.push(response.data);
  1124. })
  1125. .catch(error => {
  1126. // 处理错误
  1127. console.error(error);
  1128. });
  1129. }
  1130. fileInfoStr = row.redunit;
  1131. fileInfoArr = JSON.parse(fileInfoStr);
  1132. for (let i = 0; i < fileInfoArr.length; i++) {
  1133. await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/main', {
  1134. params: {
  1135. datasourceId: '1656243335922192384',
  1136. fieldName: 'redunit',
  1137. asImage: false,
  1138. dataId: row.id,
  1139. filename: fileInfoArr[i].filename,
  1140. Authorization: getToken(),
  1141. MenuId: '1656244747347431424'
  1142. }
  1143. })
  1144. .then(response => {
  1145. // 处理成功的响应
  1146. this.redunit.push(response.data);
  1147. })
  1148. .catch(error => {
  1149. // 处理错误
  1150. console.error(error);
  1151. });
  1152. }
  1153. fileInfoStr = row.center;
  1154. fileInfoArr = JSON.parse(fileInfoStr);
  1155. for (let i = 0; i < fileInfoArr.length; i++) {
  1156. await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/main', {
  1157. params: {
  1158. datasourceId: '1656243335922192384',
  1159. fieldName: 'center',
  1160. asImage: false,
  1161. dataId: row.id,
  1162. filename: fileInfoArr[i].filename,
  1163. Authorization: getToken(),
  1164. MenuId: '1656244747347431424'
  1165. }
  1166. })
  1167. .then(response => {
  1168. // 处理成功的响应
  1169. this.center.push(response.data);
  1170. })
  1171. .catch(error => {
  1172. // 处理错误
  1173. console.error(error);
  1174. });
  1175. }
  1176. fileInfoStr = row.satellite;
  1177. fileInfoArr = JSON.parse(fileInfoStr);
  1178. for (let i = 0; i < fileInfoArr.length; i++) {
  1179. await axios.get('http://localhost:8084/admin/online/onlineOperation/downloadDatasource/main', {
  1180. params: {
  1181. datasourceId: '1656243335922192384',
  1182. fieldName: 'satellite',
  1183. asImage: false,
  1184. dataId: row.id,
  1185. filename: fileInfoArr[i].filename,
  1186. Authorization: getToken(),
  1187. MenuId: '1656244747347431424'
  1188. }
  1189. })
  1190. .then(response => {
  1191. // 处理成功的响应
  1192. this.satellite.push(response.data);
  1193. })
  1194. .catch(error => {
  1195. // 处理错误
  1196. console.error(error);
  1197. });
  1198. }
  1199. const data = {
  1200. id: row.id,
  1201. xdname: row.xdname,
  1202. type: row.type,
  1203. creator: row.creator,
  1204. createtime: row.createtime,
  1205. endtime: row.endtime,
  1206. bluecnt: row.bluecnt,
  1207. target: row.target,
  1208. starttime: row.starttime,
  1209. steptime: row.steptime,
  1210. blueunit: this.blueunit,
  1211. redunit: this.redunit,
  1212. satellite: this.satellite,
  1213. center: this.center
  1214. };
  1215. const jsonData = JSON.stringify(data);
  1216. const blob = new Blob([jsonData], { type: 'application/json' });
  1217. const url = URL.createObjectURL(blob);
  1218. const link = document.createElement('a');
  1219. link.href = url;
  1220. link.download = data.xdname + '.json';
  1221. document.body.appendChild(link);
  1222. link.click();
  1223. document.body.removeChild(link);
  1224. }
  1225. }
  1226. httpCall.then(res => {
  1227. this.formData = {
  1228. ...this.formData,
  1229. ...res.data
  1230. }
  1231. })
  1232. }
  1233. },
  1234. getRelationTableData (tableWidget) {
  1235. if (tableWidget.widgetType === this.SysCustomWidgetType.Table) {
  1236. let table = tableWidget.table;
  1237. let temp = this.$refs[tableWidget.variableName];
  1238. if (table != null && table.relation != null && Array.isArray(table.columnList) && temp != null) {
  1239. let tableWidgetImpl = temp[0] || temp;
  1240. return tableWidgetImpl.getTableWidget().dataList.map(data => {
  1241. return table.columnList.reduce((retObj, column) => {
  1242. let fieldName = (table.relation ? table.relation.variableName + '__' : '') + column.columnName;
  1243. retObj[column.columnName] = data[fieldName];
  1244. return retObj
  1245. }, {});
  1246. });
  1247. }
  1248. }
  1249. return null;
  1250. },
  1251. getWidgetPrimaryColumnId (widget) {
  1252. let columnList = null;
  1253. if (widget.relationId == null) {
  1254. columnList = widget.datasource.masterTable.columnList;
  1255. } else {
  1256. columnList = widget.relation.slaveTable.columnList;
  1257. }
  1258. if (Array.isArray(columnList)) {
  1259. for (let i = 0; i < columnList.length; i++) {
  1260. let column = columnList[i];
  1261. if (column.primaryKey) {
  1262. let columnName = column.columnName;
  1263. if (widget.relation != null) columnName = widget.relation.variableName + '__' + columnName;
  1264. return this.formData[columnName];
  1265. }
  1266. }
  1267. }
  1268. },
  1269. ...mapMutations(['addOnlineFormCache'])
  1270. },
  1271. created () {
  1272. this.reload();
  1273. },
  1274. destoryed () {
  1275. this.clean();
  1276. },
  1277. watch: {
  1278. formId: {
  1279. handler (newValue) {
  1280. this.reload();
  1281. }
  1282. }
  1283. }
  1284. }
  1285. export {
  1286. OnlineFormMixins
  1287. }