TabFormEdit.vue 77 KB

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