TabFormEditModal.vue 76 KB

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