TabFormEditModal.vue 79 KB

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