TabFormEdit.vue 75 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389
  1. <!-- 页签表单编辑视图 -->
  2. <template>
  3. <div class="container-fluid">
  4. <!-- header -->
  5. <div class="row" style="height: 50px;">
  6. <div class="col-md-12">
  7. <h3>
  8. <a class="a-back" @click="back()"><img class="m-image" src="/static/assets/client-base-v4/image/back.png" />
  9. {{ Language.getNameTrl($i18n.locale, window) }}
  10. &nbsp;</a>/&nbsp;{{ subTitle() }}
  11. <div v-show="type != 'create'" class="btn-group" role="group">
  12. <button type="button" class="btn btn-default" @click="pre">
  13. <span class="glyphicon glyphicon-chevron-left" aria-hidden="true" />
  14. </button>
  15. <button type="button" class="btn btn-default">
  16. {{ currIndex }}/{{ totalCount }}
  17. </button>
  18. <button type="button" class="btn btn-default" @click="next">
  19. <span class="glyphicon glyphicon-chevron-right" aria-hidden="true" />
  20. </button>
  21. </div>
  22. </h3>
  23. </div>
  24. </div>
  25. <div v-show="showSpaceRow" class="row">
  26. <div class="col-md-12">
  27. <div class="m-space-btn-group" />
  28. </div>
  29. </div>
  30. <div v-show="!showApproveComment" ref="fixedButtonGroup" class="row m-row fixed-btn-group">
  31. <div class="col-md-12">
  32. <div class="btn-group">
  33. <button v-if="allowCreate" type="button" class="btn btn-success" @click="saveTabData">
  34. {{ $t("lang.tabFormEdit.save") }}
  35. </button>
  36. <button v-if="allowCreate" type="button" class="btn btn-info" @click="cancelModel">
  37. {{ $t("lang.tabFormEdit.revert") }}
  38. </button>
  39. <button v-if="refreshFlag" type="button" class="btn btn-default" @click="loadData">
  40. {{ $t("lang.tabFormEdit.refresh") }}
  41. </button>
  42. <TabButton
  43. ref="tabButton" :show-tab-dto="tab" :model-data="modelData" :uuid="uuid" :view-type="'EditForm'"
  44. :type="type" :tab-buttons="tab.tabFormView ? tab.tabFormView.tabButtons : null" @save-view="backupView"
  45. @model-data-changed="modelDataChanged"
  46. />
  47. <FormFieldDef
  48. :tab-form-fields="tabFormFields" :window-no="windowNo" :tab-index="tabIndex"
  49. @tab-form-field-property-changed="
  50. tabFormFieldPropertyChanged($event)
  51. "
  52. />
  53. <button
  54. v-if="window.htmlHelpUrl != null && window.htmlHelpUrl != ''" class="btn btn-default"
  55. @click="openHtmlHelp(window.htmlHelpUrl)"
  56. >
  57. <span class="glyphicon glyphicon-question-sign" />
  58. </button>
  59. </div>
  60. </div>
  61. </div>
  62. <div v-show="showApproveComment" ref="fixedButtonGroup" class="row m-row fixed-btn-group">
  63. <div class="col-md-12">
  64. <div class="btn-group">
  65. <button
  66. v-if="isView == true && windowDisplayType == 'Grid'" type="button" class="btn btn-default"
  67. @click="changeWindowDisplayType"
  68. >
  69. {{ $t("lang.tabFormEdit.formView") }}
  70. </button>
  71. <button
  72. v-if="isView == true && windowDisplayType == 'Report'" type="button" class="btn btn-default"
  73. @click="changeWindowDisplayType"
  74. >
  75. {{ $t("lang.tabFormEdit.reportView") }}
  76. </button>
  77. </div>
  78. </div>
  79. </div>
  80. <div v-if="windowDisplayType == 'Grid'">
  81. <div v-if="tab != null && tab.tabFormView != null" class="m-row clearfix">
  82. <div class="col-xs-12">
  83. <div
  84. v-if="singleColumn" :class="{
  85. 'form-inline': tab.tabFormView.multipleColumn,
  86. 'form-horizontal': !tab.tabFormView.multipleColumn,
  87. }"
  88. >
  89. <template v-for="fieldItem in tabFormFields">
  90. <FieldEditView
  91. v-if="tab.tabDataSource" ref="fieldItem1" :key="
  92. 'FieldEditView_' +
  93. windowNo +
  94. '_' +
  95. tabIndex +
  96. '_' +
  97. fieldItem.fieldName +
  98. '_' +
  99. fieldItem.entityFieldIndex
  100. " :class-name="tab.tabDataSource.className" :field="fieldItem" :model-data="modelData"
  101. :window-no="windowNo" :tab-index="tabIndex" :js-url="jsUrl"
  102. :is-chinese-english="window.isChineseEnglish"
  103. :multiple-column="tab.tabFormView.multipleColumn" @value-changed="valueChanged($event, fieldItem)"
  104. @execute-callout="executeCallout(fieldItem)"
  105. />
  106. </template>
  107. </div>
  108. </div>
  109. </div>
  110. <div
  111. v-if="
  112. tab != null &&
  113. tab.tabFormView != null &&
  114. tab.tabFormView.fieldGroups != null &&
  115. tab.tabFormView.fieldGroups.length > 0
  116. " class="m-row clearfix"
  117. >
  118. <ul id="myTabs" class="nav nav-tabs" role="tablist">
  119. <li
  120. v-for="(fieldGroup, fieldGroupIndex) in tab.tabFormView.fieldGroups" :key="fieldGroup.groupName"
  121. role="presentation" :class="{ active: selectedTabIndex == fieldGroupIndex }"
  122. @click="selectedTabIndex = fieldGroupIndex"
  123. >
  124. <a
  125. :id="'tab-' + fieldGroupIndex" role="tab" data-toggle="tab"
  126. aria-controls="home" aria-expanded="true"
  127. >
  128. {{ Language.getGroupNameTrl($i18n.locale, fieldGroup) }}
  129. </a>
  130. </li>
  131. </ul>
  132. <div id="myTabContent" class="tab-content">
  133. <div
  134. v-for="(fieldGroup, fieldGroupIndex) in tab.tabFormView.fieldGroups"
  135. v-show="selectedTabIndex == fieldGroupIndex" id="home" :key="fieldGroup.groupName" role="tabpanel"
  136. class="tab-pane fade active in" aria-labelledby="home-tab"
  137. >
  138. <div v-if="fieldGroup.show">
  139. <div
  140. :class="{
  141. 'form-inline': tab.tabFormView.multipleColumn,
  142. 'form-horizontal': !tab.tabFormView.multipleColumn,
  143. }"
  144. >
  145. <template v-for="fieldItem in fieldGroup.fields">
  146. <FieldEditView
  147. v-if="tab.tabDataSource" ref="fieldItem2" :key="
  148. 'FieldEditView_' +
  149. windowNo +
  150. '_' +
  151. tabIndex +
  152. '_' +
  153. fieldItem.fieldName +
  154. '_' +
  155. fieldItem.entityFieldIndex
  156. " :class-name="tab.tabDataSource.className" :field="fieldItem" :model-data="modelData"
  157. :window-no="windowNo" :tab-index="tabIndex" :js-url="jsUrl"
  158. :is-chinese-english="window.isChineseEnglish"
  159. :multiple-column="tab.tabFormView.multipleColumn" @value-changed="valueChanged($event, fieldItem)"
  160. @execute-callout="executeCallout(fieldItem)"
  161. />
  162. </template>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. <template v-if="modelData != null">
  169. <div
  170. v-for="subTab in tab.subTabs"
  171. :id="'SubTabGridEdit-' + windowNo + '-' + tabIndex + '-' + modelData.id + '-subTab-' + subTab.tabIndex"
  172. :key="'SubTabGridEdit-' + windowNo + '-' + tabIndex + '-' + modelData.id + '-subTab-' + subTab.tabIndex"
  173. class="row clearfix"
  174. >
  175. <div class="col-md-12">
  176. <SubTabGridEdit
  177. :ref="'subTab' + subTab.tabIndex" :window-no="windowNo" :tab-index="subTab.tabIndex"
  178. :fixed-button-group-height="fixedButtonGroupHeight" :tab="subTab" :parent-model-data="modelData"
  179. :parent-tab="tab" :js-url="jsUrl" :is-chinese-english="window.isChineseEnglish" @save-view="backupView"
  180. @refresh-parent="refreshParent"
  181. @change-root-parent-model-data="changeRootParentModelData"
  182. />
  183. </div>
  184. </div>
  185. </template>
  186. </div>
  187. <div v-else style="height: 400px; overflow: scroll">
  188. <ProcessReportResultPreview
  189. v-if="
  190. processReportResult != null &&
  191. (processReportResult.reportResults != null ||
  192. processReportResult.processResult != null)
  193. " :process-report-result="processReportResult" :pdf-only="false" :excel-only="false"
  194. />
  195. </div>
  196. <div v-if="attributeKey != null && attributeKey === true" class="row clearfix">
  197. <div class="col-md-12">
  198. <AttributePanel
  199. ref="attributePanel" :attribute-key="attributeKey" :attribute-value-key="attributeValueKey"
  200. :window-no="windowNo"
  201. />
  202. </div>
  203. </div>
  204. <div
  205. v-if="
  206. window != null &&
  207. tab != null &&
  208. tab.tabDataSource != null &&
  209. !window.hideCreateRecordButton
  210. " class="row clearfix"
  211. >
  212. <AttachmentPanel
  213. v-if="type == 'edit' && tab.tabDataSource" :class-name="tab.tabDataSource.className"
  214. :record-id="recordId" :tab-index="tabIndex" :window-no="windowNo"
  215. />
  216. </div>
  217. <div v-if="showApproveComment" class="row clearfix">
  218. <div class="col-md-12">
  219. <ApproveComment
  220. ref="approveComment" :workflow-type="'UserDefine'" :parent-widget="'TabFormEdit'"
  221. :work-flow="window.workflow" :window-no="windowNo" :process-definition-id="processDefinitionId"
  222. :show-choice-button="showChoiceButton" :process-instance-id="processInstanceId" :task-info-id="taskInfoId"
  223. :record-id="modelData.id" :show-tab-dto="tab" :model-data="modelData" :uuid="uuid" :workflow-class-name="tab.tabDataSource.className"
  224. @save-data="saveTabData"
  225. />
  226. </div>
  227. </div>
  228. <Modal v-model:show="modal1">
  229. <div>
  230. {{ $t("lang.tabFormEdit.validateError", { errorCount: errorCount, errorMsg: errorMsg, }) }}
  231. </div>
  232. <template #header>{{ $t("lang.tabFormEdit.validateError") }}</template>
  233. </Modal>
  234. <Modal v-model:show="modal2" @ok="dataRestore()" @cancel="cancelRestore()">
  235. <template #header>{{ $t("lang.tabFormEdit.describe3") }}</template>
  236. <div>{{ $t("lang.tabFormEdit.describe4") }}</div>
  237. </Modal>
  238. <Modal v-model:show="modal3" @ok="cancelOk()" @cancel="cancelNo()">
  239. <template #header>{{ $t("lang.tabFormEdit.describe5") }}</template>
  240. <div>{{ $t("lang.tabFormEdit.describe6") }}</div>
  241. </Modal>
  242. <Loading v-if="loading" />
  243. </div>
  244. </template>
  245. <script>
  246. import Common from '../../common/Common.js';
  247. import WindowServerUtil from '../../resource/dictionary/WindowServerUtil.js';
  248. import WindowClientUtil from '../../resource/dictionary/WindowClientUtil.js';
  249. import TabFormView from './TabFormView.js';
  250. import FieldUtil from '../../resource/dictionary/FieldUtil.js';
  251. import Context from '../common/Context.js';
  252. import ProcessReportResource from '../../api/dic/ProcessReportResource.js';
  253. import CurdWindowResource from '../../api/dic/CurdWindowResource.js';
  254. import UserStorageResource from '../../api/base/UserStorageResource.js';
  255. import Language from '../../common/Language.js';
  256. import SubTabGridEdit from '../tabGridView/SubTabGridEdit.vue';
  257. import FieldEditView from './TabFormFieldEdit.vue';
  258. import TabButton from '../tabView/TabButton.vue';
  259. import FormFieldDef from './FormFieldDef.vue';
  260. import AttachmentPanel from '../attachment/AttachmentPanel.vue';
  261. import AttributePanel from '../attribute/AttributePanel.vue';
  262. import ApproveComment from '../../workflow/ApproveComment.vue';
  263. import DataRecoveryResource from '../../api/base/DataRecoveryResource.js';
  264. import JsUtil from '../../common/JsUtil.js';
  265. import { Notify, Uuid } from 'pc-component-v3';
  266. export default {
  267. components: {
  268. SubTabGridEdit,
  269. FieldEditView,
  270. TabButton,
  271. FormFieldDef,
  272. AttachmentPanel,
  273. AttributePanel,
  274. ApproveComment,
  275. },
  276. /**
  277. * 在离开路由之前,检验数据是否已保存
  278. */
  279. beforeRouteLeave: function (to, from, next) {
  280. var _self = this;
  281. if (_self.windowDisplayType == 'Grid') {
  282. if (_self.cancelCommand == false && _self.isModelDataChanged() == true) {
  283. Notify.notice(_self.$t('lang.tabFormEdit.dataNotSaved'), _self.$t('lang.tabFormEdit.describe1'), false);
  284. next(false);
  285. } else {
  286. next();
  287. }
  288. } else {
  289. next();
  290. }
  291. if (_self.autoSaveInterval != null) {
  292. clearInterval(_self.autoSaveInterval);
  293. }
  294. },
  295. data: function () {
  296. this.Language = Language;
  297. return {
  298. type: '', // 窗口类型
  299. windowNo: '', // 窗口Id
  300. tabIndex: '', // 页签Id
  301. recordId: '', // 记录Id
  302. window: {}, // 窗口数据
  303. tab: {}, // 父页签
  304. tabFormFields: [],
  305. modelData: {},
  306. errorCount: 0, // 校验错误数量
  307. errorMsg: '', // 校验错误信息
  308. error: 0,
  309. currPage: 1,
  310. attributeKey: null,
  311. attributeValueKey: null,
  312. currIndex: 0,
  313. totalCount: 0,
  314. buttonGroupInitLeft: 0,
  315. buttonGroupInitTop: 0,
  316. showSpaceRow: false,
  317. filterParams: null,
  318. uuid: '',
  319. cancelCommand: false, // 取消命令
  320. fixedButtonGroupHeight: 0,
  321. selectedTabIndex: 0, // 选择的页签序号
  322. cacheUuid: '',
  323. // 工作流定义Id
  324. processDefinitionId: '',
  325. processInstanceId: undefined,
  326. workflowType: undefined,
  327. taskInfoId: undefined,
  328. windowDisplayType: 'Grid', // 显示类型
  329. processReportResult: undefined,
  330. isView: true, // 是否显示模式切换按钮
  331. autoSaveInterval: null, // 自动保存定时器
  332. dataRecoveryDto: undefined,
  333. isRestoreData: undefined, //是否恢复草稿数据
  334. jsUrl: null,
  335. loading: false,
  336. modal1: false,
  337. modal2: false,
  338. modal3: false,
  339. refreshFlag: false,
  340. };
  341. },
  342. computed: {
  343. /**
  344. * 是否允许新建
  345. * tab
  346. */
  347. allowCreate: function () {
  348. var _self = this;
  349. var allTabReadOnly = true;
  350. // 如果所有的页签都是只读
  351. if (_self.window != undefined && _self.window.tabs != undefined) {
  352. for (
  353. var tabIndex = 0; tabIndex < _self.window.tabs.length; tabIndex++
  354. ) {
  355. if (
  356. _self.window.tabs[tabIndex].isReadOnly == undefined ||
  357. _self.window.tabs[tabIndex].isReadOnly == false
  358. ) {
  359. allTabReadOnly = false;
  360. break;
  361. }
  362. }
  363. }
  364. return !allTabReadOnly;
  365. },
  366. /**
  367. * 页签是否单列
  368. */
  369. singleColumn: function () {
  370. var _self = this;
  371. if (_self.tab.multipleColumn == true) {
  372. return false;
  373. } else {
  374. return true;
  375. }
  376. },
  377. /**
  378. * 是否显示审批面板
  379. * 处于审批中的单据,显示审批面板
  380. */
  381. showApproveComment: function () {
  382. // 判断是否显示审批按钮
  383. if (
  384. this.window != undefined &&
  385. this.window.hasWorkflow != undefined &&
  386. this.modelData != undefined &&
  387. this.modelData.data != undefined &&
  388. this.modelData.data.processInstanceId != undefined &&
  389. this.modelData.data.processInstanceId.displayValue != undefined &&
  390. this.modelData.data.processInstanceId.displayValue[0] != undefined &&
  391. this.modelData.data.processInstanceId.displayValue[0].length > 0
  392. ) {
  393. return true;
  394. }
  395. return false;
  396. },
  397. /**
  398. * 是否显示审批评论面板
  399. * 审批完成的单据,显示审批评论面板
  400. */
  401. showChoiceButton: function () {
  402. if (
  403. this.window != undefined &&
  404. this.window.workflow != undefined &&
  405. this.modelData != undefined &&
  406. this.modelData.data != undefined &&
  407. this.modelData.data.processInstanceId != undefined &&
  408. this.modelData.data.processInstanceId.displayValue != undefined &&
  409. this.modelData.data.processInstanceId.displayValue[0] != undefined &&
  410. this.modelData.data.processInstanceId.displayValue[0].length > 0 &&
  411. this.modelData.data.documentStatus != undefined &&
  412. this.modelData.data.documentStatus.displayValue != undefined &&
  413. this.modelData.data.documentStatus.displayValue[0] != undefined &&
  414. this.modelData.data.documentStatus.displayValue[0].length > 0 &&
  415. this.modelData.data.documentStatus.displayValue[0] == 'PROCESSING' &&
  416. this.taskInfoId != undefined &&
  417. this.workflowType != 'copyTask'
  418. ) {
  419. return true;
  420. }
  421. return false;
  422. },
  423. },
  424. watch: {
  425. $route: function (to, from) {
  426. // 与 mounted 中的initView重复执行
  427. // this.initView();
  428. },
  429. modelData: {
  430. deep: true,
  431. handler(curVal, oldVal) {
  432. var _self = this;
  433. this.tabButtonsShowLogical();
  434. this.reportViewsShowLogical();
  435. if (_self.autoSaveInterval != null) {
  436. clearInterval(_self.autoSaveInterval);
  437. _self.autoSaveInterval = null;
  438. _self.startSaveInterval();
  439. } else {
  440. _self.startSaveInterval();
  441. }
  442. },
  443. },
  444. },
  445. beforeCreate: function () {
  446. console.log('WindowEdit beforeCreate.');
  447. },
  448. created: function () {
  449. console.log('WindowEdit created.');
  450. },
  451. beforeMount: function () {
  452. console.log('WindowEdit beforeMount.');
  453. },
  454. mounted: function () {
  455. var _self = this;
  456. console.log('WindowEdit mounted.');
  457. this.initView();
  458. // 按钮栏实现滚动
  459. _self.$nextTick(function () {
  460. // var fixedButtonGroup = $(_self.$refs.fixedButtonGroup);
  461. // _self.computerButtonGroupLeftTop();
  462. // $(window).scroll(function (){
  463. // if ($(window).scrollTop() > _self.buttonGroupInitTop) {
  464. // _self.showSpaceRow = true;
  465. // _self.$nextTick(function (){
  466. // fixedButtonGroup.addClass('btn-group-fixed');
  467. // fixedButtonGroup.css('left', _self.buttonGroupInitLeft + 'px');
  468. // });
  469. // } else {
  470. // _self.showSpaceRow = false;
  471. // _self.$nextTick(function (){
  472. // fixedButtonGroup.removeClass('btn-group-fixed');
  473. // fixedButtonGroup.css('left', '');
  474. // });
  475. // }
  476. // if ($(window).scrollTop() <= 10){
  477. // _self.computerButtonGroupLeftTop();
  478. // }
  479. // });
  480. var fixedButtonGroup = $(_self.$refs.fixedButtonGroup);
  481. var buttonInitTop = fixedButtonGroup.offset().top;
  482. _self.fixedButtonGroupHeight = fixedButtonGroup.outerHeight();
  483. // 按钮组实现悬浮
  484. $(window).scroll(function () {
  485. var windowTop = $(window).scrollTop();
  486. if (windowTop > buttonInitTop + fixedButtonGroup.outerHeight()) {
  487. fixedButtonGroup.offset({
  488. top: windowTop,
  489. left: fixedButtonGroup.offset().left,
  490. });
  491. } else {
  492. fixedButtonGroup.offset({
  493. top: buttonInitTop,
  494. });
  495. }
  496. });
  497. });
  498. $(window).resize(function () {
  499. _self.$nextTick(function () {
  500. _self.computerButtonGroupLeftTop();
  501. });
  502. });
  503. window.addEventListener('beforeunload', e => this.beforeunloadFn(e));
  504. },
  505. unmounted() {
  506. window.removeEventListener('beforeunload', e => this.beforeunloadFn(e));
  507. let _self = this;
  508. if (_self.autoSaveInterval != null) {
  509. clearInterval(_self.autoSaveInterval);
  510. }
  511. },
  512. methods: {
  513. /**
  514. * 删除草稿数据
  515. * @author GuoZhiBo 20210926
  516. */
  517. deleteDataRecoveryDto: function () {
  518. var _self = this;
  519. if (_self.autoSaveInterval != null) {
  520. clearInterval(_self.autoSaveInterval);
  521. _self.autoSaveInterval = null;
  522. }
  523. _self.dataRecoveryDto = {
  524. windowId: _self.windowNo,
  525. type: _self.type,
  526. };
  527. DataRecoveryResource.deleteDataRecoveryDto(_self.dataRecoveryDto).then(
  528. successData => {
  529. if (successData != null) {
  530. console.log('删除自动保存数据失败。');
  531. }
  532. },
  533. errorData => {
  534. Common.processException(errorData);
  535. },
  536. );
  537. },
  538. /**
  539. * 恢复草稿数据
  540. * @author GuoZhiBo 20210926
  541. */
  542. dataRestore: function () {
  543. var _self = this;
  544. _self.restoreModelData(_self.dataRecoveryDto.modelData);
  545. },
  546. /**
  547. * 恢复modelData数据
  548. * @param {Object} cacheModelData
  549. * @author GuoZhiBo 20210926
  550. */
  551. restoreModelData: function (cacheModelData) {
  552. var _self = this;
  553. // 恢复父页签的数据
  554. cacheModelData.restore = true;
  555. _self.modelData = cacheModelData;
  556. _self.$nextTick(function () {
  557. if (
  558. cacheModelData.saveDatas != undefined &&
  559. cacheModelData.saveDatas.length > 0
  560. ) {
  561. // bug fixed by jack 2021-10-08
  562. // 子页签修改的时候,不会影响父页签的属性,如果直接使用saveDatas,那么子页签属性发生改变的时候,deep watch parentModelData 也会发生改变。
  563. const saveDatasTemp = cacheModelData.saveDatas;
  564. cacheModelData.saveDatas = null;
  565. saveDatasTemp.forEach(function (saveData) {
  566. // 恢复子页签的数据
  567. var subTabId = 'subTab' + saveData.tabIndex;
  568. var tabElements = _self.$refs[subTabId];
  569. if (tabElements && tabElements.length > 0) {
  570. var tabElement = tabElements[0];
  571. if (tabElement) {
  572. saveData.editMode = true;
  573. tabElement.addModelData(saveData);
  574. }
  575. }
  576. });
  577. } else {
  578. // BUG描述:父子页签,编辑以后撤销,子页签数据不显示
  579. // BUG修复:刷新子页签的数据
  580. // bug fixed by jack 20180203
  581. for (var index = 0; index < _self.tab.subTabs.length; index++) {
  582. var subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  583. _self.$refs[subTabId][0].queryGridData();
  584. }
  585. }
  586. });
  587. },
  588. /**
  589. * 取消恢复
  590. * @author GuoZhiBo 20210926
  591. */
  592. cancelRestore: function () {
  593. var _self = this;
  594. _self.modal2 = false;
  595. //删除草稿数据
  596. _self.deleteDataRecoveryDto();
  597. },
  598. /**
  599. * 打开帮助页面
  600. */
  601. openHtmlHelp: function (htmlHelpUrl) {
  602. window.open(htmlHelpUrl);
  603. },
  604. // 初始化界面
  605. initView: function () {
  606. var _self = this;
  607. this.type = this.$route.params.type;
  608. this.windowNo = this.$route.params.windowNo;
  609. this.tabIndex = this.$route.params.tabIndex;
  610. this.recordId = this.$route.params.recordId;
  611. this.currPage = this.$route.query.currPage;
  612. this.currIndex = Number(this.$route.query.currIndex);
  613. this.totalCount = Number(this.$route.query.totalCount);
  614. this.uuid = this.$route.query.uuid;
  615. this.cacheUuid = this.$route.query.cacheUuid;
  616. this.workflowType = this.$route.query.workflowType;
  617. this.taskInfoId = this.$route.query.taskInfoId;
  618. this.isRestoreData = this.$route.query.isRestoreData;
  619. if (_self.type == 'edit') {
  620. if (this.isRestoreData == 1) {
  621. this.restoreView();
  622. } else {
  623. this.initEditView();
  624. }
  625. } else if (this.type == 'create') {
  626. this.initCreateView();
  627. } else if (this.type == 'restore') {
  628. // 恢复视图
  629. this.restoreView();
  630. }
  631. },
  632. // 初始化新建界面
  633. initCreateView: function () {
  634. var _self = this;
  635. if (_self.$refs.loading != undefined) {
  636. _self.loading = true;
  637. }
  638. DataRecoveryResource.queryDataRecoveryDtoByUserId(
  639. _self.windowNo,
  640. _self.type,
  641. ).then(
  642. successData => {
  643. if (successData != null) {
  644. _self.modal2 = true;
  645. _self.dataRecoveryDto = successData;
  646. }
  647. },
  648. errorData => {
  649. Common.processException(errorData);
  650. },
  651. );
  652. _self.processInstanceId = '';
  653. WindowServerUtil.getWindowById(
  654. _self.windowNo,
  655. function (window) {
  656. WindowClientUtil.parseFilterSchema(window);
  657. var tab = WindowClientUtil.getTab(window, _self.tabIndex);
  658. WindowClientUtil.parseSubTab(window, tab);
  659. WindowClientUtil.parseFieldGroup(tab);
  660. WindowClientUtil.restoreWindowTabFieldGroupsVisible(window);
  661. _self.tabFormFields = WindowClientUtil.getDetailField(tab);
  662. _self.window = window;
  663. _self.jsUrl = window.jsUrl;
  664. _self.tab = tab;
  665. TabFormView.restoreTabFormFieldDef(
  666. _self.windowNo,
  667. _self.tabIndex,
  668. _self.tabFormFields,
  669. );
  670. WindowServerUtil.newModelData(
  671. _self.windowNo,
  672. _self.tabIndex,
  673. function (modelData) {
  674. if (_self.$refs.loading != undefined) {
  675. _self.loading = false;
  676. }
  677. modelData.editMode = true;
  678. _self.modelData = modelData;
  679. _self.recordId = undefined;
  680. // add by jack 20180914
  681. // 自动点击菜单
  682. _self.autoClickMenu();
  683. },
  684. function () {
  685. if (_self.$refs.loading != undefined) {
  686. _self.loading = false;
  687. }
  688. },
  689. _self.cacheUuid,
  690. );
  691. },
  692. function () {
  693. if (_self.$refs.loading != undefined) {
  694. _self.loading = false;
  695. }
  696. },
  697. );
  698. },
  699. // 初始化编辑界面
  700. initEditView: function () {
  701. var _self = this;
  702. _self.loading = true;
  703. _self.processInstanceId = '';
  704. if (_self.taskInfoId) {
  705. CurdWindowResource.uniqueByNoWithWorkflow(
  706. null,
  707. _self.taskInfoId,
  708. _self.windowNo,
  709. ).then(
  710. successData => {
  711. initWindowAfterLoaded(successData);
  712. },
  713. errorData => {
  714. _self.loading = false;
  715. Common.processException(errorData);
  716. },
  717. );
  718. } else {
  719. WindowServerUtil.getWindowById(
  720. _self.windowNo,
  721. function (window) {
  722. initWindowAfterLoaded(window);
  723. },
  724. function () {
  725. _self.loading = false;
  726. },
  727. );
  728. }
  729. function initWindowAfterLoaded(window) {
  730. WindowClientUtil.parseFilterSchema(window);
  731. var tab = WindowClientUtil.getTab(window, _self.tabIndex);
  732. WindowClientUtil.parseSubTab(window, tab);
  733. WindowClientUtil.parseFieldGroup(tab);
  734. WindowClientUtil.restoreWindowTabFieldGroupsVisible(window);
  735. _self.tabFormFields = WindowClientUtil.getDetailField(tab);
  736. _self.window = window;
  737. _self.jsUrl = window.jsUrl;
  738. _self.tab = tab;
  739. TabFormView.restoreTabFormFieldDef(
  740. _self.windowNo,
  741. _self.tabIndex,
  742. _self.tabFormFields,
  743. );
  744. if (_self.window.workflow != undefined && _self.modelData.id > 0) {
  745. _self.processDefinitionId = _self.window.workflow.deploymentId;
  746. }
  747. if (
  748. _self.window.reportViewDto != null &&
  749. _self.window.reportViewDto.reportViewItemDtos != null &&
  750. _self.window.reportViewDto.reportViewItemDtos.length > 0 &&
  751. _self.workflowType == 'approve'
  752. ) {
  753. var isflag = false;
  754. _self.window.reportViewDto.reportViewItemDtos.forEach(function (item) {
  755. if (item.defaultDisplayReport) {
  756. isflag = true;
  757. }
  758. });
  759. if (isflag) {
  760. _self.windowDisplayType = 'Report';
  761. } else {
  762. _self.windowDisplayType = 'Grid';
  763. }
  764. } else {
  765. _self.windowDisplayType = 'Grid';
  766. _self.isView = false;
  767. }
  768. _self.loading = false;
  769. _self.loadData();
  770. }
  771. },
  772. /**
  773. * 切换显示模式
  774. * @author GuoZhiBo 20210419
  775. */
  776. changeWindowDisplayType: function () {
  777. var _self = this;
  778. if (_self.windowDisplayType == 'Grid') {
  779. _self.windowDisplayType = 'Report';
  780. } else {
  781. _self.windowDisplayType = 'Grid';
  782. _self.$nextTick(function () {
  783. for (var index = 0; index < _self.tab.subTabs.length; index++) {
  784. var subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  785. _self.$refs[subTabId][0].queryGridData();
  786. }
  787. });
  788. }
  789. },
  790. // 恢复视图
  791. restoreView: function () {
  792. let _self = this;
  793. let key = _self.uuid + '_modelData';
  794. _self.loading = true;
  795. _self.processInstanceId = '';
  796. WindowServerUtil.getWindowById(
  797. _self.windowNo,
  798. function (window) {
  799. WindowClientUtil.parseFilterSchema(window);
  800. var tab = WindowClientUtil.getTab(window, _self.tabIndex);
  801. WindowClientUtil.parseSubTab(window, tab);
  802. WindowClientUtil.parseFieldGroup(tab);
  803. WindowClientUtil.restoreWindowTabFieldGroupsVisible(window);
  804. _self.tabFormFields = WindowClientUtil.getDetailField(tab);
  805. _self.window = window;
  806. _self.jsUrl = window.jsUrl;
  807. _self.tab = tab;
  808. TabFormView.restoreTabFormFieldDef(
  809. _self.windowNo,
  810. _self.tabIndex,
  811. _self.tabFormFields,
  812. );
  813. if (_self.window.workflow != undefined && _self.modelData.id > 0) {
  814. _self.processDefinitionId = _self.window.workflow.deploymentId;
  815. }
  816. _self.loading = false;
  817. if (_self.isRestoreData == 1) {
  818. DataRecoveryResource.queryDataRecoveryDtoByUserId(
  819. _self.windowNo,
  820. _self.type,
  821. ).then(
  822. successData => {
  823. if (successData != null) {
  824. _self.restoreModelData(successData.modelData);
  825. }
  826. },
  827. errorData => {
  828. Common.processException(errorData);
  829. },
  830. );
  831. } else {
  832. UserStorageResource.uniqueByKey(key).then(
  833. successData => {
  834. // if(successData.errorCode != 0) {
  835. // Notify.error('提示', successData.errorMessage, false);
  836. // return;
  837. // }
  838. if (successData.data != null && successData.data != '') {
  839. let cacheModelData = JSON.parse(successData.data);
  840. cacheModelData.restore = true;
  841. // 恢复父页签的数据
  842. _self.modelData = cacheModelData;
  843. _self.$nextTick(function () {
  844. if (
  845. cacheModelData.saveDatas != undefined &&
  846. cacheModelData.saveDatas.length > 0
  847. ) {
  848. cacheModelData.saveDatas.forEach(function (saveData) {
  849. // 恢复子页签的数据
  850. var subTabId = 'subTab' + saveData.tabIndex;
  851. var tabElements = _self.$refs[subTabId];
  852. if (tabElements && tabElements.length > 0) {
  853. var tabElement = tabElements[0];
  854. if (tabElement) {
  855. tabElement.addModelData(saveData);
  856. }
  857. }
  858. });
  859. } else {
  860. // BUG描述:父子页签,编辑以后撤销,子页签数据不显示
  861. // BUG修复:刷新子页签的数据
  862. // bug fixed by jack 20180203
  863. for (
  864. var index = 0; index < _self.tab.subTabs.length; index++
  865. ) {
  866. var subTabId =
  867. 'subTab' + this.tab.subTabs[index].tabIndex;
  868. _self.$refs[subTabId][0].queryGridData();
  869. }
  870. }
  871. });
  872. console.log(cacheModelData);
  873. }
  874. },
  875. errorData => {
  876. Common.processException(errorData);
  877. },
  878. );
  879. }
  880. },
  881. function () {
  882. _self.loading = false;
  883. },
  884. );
  885. },
  886. /**
  887. * 数据发生改变
  888. * eg:生单界面回传了新的modelData数据
  889. */
  890. modelDataChanged: function (newModelData) {
  891. var _self = this;
  892. // 恢复父页签的数据
  893. newModelData.visible = true;
  894. if (
  895. newModelData.saveDatas != undefined &&
  896. newModelData.saveDatas.length > 0
  897. ) {
  898. newModelData.saveDatas.forEach(function (item) {
  899. item.visible = true;
  900. });
  901. }
  902. // 恢复父页签的数据
  903. _self.modelData = newModelData;
  904. _self.$nextTick(function () {
  905. if (
  906. newModelData.saveDatas != undefined &&
  907. newModelData.saveDatas.length > 0
  908. ) {
  909. let firstModelData = newModelData.saveDatas[0];
  910. // 恢复子页签的数据
  911. let subTabId = 'subTab' + firstModelData.tabIndex;
  912. var tabElements = _self.$refs[subTabId];
  913. if (tabElements && tabElements.length > 0) {
  914. var tabElement = tabElements[0];
  915. if (tabElement) {
  916. tabElement.replaceModelDatas(newModelData.saveDatas);
  917. }
  918. }
  919. // bug fixed by jack 2022-01-17
  920. // 修复生单界面跳转回来以后,如果子页签 行数多的话,输入非常卡的BUG。
  921. newModelData.saveDatas = null;
  922. } else {
  923. // BUG描述:父子页签,编辑以后撤销,子页签数据不显示
  924. // BUG修复:刷新子页签的数据
  925. // bug fixed by jack 20180203
  926. for (var index = 0; index < _self.tab.subTabs.length; index++) {
  927. let subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  928. _self.$refs[subTabId][0].queryGridData();
  929. }
  930. }
  931. });
  932. },
  933. /**
  934. * 获取界面的数据
  935. * eg:生单界面获取modelData数据
  936. */
  937. getModelData: function () {
  938. var _self = this;
  939. var subTabAllData = _self.getSubTabAllData();
  940. if (subTabAllData.length > 0) {
  941. _self.modelData.saveDatas = subTabAllData;
  942. } else {
  943. _self.modelData.saveDatas = null;
  944. }
  945. return _self.modelData;
  946. },
  947. executeProcess: function (processReportNo) {
  948. var _self = this;
  949. var ids = [];
  950. if (_self.modelDatas) {
  951. _self.modelDatas.forEach(function (modelData) {
  952. if (modelData.select == true) {
  953. ids.push(modelData.id);
  954. }
  955. });
  956. } else if (_self.modelData) {
  957. ids.push(_self.modelData.id);
  958. }
  959. ProcessReportResource.runProcessByIds(processReportNo, ids).then(
  960. successData => {
  961. var processReportResult = successData;
  962. if (_self.processReportResult == undefined) {
  963. if (
  964. processReportResult.reportResults != undefined &&
  965. processReportResult.reportResults.length > 0
  966. ) {
  967. processReportResult.reportResults.forEach(function (item, index) {
  968. item.previewIndex = 1;
  969. if (index == 0) {
  970. item['showPreview'] = true;
  971. } else {
  972. item['showPreview'] = false;
  973. }
  974. });
  975. }
  976. _self.processReportResult = processReportResult;
  977. } else {
  978. if (
  979. processReportResult.reportResults != undefined &&
  980. processReportResult.reportResults.length > 0
  981. ) {
  982. processReportResult.reportResults.forEach(function (item, index) {
  983. item.previewIndex = 1;
  984. if (index == 0) {
  985. item.showPreview = true;
  986. } else {
  987. item.showPreview = false;
  988. }
  989. _self.processReportResult.reportResults.push(item);
  990. });
  991. }
  992. }
  993. },
  994. errorData => {
  995. Common.processException(errorData);
  996. },
  997. );
  998. },
  999. getContext: Context,
  1000. /**
  1001. * 报表视图显示逻辑
  1002. */
  1003. reportViewsShowLogical: function () {
  1004. var _self = this;
  1005. if (
  1006. _self.window.reportViewDto != null &&
  1007. _self.window.reportViewDto.reportViewItemDtos != null
  1008. ) {
  1009. _self.processReportResult = undefined;
  1010. for (
  1011. let index = 0; index < _self.window.reportViewDto.reportViewItemDtos.length; index++
  1012. ) {
  1013. let reportViewItemDto =
  1014. _self.window.reportViewDto.reportViewItemDtos[index];
  1015. var logic = reportViewItemDto.showLogical;
  1016. if (logic == null || logic == '') {
  1017. reportViewItemDto.invisible = false;
  1018. _self.executeProcess(reportViewItemDto.processReportNo);
  1019. return;
  1020. }
  1021. let functionName = 'form_view_showlogical_' + index;
  1022. const executeFunction = function (){
  1023. let actions = {
  1024. subTabsRef: _self.getSubTabs(),
  1025. };
  1026. let context = new _self.getContext(_self.modelData, actions);
  1027. try{
  1028. reportViewItemDto.invisible = !_self[functionName](context);
  1029. if (reportViewItemDto.invisible == false) {
  1030. _self.executeProcess(reportViewItemDto.processReportNo);
  1031. }
  1032. }catch(e){
  1033. console.error(e);
  1034. Notify.error('数据字典定义异常', '【' + logic + '】报表显示逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  1035. }
  1036. };
  1037. if (this[functionName] == null) {
  1038. const jsUrl = this.jsUrl;
  1039. if (jsUrl == null || jsUrl == undefined) {
  1040. Notify.error('数据字典定义异常', '【' + logic + '】报表显示逻辑的JS文件不存在,请联系管理员检查数据字典是否存在JS文件', false);
  1041. return;
  1042. }
  1043. let promise = JsUtil.dynamicLoadJsFunction(jsUrl, logic);
  1044. promise.then(targetFunction => {
  1045. _self[functionName] = targetFunction;
  1046. if(targetFunction == null){
  1047. Notify.error('数据字典定义异常', '【' + logic + '】报表显示逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  1048. return;
  1049. }
  1050. executeFunction();
  1051. }, errorData => {
  1052. console.error(errorData);
  1053. });
  1054. }else{
  1055. executeFunction();
  1056. }
  1057. }
  1058. }
  1059. },
  1060. /**
  1061. * 获取子页签的集合
  1062. */
  1063. getSubTabs: function () {
  1064. var _self = this;
  1065. let subTabsRef = [];
  1066. for (var tabIndex = 0; tabIndex < _self.tab.subTabs.length; tabIndex++) {
  1067. var subTabId = 'subTab' + this.tab.subTabs[tabIndex].tabIndex;
  1068. subTabsRef.push(_self.$refs[subTabId][0]);
  1069. }
  1070. return subTabsRef;
  1071. },
  1072. // 备份视图
  1073. backupView: function () {
  1074. var _self = this;
  1075. var subTabChangedData = _self.getSubTabChangedData();
  1076. if (subTabChangedData.length > 0) {
  1077. _self.modelData.saveDatas = subTabChangedData;
  1078. } else {
  1079. _self.modelData.saveDatas = null;
  1080. }
  1081. _self.modelData.restore = null;
  1082. // bug 修复:生单功能问题:新建单据,再点击生单,会提示需要保存或撤销,必须先保存一次如此提示过后,才可以点击生单按钮进入来源单据选择页面,并且在勾选来源单据后点击确定无反应
  1083. _self.cancelCommand = true;
  1084. let key = _self.uuid + '_modelData';
  1085. let userStorageDtos = [{
  1086. key: key,
  1087. value: JSON.stringify(_self.modelData),
  1088. }];
  1089. let promise = new Promise(function (reslove, reject) {
  1090. // 组装查询条件,然后放到后台数据库当中
  1091. UserStorageResource.uploadUserStorage(userStorageDtos).then(
  1092. successData => {
  1093. reslove();
  1094. },
  1095. errorData => {
  1096. Common.processException(errorData);
  1097. reject();
  1098. },
  1099. );
  1100. });
  1101. return promise;
  1102. },
  1103. loadData: function () {
  1104. var _self = this;
  1105. if (_self.recordId == undefined) {
  1106. return;
  1107. }
  1108. var tabLoadParam = {
  1109. windowNo: _self.windowNo,
  1110. tabIndex: _self.tabIndex,
  1111. recordId: _self.recordId,
  1112. };
  1113. _self.loading = true;
  1114. WindowServerUtil.loadTabSingleData(
  1115. tabLoadParam,
  1116. function (modelData) {
  1117. _self.modelData = modelData;
  1118. // 判断是否有属性
  1119. if (
  1120. modelData.data.attributeKey != undefined &&
  1121. modelData.data.attributeKey.displayValue != undefined
  1122. ) {
  1123. let displayValue = modelData.data.attributeKey.displayValue;
  1124. if (displayValue.length > 0) {
  1125. _self.attributeKey = displayValue[0];
  1126. }
  1127. }
  1128. // 判断是否有属性值
  1129. if (
  1130. modelData.data.attributeValueKey != undefined &&
  1131. modelData.data.attributeValueKey.displayValue != undefined
  1132. ) {
  1133. let displayValue1 = modelData.data.attributeValueKey.displayValue;
  1134. if (displayValue1.length > 0) {
  1135. _self.attributeValueKey = displayValue1[0];
  1136. }
  1137. }
  1138. // 判断是否显示审批状态
  1139. if (
  1140. _self.modelData != null &&
  1141. _self.modelData.data != null &&
  1142. _self.modelData.data.processInstanceId != null
  1143. ) {
  1144. let displayValue =
  1145. _self.modelData.data.processInstanceId.displayValue;
  1146. if (displayValue != null && displayValue.length > 0) {
  1147. _self.processInstanceId = displayValue[0];
  1148. } else {
  1149. _self.processInstanceId = '';
  1150. }
  1151. } else {
  1152. _self.processInstanceId = '';
  1153. }
  1154. _self.loading = false;
  1155. },
  1156. function () {
  1157. _self.loading = false;
  1158. },
  1159. );
  1160. },
  1161. // 保存
  1162. saveTabData: function (command) {
  1163. var _self = this;
  1164. var fieldWidgets1 = _self.$refs.fieldItem1;
  1165. var fieldWidgets2 = _self.$refs.fieldItem2;
  1166. // 保存的时候取消判断
  1167. _self.cancelCommand = true;
  1168. _self.errorMsg = '';
  1169. var promises = [];
  1170. _self.error = 0;
  1171. if (fieldWidgets1 != undefined) {
  1172. fieldWidgets1.forEach(function (w) {
  1173. var validateResult = w.performValide();
  1174. if (!validateResult) {
  1175. _self.error++;
  1176. }
  1177. });
  1178. }
  1179. if (fieldWidgets2 != undefined) {
  1180. fieldWidgets2.forEach(function (w) {
  1181. var validateResult = w.performValide();
  1182. if (!validateResult) {
  1183. _self.error++;
  1184. }
  1185. });
  1186. }
  1187. var subTabValidateResults = _self.getSubTabValidatePromise();
  1188. if (
  1189. subTabValidateResults != undefined &&
  1190. subTabValidateResults.length > 0
  1191. ) {
  1192. subTabValidateResults.forEach(function (subTabValidateResult) {
  1193. if (subTabValidateResult != true) {
  1194. _self.error++;
  1195. }
  1196. });
  1197. }
  1198. if (_self.attributeKey != null) {
  1199. var attributeValidateResult =
  1200. _self.$refs.attributePanel.performValide();
  1201. if (attributeValidateResult != true) {
  1202. _self.error++;
  1203. }
  1204. var attributeValueDtos = _self.$refs.attributePanel.getValue();
  1205. }
  1206. console.log('check finished');
  1207. if (_self.error == 0) {
  1208. executeSave();
  1209. } else {
  1210. _self.errorCount = _self.error;
  1211. _self.modal1 = true;
  1212. }
  1213. function executeSave() {
  1214. _self.modelData.changed = true;
  1215. var subTabChangedData = _self.getSubTabChangedData();
  1216. if (subTabChangedData.length > 0) {
  1217. _self.modelData.saveDatas = subTabChangedData;
  1218. } else {
  1219. _self.modelData.saveDatas = null;
  1220. }
  1221. var tabSaveData = {
  1222. attributeValueDtos: attributeValueDtos,
  1223. persistenceData: _self.modelData,
  1224. };
  1225. _self.loading = true;
  1226. WindowServerUtil.saveTabData(
  1227. tabSaveData,
  1228. function (id) {
  1229. _self.loading = false;
  1230. // 自动关闭
  1231. var saveClose = Common.getRouteParam('saveClose');
  1232. if (saveClose == 'true') {
  1233. window.setTimeout(function () {
  1234. window.close();
  1235. }, 1000);
  1236. Notify.success(_self.$t('lang.tabFormEdit.savingSucceeded'), _self.$t('lang.tabFormEdit.describe2'), 1500);
  1237. return;
  1238. } else {
  1239. Notify.success(_self.$t('lang.tabFormEdit.savingSucceeded'), _self.$t('lang.tabFormEdit.dataSavingSucceeded'), 1500);
  1240. }
  1241. _self.modelData.id = id;
  1242. _self.callAfterSaveLogical();
  1243. if (_self.taskInfoId && _self.$refs.approveComment && command) {
  1244. // 从后台加载modelData数据
  1245. _self.loading = true;
  1246. CurdWindowResource.loadTabData(
  1247. _self.windowNo,
  1248. _self.tabIndex,
  1249. id,
  1250. ).then(
  1251. successData => {
  1252. _self.loading = false;
  1253. _self.$refs.approveComment.saveData(command, successData);
  1254. },
  1255. errorData => {
  1256. _self.loading = false;
  1257. Common.processException(errorData);
  1258. },
  1259. );
  1260. return;
  1261. }
  1262. //删除草稿数据
  1263. _self.deleteDataRecoveryDto();
  1264. var currIndex = _self.currIndex;
  1265. var totalCount = _self.totalCount;
  1266. if (_self.type == 'edit') {
  1267. _self.$router.push(
  1268. '/desktop/window/window-read/view/' +
  1269. _self.windowNo +
  1270. '/' +
  1271. _self.tabIndex +
  1272. '/' +
  1273. id +
  1274. '?currPage=' +
  1275. _self.currPage +
  1276. '&currIndex=' +
  1277. currIndex +
  1278. '&totalCount=' +
  1279. totalCount +
  1280. '&uuid=' +
  1281. _self.uuid,
  1282. );
  1283. } else if (_self.type == 'create') {
  1284. _self.$router.push(
  1285. '/desktop/window/window-read/view/' +
  1286. _self.windowNo +
  1287. '/' +
  1288. _self.tabIndex +
  1289. '/' +
  1290. id +
  1291. '?currPage=' +
  1292. _self.currPage +
  1293. '&currIndex=' +
  1294. 1 +
  1295. '&totalCount=' +
  1296. (Number(totalCount) + 1) +
  1297. '&uuid=' +
  1298. _self.uuid,
  1299. );
  1300. } else if (_self.type == 'restore') {
  1301. _self.$router.push(
  1302. '/desktop/window/window-read/view/' +
  1303. _self.windowNo +
  1304. '/' +
  1305. _self.tabIndex +
  1306. '/' +
  1307. id +
  1308. '?currPage=' +
  1309. 1 +
  1310. '&currIndex=' +
  1311. 1 +
  1312. '&totalCount=' +
  1313. 1 +
  1314. '&uuid=' +
  1315. _self.uuid,
  1316. );
  1317. }
  1318. },
  1319. function () {
  1320. _self.loading = false;
  1321. },
  1322. );
  1323. }
  1324. },
  1325. // 改变字段分组的显示和隐藏
  1326. changeFieldGroupStatus: function (fieldGroup) {
  1327. fieldGroup.show = !fieldGroup.show;
  1328. var index = this.tab.tabFormView.fieldGroups.indexOf(fieldGroup);
  1329. if (index != -1) {
  1330. this.tab.tabFormView.fieldGroups[index] = fieldGroup;
  1331. localStorage.setItem(
  1332. 'FieldGroupStatus_' +
  1333. this.windowNo +
  1334. '_' +
  1335. this.tabIndex +
  1336. '_' +
  1337. fieldGroup.groupName,
  1338. fieldGroup.show,
  1339. );
  1340. }
  1341. },
  1342. /**
  1343. * 执行Callout
  1344. */
  1345. executeCallout: function (fieldItem) {
  1346. var _self = this;
  1347. if (fieldItem.calloutProcessReportNo != null) {
  1348. _self.callout(fieldItem.calloutProcessReportNo);
  1349. }
  1350. },
  1351. // 值改变事件
  1352. valueChanged: function (newFieldValue, fieldItem) {
  1353. var _self = this;
  1354. console.log(fieldItem.fieldName + ' ValueChanged.');
  1355. console.log(newFieldValue);
  1356. var oldFieldValue = this.modelData.data[fieldItem.fieldName];
  1357. if (FieldUtil.isFieldValueEqual(newFieldValue, oldFieldValue) == false) {
  1358. this.modelData.data[fieldItem.fieldName] = newFieldValue;
  1359. if (
  1360. fieldItem.calloutProcessReportNo != undefined &&
  1361. fieldItem.calloutProcessReportNo != null
  1362. ) {
  1363. _self.callout(fieldItem.calloutProcessReportNo);
  1364. }
  1365. if (
  1366. fieldItem.calloutLogical != undefined &&
  1367. fieldItem.calloutLogical != null
  1368. ) {
  1369. _self.executeCalloutJs(fieldItem, fieldItem.calloutLogical);
  1370. }
  1371. if (
  1372. _self.modelData.changed &&
  1373. fieldItem.displayType == 'ListBoxEditor'
  1374. ) {
  1375. // 值改变时,刷新所有下拉框的keyValues
  1376. _self.refreshSelectField(fieldItem.fieldName);
  1377. }
  1378. // add by jack 20170808
  1379. _self.modelData.changed = true;
  1380. let clearDynamicValidField = function (item) {
  1381. var fieldName1 = item.fieldName;
  1382. var dynamicValidFields = item.dynamicValidFields;
  1383. if (
  1384. fieldName0 != fieldName1 &&
  1385. dynamicValidFields != undefined &&
  1386. dynamicValidFields.indexOf(fieldName0) >= 0
  1387. ) {
  1388. var fieldValue0 = _self.modelData.data[fieldName1];
  1389. fieldValue0.id = undefined;
  1390. if (fieldValue0.displayValue != undefined) {
  1391. fieldValue0.displayValue.splice(
  1392. 0,
  1393. fieldValue0.displayValue.length,
  1394. );
  1395. } else {
  1396. fieldValue0.displayValue = [];
  1397. }
  1398. _self.modelData.data[fieldName1] = fieldValue0;
  1399. }
  1400. };
  1401. // 遍历所有的字段,判断是否有动态约束
  1402. // 如果有关联的动态约束,则清空字段
  1403. var fieldName0 = fieldItem.fieldName;
  1404. _self.tabFormFields.forEach(function (item) {
  1405. clearDynamicValidField(item);
  1406. });
  1407. let fieldGroups = _self.tab.tabFormView.fieldGroups;
  1408. if (fieldGroups != null && fieldGroups.length > 0) {
  1409. fieldGroups.forEach(fieldGroup => {
  1410. if (fieldGroup.fields != null && fieldGroup.fields != null) {
  1411. fieldGroup.fields.forEach(field => {
  1412. clearDynamicValidField(field);
  1413. });
  1414. }
  1415. });
  1416. }
  1417. }
  1418. },
  1419. // 刷新下拉选择框keyValues
  1420. refreshSelectField: function (valueChangedFieldName) {
  1421. var _self = this;
  1422. if (_self.tabFormFields) {
  1423. _self.tabFormFields.forEach(function (item) {
  1424. if (item.displayType == 'ListBoxEditor') {
  1425. var name1 = ':' + valueChangedFieldName;
  1426. //var name2 = ":Parent_" + valueChangedFieldName;
  1427. var showLogical = item.showLogical;
  1428. if (showLogical != undefined && showLogical.indexOf(name1) >= 0) {
  1429. refresh(item);
  1430. }
  1431. }
  1432. });
  1433. }
  1434. if (_self.fieldGroup) {
  1435. _self.fieldGroup.fields.forEach(function (item) {
  1436. if (item.displayType == 'ListBoxEditor') {
  1437. var name1 = ':' + valueChangedFieldName;
  1438. //var name2 = ":Parent_" + valueChangedFieldName;
  1439. var showLogical = item.showLogical;
  1440. if (showLogical != undefined && showLogical.indexOf(name1) >= 0) {
  1441. refresh(item);
  1442. }
  1443. }
  1444. });
  1445. }
  1446. function refresh(item) {
  1447. var obj = {
  1448. windowNo: _self.windowNo,
  1449. tabIndex: _self.tabIndex,
  1450. fieldName: item.fieldName,
  1451. modelData: _self.modelData,
  1452. };
  1453. console.log('WindowEdit RefreshField');
  1454. $.ajax({
  1455. url: Common.getApiURL('FieldResource/refreshField'),
  1456. async: false,
  1457. dataType: 'json',
  1458. type: 'post',
  1459. data: JSON.stringify(obj),
  1460. contentType: 'application/json',
  1461. beforeSend: function (request) {
  1462. Common.addTokenToRequest(request);
  1463. },
  1464. success: function (data) {
  1465. if (data != undefined) {
  1466. item.keyValues = data.keyValues;
  1467. }
  1468. },
  1469. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1470. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  1471. },
  1472. });
  1473. }
  1474. },
  1475. /**
  1476. * 子页签触发父页签刷新
  1477. * @return {[type]} [description]
  1478. */
  1479. refreshParent: function () {
  1480. this.loadData();
  1481. },
  1482. /**
  1483. * 执行JS Callout
  1484. */
  1485. executeCalloutJs: function (fieldItem, scriptText) {
  1486. var _self = this;
  1487. // add by jack 20180529
  1488. var subTabChangedData = _self.getSubTabChangedData();
  1489. if (subTabChangedData.length > 0) {
  1490. _self.modelData.saveDatas = subTabChangedData;
  1491. } else {
  1492. _self.modelData.saveDatas = null;
  1493. }
  1494. let functionName = fieldItem.fieldName.replace('.', '_') + '_calloutjs';
  1495. let executeFunction = function(){
  1496. let actions = {
  1497. subTabsRef: _self.getSubTabs(),
  1498. };
  1499. let context = new _self.getContext(_self.modelData, actions);
  1500. try {
  1501. _self[functionName](context);
  1502. } catch (e) {
  1503. console.error(e);
  1504. Notify.error('数据字典定义异常', '【' + scriptText + '】前端列显示逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  1505. }
  1506. };
  1507. if (_self[functionName] == null) {
  1508. // 执行服务端的脚本
  1509. const jsUrl = _self.jsUrl;
  1510. if (jsUrl == null || jsUrl == undefined) {
  1511. Notify.error('数据字典定义异常', '【' + scriptText + '】Callout前端逻辑的JS文件不存在,请联系管理员检查数据字典是否JS文件。', false);
  1512. return;
  1513. }
  1514. let promise = JsUtil.dynamicLoadJsFunction(jsUrl, scriptText);
  1515. promise.then(targetFunction => {
  1516. console.log(targetFunction);
  1517. if (targetFunction == null) {
  1518. Notify.error('数据字典定义异常', '【' + scriptText + '】Callout前端逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  1519. return;
  1520. }
  1521. _self[functionName] = targetFunction;
  1522. executeFunction();
  1523. }, errorData => {
  1524. console.error(errorData);
  1525. });
  1526. } else {
  1527. executeFunction();
  1528. }
  1529. },
  1530. /**
  1531. * callout
  1532. * @param {[type]} calloutProcessReportNo [description]
  1533. * @return {[type]} [description]
  1534. */
  1535. callout: function (calloutProcessReportNo) {
  1536. var _self = this;
  1537. // add by jack 20180529
  1538. var subTabChangedData = _self.getSubTabChangedData();
  1539. if (subTabChangedData.length > 0) {
  1540. _self.modelData.saveDatas = subTabChangedData;
  1541. } else {
  1542. _self.modelData.saveDatas = null;
  1543. }
  1544. // 查询流程和报表的定义
  1545. ProcessReportResource.uniqueByNo(calloutProcessReportNo).then(
  1546. successData => {
  1547. if (successData == null) {
  1548. return;
  1549. }
  1550. // 执行服务端的脚本
  1551. ProcessReportResource.runCallout(
  1552. calloutProcessReportNo,
  1553. _self.modelData,
  1554. ).then(
  1555. successData => {
  1556. if (successData && successData.modelData) {
  1557. _self.modelData = successData.modelData;
  1558. }
  1559. // add by jack 20180529
  1560. // add by jack 20220601
  1561. _self.modelData.saveDatas = undefined;
  1562. },
  1563. errorData => {
  1564. Common.processException(errorData);
  1565. },
  1566. );
  1567. },
  1568. errorData => {
  1569. Common.processException(errorData);
  1570. },
  1571. );
  1572. },
  1573. // 获取子页签全部的数据
  1574. getSubTabAllData: function () {
  1575. var subTabAllRecords = [];
  1576. if (this.tab.subTabs != undefined) {
  1577. for (var index = 0; index < this.tab.subTabs.length; index++) {
  1578. var subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  1579. var modelDatas = this.$refs[subTabId][0].getAllModelData();
  1580. if (modelDatas != undefined && modelDatas.length > 0) {
  1581. modelDatas.forEach(function (modelData) {
  1582. subTabAllRecords.push(modelData);
  1583. });
  1584. }
  1585. }
  1586. }
  1587. console.log(subTabAllRecords);
  1588. return subTabAllRecords;
  1589. },
  1590. // 获取子页签发生改变的数据
  1591. getSubTabChangedData: function () {
  1592. var subTabChangedRecords = [];
  1593. if (this.tab.subTabs != undefined) {
  1594. for (var index = 0; index < this.tab.subTabs.length; index++) {
  1595. var subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  1596. var modelDatas = this.$refs[subTabId][0].getChangedModelData();
  1597. if (modelDatas != undefined && modelDatas.length > 0) {
  1598. modelDatas.forEach(function (modelData) {
  1599. subTabChangedRecords.push(modelData);
  1600. });
  1601. }
  1602. }
  1603. }
  1604. console.log(subTabChangedRecords);
  1605. return subTabChangedRecords;
  1606. },
  1607. // 获取子页签数据校验的Promise
  1608. getSubTabValidatePromise: function () {
  1609. var _self = this;
  1610. var subTabValidates = [];
  1611. if (this.tab.subTabs != undefined) {
  1612. for (var index = 0; index < this.tab.subTabs.length; index++) {
  1613. var subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  1614. var result = this.$refs[subTabId][0].performValidate();
  1615. if (result != undefined && result.length > 0) {
  1616. subTabValidates = subTabValidates.concat(result);
  1617. }
  1618. }
  1619. }
  1620. return subTabValidates;
  1621. },
  1622. /**
  1623. * 表单字段的属性(显示)属性发生改变事件
  1624. */
  1625. tabFormFieldPropertyChanged: function (tabFormFieldClone) {
  1626. TabFormView.restoreTabFormFieldDef(
  1627. this.windowNo,
  1628. this.tabIndex,
  1629. this.tabFormFields,
  1630. );
  1631. },
  1632. /**
  1633. * 撤销提示
  1634. */
  1635. cancelModel: function () {
  1636. var _self = this;
  1637. _self.modal3 = true;
  1638. },
  1639. /**
  1640. * 取消
  1641. */
  1642. cancelNo: function () {
  1643. var _self = this;
  1644. _self.modal3 = false;
  1645. },
  1646. /**
  1647. * 撤销
  1648. * @return {void}
  1649. */
  1650. cancelOk: function () {
  1651. var _self = this;
  1652. var currPage = _self.currPage;
  1653. var currIndex = _self.currIndex;
  1654. var totalCount = _self.totalCount;
  1655. _self.cancelCommand = true;
  1656. if (_self.recordId == null || _self.recordId == '') {
  1657. _self.$router.push(
  1658. '/desktop/window/' +
  1659. _self.windowNo +
  1660. '?currPage=' +
  1661. currPage +
  1662. '&uuid=' +
  1663. this.uuid,
  1664. );
  1665. } else {
  1666. // bug fixed by jack,编辑后直接取消
  1667. // var cacheData = localStorage.getItem(_self.uuid);
  1668. // if (cacheData != undefined && cacheData.length > 0) {
  1669. // cacheData = JSON.parse(cacheData);
  1670. // var window = cacheData.window;
  1671. // var tab = cacheData.tab;
  1672. // if (window == undefined || tab == undefined) {
  1673. // _self.$router.push('/desktop/window/' + _self.windowNo + "?currPage=" + currPage + "&uuid=" + this.uuid);
  1674. // return;
  1675. // }
  1676. // }
  1677. _self.$router.push(
  1678. '/desktop/window/window-read/view/' +
  1679. _self.windowNo +
  1680. '/' +
  1681. _self.tabIndex +
  1682. '/' +
  1683. _self.recordId +
  1684. '?currPage=' +
  1685. currPage +
  1686. '&currIndex=' +
  1687. currIndex +
  1688. '&totalCount=' +
  1689. totalCount +
  1690. '&uuid=' +
  1691. this.uuid,
  1692. );
  1693. }
  1694. //删除草稿数据
  1695. _self.deleteDataRecoveryDto();
  1696. },
  1697. /**
  1698. * 子标题
  1699. * @return {String} 子标题
  1700. */
  1701. subTitle: function () {
  1702. var _self = this;
  1703. var subTitle = '';
  1704. if (_self.modelData != null && _self.modelData.data == null) {
  1705. return subTitle;
  1706. }
  1707. if (
  1708. _self.modelData != null &&
  1709. _self.modelData.data != null &&
  1710. _self.modelData.data.documentNo != null
  1711. ) {
  1712. subTitle =
  1713. _self.modelData.data.documentNo.displayValue == null ?
  1714. '' :
  1715. _self.modelData.data.documentNo.displayValue[0];
  1716. } else if (
  1717. _self.modelData != null &&
  1718. _self.modelData.data != null &&
  1719. _self.modelData.data.no != null
  1720. ) {
  1721. subTitle =
  1722. _self.modelData.data.no.displayValue == null ?
  1723. '' :
  1724. _self.modelData.data.no.displayValue[0];
  1725. } else if (
  1726. _self.modelData != null &&
  1727. _self.modelData.data != null &&
  1728. _self.modelData.data.name != null
  1729. ) {
  1730. subTitle =
  1731. _self.modelData.data.name.displayValue == null ?
  1732. '' :
  1733. _self.modelData.data.name.displayValue[0];
  1734. }
  1735. return subTitle;
  1736. },
  1737. back: function () {
  1738. var _self = this;
  1739. _self.$router.push(
  1740. '/desktop/window/' +
  1741. _self.windowNo +
  1742. '?currPage=' +
  1743. _self.currPage +
  1744. '&uuid=' +
  1745. this.uuid,
  1746. );
  1747. },
  1748. /**
  1749. * 上一条数据
  1750. * @return {void}
  1751. */
  1752. pre: function () {
  1753. var _self = this;
  1754. if (_self.isModelDataChanged() == true) {
  1755. Notify.notice(_self.$t('lang.tabFormEdit.dataNotSaved'), _self.$t('lang.tabFormEdit.describe1'), false);
  1756. return;
  1757. }
  1758. if (_self.currIndex <= 1) {
  1759. return;
  1760. }
  1761. _self.currIndex--;
  1762. var tabQueryParam = {
  1763. range: {
  1764. start: _self.currIndex - 1,
  1765. length: 1,
  1766. },
  1767. tabIndex: _self.tabIndex,
  1768. windowNo: _self.windowNo,
  1769. };
  1770. UserStorageResource.uniqueByKey(_self.uuid).then(
  1771. successData => {
  1772. // if(successData.errorCode != 0) {
  1773. // Notify.error('提示', successData.errorMessage, false);
  1774. // return;
  1775. // }
  1776. let simpleFilterParams = null;
  1777. let complexFilterParams = null;
  1778. if (successData.data != null && successData.data != '') {
  1779. let temp = JSON.parse(successData.data);
  1780. // 分页数据
  1781. // 简单过滤条件
  1782. tabQueryParam.simpleFilterCondition = temp.simpleFilterParams;
  1783. // 复杂过滤条件
  1784. tabQueryParam.filterParams = temp.complexFilterParams;
  1785. // 排序
  1786. tabQueryParam.sortStr = temp.sortStr;
  1787. }
  1788. _self.loadTabData(tabQueryParam);
  1789. },
  1790. errorData => {
  1791. Common.processException(errorData);
  1792. },
  1793. );
  1794. },
  1795. /**
  1796. * 下一条数据
  1797. * @return {void}
  1798. */
  1799. next: function () {
  1800. var _self = this;
  1801. if (_self.isModelDataChanged() == true) {
  1802. Notify.notice(_self.$t('lang.tabFormEdit.dataNotSaved'), _self.$t('lang.tabFormEdit.describe1'), false);
  1803. return;
  1804. }
  1805. var totalCount = _self.totalCount;
  1806. if (_self.currIndex >= totalCount) {
  1807. return;
  1808. }
  1809. _self.currIndex++;
  1810. var tabQueryParam = {
  1811. range: {
  1812. start: _self.currIndex - 1,
  1813. length: 1,
  1814. },
  1815. tabIndex: _self.tabIndex,
  1816. windowNo: _self.windowNo,
  1817. };
  1818. UserStorageResource.uniqueByKey(_self.uuid).then(
  1819. successData => {
  1820. // if(successData.errorCode != 0) {
  1821. // Notify.error('提示', successData.errorMessage, false);
  1822. // return;
  1823. // }
  1824. if (successData.data != null && successData.data != '') {
  1825. let temp = JSON.parse(successData.data);
  1826. // 分页数据
  1827. // 简单过滤条件
  1828. tabQueryParam.simpleFilterCondition = temp.simpleFilterParams;
  1829. // 复杂过滤条件
  1830. tabQueryParam.filterParams = temp.complexFilterParams;
  1831. // 排序
  1832. tabQueryParam.sortStr = temp.sortStr;
  1833. // 是否需要审批
  1834. tabQueryParam.isHasWorkflow = false;
  1835. }
  1836. _self.loadTabData(tabQueryParam);
  1837. },
  1838. errorData => {
  1839. Common.processException(errorData);
  1840. },
  1841. );
  1842. },
  1843. /**
  1844. * 加载一条数据
  1845. * @param {Object} tabQueryParam 查询条件
  1846. * @return {void}
  1847. */
  1848. loadTabData: function (tabQueryParam) {
  1849. var _self = this;
  1850. _self.loading = true;
  1851. WindowServerUtil.queryTabData(
  1852. tabQueryParam,
  1853. function (gridData) {
  1854. var dataLists = gridData.dataList;
  1855. if (dataLists != undefined && dataLists.length > 0) {
  1856. _self.modelData = dataLists[0];
  1857. }
  1858. _self.loading = false;
  1859. },
  1860. function () {
  1861. _self.loading = false;
  1862. },
  1863. );
  1864. },
  1865. /**
  1866. * 计算按钮坐标
  1867. *
  1868. */
  1869. computerButtonGroupLeftTop: function () {
  1870. var _self = this;
  1871. var fixedButtonGroup = $(_self.$refs.fixedButtonGroup);
  1872. if (fixedButtonGroup != undefined) {
  1873. var offset = fixedButtonGroup.offset();
  1874. if (offset != undefined) {
  1875. _self.buttonGroupInitLeft = offset.left;
  1876. _self.buttonGroupInitTop = offset.top;
  1877. }
  1878. }
  1879. },
  1880. /**
  1881. * ModelData 是否发生变化
  1882. */
  1883. isModelDataChanged: function () {
  1884. var _self = this;
  1885. // 判断当前数据是否发生改变
  1886. if (_self.modelData.changed == true) {
  1887. return true;
  1888. }
  1889. // 判断子页签数据是否发生改变
  1890. var subTabChangedData = _self.getSubTabChangedData();
  1891. if (subTabChangedData != undefined && subTabChangedData.length > 0) {
  1892. return true;
  1893. }
  1894. return false;
  1895. },
  1896. /**
  1897. * 自动点击菜单
  1898. */
  1899. autoClickMenu: function () {
  1900. var _self = this;
  1901. // 判断是否有URL参数 自动点击菜单 canAutoClickMenu
  1902. var canAutoClickMenu = Common.getRouteParam('canAutoClickMenu');
  1903. if (
  1904. (canAutoClickMenu == null || canAutoClickMenu == '') &&
  1905. canAutoClickMenu != 'true'
  1906. ) {
  1907. const route1 = this.$route;
  1908. let path = route1.path;
  1909. let query = route1.query; // 这里可以用Vue的方法获取参数,也可以用正则的方法获取url中的参数
  1910. query.canAutoClickMenu = true;
  1911. // !!!!不推荐使用push的方式进行更新路由参数这样会增加路由的历史记录 (浏览器的后退键被破坏)
  1912. this.$router.push({ path, query });
  1913. // 推荐使用
  1914. // this.$router.replace({path, query}); // 更新url上面的内容,且页面不会重载 / 刷新
  1915. if (_self.type == 'create') {
  1916. if (
  1917. _self.tab &&
  1918. _self.tab.tabButtons &&
  1919. _self.tab.tabButtons.length > 0
  1920. ) {
  1921. for (var i = 0; i < _self.tab.tabButtons.length; i++) {
  1922. var itemButton = _self.tab.tabButtons[i];
  1923. if (itemButton.createAutoClick == true) {
  1924. _self.backupView().then(
  1925. successData => {
  1926. _self.$refs.tabButton.execute(itemButton);
  1927. },
  1928. errorData => { },
  1929. );
  1930. break;
  1931. }
  1932. }
  1933. }
  1934. }
  1935. }
  1936. },
  1937. /**
  1938. * 开启草稿保存功能,每隔15秒保存一次
  1939. * @author GuoZhiBo 20211008
  1940. */
  1941. startSaveInterval: function () {
  1942. var _self = this;
  1943. _self.autoSaveInterval = setInterval(function () {
  1944. var subTabChangedData = _self.getSubTabChangedData();
  1945. // bug fixed by jack
  1946. // 这里不能对 _self.modelData.saveDatas 属性赋值,否则在 当页签的GridBody中修改了某个值以后,
  1947. // 其监听 parentModelData 也会发生改变,导致性能很差
  1948. var modelDataClone = JSON.parse(JSON.stringify(_self.modelData));
  1949. if (subTabChangedData.length > 0) {
  1950. var subTabChangedDataClone = JSON.parse(
  1951. JSON.stringify(subTabChangedData),
  1952. );
  1953. modelDataClone.saveDatas = subTabChangedDataClone;
  1954. } else {
  1955. modelDataClone.saveDatas = null;
  1956. }
  1957. if (_self.dataRecoveryDto == undefined) {
  1958. _self.dataRecoveryDto = {
  1959. modelData: modelDataClone,
  1960. windowId: _self.windowNo,
  1961. type: _self.type,
  1962. };
  1963. } else {
  1964. _self.dataRecoveryDto.modelData = modelDataClone;
  1965. }
  1966. DataRecoveryResource.saveDataRecoveryDto(
  1967. _self.dataRecoveryDto,
  1968. function (data) {
  1969. console.log('草稿数据保存成功.');
  1970. },
  1971. function (xmlHttpRequest) {
  1972. console.log('草稿数据保存失败: %s 。', xmlHttpRequest.responseText);
  1973. },
  1974. );
  1975. }, 15000);
  1976. },
  1977. /**
  1978. * 页签按钮的显示逻辑
  1979. */
  1980. tabButtonsShowLogical: function () {
  1981. let _self = this;
  1982. if (
  1983. this.tab.tabFormView != null &&
  1984. this.tab.tabFormView.tabButtons != null
  1985. ) {
  1986. for (
  1987. let index = 0; index < this.tab.tabFormView.tabButtons.length; index++
  1988. ) {
  1989. let tabButton = this.tab.tabFormView.tabButtons[index];
  1990. if (tabButton.editMode == true) {
  1991. var logic = tabButton.showLogical;
  1992. if (logic == null || logic == '') {
  1993. tabButton.invisible = false;
  1994. return;
  1995. }
  1996. let functionName = 'form_edit_show_logical_' + index;
  1997. let executeFunction = function(){
  1998. let actions = {
  1999. subTabsRef: _self.getSubTabs(),
  2000. };
  2001. try {
  2002. let context = new _self.getContext(_self.modelData, actions);
  2003. tabButton.invisible = !_self[functionName](context);
  2004. } catch (error) {
  2005. console.error(error);
  2006. Notify.error('数据字典定义异常', '【' + logic + '】按钮显示逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  2007. }
  2008. };
  2009. if (this[functionName] == null) {
  2010. const jsUrl = this.jsUrl;
  2011. if (jsUrl == null || jsUrl == undefined) {
  2012. Notify.error('数据字典定义异常', '【' + logic + '】按钮显示逻辑的JS文件不存在,请联系管理员检查数据字典是否存在JS文件', false);
  2013. return;
  2014. }
  2015. let promise = JsUtil.dynamicLoadJsFunction(jsUrl, logic);
  2016. promise.then(targetFunction => {
  2017. if (targetFunction == null) {
  2018. Notify.error('数据字典定义异常', '【' + logic + '】按钮显示逻辑逻辑定义异常,请联系管理员检查数据字典的定义', false);
  2019. return;
  2020. }
  2021. console.log(targetFunction);
  2022. this[functionName] = targetFunction;
  2023. executeFunction();
  2024. }, errorData => {
  2025. console.error(errorData);
  2026. });
  2027. } else {
  2028. executeFunction();
  2029. }
  2030. }
  2031. }
  2032. }
  2033. },
  2034. /**
  2035. * 调用保存后的业务逻辑
  2036. */
  2037. callAfterSaveLogical: function () {
  2038. var _self = this;
  2039. if (
  2040. this.tab != null &&
  2041. this.tab.tabFormView != null &&
  2042. this.tab.tabFormView.logicalAfterSave != null &&
  2043. this.tab.tabFormView.logicalAfterSave.length > 0
  2044. ) {
  2045. var logic = this.tab.tabFormView.logicalAfterSave;
  2046. if (logic == null || logic == '') {
  2047. return;
  2048. }
  2049. let functionName = 'form_edit_logical_after_save';
  2050. const executeFunction = function (){
  2051. let actions = {
  2052. subTabsRef: _self.getSubTabs(),
  2053. };
  2054. let context = new _self.getContext(_self.modelData, actions);
  2055. try{
  2056. _self[functionName](context);
  2057. }catch(e){
  2058. console.error(e);
  2059. Notify.error('数据字典定义异常', '【' + logic + '】保存后业务逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  2060. }
  2061. };
  2062. if (_self[functionName] == null) {
  2063. const jsUrl = this.jsUrl;
  2064. if (jsUrl == null || jsUrl == undefined) {
  2065. Notify.error('数据字典定义异常', '【' + logic + '】保存后业务逻辑的JS文件不存在,请联系管理员检查数据字典是否存在JS文件', false);
  2066. return;
  2067. }
  2068. let promise = JsUtil.dynamicLoadJsFunction(jsUrl, logic);
  2069. promise.then(targetFunction => {
  2070. if(targetFunction == null){
  2071. Notify.error('数据字典定义异常', '【' + logic + '】保存后业务逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  2072. return;
  2073. }
  2074. _self[functionName] = targetFunction;
  2075. executeFunction();
  2076. }, errorData => {
  2077. console.error(errorData);
  2078. });
  2079. }else{
  2080. executeFunction();
  2081. }
  2082. }
  2083. },
  2084. /**
  2085. * 当页面卸载(关闭)或刷新时调用
  2086. */
  2087. beforeunloadFn: function (e) {
  2088. e = e || window.event;
  2089. if (e) {
  2090. e.returnValue = '关闭提示';
  2091. }
  2092. return '关闭提示';
  2093. },
  2094. /**
  2095. * 子页签(表格)修改父页签的数据
  2096. * @param { String } fieldName 字段名称
  2097. * @param { com.leanwo.prodog.restful.base.model.FieldValue } fieldValue 字段的值
  2098. * @author YangZhiJie 20211012
  2099. */
  2100. changeRootParentModelData: function (data) {
  2101. if (data === undefined || data === null) {
  2102. console.error('子页签修改父页签的数据,但数据为空。');
  2103. return;
  2104. }
  2105. const fieldName = data.fieldName;
  2106. const fieldValue = data.fieldValue;
  2107. if (fieldName === undefined || fieldName === null) {
  2108. console.error(
  2109. '子页签修改父页签的数据,但字段名称 %s 为空。',
  2110. fieldName,
  2111. );
  2112. return;
  2113. }
  2114. if (fieldValue === undefined || fieldValue === null) {
  2115. console.error('子页签修改父页签的数据,但字段值 %s 为空。', fieldName);
  2116. return;
  2117. }
  2118. let fieldItem = null;
  2119. for (let index = 0; index < this.tabFormFields.length; index++) {
  2120. if (this.tabFormFields[index].fieldName === fieldName) {
  2121. fieldItem = this.tabFormFields[index];
  2122. break;
  2123. }
  2124. }
  2125. if (fieldItem === null) {
  2126. console.error(
  2127. '子页签修改父页签的数据,但找不到字段 %s 的定义。',
  2128. fieldName,
  2129. );
  2130. return;
  2131. }
  2132. console.debug('子页签修改父页签的数据。', fieldName, fieldValue);
  2133. this.valueChanged(fieldValue, fieldItem);
  2134. },
  2135. },
  2136. };
  2137. </script>
  2138. <style scoped>
  2139. .field-group {
  2140. padding-left: 30px;
  2141. padding-right: 30px;
  2142. }
  2143. .fieldGroup-head {
  2144. cursor: pointer;
  2145. }
  2146. .a-back {
  2147. cursor: pointer;
  2148. text-decoration: none;
  2149. }
  2150. .m-space-btn-group {
  2151. height: 34px;
  2152. }
  2153. .m-row {
  2154. margin-bottom: 15px;
  2155. }
  2156. .fixed-btn-group {
  2157. z-index: 3;
  2158. background-color: #f7f7f7;
  2159. }
  2160. </style>
  2161. <style>
  2162. .btn-group-fixed {
  2163. position: fixed;
  2164. top: 0;
  2165. left: 0;
  2166. z-index: 3;
  2167. }
  2168. .m-image {
  2169. height: 50px;
  2170. cursor: pointer;
  2171. }
  2172. </style>