TabFormEdit.vue 76 KB

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