TabFormEditModal.vue 78 KB

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