TabFormEditModal.vue 81 KB

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