TabFormEdit.vue 78 KB

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