TabFormEditModal.vue 76 KB

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