TabFormEdit.vue 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412
  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.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 './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. function (modelData) {
  686. if (_self.$refs.loading != undefined) {
  687. _self.loading = false;
  688. }
  689. modelData.editMode = true;
  690. _self.modelData = modelData;
  691. _self.recordId = undefined;
  692. // add by jack 20180914
  693. // 自动点击菜单
  694. _self.autoClickMenu();
  695. },
  696. function () {
  697. if (_self.$refs.loading != undefined) {
  698. _self.loading = false;
  699. }
  700. },
  701. );
  702. },
  703. function () {
  704. if (_self.$refs.loading != undefined) {
  705. _self.loading = false;
  706. }
  707. },
  708. );
  709. },
  710. // 初始化编辑界面
  711. initEditView: function () {
  712. var _self = this;
  713. _self.loading = true;
  714. _self.processInstanceId = '';
  715. if (_self.taskInfoId) {
  716. CurdWindowResource.uniqueByNoWithWorkflow(
  717. null,
  718. _self.taskInfoId,
  719. _self.windowNo,
  720. ).then(
  721. successData => {
  722. initWindowAfterLoaded(successData);
  723. },
  724. errorData => {
  725. _self.loading = false;
  726. Common.processException(errorData);
  727. },
  728. );
  729. } else {
  730. WindowServerUtil.getWindowById(
  731. _self.windowNo,
  732. function (window) {
  733. initWindowAfterLoaded(window);
  734. },
  735. function () {
  736. _self.loading = false;
  737. },
  738. );
  739. }
  740. function initWindowAfterLoaded(window) {
  741. WindowClientUtil.parseFilterSchema(window);
  742. var tab = WindowClientUtil.getTab(window, _self.tabIndex);
  743. WindowClientUtil.parseSubTab(window, tab);
  744. WindowClientUtil.parseFieldGroup(tab);
  745. WindowClientUtil.restoreWindowTabFieldGroupsVisible(window);
  746. _self.tabFormFields = WindowClientUtil.getDetailField(tab);
  747. _self.window = window;
  748. _self.jsUrl = window.jsUrl;
  749. _self.tab = tab;
  750. TabFormView.restoreTabFormFieldDef(
  751. _self.windowNo,
  752. _self.tabIndex,
  753. _self.tabFormFields,
  754. );
  755. if (_self.window.workflow != undefined && _self.modelData.id > 0) {
  756. _self.processDefinitionId = _self.window.workflow.deploymentId;
  757. }
  758. if (
  759. _self.window.reportViewDto != null &&
  760. _self.window.reportViewDto.reportViewItemDtos != null &&
  761. _self.window.reportViewDto.reportViewItemDtos.length > 0 &&
  762. _self.workflowType == 'approve'
  763. ) {
  764. var isflag = false;
  765. _self.window.reportViewDto.reportViewItemDtos.forEach(function (item) {
  766. if (item.defaultDisplayReport) {
  767. isflag = true;
  768. }
  769. });
  770. if (isflag) {
  771. _self.windowDisplayType = 'Report';
  772. } else {
  773. _self.windowDisplayType = 'Grid';
  774. }
  775. } else {
  776. _self.windowDisplayType = 'Grid';
  777. _self.isView = false;
  778. }
  779. _self.loading = false;
  780. _self.loadData();
  781. }
  782. },
  783. /**
  784. * 切换显示模式
  785. * @author GuoZhiBo 20210419
  786. */
  787. changeWindowDisplayType: function () {
  788. var _self = this;
  789. if (_self.windowDisplayType == 'Grid') {
  790. _self.windowDisplayType = 'Report';
  791. } else {
  792. _self.windowDisplayType = 'Grid';
  793. _self.$nextTick(function () {
  794. for (var index = 0; index < _self.tab.subTabs.length; index++) {
  795. var subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  796. _self.$refs[subTabId][0].queryGridData();
  797. }
  798. });
  799. }
  800. },
  801. // 恢复视图
  802. restoreView: function () {
  803. let _self = this;
  804. let key = _self.uuid + '_modelData';
  805. _self.loading = true;
  806. _self.processInstanceId = '';
  807. WindowServerUtil.getWindowById(
  808. _self.windowNo,
  809. function (window) {
  810. WindowClientUtil.parseFilterSchema(window);
  811. var tab = WindowClientUtil.getTab(window, _self.tabIndex);
  812. WindowClientUtil.parseSubTab(window, tab);
  813. WindowClientUtil.parseFieldGroup(tab);
  814. WindowClientUtil.restoreWindowTabFieldGroupsVisible(window);
  815. _self.tabFormFields = WindowClientUtil.getDetailField(tab);
  816. _self.window = window;
  817. _self.jsUrl = window.jsUrl;
  818. _self.tab = tab;
  819. TabFormView.restoreTabFormFieldDef(
  820. _self.windowNo,
  821. _self.tabIndex,
  822. _self.tabFormFields,
  823. );
  824. if (_self.window.workflow != undefined && _self.modelData.id > 0) {
  825. _self.processDefinitionId = _self.window.workflow.deploymentId;
  826. }
  827. _self.loading = false;
  828. if (_self.isRestoreData == 1) {
  829. DataRecoveryResource.queryDataRecoveryDtoByUserId(
  830. _self.windowNo,
  831. _self.type,
  832. ).then(
  833. successData => {
  834. if (successData != null) {
  835. _self.restoreModelData(successData.modelData);
  836. }
  837. },
  838. errorData => {
  839. Common.processException(errorData);
  840. },
  841. );
  842. } else {
  843. UserStorageResource.uniqueByKey(key).then(
  844. successData => {
  845. // if(successData.errorCode != 0) {
  846. // Notify.error('提示', successData.errorMessage, false);
  847. // return;
  848. // }
  849. if (successData.data != null && successData.data != '') {
  850. let cacheModelData = JSON.parse(successData.data);
  851. cacheModelData.restore = true;
  852. // 恢复父页签的数据
  853. _self.modelData = cacheModelData;
  854. _self.$nextTick(function () {
  855. if (
  856. cacheModelData.saveDatas != undefined &&
  857. cacheModelData.saveDatas.length > 0
  858. ) {
  859. cacheModelData.saveDatas.forEach(function (saveData) {
  860. // 恢复子页签的数据
  861. var subTabId = 'subTab' + saveData.tabIndex;
  862. var tabElements = _self.$refs[subTabId];
  863. if (tabElements && tabElements.length > 0) {
  864. var tabElement = tabElements[0];
  865. if (tabElement) {
  866. tabElement.addModelData(saveData);
  867. }
  868. }
  869. });
  870. } else {
  871. // BUG描述:父子页签,编辑以后撤销,子页签数据不显示
  872. // BUG修复:刷新子页签的数据
  873. // bug fixed by jack 20180203
  874. for (
  875. var index = 0; index < _self.tab.subTabs.length; index++
  876. ) {
  877. var subTabId =
  878. 'subTab' + this.tab.subTabs[index].tabIndex;
  879. _self.$refs[subTabId][0].queryGridData();
  880. }
  881. }
  882. });
  883. console.log(cacheModelData);
  884. }
  885. },
  886. errorData => {
  887. Common.processException(errorData);
  888. },
  889. );
  890. }
  891. },
  892. function () {
  893. _self.loading = false;
  894. },
  895. );
  896. },
  897. /**
  898. * 数据发生改变
  899. * eg:生单界面回传了新的modelData数据
  900. */
  901. modelDataChanged: function (newModelData) {
  902. var _self = this;
  903. // 恢复父页签的数据
  904. newModelData.visible = true;
  905. if (
  906. newModelData.saveDatas != undefined &&
  907. newModelData.saveDatas.length > 0
  908. ) {
  909. newModelData.saveDatas.forEach(function (item) {
  910. item.visible = true;
  911. });
  912. }
  913. // 恢复父页签的数据
  914. _self.modelData = newModelData;
  915. _self.$nextTick(function () {
  916. if (
  917. newModelData.saveDatas != undefined &&
  918. newModelData.saveDatas.length > 0
  919. ) {
  920. let firstModelData = newModelData.saveDatas[0];
  921. // 恢复子页签的数据
  922. let subTabId = 'subTab' + firstModelData.tabIndex;
  923. var tabElements = _self.$refs[subTabId];
  924. if (tabElements && tabElements.length > 0) {
  925. var tabElement = tabElements[0];
  926. if (tabElement) {
  927. tabElement.replaceModelDatas(newModelData.saveDatas);
  928. }
  929. }
  930. // bug fixed by jack 2022-01-17
  931. // 修复生单界面跳转回来以后,如果子页签 行数多的话,输入非常卡的BUG。
  932. newModelData.saveDatas = null;
  933. } else {
  934. // BUG描述:父子页签,编辑以后撤销,子页签数据不显示
  935. // BUG修复:刷新子页签的数据
  936. // bug fixed by jack 20180203
  937. for (var index = 0; index < _self.tab.subTabs.length; index++) {
  938. let subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  939. _self.$refs[subTabId][0].queryGridData();
  940. }
  941. }
  942. });
  943. },
  944. /**
  945. * 获取界面的数据
  946. * eg:生单界面获取modelData数据
  947. */
  948. getModelData: function () {
  949. var _self = this;
  950. var subTabAllData = _self.getSubTabAllData();
  951. if (subTabAllData.length > 0) {
  952. _self.modelData.saveDatas = subTabAllData;
  953. } else {
  954. _self.modelData.saveDatas = null;
  955. }
  956. return _self.modelData;
  957. },
  958. executeProcess: function (processReportNo) {
  959. var _self = this;
  960. var ids = [];
  961. if (_self.modelDatas) {
  962. _self.modelDatas.forEach(function (modelData) {
  963. if (modelData.select == true) {
  964. ids.push(modelData.id);
  965. }
  966. });
  967. } else if (_self.modelData) {
  968. ids.push(_self.modelData.id);
  969. }
  970. ProcessReportResource.runProcessByIds(processReportNo, ids).then(
  971. successData => {
  972. var processReportResult = successData;
  973. if (_self.processReportResult == undefined) {
  974. if (
  975. processReportResult.reportResults != undefined &&
  976. processReportResult.reportResults.length > 0
  977. ) {
  978. processReportResult.reportResults.forEach(function (item, index) {
  979. if (item.reportDefinitionType!=='ExcelReport') {
  980. item.previewIndex=1;
  981. } else {
  982. item.previewIndex=2;
  983. }
  984. if (index == 0) {
  985. item['showPreview'] = true;
  986. } else {
  987. item['showPreview'] = false;
  988. }
  989. });
  990. }
  991. _self.processReportResult = processReportResult;
  992. } else {
  993. if (
  994. processReportResult.reportResults != undefined &&
  995. processReportResult.reportResults.length > 0
  996. ) {
  997. processReportResult.reportResults.forEach(function (item, index) {
  998. item.previewIndex = 1;
  999. if (index == 0) {
  1000. item.showPreview = true;
  1001. } else {
  1002. item.showPreview = false;
  1003. }
  1004. _self.processReportResult.reportResults.push(item);
  1005. });
  1006. }
  1007. }
  1008. },
  1009. errorData => {
  1010. Common.processException(errorData);
  1011. },
  1012. );
  1013. },
  1014. getContext: Context,
  1015. /**
  1016. * 报表视图显示逻辑
  1017. */
  1018. reportViewsShowLogical: function () {
  1019. var _self = this;
  1020. if(_self.windowDisplayType != 'Report'){
  1021. // add by jack 2023-12-05
  1022. // 如果不处于报表界面,那么不执行下述业务逻辑
  1023. return;
  1024. }
  1025. if (
  1026. _self.window.reportViewDto != null &&
  1027. _self.window.reportViewDto.reportViewItemDtos != null
  1028. ) {
  1029. _self.processReportResult = undefined;
  1030. for (
  1031. let index = 0; index < _self.window.reportViewDto.reportViewItemDtos.length; index++
  1032. ) {
  1033. let reportViewItemDto =
  1034. _self.window.reportViewDto.reportViewItemDtos[index];
  1035. var logic = reportViewItemDto.showLogical;
  1036. if (logic == null || logic == '') {
  1037. reportViewItemDto.invisible = false;
  1038. _self.executeProcess(reportViewItemDto.processReportNo);
  1039. return;
  1040. }
  1041. let functionName = 'form_view_showlogical_' + index;
  1042. const executeFunction = function (){
  1043. let actions = {
  1044. subTabsRef: _self.getSubTabs(),
  1045. };
  1046. let context = new _self.getContext(_self.modelData, actions);
  1047. try{
  1048. reportViewItemDto.invisible = !_self[functionName](context);
  1049. if (reportViewItemDto.invisible == false) {
  1050. _self.executeProcess(reportViewItemDto.processReportNo);
  1051. }
  1052. }catch(e){
  1053. console.error(e);
  1054. Notify.error('数据字典定义异常', '【' + logic + '】报表显示逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  1055. }
  1056. };
  1057. if (this[functionName] == null) {
  1058. const jsUrl = this.jsUrl;
  1059. if (jsUrl == null || jsUrl == undefined) {
  1060. Notify.error('数据字典定义异常', '【' + logic + '】报表显示逻辑的JS文件不存在,请联系管理员检查数据字典是否存在JS文件', false);
  1061. return;
  1062. }
  1063. let promise = JsUtil.dynamicLoadJsFunction(jsUrl, logic);
  1064. promise.then(targetFunction => {
  1065. _self[functionName] = targetFunction;
  1066. if(targetFunction == null){
  1067. Notify.error('数据字典定义异常', '【' + logic + '】报表显示逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  1068. return;
  1069. }
  1070. executeFunction();
  1071. }, errorData => {
  1072. console.error(errorData);
  1073. });
  1074. }else{
  1075. executeFunction();
  1076. }
  1077. }
  1078. }
  1079. },
  1080. /**
  1081. * 获取子页签的集合
  1082. */
  1083. getSubTabs: function () {
  1084. var _self = this;
  1085. let subTabsRef = [];
  1086. for (var tabIndex = 0; tabIndex < _self.tab.subTabs.length; tabIndex++) {
  1087. var subTabId = 'subTab' + this.tab.subTabs[tabIndex].tabIndex;
  1088. subTabsRef.push(_self.$refs[subTabId][0]);
  1089. }
  1090. return subTabsRef;
  1091. },
  1092. // 备份视图
  1093. backupView: function () {
  1094. var _self = this;
  1095. var subTabChangedData = _self.getSubTabChangedData();
  1096. if (subTabChangedData.length > 0) {
  1097. _self.modelData.saveDatas = subTabChangedData;
  1098. } else {
  1099. _self.modelData.saveDatas = null;
  1100. }
  1101. _self.modelData.restore = null;
  1102. // bug 修复:生单功能问题:新建单据,再点击生单,会提示需要保存或撤销,必须先保存一次如此提示过后,才可以点击生单按钮进入来源单据选择页面,并且在勾选来源单据后点击确定无反应
  1103. _self.cancelCommand = true;
  1104. let key = _self.uuid + '_modelData';
  1105. let userStorageDtos = [{
  1106. key: key,
  1107. value: JSON.stringify(_self.modelData),
  1108. }];
  1109. let promise = new Promise(function (reslove, reject) {
  1110. // 组装查询条件,然后放到后台数据库当中
  1111. UserStorageResource.uploadUserStorage(userStorageDtos).then(
  1112. successData => {
  1113. reslove();
  1114. },
  1115. errorData => {
  1116. Common.processException(errorData);
  1117. reject();
  1118. },
  1119. );
  1120. });
  1121. return promise;
  1122. },
  1123. loadData: function () {
  1124. var _self = this;
  1125. if (_self.recordId == undefined) {
  1126. return;
  1127. }
  1128. var tabLoadParam = {
  1129. windowNo: _self.windowNo,
  1130. tabIndex: _self.tabIndex,
  1131. recordId: _self.recordId,
  1132. };
  1133. _self.loading = true;
  1134. WindowServerUtil.loadTabSingleData(
  1135. tabLoadParam,
  1136. function (modelData) {
  1137. _self.modelData = modelData;
  1138. // 判断是否有属性
  1139. if (
  1140. modelData.data.attributeKey != undefined &&
  1141. modelData.data.attributeKey.displayValue != undefined
  1142. ) {
  1143. let displayValue = modelData.data.attributeKey.displayValue;
  1144. if (displayValue.length > 0) {
  1145. _self.attributeKey = displayValue[0];
  1146. }
  1147. }
  1148. // 判断是否有属性值
  1149. if (
  1150. modelData.data.attributeValueKey != undefined &&
  1151. modelData.data.attributeValueKey.displayValue != undefined
  1152. ) {
  1153. let displayValue1 = modelData.data.attributeValueKey.displayValue;
  1154. if (displayValue1.length > 0) {
  1155. _self.attributeValueKey = displayValue1[0];
  1156. }
  1157. }
  1158. // 判断是否显示审批状态
  1159. if (
  1160. _self.modelData != null &&
  1161. _self.modelData.data != null &&
  1162. _self.modelData.data.processInstanceId != null
  1163. ) {
  1164. let displayValue =
  1165. _self.modelData.data.processInstanceId.displayValue;
  1166. if (displayValue != null && displayValue.length > 0) {
  1167. _self.processInstanceId = displayValue[0];
  1168. } else {
  1169. _self.processInstanceId = '';
  1170. }
  1171. } else {
  1172. _self.processInstanceId = '';
  1173. }
  1174. _self.loading = false;
  1175. },
  1176. function () {
  1177. _self.loading = false;
  1178. },
  1179. );
  1180. },
  1181. // 保存
  1182. saveTabData: function (command) {
  1183. var _self = this;
  1184. var fieldWidgets1 = _self.$refs.fieldItem1;
  1185. var fieldWidgets2 = _self.$refs.fieldItem2;
  1186. // 保存的时候取消判断
  1187. _self.cancelCommand = true;
  1188. _self.errorMsg = '';
  1189. var promises = [];
  1190. _self.error = 0;
  1191. if (fieldWidgets1 != undefined) {
  1192. fieldWidgets1.forEach(function (w) {
  1193. var validateResult = w.performValide();
  1194. if (!validateResult) {
  1195. _self.error++;
  1196. }
  1197. });
  1198. }
  1199. if (fieldWidgets2 != undefined) {
  1200. fieldWidgets2.forEach(function (w) {
  1201. var validateResult = w.performValide();
  1202. if (!validateResult) {
  1203. _self.error++;
  1204. }
  1205. });
  1206. }
  1207. var subTabValidateResults = _self.getSubTabValidatePromise();
  1208. if (
  1209. subTabValidateResults != undefined &&
  1210. subTabValidateResults.length > 0
  1211. ) {
  1212. subTabValidateResults.forEach(function (subTabValidateResult) {
  1213. if (subTabValidateResult != true) {
  1214. _self.error++;
  1215. }
  1216. });
  1217. }
  1218. if (_self.attributeKey != null) {
  1219. var attributeValidateResult =
  1220. _self.$refs.attributePanel.performValide();
  1221. if (attributeValidateResult != true) {
  1222. _self.error++;
  1223. }
  1224. var attributeValueDtos = _self.$refs.attributePanel.getValue();
  1225. }
  1226. console.log('check finished');
  1227. if (_self.error == 0) {
  1228. executeSave();
  1229. } else {
  1230. _self.errorCount = _self.error;
  1231. _self.modal1 = true;
  1232. }
  1233. function executeSave() {
  1234. _self.modelData.changed = true;
  1235. var subTabChangedData = _self.getSubTabChangedData();
  1236. if (subTabChangedData.length > 0) {
  1237. _self.modelData.saveDatas = subTabChangedData;
  1238. } else {
  1239. _self.modelData.saveDatas = null;
  1240. }
  1241. var tabSaveData = {
  1242. attributeValueDtos: attributeValueDtos,
  1243. persistenceData: _self.modelData,
  1244. };
  1245. _self.loading = true;
  1246. WindowServerUtil.saveTabData(
  1247. tabSaveData,
  1248. function (id) {
  1249. _self.loading = false;
  1250. // 自动关闭
  1251. var saveClose = Common.getRouteParam('saveClose');
  1252. if (saveClose == 'true') {
  1253. window.setTimeout(function () {
  1254. window.close();
  1255. }, 1000);
  1256. Notify.success(_self.$t('lang.tabFormEdit.savingSucceeded'), _self.$t('lang.tabFormEdit.describe2'), 1500);
  1257. return;
  1258. } else {
  1259. Notify.success(_self.$t('lang.tabFormEdit.savingSucceeded'), _self.$t('lang.tabFormEdit.dataSavingSucceeded'), 1500);
  1260. }
  1261. _self.modelData.id = id;
  1262. _self.callAfterSaveLogical();
  1263. if (_self.taskInfoId && _self.$refs.approveComment && command) {
  1264. // 从后台加载modelData数据
  1265. _self.loading = true;
  1266. CurdWindowResource.loadTabData(
  1267. _self.windowNo,
  1268. _self.tabIndex,
  1269. id,
  1270. ).then(
  1271. successData => {
  1272. _self.loading = false;
  1273. _self.$refs.approveComment.saveData(command, successData);
  1274. },
  1275. errorData => {
  1276. _self.loading = false;
  1277. Common.processException(errorData);
  1278. },
  1279. );
  1280. return;
  1281. }
  1282. //删除草稿数据
  1283. _self.deleteDataRecoveryDto();
  1284. var currIndex = _self.currIndex;
  1285. var totalCount = _self.totalCount;
  1286. if (_self.type == 'edit') {
  1287. _self.$router.push(
  1288. '/desktop/window/window-read/view/' +
  1289. _self.windowNo +
  1290. '/' +
  1291. _self.tabIndex +
  1292. '/' +
  1293. id +
  1294. '?currPage=' +
  1295. _self.currPage +
  1296. '&currIndex=' +
  1297. currIndex +
  1298. '&totalCount=' +
  1299. totalCount +
  1300. '&uuid=' +
  1301. _self.uuid,
  1302. );
  1303. } else if (_self.type == 'create') {
  1304. _self.$router.push(
  1305. '/desktop/window/window-read/view/' +
  1306. _self.windowNo +
  1307. '/' +
  1308. _self.tabIndex +
  1309. '/' +
  1310. id +
  1311. '?currPage=' +
  1312. _self.currPage +
  1313. '&currIndex=' +
  1314. 1 +
  1315. '&totalCount=' +
  1316. (Number(totalCount) + 1) +
  1317. '&uuid=' +
  1318. _self.uuid,
  1319. );
  1320. } else if (_self.type == 'restore') {
  1321. _self.$router.push(
  1322. '/desktop/window/window-read/view/' +
  1323. _self.windowNo +
  1324. '/' +
  1325. _self.tabIndex +
  1326. '/' +
  1327. id +
  1328. '?currPage=' +
  1329. 1 +
  1330. '&currIndex=' +
  1331. 1 +
  1332. '&totalCount=' +
  1333. 1 +
  1334. '&uuid=' +
  1335. _self.uuid,
  1336. );
  1337. }
  1338. },
  1339. function () {
  1340. _self.loading = false;
  1341. },
  1342. );
  1343. }
  1344. },
  1345. // 改变字段分组的显示和隐藏
  1346. changeFieldGroupStatus: function (fieldGroup) {
  1347. fieldGroup.show = !fieldGroup.show;
  1348. var index = this.tab.tabFormView.fieldGroups.indexOf(fieldGroup);
  1349. if (index != -1) {
  1350. this.tab.tabFormView.fieldGroups[index] = fieldGroup;
  1351. localStorage.setItem(
  1352. 'FieldGroupStatus_' +
  1353. this.windowNo +
  1354. '_' +
  1355. this.tabIndex +
  1356. '_' +
  1357. fieldGroup.groupName,
  1358. fieldGroup.show,
  1359. );
  1360. }
  1361. },
  1362. /**
  1363. * 执行Callout
  1364. */
  1365. executeCallout: function (fieldItem) {
  1366. var _self = this;
  1367. if (fieldItem.calloutProcessReportNo != null) {
  1368. _self.callout(fieldItem.calloutProcessReportNo);
  1369. }
  1370. },
  1371. // 值改变事件
  1372. valueChanged: function (newFieldValue, fieldItem) {
  1373. var _self = this;
  1374. console.log(fieldItem.fieldName + ' ValueChanged.');
  1375. console.log(newFieldValue);
  1376. var oldFieldValue = this.modelData.data[fieldItem.fieldName];
  1377. if (FieldUtil.isFieldValueEqual(newFieldValue, oldFieldValue) == false) {
  1378. this.modelData.data[fieldItem.fieldName] = newFieldValue;
  1379. if (
  1380. fieldItem.calloutProcessReportNo != undefined &&
  1381. fieldItem.calloutProcessReportNo != null
  1382. ) {
  1383. _self.callout(fieldItem.calloutProcessReportNo);
  1384. }
  1385. if (
  1386. fieldItem.calloutLogical != undefined &&
  1387. fieldItem.calloutLogical != null
  1388. ) {
  1389. _self.executeCalloutJs(fieldItem, fieldItem.calloutLogical);
  1390. }
  1391. if (
  1392. _self.modelData.changed &&
  1393. fieldItem.displayType == 'ListBoxEditor'
  1394. ) {
  1395. // 值改变时,刷新所有下拉框的keyValues
  1396. _self.refreshSelectField(fieldItem.fieldName);
  1397. }
  1398. // add by jack 20170808
  1399. _self.modelData.changed = true;
  1400. let clearDynamicValidField = function (item) {
  1401. var fieldName1 = item.fieldName;
  1402. var dynamicValidFields = item.dynamicValidFields;
  1403. if (
  1404. fieldName0 != fieldName1 &&
  1405. dynamicValidFields != undefined &&
  1406. dynamicValidFields.indexOf(fieldName0) >= 0
  1407. ) {
  1408. var fieldValue0 = _self.modelData.data[fieldName1];
  1409. fieldValue0.id = undefined;
  1410. if (fieldValue0.displayValue != undefined) {
  1411. fieldValue0.displayValue.splice(
  1412. 0,
  1413. fieldValue0.displayValue.length,
  1414. );
  1415. } else {
  1416. fieldValue0.displayValue = [];
  1417. }
  1418. _self.modelData.data[fieldName1] = fieldValue0;
  1419. }
  1420. };
  1421. // 遍历所有的字段,判断是否有动态约束
  1422. // 如果有关联的动态约束,则清空字段
  1423. var fieldName0 = fieldItem.fieldName;
  1424. _self.tabFormFields.forEach(function (item) {
  1425. clearDynamicValidField(item);
  1426. });
  1427. let fieldGroups = _self.tab.tabFormView.fieldGroups;
  1428. if (fieldGroups != null && fieldGroups.length > 0) {
  1429. fieldGroups.forEach(fieldGroup => {
  1430. if (fieldGroup.fields != null && fieldGroup.fields != null) {
  1431. fieldGroup.fields.forEach(field => {
  1432. clearDynamicValidField(field);
  1433. });
  1434. }
  1435. });
  1436. }
  1437. }
  1438. },
  1439. // 刷新下拉选择框keyValues
  1440. refreshSelectField: function (valueChangedFieldName) {
  1441. var _self = this;
  1442. if (_self.tabFormFields) {
  1443. _self.tabFormFields.forEach(function (item) {
  1444. if (item.displayType == 'ListBoxEditor') {
  1445. var name1 = ':' + valueChangedFieldName;
  1446. //var name2 = ":Parent_" + valueChangedFieldName;
  1447. var showLogical = item.showLogical;
  1448. if (showLogical != undefined && showLogical.indexOf(name1) >= 0) {
  1449. refresh(item);
  1450. }
  1451. }
  1452. });
  1453. }
  1454. if (_self.fieldGroup) {
  1455. _self.fieldGroup.fields.forEach(function (item) {
  1456. if (item.displayType == 'ListBoxEditor') {
  1457. var name1 = ':' + valueChangedFieldName;
  1458. //var name2 = ":Parent_" + valueChangedFieldName;
  1459. var showLogical = item.showLogical;
  1460. if (showLogical != undefined && showLogical.indexOf(name1) >= 0) {
  1461. refresh(item);
  1462. }
  1463. }
  1464. });
  1465. }
  1466. function refresh(item) {
  1467. var obj = {
  1468. windowNo: _self.windowNo,
  1469. tabIndex: _self.tabIndex,
  1470. fieldName: item.fieldName,
  1471. modelData: _self.modelData,
  1472. };
  1473. console.log('WindowEdit RefreshField');
  1474. $.ajax({
  1475. url: Common.getApiURL('FieldResource/refreshField'),
  1476. async: false,
  1477. dataType: 'json',
  1478. type: 'post',
  1479. data: JSON.stringify(obj),
  1480. contentType: 'application/json',
  1481. beforeSend: function (request) {
  1482. Common.addTokenToRequest(request);
  1483. },
  1484. success: function (data) {
  1485. if (data != undefined) {
  1486. item.keyValues = data.keyValues;
  1487. }
  1488. },
  1489. error: function (XMLHttpRequest, textStatus, errorThrown) {
  1490. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  1491. },
  1492. });
  1493. }
  1494. },
  1495. /**
  1496. * 子页签触发父页签刷新
  1497. * @return {[type]} [description]
  1498. */
  1499. refreshParent: function () {
  1500. this.loadData();
  1501. },
  1502. /**
  1503. * 执行JS Callout
  1504. */
  1505. executeCalloutJs: function (fieldItem, scriptText) {
  1506. var _self = this;
  1507. // add by jack 20180529
  1508. var subTabChangedData = _self.getSubTabChangedData();
  1509. if (subTabChangedData.length > 0) {
  1510. _self.modelData.saveDatas = subTabChangedData;
  1511. } else {
  1512. _self.modelData.saveDatas = null;
  1513. }
  1514. let functionName = fieldItem.fieldName.replace('.', '_') + '_calloutjs';
  1515. let executeFunction = function(){
  1516. let actions = {
  1517. subTabsRef: _self.getSubTabs(),
  1518. };
  1519. let context = new _self.getContext(_self.modelData, actions);
  1520. try {
  1521. _self[functionName](context);
  1522. } catch (e) {
  1523. console.error(e);
  1524. Notify.error('数据字典定义异常', '【' + scriptText + '】前端列显示逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  1525. }
  1526. };
  1527. if (_self[functionName] == null) {
  1528. // 执行服务端的脚本
  1529. const jsUrl = _self.jsUrl;
  1530. if (jsUrl == null || jsUrl == undefined) {
  1531. Notify.error('数据字典定义异常', '【' + scriptText + '】Callout前端逻辑的JS文件不存在,请联系管理员检查数据字典是否JS文件。', false);
  1532. return;
  1533. }
  1534. let promise = JsUtil.dynamicLoadJsFunction(jsUrl, scriptText);
  1535. promise.then(targetFunction => {
  1536. console.log(targetFunction);
  1537. if (targetFunction == null) {
  1538. Notify.error('数据字典定义异常', '【' + scriptText + '】Callout前端逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  1539. return;
  1540. }
  1541. _self[functionName] = targetFunction;
  1542. executeFunction();
  1543. }, errorData => {
  1544. console.error(errorData);
  1545. });
  1546. } else {
  1547. executeFunction();
  1548. }
  1549. },
  1550. /**
  1551. * callout
  1552. * @param {[type]} calloutProcessReportNo [description]
  1553. * @return {[type]} [description]
  1554. */
  1555. callout: function (calloutProcessReportNo) {
  1556. var _self = this;
  1557. // add by jack 20180529
  1558. var subTabChangedData = _self.getSubTabChangedData();
  1559. if (subTabChangedData.length > 0) {
  1560. _self.modelData.saveDatas = subTabChangedData;
  1561. } else {
  1562. _self.modelData.saveDatas = null;
  1563. }
  1564. // 查询流程和报表的定义
  1565. ProcessReportResource.uniqueByNo(calloutProcessReportNo).then(
  1566. successData => {
  1567. if (successData == null) {
  1568. return;
  1569. }
  1570. // 执行服务端的脚本
  1571. ProcessReportResource.runCallout(
  1572. calloutProcessReportNo,
  1573. _self.modelData,
  1574. ).then(
  1575. successData => {
  1576. if (successData && successData.modelData) {
  1577. _self.modelData = successData.modelData;
  1578. }
  1579. // add by jack 20180529
  1580. // add by jack 20220601
  1581. _self.modelData.saveDatas = undefined;
  1582. },
  1583. errorData => {
  1584. Common.processException(errorData);
  1585. },
  1586. );
  1587. },
  1588. errorData => {
  1589. Common.processException(errorData);
  1590. },
  1591. );
  1592. },
  1593. // 获取子页签全部的数据
  1594. getSubTabAllData: function () {
  1595. var subTabAllRecords = [];
  1596. if (this.tab.subTabs != undefined) {
  1597. for (var index = 0; index < this.tab.subTabs.length; index++) {
  1598. var subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  1599. var modelDatas = this.$refs[subTabId][0].getAllModelData();
  1600. if (modelDatas != undefined && modelDatas.length > 0) {
  1601. modelDatas.forEach(function (modelData) {
  1602. subTabAllRecords.push(modelData);
  1603. });
  1604. }
  1605. }
  1606. }
  1607. console.log(subTabAllRecords);
  1608. return subTabAllRecords;
  1609. },
  1610. // 获取子页签发生改变的数据
  1611. getSubTabChangedData: function () {
  1612. var subTabChangedRecords = [];
  1613. if (this.tab.subTabs != undefined) {
  1614. for (var index = 0; index < this.tab.subTabs.length; index++) {
  1615. var subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  1616. var modelDatas = this.$refs[subTabId][0].getChangedModelData();
  1617. if (modelDatas != undefined && modelDatas.length > 0) {
  1618. modelDatas.forEach(function (modelData) {
  1619. subTabChangedRecords.push(modelData);
  1620. });
  1621. }
  1622. }
  1623. }
  1624. console.log(subTabChangedRecords);
  1625. return subTabChangedRecords;
  1626. },
  1627. // 获取子页签数据校验的Promise
  1628. getSubTabValidatePromise: function () {
  1629. var _self = this;
  1630. var subTabValidates = [];
  1631. if (this.tab.subTabs != undefined) {
  1632. for (var index = 0; index < this.tab.subTabs.length; index++) {
  1633. var subTabId = 'subTab' + this.tab.subTabs[index].tabIndex;
  1634. var result = this.$refs[subTabId][0].performValidate();
  1635. if (result != undefined && result.length > 0) {
  1636. subTabValidates = subTabValidates.concat(result);
  1637. }
  1638. }
  1639. }
  1640. return subTabValidates;
  1641. },
  1642. /**
  1643. * 表单字段的属性(显示)属性发生改变事件
  1644. */
  1645. tabFormFieldPropertyChanged: function (tabFormFieldClone) {
  1646. TabFormView.restoreTabFormFieldDef(
  1647. this.windowNo,
  1648. this.tabIndex,
  1649. this.tabFormFields,
  1650. );
  1651. },
  1652. /**
  1653. * 撤销提示
  1654. */
  1655. cancelModel: function () {
  1656. var _self = this;
  1657. _self.modal3 = true;
  1658. },
  1659. /**
  1660. * 取消
  1661. */
  1662. cancelNo: function () {
  1663. var _self = this;
  1664. _self.modal3 = false;
  1665. },
  1666. /**
  1667. * 撤销
  1668. * @return {void}
  1669. */
  1670. cancelOk: function () {
  1671. var _self = this;
  1672. var currPage = _self.currPage;
  1673. var currIndex = _self.currIndex;
  1674. var totalCount = _self.totalCount;
  1675. _self.cancelCommand = true;
  1676. if (_self.recordId == null || _self.recordId == '') {
  1677. _self.$router.push(
  1678. '/desktop/window/' +
  1679. _self.windowNo +
  1680. '?currPage=' +
  1681. currPage +
  1682. '&uuid=' +
  1683. this.uuid,
  1684. );
  1685. } else {
  1686. // bug fixed by jack,编辑后直接取消
  1687. // var cacheData = localStorage.getItem(_self.uuid);
  1688. // if (cacheData != undefined && cacheData.length > 0) {
  1689. // cacheData = JSON.parse(cacheData);
  1690. // var window = cacheData.window;
  1691. // var tab = cacheData.tab;
  1692. // if (window == undefined || tab == undefined) {
  1693. // _self.$router.push('/desktop/window/' + _self.windowNo + "?currPage=" + currPage + "&uuid=" + this.uuid);
  1694. // return;
  1695. // }
  1696. // }
  1697. _self.$router.push(
  1698. '/desktop/window/window-read/view/' +
  1699. _self.windowNo +
  1700. '/' +
  1701. _self.tabIndex +
  1702. '/' +
  1703. _self.recordId +
  1704. '?currPage=' +
  1705. currPage +
  1706. '&currIndex=' +
  1707. currIndex +
  1708. '&totalCount=' +
  1709. totalCount +
  1710. '&uuid=' +
  1711. this.uuid,
  1712. );
  1713. }
  1714. //删除草稿数据
  1715. _self.deleteDataRecoveryDto();
  1716. },
  1717. /**
  1718. * 子标题
  1719. * @return {String} 子标题
  1720. */
  1721. subTitle: function () {
  1722. var _self = this;
  1723. var subTitle = '';
  1724. if (_self.modelData != null && _self.modelData.data == null) {
  1725. return subTitle;
  1726. }
  1727. if (
  1728. _self.modelData != null &&
  1729. _self.modelData.data != null &&
  1730. _self.modelData.data.documentNo != null
  1731. ) {
  1732. subTitle =
  1733. _self.modelData.data.documentNo.displayValue == null ?
  1734. '' :
  1735. _self.modelData.data.documentNo.displayValue[0];
  1736. } else if (
  1737. _self.modelData != null &&
  1738. _self.modelData.data != null &&
  1739. _self.modelData.data.no != null
  1740. ) {
  1741. subTitle =
  1742. _self.modelData.data.no.displayValue == null ?
  1743. '' :
  1744. _self.modelData.data.no.displayValue[0];
  1745. } else if (
  1746. _self.modelData != null &&
  1747. _self.modelData.data != null &&
  1748. _self.modelData.data.name != null
  1749. ) {
  1750. subTitle =
  1751. _self.modelData.data.name.displayValue == null ?
  1752. '' :
  1753. _self.modelData.data.name.displayValue[0];
  1754. }
  1755. return subTitle;
  1756. },
  1757. back: function () {
  1758. var _self = this;
  1759. _self.$router.push(
  1760. '/desktop/window/' +
  1761. _self.windowNo +
  1762. '?currPage=' +
  1763. _self.currPage +
  1764. '&uuid=' +
  1765. this.uuid,
  1766. );
  1767. },
  1768. /**
  1769. * 上一条数据
  1770. * @return {void}
  1771. */
  1772. pre: function () {
  1773. var _self = this;
  1774. if (_self.isModelDataChanged() == true) {
  1775. Notify.notice(_self.$t('lang.tabFormEdit.dataNotSaved'), _self.$t('lang.tabFormEdit.describe1'), false);
  1776. return;
  1777. }
  1778. if (_self.currIndex <= 1) {
  1779. return;
  1780. }
  1781. _self.currIndex--;
  1782. var tabQueryParam = {
  1783. range: {
  1784. start: _self.currIndex - 1,
  1785. length: 1,
  1786. },
  1787. tabIndex: _self.tabIndex,
  1788. windowNo: _self.windowNo,
  1789. };
  1790. UserStorageResource.uniqueByKey(_self.uuid).then(
  1791. successData => {
  1792. // if(successData.errorCode != 0) {
  1793. // Notify.error('提示', successData.errorMessage, false);
  1794. // return;
  1795. // }
  1796. let simpleFilterParams = null;
  1797. let complexFilterParams = null;
  1798. if (successData.data != null && successData.data != '') {
  1799. let temp = JSON.parse(successData.data);
  1800. // 分页数据
  1801. // 简单过滤条件
  1802. tabQueryParam.simpleFilterCondition = temp.simpleFilterParams;
  1803. // 复杂过滤条件
  1804. tabQueryParam.filterParams = temp.complexFilterParams;
  1805. // 排序
  1806. tabQueryParam.sortStr = temp.sortStr;
  1807. }
  1808. _self.loadTabData(tabQueryParam);
  1809. },
  1810. errorData => {
  1811. Common.processException(errorData);
  1812. },
  1813. );
  1814. },
  1815. /**
  1816. * 下一条数据
  1817. * @return {void}
  1818. */
  1819. next: function () {
  1820. var _self = this;
  1821. if (_self.isModelDataChanged() == true) {
  1822. Notify.notice(_self.$t('lang.tabFormEdit.dataNotSaved'), _self.$t('lang.tabFormEdit.describe1'), false);
  1823. return;
  1824. }
  1825. var totalCount = _self.totalCount;
  1826. if (_self.currIndex >= totalCount) {
  1827. return;
  1828. }
  1829. _self.currIndex++;
  1830. var tabQueryParam = {
  1831. range: {
  1832. start: _self.currIndex - 1,
  1833. length: 1,
  1834. },
  1835. tabIndex: _self.tabIndex,
  1836. windowNo: _self.windowNo,
  1837. };
  1838. UserStorageResource.uniqueByKey(_self.uuid).then(
  1839. successData => {
  1840. // if(successData.errorCode != 0) {
  1841. // Notify.error('提示', successData.errorMessage, false);
  1842. // return;
  1843. // }
  1844. if (successData.data != null && successData.data != '') {
  1845. let temp = JSON.parse(successData.data);
  1846. // 分页数据
  1847. // 简单过滤条件
  1848. tabQueryParam.simpleFilterCondition = temp.simpleFilterParams;
  1849. // 复杂过滤条件
  1850. tabQueryParam.filterParams = temp.complexFilterParams;
  1851. // 排序
  1852. tabQueryParam.sortStr = temp.sortStr;
  1853. }
  1854. _self.loadTabData(tabQueryParam);
  1855. },
  1856. errorData => {
  1857. Common.processException(errorData);
  1858. },
  1859. );
  1860. },
  1861. /**
  1862. * 加载一条数据
  1863. * @param {Object} tabQueryParam 查询条件
  1864. * @return {void}
  1865. */
  1866. loadTabData: function (tabQueryParam) {
  1867. var _self = this;
  1868. _self.loading = true;
  1869. WindowServerUtil.queryTabData(
  1870. tabQueryParam,
  1871. function (gridData) {
  1872. var dataLists = gridData.dataList;
  1873. if (dataLists != undefined && dataLists.length > 0) {
  1874. _self.modelData = dataLists[0];
  1875. }
  1876. _self.loading = false;
  1877. },
  1878. function () {
  1879. _self.loading = false;
  1880. },
  1881. );
  1882. },
  1883. /**
  1884. * 计算按钮坐标
  1885. *
  1886. */
  1887. computerButtonGroupLeftTop: function () {
  1888. var _self = this;
  1889. var fixedButtonGroup = $(_self.$refs.fixedButtonGroup);
  1890. if (fixedButtonGroup != undefined) {
  1891. var offset = fixedButtonGroup.offset();
  1892. if (offset != undefined) {
  1893. _self.buttonGroupInitLeft = offset.left;
  1894. _self.buttonGroupInitTop = offset.top;
  1895. }
  1896. }
  1897. },
  1898. /**
  1899. * ModelData 是否发生变化
  1900. */
  1901. isModelDataChanged: function () {
  1902. var _self = this;
  1903. // 判断当前数据是否发生改变
  1904. if (_self.modelData.changed == true) {
  1905. return true;
  1906. }
  1907. // 判断子页签数据是否发生改变
  1908. var subTabChangedData = _self.getSubTabChangedData();
  1909. if (subTabChangedData != undefined && subTabChangedData.length > 0) {
  1910. return true;
  1911. }
  1912. return false;
  1913. },
  1914. /**
  1915. * 自动点击菜单
  1916. */
  1917. autoClickMenu: function () {
  1918. var _self = this;
  1919. // 判断是否有URL参数 自动点击菜单 canAutoClickMenu
  1920. var canAutoClickMenu = Common.getRouteParam('canAutoClickMenu');
  1921. if (
  1922. (canAutoClickMenu == null || canAutoClickMenu == '') &&
  1923. canAutoClickMenu != 'true'
  1924. ) {
  1925. const route1 = this.$route;
  1926. let path = route1.path;
  1927. let query = route1.query; // 这里可以用Vue的方法获取参数,也可以用正则的方法获取url中的参数
  1928. query.canAutoClickMenu = true;
  1929. // !!!!不推荐使用push的方式进行更新路由参数这样会增加路由的历史记录 (浏览器的后退键被破坏)
  1930. this.$router.push({ path, query });
  1931. // 推荐使用
  1932. // this.$router.replace({path, query}); // 更新url上面的内容,且页面不会重载 / 刷新
  1933. if (_self.type == 'create') {
  1934. if (
  1935. _self.tab &&
  1936. _self.tab.tabButtons &&
  1937. _self.tab.tabButtons.length > 0
  1938. ) {
  1939. for (var i = 0; i < _self.tab.tabButtons.length; i++) {
  1940. var itemButton = _self.tab.tabButtons[i];
  1941. if (itemButton.createAutoClick == true) {
  1942. _self.backupView().then(
  1943. successData => {
  1944. _self.$refs.tabButton.execute(itemButton);
  1945. },
  1946. errorData => { },
  1947. );
  1948. break;
  1949. }
  1950. }
  1951. }
  1952. }
  1953. }
  1954. },
  1955. /**
  1956. * 开启草稿保存功能,每隔15秒保存一次
  1957. * @author GuoZhiBo 20211008
  1958. */
  1959. startSaveInterval: function () {
  1960. var _self = this;
  1961. _self.autoSaveInterval = setInterval(function () {
  1962. var subTabChangedData = _self.getSubTabChangedData();
  1963. // bug fixed by jack
  1964. // 这里不能对 _self.modelData.saveDatas 属性赋值,否则在 当页签的GridBody中修改了某个值以后,
  1965. // 其监听 parentModelData 也会发生改变,导致性能很差
  1966. var modelDataClone = JSON.parse(JSON.stringify(_self.modelData));
  1967. if (subTabChangedData.length > 0) {
  1968. var subTabChangedDataClone = JSON.parse(
  1969. JSON.stringify(subTabChangedData),
  1970. );
  1971. modelDataClone.saveDatas = subTabChangedDataClone;
  1972. } else {
  1973. modelDataClone.saveDatas = null;
  1974. }
  1975. if (_self.dataRecoveryDto == undefined) {
  1976. _self.dataRecoveryDto = {
  1977. modelData: modelDataClone,
  1978. windowId: _self.windowNo,
  1979. type: _self.type,
  1980. };
  1981. } else {
  1982. _self.dataRecoveryDto.modelData = modelDataClone;
  1983. }
  1984. DataRecoveryResource.saveDataRecoveryDto(
  1985. _self.dataRecoveryDto,
  1986. function (data) {
  1987. console.log('草稿数据保存成功.');
  1988. },
  1989. function (xmlHttpRequest) {
  1990. console.log('草稿数据保存失败: %s 。', xmlHttpRequest.responseText);
  1991. },
  1992. );
  1993. }, 15000);
  1994. },
  1995. /**
  1996. * 页签按钮的显示逻辑
  1997. */
  1998. tabButtonsShowLogical: function () {
  1999. let _self = this;
  2000. if (
  2001. this.tab.tabFormView != null &&
  2002. this.tab.tabFormView.tabButtons != null
  2003. ) {
  2004. for (
  2005. let index = 0; index < this.tab.tabFormView.tabButtons.length; index++
  2006. ) {
  2007. let tabButton = this.tab.tabFormView.tabButtons[index];
  2008. if (tabButton.editMode == true) {
  2009. var logic = tabButton.showLogical;
  2010. if (logic == null || logic == '') {
  2011. tabButton.invisible = false;
  2012. return;
  2013. }
  2014. let functionName = 'form_edit_show_logical_' + index;
  2015. let executeFunction = function(){
  2016. let actions = {
  2017. subTabsRef: _self.getSubTabs(),
  2018. };
  2019. try {
  2020. let context = new _self.getContext(_self.modelData, actions);
  2021. tabButton.invisible = !_self[functionName](context);
  2022. } catch (error) {
  2023. console.error(error);
  2024. Notify.error('数据字典定义异常', '【' + logic + '】按钮显示逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  2025. }
  2026. };
  2027. if (this[functionName] == null) {
  2028. const jsUrl = this.jsUrl;
  2029. if (jsUrl == null || jsUrl == undefined) {
  2030. Notify.error('数据字典定义异常', '【' + logic + '】按钮显示逻辑的JS文件不存在,请联系管理员检查数据字典是否存在JS文件', false);
  2031. return;
  2032. }
  2033. let promise = JsUtil.dynamicLoadJsFunction(jsUrl, logic);
  2034. promise.then(targetFunction => {
  2035. if (targetFunction == null) {
  2036. Notify.error('数据字典定义异常', '【' + logic + '】按钮显示逻辑逻辑定义异常,请联系管理员检查数据字典的定义', false);
  2037. return;
  2038. }
  2039. console.log(targetFunction);
  2040. this[functionName] = targetFunction;
  2041. executeFunction();
  2042. }, errorData => {
  2043. console.error(errorData);
  2044. });
  2045. } else {
  2046. executeFunction();
  2047. }
  2048. }
  2049. }
  2050. }
  2051. },
  2052. /**
  2053. * 调用保存后的业务逻辑
  2054. */
  2055. callAfterSaveLogical: function () {
  2056. var _self = this;
  2057. if (
  2058. this.tab != null &&
  2059. this.tab.tabFormView != null &&
  2060. this.tab.tabFormView.logicalAfterSave != null &&
  2061. this.tab.tabFormView.logicalAfterSave.length > 0
  2062. ) {
  2063. var logic = this.tab.tabFormView.logicalAfterSave;
  2064. if (logic == null || logic == '') {
  2065. return;
  2066. }
  2067. let functionName = 'form_edit_logical_after_save';
  2068. const executeFunction = function (){
  2069. let actions = {
  2070. subTabsRef: _self.getSubTabs(),
  2071. };
  2072. let context = new _self.getContext(_self.modelData, actions);
  2073. try{
  2074. _self[functionName](context);
  2075. }catch(e){
  2076. console.error(e);
  2077. Notify.error('数据字典定义异常', '【' + logic + '】保存后业务逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  2078. }
  2079. };
  2080. if (_self[functionName] == null) {
  2081. const jsUrl = this.jsUrl;
  2082. if (jsUrl == null || jsUrl == undefined) {
  2083. Notify.error('数据字典定义异常', '【' + logic + '】保存后业务逻辑的JS文件不存在,请联系管理员检查数据字典是否存在JS文件', false);
  2084. return;
  2085. }
  2086. let promise = JsUtil.dynamicLoadJsFunction(jsUrl, logic);
  2087. promise.then(targetFunction => {
  2088. if(targetFunction == null){
  2089. Notify.error('数据字典定义异常', '【' + logic + '】保存后业务逻辑定义异常,请联系管理员检查数据字典的定义。', false);
  2090. return;
  2091. }
  2092. _self[functionName] = targetFunction;
  2093. executeFunction();
  2094. }, errorData => {
  2095. console.error(errorData);
  2096. });
  2097. }else{
  2098. executeFunction();
  2099. }
  2100. }
  2101. },
  2102. /**
  2103. * 当页面卸载(关闭)或刷新时调用
  2104. */
  2105. beforeunloadFn: function (e) {
  2106. e = e || window.event;
  2107. if (e) {
  2108. e.returnValue = '关闭提示';
  2109. }
  2110. return '关闭提示';
  2111. },
  2112. /**
  2113. * 子页签(表格)修改父页签的数据
  2114. * @param { String } fieldName 字段名称
  2115. * @param { com.leanwo.prodog.restful.base.model.FieldValue } fieldValue 字段的值
  2116. * @author YangZhiJie 20211012
  2117. */
  2118. changeRootParentModelData: function (data) {
  2119. if (data === undefined || data === null) {
  2120. console.error('子页签修改父页签的数据,但数据为空。');
  2121. return;
  2122. }
  2123. const fieldName = data.fieldName;
  2124. const fieldValue = data.fieldValue;
  2125. if (fieldName === undefined || fieldName === null) {
  2126. console.error(
  2127. '子页签修改父页签的数据,但字段名称 %s 为空。',
  2128. fieldName,
  2129. );
  2130. return;
  2131. }
  2132. if (fieldValue === undefined || fieldValue === null) {
  2133. console.error('子页签修改父页签的数据,但字段值 %s 为空。', fieldName);
  2134. return;
  2135. }
  2136. let fieldItem = null;
  2137. for (let index = 0; index < this.tabFormFields.length; index++) {
  2138. if (this.tabFormFields[index].fieldName === fieldName) {
  2139. fieldItem = this.tabFormFields[index];
  2140. break;
  2141. }
  2142. }
  2143. if (fieldItem === null) {
  2144. console.error(
  2145. '子页签修改父页签的数据,但找不到字段 %s 的定义。',
  2146. fieldName,
  2147. );
  2148. return;
  2149. }
  2150. console.debug('子页签修改父页签的数据。', fieldName, fieldValue);
  2151. this.valueChanged(fieldValue, fieldItem);
  2152. },
  2153. },
  2154. };
  2155. </script>
  2156. <style scoped>
  2157. .field-group {
  2158. padding-left: 30px;
  2159. padding-right: 30px;
  2160. }
  2161. .fieldGroup-head {
  2162. cursor: pointer;
  2163. }
  2164. .a-back {
  2165. cursor: pointer;
  2166. text-decoration: none;
  2167. }
  2168. .m-space-btn-group {
  2169. height: 34px;
  2170. }
  2171. .m-row {
  2172. margin-bottom: 15px;
  2173. }
  2174. .fixed-btn-group {
  2175. z-index: 3;
  2176. background-color: #f7f7f7;
  2177. }
  2178. </style>
  2179. <style>
  2180. .btn-group-fixed {
  2181. position: fixed;
  2182. top: 0;
  2183. left: 0;
  2184. z-index: 3;
  2185. }
  2186. .m-image {
  2187. height: 50px;
  2188. cursor: pointer;
  2189. }
  2190. </style>