TabFormEdit.vue 76 KB

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