TabGridEdit.vue 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871
  1. <!-- CRUD列表 -->
  2. <template>
  3. <div>
  4. <Navbar :title="Language.getNameTrl($i18n.locale, window)" :is-go-back="false" />
  5. <WindowTab
  6. v-if="
  7. tab && tab.tabDataSource && tab.tabDataSource.tabDataSourceGroupDtos
  8. " :tab-props="tab.tabDataSource.tabDataSourceGroupDtos" @get-now-tab="getNowTab"
  9. />
  10. <div
  11. class="grid-container" :style="{
  12. 'padding-right': showComplexFilterPanel == true ? '360px' : '0px',
  13. }"
  14. >
  15. <div class="operationClass">
  16. <div class="grid-item-row1" style="width: 400px">
  17. <SimpleFilterPanel
  18. :key="'simple-filter-panel-' + windowNo" v-model:searchText="searchText"
  19. :disabled="complexFilterParams != null" :window-no="windowNo" :tab-index="tabIndex"
  20. :filter-schema="tab.filterSchema" @simple-search="simpleSearch"
  21. @show-complex-filter-panel="showComplexFilterPanel = true"
  22. />
  23. </div>
  24. <div>
  25. <a-pagination
  26. v-model:current="pagination.current_page" v-model:pageSize="pagination.per_page"
  27. show-quick-jumper size="small" :total="pagination.total" :page-size-options="pageSizeOptions"
  28. @change="handlePageChange" @show-size-change="handleShowSizeChange"
  29. />
  30. </div>
  31. </div>
  32. <div class="grid-item-row2">
  33. <NewTabButton
  34. :window="window" :now-tab="nowTab" :simple-filter-params="searchText"
  35. :complex-filter-params="complexFilterParams" :uuid="uuid" :show-tab-dto="tab" :model-datas="modelDatas"
  36. :view-type="'Grid'" :curd-window-function-access="curdWindowFunctionAccess"
  37. @create-record-in-window-edit="createRecordInWindowEdit" @delete-records="deleteRecords"
  38. @refresh-datas="refreshDatas"
  39. />
  40. </div>
  41. <div class="grid-item-row3-column1 tableFixHead">
  42. <!-- eslint-disable-next-line -->
  43. <div v-html="headerHtml" />
  44. <!-- table -->
  45. <div v-if="tab != null && tab.tabGridView != null">
  46. <div :id="scrollObject.tableOutDivUuid1" ref="tableContainer1" style="padding-left: 0px">
  47. <div :id="scrollObject.tableOutDivUuid2" ref="tableContainer2">
  48. <table id="fixedTbody" class="fixed-table table-striped table-bordered" :width="tableWidth">
  49. <thead>
  50. <GridHeader
  51. :is-show-edit="!tab.tabDataSource.readOnly" :tab-grid-fields="tabGridFields"
  52. :window-no="windowNo" :tab-index="tabIndex" :is-chinese-english="window.isChineseEnglish"
  53. height="40px" @on-sort="onSort($event)" @property-changed="propertyChanged($event)"
  54. @select-all="selectAll($event)" @multiple-select="changeSelectMode($event)"
  55. />
  56. </thead>
  57. <tbody>
  58. <template v-for="(modelData, index) in modelDatas" :key="modelData.id">
  59. <GridBody
  60. ref="gridBody" :window-no="windowNo" :tab-index="tabIndex" :serial-number="index +
  61. 1 +
  62. (pagination.current_page - 1) * pagination.per_page
  63. " :is-show-edit="!tab.tabDataSource.readOnly" :tab-grid-fields="tabGridFields"
  64. :tab-grid-title-fields="tabGridTitleFields"
  65. :model-data="modelData"
  66. :class-name="tab.tabDataSource.className"
  67. :scroll-object="scrollObject" :js-url="jsUrl" @delete-record="deleteRecord(modelData, true)"
  68. @edit-record="editRecord(modelData, index)" @click-model-data="clickModelData(modelData)"
  69. @read-record="readRecord(modelData, index)"
  70. @value-changed="valueChanged($event, modelData, index)" @execute-callout="
  71. executeCallout($event, modelData, index)
  72. "
  73. />
  74. </template>
  75. </tbody>
  76. </table>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. <a-drawer
  82. v-model:open="showComplexFilterPanel" :title="$t('lang.tabGridEdit.advancedSearch')" :width="400"
  83. :footer-style="{ textAlign: 'right' }" :mask="false" :mask-closable="false"
  84. @close="showComplexFilterPanel = false"
  85. >
  86. <ComplexFilterPanel
  87. ref="complexFilterPanel" :key="'complex-filter-panel-' + windowNo + '-' + tabIndex"
  88. :window-no="windowNo" :tab-index="tabIndex" :filter-schema="tab.filterSchema"
  89. @complex-search="advancedSearchOk"
  90. />
  91. </a-drawer>
  92. </div>
  93. <Modal v-model:show="modal1">
  94. <template #header>
  95. {{ $t("lang.tabGridEdit.validateError") }}
  96. </template>
  97. <div>
  98. {{
  99. $t("lang.tabGridEdit.validateErrorMsg", { errorCount: errorCount })
  100. }}
  101. </div>
  102. </Modal>
  103. <Modal v-model:show="modal2" @ok="dataRestore()" @cancel="cancelRestore()">
  104. <template #header> 数据恢复提示 </template>
  105. <div>存在草稿,是否恢复数据?</div>
  106. </Modal>
  107. <Loading v-if="loading" />
  108. </div>
  109. <component
  110. :is="dynamicComponent"
  111. v-if="dynamicComponentOpen"
  112. v-model:open="dynamicComponentOpen"
  113. v-bind="dynamicComponentParam"
  114. />
  115. </template>
  116. <script>
  117. import Common from '../../common/Common.js';
  118. import WindowServerUtil from '../../resource/dictionary/WindowServerUtil.js';
  119. import WindowClientUtil from '../../resource/dictionary/WindowClientUtil.js';
  120. import FieldUtil from '../../resource/dictionary/FieldUtil.js';
  121. import ProcessReportResource from '../../api/dic/ProcessReportResource.js';
  122. import GridColumnDefUtil from '../tabGridView/GridColumnDef.js';
  123. import UserStorageResource from '../../api/base/UserStorageResource.js';
  124. import Context from '../common/Context.js';
  125. import Language from '../../common/Language.js';
  126. import CurdWindowEditResource from '../../api/dic/CurdWindowEditResource.js';
  127. import GridHeader from '../tabGridView/GridHeader.vue';
  128. import GridBody from '../tabGridView/GridBody.vue';
  129. import SimpleFilterPanel from '../filter/SimpleFilterPanel.vue';
  130. import ComplexFilterPanel from '../filter/ComplexFilterPanel.vue';
  131. import TabButton from '../tabView/TabButton.vue';
  132. import AuthImage from '../../widget/AuthImage.vue';
  133. import DataRecoveryResource from '../../api/base/DataRecoveryResource.js';
  134. import CurdWindowResourceV2 from '../../api/dic/CurdWindowResourceV2.js';
  135. import JsUtil from '../../common/JsUtil.js';
  136. import { Notify, Uuid, CssUtil } from 'pc-component-v3';
  137. import WindowTab from './WindowTab.vue';
  138. import NewTabButton from './NewTabButton.vue';
  139. import {
  140. PlusCircleTwoTone,
  141. PlusSquareTwoTone,
  142. DeleteTwoTone,
  143. SaveTwoTone,
  144. WalletTwoTone,
  145. EditTwoTone,
  146. CheckSquareTwoTone,
  147. CloseCircleTwoTone,
  148. IdcardTwoTone,
  149. } from '@ant-design/icons-vue';
  150. import { defineAsyncComponent } from 'vue';
  151. export default {
  152. components: {
  153. AuthImage,
  154. SimpleFilterPanel,
  155. TabButton,
  156. GridHeader,
  157. GridBody,
  158. NewTabButton,
  159. ComplexFilterPanel,
  160. WindowTab,
  161. PlusCircleTwoTone,
  162. PlusSquareTwoTone,
  163. SaveTwoTone,
  164. DeleteTwoTone,
  165. WalletTwoTone,
  166. EditTwoTone,
  167. CheckSquareTwoTone,
  168. CloseCircleTwoTone,
  169. IdcardTwoTone,
  170. },
  171. props: {
  172. windowNo: {
  173. type: String,
  174. default: null,
  175. },
  176. },
  177. data: function () {
  178. this.Language = Language;
  179. return {
  180. window: {},
  181. tabIndex: null,
  182. nowTab: null, // 当前是哪个阶段
  183. nowAsset: '', // 所选资产分类名称
  184. selectCategory: null, //所选资产分类数据
  185. tab: {},
  186. tabGridTitleFields: [], // 表格标题字段
  187. tabGridFields: [], // 表格字段
  188. modelDatas: [],
  189. pageSizeOptions: ['20', '50', '100', '200', '1000'],
  190. pagination: {
  191. total: 0,
  192. per_page: Common.pageSize, // required
  193. current_page: 1, // required
  194. last_page: 10, // required
  195. },
  196. complexFilterParams: [], // 复杂过滤条件
  197. gridFieldItemMap: {},
  198. isASC: true,
  199. sortStr: '', // 排序
  200. sortStyle: ' ASC',
  201. errorCount: 0,
  202. buttonGroupInitLeft: 0,
  203. buttonGroupInitTop: 0,
  204. tableHeadInitLeft: 0,
  205. tableHeadInitTop: 0,
  206. showSpaceRow: false,
  207. dataChanged: false,
  208. scrollObject: {
  209. // 表格滚动
  210. tableOutDivUuid1: Uuid.createUUID(), // table 的 uuid
  211. tableOutDivUuid2: Uuid.createUUID(), // table 外部 DIV 的 uuid
  212. },
  213. multipleSelect: true,
  214. uuid: null,
  215. refreshCommand: false, // 是否是刷新命令
  216. headerHtml: '', // Tab头HTML
  217. footerHtml: '', // Tab尾HTML
  218. headerApiUrl: '', // Tab头API URL
  219. footerApiUrl: '', // Tab尾API URL
  220. showComplexFilterPanel: false, // 显示复杂过滤面板
  221. dataRecoveryDto: undefined,
  222. isRestoreData: 0, //是否使用草稿恢复数据,0代表false,1代表true
  223. curdWindowFunctionAccess: null,
  224. jsUrl: null,
  225. loading: false,
  226. modal1: false,
  227. modal2: false,
  228. searchText: '', // 简单过滤条件
  229. dynamicComponent: null,
  230. dynamicComponentParam: null,
  231. dynamicComponentOpen: true,
  232. };
  233. },
  234. computed: {
  235. tableWidth: function () {
  236. // 第一列和第二列
  237. var totalWidth = 30 + 95;
  238. if (this.tabGridFields.length != 0) {
  239. this.tabGridFields.forEach(function (gridFieldItem) {
  240. // 列显示的时候才计算宽度
  241. if (gridFieldItem.visible) {
  242. totalWidth += Number(gridFieldItem.width);
  243. }
  244. });
  245. }
  246. return totalWidth + 'px';
  247. },
  248. /**
  249. * 是否显示新建按钮
  250. * @return {Boolean} [description]
  251. */
  252. isShowCreateRecordButton: function () {
  253. if (this.curdWindowFunctionAccess == null) {
  254. return false;
  255. }
  256. if (
  257. this.curdWindowFunctionAccess.allowCreate == undefined ||
  258. this.curdWindowFunctionAccess.allowCreate == null
  259. ) {
  260. return false;
  261. }
  262. if (this.curdWindowFunctionAccess.allowCreate == false) {
  263. return false;
  264. }
  265. if (this.window == undefined || this.window.tabs == undefined) {
  266. return false;
  267. } else if (this.window.readOnly) {
  268. return false;
  269. } else if (this.window.tabs.length > 1) {
  270. return false;
  271. } else if (this.window.tabs.length == 1) {
  272. var customerWindowUrl = this.tab.customerWindowUrl;
  273. if (customerWindowUrl != undefined && customerWindowUrl != '') {
  274. return false;
  275. }
  276. return true;
  277. }
  278. return true;
  279. },
  280. /**
  281. * 是否显示编辑全部按钮
  282. * @return {Boolean} [description]
  283. */
  284. isShowEditAllButton: function () {
  285. if (
  286. this.curdWindowFunctionAccess == undefined ||
  287. this.curdWindowFunctionAccess.allowUpdate == undefined ||
  288. this.curdWindowFunctionAccess.allowUpdate == false
  289. ) {
  290. return false;
  291. }
  292. if (this.window == undefined || this.window.tabs == undefined) {
  293. return false;
  294. } else if (this.window.readOnly) {
  295. return false;
  296. } else if (this.window.tabs.length > 1) {
  297. return false;
  298. } else if (this.window.tabs.length == 1) {
  299. var customerWindowUrl = this.tab.customerWindowUrl;
  300. if (customerWindowUrl != undefined && customerWindowUrl != '') {
  301. return false;
  302. }
  303. return true;
  304. }
  305. return false;
  306. },
  307. /**
  308. * 是否显示删除按钮
  309. * @return {Boolean} [description]
  310. */
  311. isShowDeleteButton: function () {
  312. if (this.window == undefined || this.window.tabs == undefined) {
  313. return false;
  314. } else if (this.window.readOnly) {
  315. return false;
  316. }
  317. if (
  318. this.curdWindowFunctionAccess == undefined ||
  319. this.curdWindowFunctionAccess.allowDelete == undefined ||
  320. this.curdWindowFunctionAccess.allowDelete == false
  321. ) {
  322. return false;
  323. }
  324. return true;
  325. },
  326. /**
  327. * 是否显示新页面创建数据按钮
  328. */
  329. isShowNewPageCreateRecordButton: function () {
  330. if (this.window == undefined || this.window.tabs == undefined) {
  331. return false;
  332. } else if (this.window.readOnly) {
  333. return false;
  334. } else if (
  335. this.tab == undefined ||
  336. this.tab.tabDataSource == undefined ||
  337. this.tab.tabGridView == undefined
  338. ) {
  339. return false;
  340. } else if (
  341. this.tab.tabDataSource.readOnly == true ||
  342. this.tab.tabGridView.disableCreateInFormViewButton == true
  343. ) {
  344. return false;
  345. }
  346. if (this.curdWindowFunctionAccess == null) {
  347. return false;
  348. }
  349. return true;
  350. },
  351. },
  352. watch: {
  353. /**
  354. * 监控数据模型
  355. * @type {Object}
  356. */
  357. modelDatas: {
  358. deep: true,
  359. handler(curVal, oldVal) {
  360. console.log(this.modelDatas.length);
  361. },
  362. },
  363. /**
  364. * 如果模态框关闭,那么刷新一下表格的数据
  365. * @param currentValue
  366. * @param oldValue
  367. */
  368. dynamicComponentOpen: function(currentValue, oldValue){
  369. if(currentValue == false){
  370. this.queryGridData(false);
  371. }
  372. },
  373. windowNo: function (curVal, oldVal) {
  374. var _self = this;
  375. _self.uuid = _self.$route.query.uuid;
  376. UserStorageResource.uniqueByKey(_self.uuid).then(
  377. successData => {
  378. // if(successData.errorCode != 0) {
  379. // Notify.error('提示', successData.errorMessage, false);
  380. // return;
  381. // }
  382. if (successData.data != null && successData.data != '') {
  383. let tabQueryParam = JSON.parse(successData.data);
  384. // 分页数据
  385. _self.pagination = tabQueryParam.pagination;
  386. // 简单过滤条件
  387. _self.searchText = tabQueryParam.simpleFilterParams;
  388. // 复杂过滤条件
  389. _self.complexFilterParams = tabQueryParam.complexFilterParams;
  390. // 排序
  391. _self.sortStr = tabQueryParam.sortStr;
  392. // 显示高级过滤
  393. _self.showComplexFilterPanel =
  394. tabQueryParam.showComplexFilterPanel == true;
  395. } else {
  396. // 简单过滤条件
  397. _self.searchText = null;
  398. // 复杂过滤条件
  399. _self.complexFilterParams = null;
  400. // 分页数据
  401. _self.pagination = {
  402. total: 0,
  403. per_page: Common.pageSize, // required
  404. current_page: 1, // required
  405. last_page: 10, // required
  406. };
  407. _self.rememberPageSize();
  408. // 切换窗口的时候清空排序字段
  409. _self.sortStr = '';
  410. // 显示高级过滤
  411. _self.showComplexFilterPanel = false;
  412. }
  413. _self.loadWindow();
  414. },
  415. errorData => {
  416. Common.processException(errorData);
  417. },
  418. );
  419. },
  420. },
  421. created: function () {
  422. this.rememberPageSize();
  423. },
  424. beforeUnmount: function () {
  425. let _self = this;
  426. var tabQueryParam = {
  427. // 分页数据
  428. pagination: _self.pagination,
  429. // 简单过滤条件
  430. simpleFilterParams: _self.searchText,
  431. // 复杂过滤条件
  432. complexFilterParams: _self.complexFilterParams,
  433. // 排序
  434. sortStr: _self.sortStr,
  435. // 是否现在复杂查询面板
  436. showComplexFilterPanel: _self.showComplexFilterPanel,
  437. };
  438. let userStorageDtos = [
  439. {
  440. key: _self.uuid,
  441. value: JSON.stringify(tabQueryParam),
  442. },
  443. ];
  444. // 组装查询条件,然后放到后台数据库当中
  445. UserStorageResource.uploadUserStorage(userStorageDtos).then(
  446. successData => { },
  447. errorData => {
  448. Common.processException(errorData);
  449. },
  450. );
  451. },
  452. beforeMount: function () { },
  453. mounted: function () { },
  454. methods: {
  455. getContext: Context,
  456. // 获取当前tab为哪个阶段
  457. getNowTab: function (tab) {
  458. this.nowTab = tab;
  459. console.log(this.nowTab);
  460. this.pagination.current_page = 1;
  461. this.queryGridData(true);
  462. },
  463. // 页数改变
  464. handlePageChange: function (page) {
  465. this.pagination.current_page = page;
  466. setTimeout(() => {
  467. this.queryGridData(true);
  468. }, 100);
  469. },
  470. // 每页条数改变
  471. handleShowSizeChange: function (current, size) {
  472. setTimeout(() => {
  473. this.pagination.current_page = 1;
  474. });
  475. this.pagination.per_page = size;
  476. localStorage.setItem(`CurdWindowPageSize${this.windowNo}`, size);
  477. },
  478. /**
  479. * 删除草稿数据
  480. * @author GuoZhiBo 20211008
  481. */
  482. deleteDataRecoveryDto: function () {
  483. var _self = this;
  484. var dataRecoveryDto = {
  485. windowId: _self.windowNo,
  486. type: 'edit',
  487. };
  488. DataRecoveryResource.deleteDataRecoveryDto(dataRecoveryDto).then(
  489. successData => {
  490. if (successData != null) {
  491. console.log('删除草稿数据失败。');
  492. }
  493. },
  494. errorData => {
  495. Common.processException(errorData);
  496. },
  497. );
  498. },
  499. /**
  500. * 恢复草稿数据
  501. * @author GuoZhiBo 20210926
  502. */
  503. dataRestore: function () {
  504. var _self = this;
  505. _self.isRestoreData = 1;
  506. _self.editRecord(_self.dataRecoveryDto.modelData, 1);
  507. },
  508. /**
  509. * 取消恢复
  510. * @author GuoZhiBo 20210926
  511. */
  512. cancelRestore: function () {
  513. var _self = this;
  514. _self.modal2 = false;
  515. _self.deleteDataRecoveryDto();
  516. },
  517. /**
  518. * 打开帮助页面
  519. */
  520. openHtmlHelp: function (htmlHelpUrl) {
  521. window.open(htmlHelpUrl);
  522. },
  523. // 改变多选/单选
  524. changeSelectMode: function (val) {
  525. this.multipleSelect = val;
  526. },
  527. // 记住每页条数
  528. rememberPageSize: function () {
  529. const curdPageSize = localStorage.getItem(
  530. `CurdWindowPageSize${this.$route.params.windowNo}`,
  531. );
  532. if (curdPageSize) {
  533. this.pagination.per_page = curdPageSize;
  534. }
  535. },
  536. /**
  537. * 加载窗口的定义
  538. */
  539. loadWindow: function () {
  540. var _self = this;
  541. if (_self.windowNo) {
  542. WindowServerUtil.uniqueByNoWithRoleNew(_self.windowNo, function (data) {
  543. WindowClientUtil.parseFilterSchema(data);
  544. _self.initWindow(data);
  545. });
  546. }
  547. },
  548. // 根据windowId获取window
  549. initWindow: function (window) {
  550. var _self = this;
  551. DataRecoveryResource.queryDataRecoveryDtoByUserId(
  552. _self.windowNo,
  553. 'edit',
  554. ).then(
  555. successData => {
  556. if (successData != null) {
  557. _self.modal2 = true;
  558. _self.dataRecoveryDto = successData;
  559. }
  560. },
  561. errorData => {
  562. Common.processException(errorData);
  563. },
  564. );
  565. // 切换窗口的时候恢复分页插件到第一页
  566. // toggled by jack 2024-01-11
  567. // 界面后退的时候,需要记住分页数据。
  568. //_self.pagination = {
  569. // total: 0,
  570. // per_page: Common.pageSize, // required
  571. // current_page: 1, // required
  572. // last_page: 10, // required
  573. //};
  574. _self.rememberPageSize();
  575. // _self.windowNo = window.no;
  576. _self.window = window;
  577. _self.jsUrl = window.jsUrl;
  578. CurdWindowResourceV2.uniqueByNoAccessControl(_self.windowNo).then(
  579. successData => {
  580. if (successData.errorCode === 0) {
  581. this.curdWindowFunctionAccess = successData.data;
  582. if (
  583. this.curdWindowFunctionAccess.readOnly != null &&
  584. this.curdWindowFunctionAccess.readOnly === true
  585. ) {
  586. _self.window.readOnly = true;
  587. }
  588. } else {
  589. Notify.error(
  590. _self.$t('lang.tabGridEdit.describe1'),
  591. successData.errorMessage,
  592. false,
  593. );
  594. }
  595. },
  596. errorData => {
  597. Common.processException(errorData);
  598. },
  599. );
  600. _self.tabIndex = 0;
  601. _self.tab = window.tabs[0];
  602. _self.tabGridFields = WindowClientUtil.getGridField(_self.tab);
  603. _self.tabGridTitleFields = WindowClientUtil.getGridTitleField(_self.tab);
  604. GridColumnDefUtil.restoreTabGridFieldDef(
  605. this.windowNo,
  606. this.tabIndex,
  607. this.tabGridFields,
  608. );
  609. if (
  610. _self.tab.tabDataSource.tabDataSourceGroupDtos &&
  611. _self.tab.tabDataSource.tabDataSourceGroupDtos.length
  612. ) {
  613. _self.nowTab =
  614. _self.tab.tabDataSource.tabDataSourceGroupDtos[0].groupName;
  615. }
  616. console.log(_self.nowTab, '_self.nowTab=======================');
  617. _self.$nextTick(function () {
  618. // 设置复杂查询条件
  619. if (
  620. _self.complexFilterParams != null &&
  621. _self.$refs.complexFilterPanel != null
  622. ) {
  623. _self.$refs.complexFilterPanel.setFilterParams(
  624. _self.complexFilterParams,
  625. );
  626. }
  627. _self.queryGridData(false);
  628. });
  629. // 初始化表头和表尾API方法
  630. _self.initHeaderAndFooterApiUrl();
  631. },
  632. /**
  633. * 初始化表头和表尾API方法
  634. * @return {[type]} [description]
  635. */
  636. initHeaderAndFooterApiUrl: function () {
  637. if (this.tab != undefined && this.tab.tabGridView != undefined) {
  638. this.headerApiUrl = this.tab.tabGridView.headerApiUrl;
  639. this.footerApiUrl = this.tab.tabGridView.footerApiUrl;
  640. }
  641. },
  642. /**
  643. * 检查数据是否发生变更,然后刷新表格
  644. */
  645. checkDataChangedQueryGridData: function () {
  646. this.queryGridData(true);
  647. },
  648. /**
  649. * 根据查询参数获取数据模型
  650. * checkDataChanged : 是否判断数据是否发生改变
  651. */
  652. queryGridData: function (checkDataChanged) {
  653. var _self = this;
  654. if (checkDataChanged) {
  655. if (_self.dataChanged == true) {
  656. Notify.notice(
  657. _self.$t('lang.tabGridEdit.describe2'),
  658. _self.$t('lang.tabGridEdit.describe3'),
  659. false,
  660. );
  661. return;
  662. }
  663. }
  664. _self.refreshCommand = true;
  665. _self.modelDatas.splice(0, _self.modelDatas.length);
  666. if (_self.tab == undefined) {
  667. return;
  668. }
  669. // 简单过滤条件
  670. let simpleFilterCondition = null;
  671. let filterParams = null;
  672. // BUG fixed by jack 2024-01-11
  673. // 不应该以仪表盘的显示隐藏状态作为判断是否是高级搜索的依据。
  674. // 1. 点击高级搜索的【查询】按钮。
  675. // 2. 保存高级搜索的查询条件 complexFilterParams
  676. // 3. 判断complexFilterParams是否为空,作为是否是高级搜索的依据。
  677. if (_self.complexFilterParams != null) {
  678. filterParams = _self.complexFilterParams;
  679. } else {
  680. simpleFilterCondition = _self.searchText;
  681. }
  682. let groupNameOne;
  683. if (
  684. _self.tab.tabDataSource.tabDataSourceGroupDtos &&
  685. _self.tab.tabDataSource.tabDataSourceGroupDtos.length
  686. ) {
  687. groupNameOne =
  688. _self.tab.tabDataSource.tabDataSourceGroupDtos[0].groupName;
  689. } else {
  690. groupNameOne = null;
  691. }
  692. var tabQueryParam = {
  693. range: {
  694. start:
  695. (_self.pagination.current_page - 1) * _self.pagination.per_page,
  696. length: _self.pagination.per_page,
  697. },
  698. windowNo: _self.windowNo,
  699. tabIndex: _self.tabIndex,
  700. filterParams: filterParams,
  701. simpleFilterCondition: simpleFilterCondition,
  702. sortStr: _self.sortStr,
  703. groupName: _self.nowTab ? _self.nowTab : groupNameOne,
  704. };
  705. _self.dataChanged = false;
  706. _self.loading = true;
  707. WindowServerUtil.queryTabData(
  708. tabQueryParam,
  709. function (data) {
  710. var modelDatas = data.dataList;
  711. if (modelDatas != undefined) {
  712. for (var index = 0, len = modelDatas.length; index < len; index++) {
  713. modelDatas[index].editMode = false;
  714. _self.modelDatas[index] = modelDatas[index];
  715. }
  716. }
  717. _self.pagination.total = data.totalSize;
  718. _self.pagination.last_page = Math.ceil(
  719. data.totalSize / data.range.length,
  720. );
  721. _self.loadHeaderAndFooterContent(tabQueryParam);
  722. _self.loading = false;
  723. _self.refreshCommand = false;
  724. _self.fixedTableHeader();
  725. },
  726. function () {
  727. _self.loading = false;
  728. _self.refreshCommand = false;
  729. },
  730. );
  731. },
  732. /**
  733. * 加载表头和表位的方法
  734. * @return {[type]} [description]
  735. */
  736. loadHeaderAndFooterContent: function (tabQueryParam) {
  737. var _self = this;
  738. if (this.headerApiUrl != undefined && this.headerApiUrl.length > 0) {
  739. $.ajax({
  740. url: Common.getApiURL(_self.headerApiUrl),
  741. type: 'post',
  742. contentType: 'application/json',
  743. beforeSend: function (request) {
  744. Common.addTokenToRequest(request);
  745. },
  746. data: JSON.stringify(tabQueryParam),
  747. dataType: 'text',
  748. success: function (data) {
  749. _self.headerHtml = data;
  750. },
  751. error: function (XMLHttpRequest, textStatus, errorThrown) {
  752. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  753. },
  754. });
  755. } else {
  756. _self.headerHtml = '';
  757. }
  758. if (this.footerApiUrl != undefined && this.footerApiUrl.length > 0) {
  759. $.ajax({
  760. url: Common.getApiURL(_self.footerApiUrl),
  761. type: 'post',
  762. contentType: 'application/json',
  763. beforeSend: function (request) {
  764. Common.addTokenToRequest(request);
  765. },
  766. data: JSON.stringify(tabQueryParam),
  767. dataType: 'text',
  768. success: function (data) {
  769. _self.footerHtml = data;
  770. },
  771. error: function (XMLHttpRequest, textStatus, errorThrown) {
  772. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  773. },
  774. });
  775. } else {
  776. _self.footerHtml = '';
  777. }
  778. },
  779. /**
  780. * 在表格中新建数据或者WindowEdit中新建数据
  781. * 在WindowEdit界面中新增数据
  782. *
  783. */
  784. createRecord: function () {
  785. var _self = this;
  786. if (
  787. _self.curdWindowFunctionAccess.allowCreate === null ||
  788. _self.curdWindowFunctionAccess.allowCreate === undefined ||
  789. _self.curdWindowFunctionAccess.allowCreate === false
  790. ) {
  791. Notify.error(
  792. _self.$t('lang.tabGridEdit.describe4'),
  793. _self.$t('lang.tabGridEdit.describe5'),
  794. false,
  795. );
  796. } else {
  797. // 如果存在子页签,则进入到新建的界面
  798. if (_self.window.tabs != undefined && _self.window.tabs.length > 1) {
  799. let currPage = _self.pagination.current_page;
  800. let totalCount = _self.pagination.total;
  801. _self.dynamicComponentParam = {
  802. viewType: 'create',
  803. curdWindowNo: this.windowNo,
  804. tabIndex: this.tabIndex,
  805. currentPage: currPage,
  806. currentIndex: 0,
  807. totalRecords: totalCount,
  808. isRestoreData: true,
  809. uuid: _self.uuid,
  810. };
  811. _self.dynamicComponent = 'CurdWindowModal';
  812. _self.dynamicComponentOpen = true;
  813. // this.$router.push(
  814. // 'window-edit/create/' +
  815. // this.windowNo +
  816. // '/' +
  817. // this.tabIndex +
  818. // '?currPage=' +
  819. // currPage,
  820. // );
  821. } else {
  822. // 如果不存在子页签,则可以直接在当前的界面上新建数据
  823. // var modelData = WindowClientUtil.newModelData(_self.tab);
  824. _self.loading = true;
  825. WindowServerUtil.newModelData(
  826. _self.windowNo,
  827. _self.tabIndex,
  828. function (modelData) {
  829. _self.loading = false;
  830. modelData.editMode = true;
  831. for (var i = _self.modelDatas.length; i > 0; i--) {
  832. _self.modelDatas[i] = _self.modelDatas[i - 1];
  833. }
  834. _self.modelDatas[0] = modelData;
  835. _self.dataChanged = true;
  836. },
  837. function () {
  838. _self.loading = false;
  839. },
  840. );
  841. }
  842. }
  843. },
  844. /**
  845. * 在WindowEdit界面中新增数据
  846. *
  847. */
  848. createRecordInWindowEdit: async function () {
  849. var _self = this;
  850. var currPage = _self.pagination.current_page;
  851. var totalCount = _self.pagination.total;
  852. var customerWindowUrl = _self.tab.customerWindowUrl;
  853. if (
  854. _self.curdWindowFunctionAccess.allowCreate === null ||
  855. _self.curdWindowFunctionAccess.allowCreate === undefined ||
  856. _self.curdWindowFunctionAccess.allowCreate === false
  857. ) {
  858. Notify.error(
  859. _self.$t('lang.tabGridEdit.describe4'),
  860. _self.$t('lang.tabGridEdit.describe5'),
  861. false,
  862. );
  863. } else {
  864. _self.dynamicComponentParam = {
  865. viewType: 'create',
  866. curdWindowNo: _self.windowNo,
  867. tabIndex: _self.tabIndex,
  868. currentPage: currPage,
  869. currentIndex: 0,
  870. totalRecords: totalCount,
  871. isRestoreData: true,
  872. uuid: _self.uuid,
  873. };
  874. _self.dynamicComponent = 'CurdWindowModal';
  875. _self.dynamicComponentOpen = true;
  876. // if (customerWindowUrl != undefined && customerWindowUrl != '') {
  877. // this.$router.push(
  878. // customerWindowUrl + '/create/' + this.windowNo + '/' + this.tabIndex,
  879. // );
  880. // } else {
  881. // this.$router.push(
  882. // 'window-edit/create/' +
  883. // this.windowNo +
  884. // '/' +
  885. // this.tabIndex +
  886. // '?currPage=' +
  887. // currPage +
  888. // '&totalCount=' +
  889. // totalCount +
  890. // '&uuid=' +
  891. // this.uuid,
  892. // );
  893. // }
  894. }
  895. },
  896. /**
  897. * 点击编辑全部按钮
  898. */
  899. editAllTabData: function () {
  900. var _self = this;
  901. if (
  902. _self.curdWindowFunctionAccess.allowUpdate === null ||
  903. _self.curdWindowFunctionAccess.allowUpdate === undefined ||
  904. _self.curdWindowFunctionAccess.allowUpdate === false
  905. ) {
  906. Notify.error(
  907. _self.$t('lang.tabGridEdit.describe6'),
  908. _self.$t('lang.tabGridEdit.describe7'),
  909. false,
  910. );
  911. } else {
  912. _self.modelDatas.forEach(function (item) {
  913. _self.editRecord(item);
  914. });
  915. }
  916. },
  917. // 编辑
  918. editRecord: function (modelData, index) {
  919. var _self = this;
  920. if (
  921. _self.curdWindowFunctionAccess.allowUpdate === null ||
  922. _self.curdWindowFunctionAccess.allowUpdate === undefined ||
  923. _self.curdWindowFunctionAccess.allowUpdate === false
  924. ) {
  925. Notify.error(
  926. _self.$t('lang.tabGridEdit.describe6'),
  927. _self.$t('lang.tabGridEdit.describe7'),
  928. false,
  929. );
  930. } else {
  931. // 如果存在子页签,则进入到新建的界面
  932. if (_self.window.tabs != undefined && _self.window.tabs.length > 1) {
  933. var currPage = _self.pagination.current_page;
  934. var currIndex = (currPage - 1) * Common.pageSize + index + 1;
  935. var totalCount = _self.pagination.total;
  936. _self.dynamicComponentParam = {
  937. viewType: 'edit',
  938. curdWindowNo: _self.windowNo,
  939. tabIndex: _self.tabIndex,
  940. modelDataId: modelData.id,
  941. currentPage: currPage,
  942. currentIndex: currIndex,
  943. totalRecords: totalCount,
  944. isRestoreData: _self.isRestoreData,
  945. uuid: _self.uuid,
  946. };
  947. _self.dynamicComponent = 'CurdWindowModal';
  948. _self.dynamicComponentOpen = true;
  949. // this.$router.push(
  950. // 'window-edit/edit/' +
  951. // this.windowNo +
  952. // '/' +
  953. // this.tabIndex +
  954. // '/' +
  955. // modelData.id +
  956. // '?currPage=' +
  957. // currPage +
  958. // '&currIndex=' +
  959. // currIndex +
  960. // '&totalCount=' +
  961. // totalCount +
  962. // '&uuid=' +
  963. // this.uuid +
  964. // '&isRestoreData=' +
  965. // _self.isRestoreData,
  966. // );
  967. } else {
  968. if (!modelData.editMode) {
  969. modelData.editMode = true;
  970. } else {
  971. this.saveTabData(modelData, index);
  972. }
  973. modelData.changed = true;
  974. _self.dataChanged = true;
  975. let index1 = this.modelDatas.indexOf(modelData);
  976. if (index1 != -1) {
  977. this.modelDatas[index1] = modelData;
  978. }
  979. }
  980. }
  981. },
  982. // 长按打开详细
  983. readRecordLongTap: function (e, args) {
  984. this.readRecord(args.modelData, args.index);
  985. },
  986. // 只读
  987. readRecord: function (modelData, index) {
  988. if (modelData.editMode == true) {
  989. return;
  990. }
  991. var _self = this;
  992. var currPage = _self.pagination.current_page;
  993. var currIndex = (currPage - 1) * Common.pageSize + index + 1;
  994. var totalCount = _self.pagination.total;
  995. var customerWindowUrl = _self.tab.customerWindowUrl;
  996. if (customerWindowUrl != undefined && customerWindowUrl != '') {
  997. this.$router.push(
  998. customerWindowUrl +
  999. '/view/' +
  1000. this.windowNo +
  1001. '/' +
  1002. this.tabIndex +
  1003. '/' +
  1004. modelData.id +
  1005. '?currPage=' +
  1006. currPage +
  1007. '&currIndex=' +
  1008. currIndex +
  1009. '&totalCount=' +
  1010. totalCount +
  1011. '&uuid=' +
  1012. this.uuid,
  1013. );
  1014. } else {
  1015. _self.dynamicComponentParam = {
  1016. viewType: 'view',
  1017. curdWindowNo: this.windowNo,
  1018. tabIndex: this.tabIndex,
  1019. modelDataId: modelData.id,
  1020. currentPage: currPage,
  1021. currentIndex: currIndex,
  1022. totalRecords: totalCount,
  1023. isRestoreData: false,
  1024. uuid: this.uuid,
  1025. };
  1026. _self.dynamicComponent = 'CurdWindowModal';
  1027. _self.dynamicComponentOpen = true;
  1028. // this.$router.push(
  1029. // 'window-read/view/' +
  1030. // this.windowNo +
  1031. // '/' +
  1032. // this.tabIndex +
  1033. // '/' +
  1034. // modelData.id +
  1035. // '?currPage=' +
  1036. // currPage +
  1037. // '&currIndex=' +
  1038. // currIndex +
  1039. // '&totalCount=' +
  1040. // totalCount +
  1041. // '&uuid=' +
  1042. // this.uuid,
  1043. // );
  1044. }
  1045. },
  1046. /**
  1047. * 简单搜索
  1048. */
  1049. simpleSearch: function () {
  1050. var _self = this;
  1051. _self.pagination.current_page = 1;
  1052. _self.showComplexFilterPanel = false;
  1053. _self.complexFilterParams = null;
  1054. _self.queryGridData(true);
  1055. },
  1056. /**
  1057. * 高级搜索
  1058. */
  1059. advancedSearchOk: function (filterParams) {
  1060. var _self = this;
  1061. _self.pagination.current_page = 1;
  1062. _self.complexFilterParams = filterParams;
  1063. _self.searchText = null;
  1064. _self.queryGridData(true);
  1065. },
  1066. // 刷新数据
  1067. refreshDatas: function (flag) {
  1068. this.queryGridData(flag);
  1069. },
  1070. // 删除选择的数据
  1071. deleteRecords: function (isAlert) {
  1072. var _self = this;
  1073. if (
  1074. _self.curdWindowFunctionAccess.allowDelete === null ||
  1075. _self.curdWindowFunctionAccess.allowDelete === undefined ||
  1076. _self.curdWindowFunctionAccess.allowDelete === false
  1077. ) {
  1078. Notify.error(
  1079. _self.$t('lang.tabGridEdit.describe8'),
  1080. _self.$t('lang.tabGridEdit.describe9'),
  1081. false,
  1082. );
  1083. } else {
  1084. // 待删除的数据集合
  1085. var dataPrepareDelete = [];
  1086. _self.modelDatas.forEach(function (modelData) {
  1087. if (modelData.select == true) {
  1088. dataPrepareDelete.push(modelData);
  1089. }
  1090. });
  1091. if (dataPrepareDelete.length == 0) {
  1092. Notify.error(
  1093. _self.$t('lang.tabGridEdit.describe10'),
  1094. _self.$t('lang.tabGridEdit.describe11'),
  1095. false,
  1096. );
  1097. return;
  1098. }
  1099. if (isAlert) {
  1100. Notify.show({
  1101. title: _self.$t('lang.tabGridEdit.deleteConfirmation'),
  1102. message:
  1103. _self.$t('lang.tabGridEdit.someWhatOne') +
  1104. dataPrepareDelete.length +
  1105. _self.$t('lang.tabGridEdit.someWhatTwo'),
  1106. buttons: [
  1107. {
  1108. label: _self.$t('lang.tabGridEdit.determine'),
  1109. cssClass: 'btn-primary',
  1110. action: function (dialogItself) {
  1111. dialogItself.close();
  1112. _self.deleteRecords(false);
  1113. },
  1114. },
  1115. {
  1116. label: _self.$t('lang.tabGridEdit.cancel'),
  1117. action: function (dialogItself) {
  1118. dialogItself.close();
  1119. },
  1120. },
  1121. ],
  1122. });
  1123. return;
  1124. }
  1125. var repareDeleteData = [];
  1126. for (var index = 0; index < dataPrepareDelete.length; index++) {
  1127. if (dataPrepareDelete[index].id < 0) {
  1128. var index1 = _self.modelDatas.indexOf(dataPrepareDelete[index]);
  1129. if (index1 >= 0) {
  1130. _self.modelDatas.splice(index1, 1);
  1131. }
  1132. } else {
  1133. repareDeleteData.push(dataPrepareDelete[index]);
  1134. }
  1135. }
  1136. var hasChanged = false;
  1137. _self.modelDatas.forEach(function (modelData) {
  1138. if (modelData.changed == true) {
  1139. hasChanged = true;
  1140. }
  1141. });
  1142. if (hasChanged == false) {
  1143. _self.dataChanged = false;
  1144. }
  1145. if (repareDeleteData.length == 0) {
  1146. return;
  1147. }
  1148. var tabDeleteData = {
  1149. windowNo: _self.windowNo,
  1150. tabIndex: _self.tabIndex,
  1151. modelDatas: repareDeleteData,
  1152. };
  1153. _self.loading = true;
  1154. WindowServerUtil.deleteTabData(
  1155. tabDeleteData,
  1156. function (result) {
  1157. for (var index = 0; index < dataPrepareDelete.length; index++) {
  1158. if (dataPrepareDelete[index].id > 0) {
  1159. var index1 = _self.modelDatas.indexOf(dataPrepareDelete[index]);
  1160. if (index1 >= 0) {
  1161. _self.modelDatas.splice(index1, 1);
  1162. }
  1163. }
  1164. }
  1165. _self.queryGridData(false);
  1166. _self.loading = false;
  1167. },
  1168. function () {
  1169. _self.loading = false;
  1170. },
  1171. );
  1172. }
  1173. },
  1174. // 删除数据
  1175. deleteRecord: function (modelData, isAlert) {
  1176. var _self = this;
  1177. var index = _self.modelDatas.indexOf(modelData);
  1178. if (index == -1) {
  1179. return;
  1180. }
  1181. if (
  1182. _self.curdWindowFunctionAccess.allowDelete === null ||
  1183. _self.curdWindowFunctionAccess.allowDelete === undefined ||
  1184. _self.curdWindowFunctionAccess.allowDelete === false
  1185. ) {
  1186. Notify.error(
  1187. _self.$t('lang.tabGridEdit.describe12'),
  1188. _self.$t('lang.tabGridEdit.describe13'),
  1189. false,
  1190. );
  1191. } else {
  1192. if (isAlert) {
  1193. Notify.show({
  1194. title: _self.$t('lang.tabGridEdit.deleteConfirmation'),
  1195. message: _self.$t('lang.tabGridEdit.someWhatThree'),
  1196. buttons: [
  1197. {
  1198. label: _self.$t('lang.tabGridEdit.determine'),
  1199. cssClass: 'btn-primary',
  1200. action: function (dialogItself) {
  1201. dialogItself.close();
  1202. _self.deleteRecord(modelData, false);
  1203. },
  1204. },
  1205. {
  1206. label: _self.$t('lang.tabGridEdit.cancel'),
  1207. action: function (dialogItself) {
  1208. dialogItself.close();
  1209. },
  1210. },
  1211. ],
  1212. });
  1213. return;
  1214. }
  1215. if (modelData.id < 0) {
  1216. _self.modelDatas.splice(index, 1);
  1217. var hasChanged = false;
  1218. _self.modelDatas.forEach(function (modelData) {
  1219. if (modelData.changed == true) {
  1220. hasChanged = true;
  1221. }
  1222. });
  1223. if (hasChanged == false) {
  1224. _self.dataChanged = false;
  1225. }
  1226. return;
  1227. }
  1228. var tabDeleteData = {
  1229. windowNo: _self.windowNo,
  1230. tabIndex: _self.tabIndex,
  1231. modelDatas: [modelData],
  1232. };
  1233. _self.loading = true;
  1234. WindowServerUtil.deleteTabData(
  1235. tabDeleteData,
  1236. function (result) {
  1237. _self.modelDatas.splice(index, 1);
  1238. _self.queryGridData(false);
  1239. _self.loading = false;
  1240. },
  1241. function () {
  1242. _self.loading = false;
  1243. },
  1244. );
  1245. }
  1246. },
  1247. gridSizeSelect: function (newPageSize) {
  1248. this.pagination.per_page = newPageSize;
  1249. this.pagination.current_page = 1;
  1250. localStorage.setItem(`CurdWindowPageSize${this.windowNo}`, newPageSize);
  1251. // 刷新界面
  1252. // this.queryGridData(true);
  1253. },
  1254. propertyChanged: function (changeEvent) {
  1255. GridColumnDefUtil.restoreTabGridFieldDef(
  1256. this.windowNo,
  1257. this.tabIndex,
  1258. this.tabGridFields,
  1259. );
  1260. },
  1261. onSort: function (gridFieldItem) {
  1262. var _self = this;
  1263. _self.sortStr = gridFieldItem.fieldName + _self.sortStyle;
  1264. _self.queryGridData(true);
  1265. _self.sortStyle = _self.sortStyle == ' ASC' ? ' DESC' : ' ASC';
  1266. },
  1267. // 表格中选择了一行
  1268. clickModelData: function (modelData) {
  1269. var _self = this;
  1270. var currentStatus = modelData.select;
  1271. if (!_self.multipleSelect) {
  1272. _self.modelDatas.forEach(function (item) {
  1273. item.select = false;
  1274. });
  1275. }
  1276. modelData.select = !currentStatus;
  1277. },
  1278. /**
  1279. * 全选/取消全选
  1280. * @param {Boolean} val 状态
  1281. * @return {void}
  1282. */
  1283. selectAll: function (val) {
  1284. var _self = this;
  1285. _self.modelDatas.forEach(function (item) {
  1286. item.select = val;
  1287. });
  1288. },
  1289. /**
  1290. * 验证数据
  1291. * @return {Array} Promises
  1292. */
  1293. performValidate: function (index) {
  1294. var _self = this;
  1295. var validatePromises = [];
  1296. if (this.$refs.gridBody != undefined) {
  1297. if (_self.modelDatas[index].changed == true) {
  1298. var validatePromises1 = this.$refs.gridBody[index].performValidate();
  1299. validatePromises = validatePromises.concat(validatePromises1);
  1300. }
  1301. }
  1302. return validatePromises;
  1303. },
  1304. /**
  1305. * 验证所有数据
  1306. * @return {void}
  1307. */
  1308. performValidateAll: function () {
  1309. var _self = this;
  1310. var validatePromises = [];
  1311. if (_self.$refs.gridBody != undefined) {
  1312. for (var i = 0, len = _self.$refs.gridBody.length; i < len; i++) {
  1313. if (_self.modelDatas[i].changed == true) {
  1314. var validatePromises1 = _self.$refs.gridBody[i].performValidate();
  1315. validatePromises = validatePromises.concat(validatePromises1);
  1316. }
  1317. }
  1318. }
  1319. return validatePromises;
  1320. },
  1321. /**
  1322. * 值改变事件
  1323. * @param {[type]} event [description]
  1324. * @param {[type]} modelData [description]
  1325. * @return {[type]} [description]
  1326. */
  1327. valueChanged: function (event, modelData, index) {
  1328. var gridFieldItem = event.gridFieldItem;
  1329. var newFieldValue = event.newFieldValue;
  1330. var oldFieldValue = modelData.data[gridFieldItem.fieldName];
  1331. if (FieldUtil.isFieldValueEqual(newFieldValue, oldFieldValue) == false) {
  1332. modelData.data[gridFieldItem.fieldName] = newFieldValue;
  1333. if (
  1334. gridFieldItem.calloutProcessReportNo != undefined &&
  1335. gridFieldItem.calloutProcessReportNo != null
  1336. ) {
  1337. this.callout(gridFieldItem.calloutProcessReportNo, modelData, index);
  1338. }
  1339. if (
  1340. gridFieldItem.calloutLogical != undefined &&
  1341. gridFieldItem.calloutLogical != null
  1342. ) {
  1343. this.executeCalloutJs(
  1344. gridFieldItem,
  1345. gridFieldItem.calloutLogical,
  1346. modelData,
  1347. );
  1348. }
  1349. }
  1350. },
  1351. /**
  1352. * 执行JS Callout
  1353. */
  1354. executeCalloutJs: function (gridFieldItem, scriptText, modelData) {
  1355. var _self = this;
  1356. let functionName =
  1357. gridFieldItem.fieldName.replace('.', '_') + '_calloutjs';
  1358. let executeFunction = function () {
  1359. let context = new _self.getContext(modelData);
  1360. try {
  1361. _self[functionName](context);
  1362. } catch (error) {
  1363. console.error(error);
  1364. Notify.error(
  1365. '数据字典定义异常',
  1366. '【' +
  1367. scriptText +
  1368. '】Callout前端逻辑定义异常,请联系管理员检查数据字典的定义。',
  1369. false,
  1370. );
  1371. }
  1372. };
  1373. if (_self[functionName] == null) {
  1374. // 执行服务端的脚本
  1375. const jsUrl = _self.jsUrl;
  1376. if (jsUrl == null || jsUrl == undefined) {
  1377. Notify.error(
  1378. '数据字典定义异常',
  1379. '【' +
  1380. scriptText +
  1381. '】Callout前端逻辑的JS文件不存在,请联系管理员检查数据字典是否存在JS文件。',
  1382. false,
  1383. );
  1384. return;
  1385. }
  1386. let promise = JsUtil.dynamicLoadJsFunction(jsUrl, scriptText);
  1387. promise.then(
  1388. targetFunction => {
  1389. if (targetFunction == null) {
  1390. Notify.error(
  1391. '数据字典定义异常',
  1392. '【' +
  1393. scriptText +
  1394. '】Callout前端逻辑定义异常,请联系管理员检查数据字典的定义。',
  1395. false,
  1396. );
  1397. return;
  1398. }
  1399. _self[functionName] = targetFunction;
  1400. executeFunction();
  1401. },
  1402. errorData => {
  1403. console.error(errorData);
  1404. },
  1405. );
  1406. } else {
  1407. executeFunction();
  1408. }
  1409. },
  1410. /**
  1411. * callout
  1412. * @param {[type]} calloutProcessReportNo [description]
  1413. * @return {[type]} [description]
  1414. */
  1415. callout: function (calloutProcessReportNo, modelData, index) {
  1416. var _self = this;
  1417. // 查询流程和报表的定义
  1418. ProcessReportResource.uniqueByNo(calloutProcessReportNo).then(
  1419. successData => {
  1420. if (successData == null) {
  1421. return;
  1422. }
  1423. // 执行服务端的脚本
  1424. ProcessReportResource.runCallout(
  1425. calloutProcessReportNo,
  1426. modelData,
  1427. ).then(
  1428. successData => {
  1429. if (successData && successData.modelData) {
  1430. var newModelData = successData.modelData;
  1431. newModelData.editMode = modelData.editMode;
  1432. _self.modelDatas[index] = newModelData;
  1433. }
  1434. },
  1435. errorData => {
  1436. Common.processException(errorData);
  1437. },
  1438. );
  1439. },
  1440. errorData => {
  1441. _self.loading = false;
  1442. Common.processException(errorData);
  1443. },
  1444. );
  1445. },
  1446. /**
  1447. * 保存所有数据
  1448. * @return {void}
  1449. */
  1450. saveAllTabData: function () {
  1451. var _self = this;
  1452. var promises = [];
  1453. var error = 0;
  1454. var subTabPromises = _self.performValidateAll();
  1455. if (subTabPromises != undefined) {
  1456. subTabPromises.forEach(function (tabPromise) {
  1457. if (tabPromise != true) {
  1458. error++;
  1459. }
  1460. });
  1461. }
  1462. if (error == 0) {
  1463. executeSave();
  1464. } else {
  1465. _self.errorCount = error;
  1466. _self.modal1 = true;
  1467. }
  1468. function executeSave() {
  1469. _self.loading = true;
  1470. var modelDatas = _self.modelDatas;
  1471. var tabSaveDatas = [];
  1472. modelDatas.forEach(function (item) {
  1473. //item.editMode = false;
  1474. if (item.changed) {
  1475. var tabSaveData = {
  1476. attributeValueDtos: null,
  1477. persistenceData: item,
  1478. };
  1479. tabSaveDatas.push(tabSaveData);
  1480. }
  1481. });
  1482. if (tabSaveDatas.length > 0) {
  1483. WindowServerUtil.saveTabDatas(
  1484. tabSaveDatas,
  1485. function (id) {
  1486. _self.queryGridData(false);
  1487. _self.loading = false;
  1488. Notify.success(
  1489. _self.$t('lang.tabGridEdit.describe14'),
  1490. _self.$t('lang.tabGridEdit.describe15'),
  1491. 1500,
  1492. );
  1493. },
  1494. function () {
  1495. _self.loading = false;
  1496. },
  1497. );
  1498. } else {
  1499. _self.loading = false;
  1500. Notify.error(
  1501. _self.$t('lang.Notify.error'),
  1502. _self.$t('lang.tabGridEdit.describe16'),
  1503. true,
  1504. );
  1505. }
  1506. }
  1507. },
  1508. /**
  1509. * 保存数据
  1510. * @param {[type]} modelData [description]
  1511. * @return {[type]} [description]
  1512. */
  1513. saveTabData: function (modelData, index) {
  1514. var _self = this;
  1515. var promises = [];
  1516. var error = 0;
  1517. var subTabPromises = _self.performValidate(index);
  1518. if (subTabPromises != undefined) {
  1519. subTabPromises.forEach(function (tabPromise) {
  1520. if (tabPromise != true) {
  1521. error++;
  1522. }
  1523. });
  1524. }
  1525. if (error == 0) {
  1526. executeSave();
  1527. } else {
  1528. _self.errorCount = error;
  1529. _self.modal1 = true;
  1530. }
  1531. function executeSave() {
  1532. modelData.editMode = false;
  1533. modelData.changed = true;
  1534. var tabSaveData = {
  1535. attributeValueDtos: null,
  1536. persistenceData: modelData,
  1537. };
  1538. _self.loading = true;
  1539. WindowServerUtil.saveTabData(
  1540. tabSaveData,
  1541. function (id) {
  1542. var tabLoadParam = {
  1543. windowNo: _self.windowNo,
  1544. tabIndex: modelData.tabIndex,
  1545. recordId: id,
  1546. };
  1547. WindowServerUtil.loadTabSingleData(
  1548. tabLoadParam,
  1549. function (modelDataSaved) {
  1550. Notify.success(
  1551. _self.$t('lang.tabGridEdit.describe14'),
  1552. _self.$t('lang.tabGridEdit.describe15'),
  1553. 1500,
  1554. );
  1555. var index = _self.modelDatas.indexOf(modelData);
  1556. modelDataSaved.editMode = false;
  1557. modelDataSaved.changed = false;
  1558. if (index != -1) {
  1559. _self.modelDatas[index] = modelDataSaved;
  1560. }
  1561. _self.loading = false;
  1562. _self.dataChanged = false;
  1563. },
  1564. function () {
  1565. _self.loading = false;
  1566. },
  1567. );
  1568. },
  1569. function () {
  1570. _self.loading = false;
  1571. },
  1572. );
  1573. }
  1574. },
  1575. /**
  1576. * 在离开路由之前,判断数据是否已保存
  1577. */
  1578. hasDataChanged: function () {
  1579. var _self = this;
  1580. if (_self.refreshCommand == false && _self.dataChanged == true) {
  1581. return true;
  1582. } else {
  1583. return false;
  1584. }
  1585. },
  1586. /**
  1587. * 执行Callout
  1588. */
  1589. executeCallout: function (gridFieldItem, modelData, index) {
  1590. var _self = this;
  1591. if (gridFieldItem.calloutProcessReportNo != null) {
  1592. _self.callout(gridFieldItem.calloutProcessReportNo, modelData, index);
  1593. }
  1594. },
  1595. /**
  1596. * 冻结表头
  1597. */
  1598. fixedTableHeader: function () {
  1599. let _self = this;
  1600. _self.$nextTick(function () {
  1601. var $th = $('.tableFixHead').find('thead');
  1602. $('.tableFixHead').on('scroll', function () {
  1603. $th.css('transform', 'translateY(' + this.scrollTop + 'px)');
  1604. });
  1605. });
  1606. },
  1607. backupView: function () {
  1608. let _self = this;
  1609. // 请勿修改,会影响生单的功能
  1610. let key = _self.uuid + '_modelDatas';
  1611. let userStorageDtos = [
  1612. {
  1613. key: key,
  1614. value: JSON.stringify(_self.modelDatas),
  1615. },
  1616. ];
  1617. UserStorageResource.uploadUserStorage(userStorageDtos).then(
  1618. successData => { },
  1619. errorData => {
  1620. Common.processException(errorData);
  1621. },
  1622. );
  1623. },
  1624. },
  1625. };
  1626. </script>
  1627. <style scoped>
  1628. .grid-container {
  1629. margin-top: 10px;
  1630. display: grid;
  1631. grid-template-columns: auto 17px 0px;
  1632. grid-template-rows: 40px 40px auto 40px;
  1633. gap: 5px;
  1634. justify-items: stretch;
  1635. align-items: stretch;
  1636. height: calc(100vh - 154px);
  1637. }
  1638. .grid-item-row1 {
  1639. grid-row-start: 1;
  1640. grid-row-end: 2;
  1641. grid-column-start: 1;
  1642. grid-column-end: 4;
  1643. }
  1644. .grid-item-row2 {
  1645. grid-row-start: 2;
  1646. grid-row-end: 3;
  1647. grid-column-start: 1;
  1648. grid-column-end: 4;
  1649. }
  1650. .grid-item-row3-column1 {
  1651. grid-row-start: 3;
  1652. grid-row-end: 4;
  1653. grid-column-start: 1;
  1654. grid-column-end: 3;
  1655. overflow: auto;
  1656. }
  1657. .grid-item-row3-column2 {
  1658. grid-row-start: 3;
  1659. grid-row-end: 4;
  1660. grid-column-start: 2;
  1661. grid-column-end: 3;
  1662. overflow: hidden;
  1663. border: 1px solid #ddd;
  1664. border-radius: 4px;
  1665. }
  1666. .grid-item-row4 {
  1667. grid-row-start: 4;
  1668. grid-row-end: 5;
  1669. grid-column-start: 1;
  1670. grid-column-end: 4;
  1671. }
  1672. .operationClass,
  1673. .button_list {
  1674. display: flex;
  1675. justify-content: space-between;
  1676. align-items: center;
  1677. }
  1678. .tableFixHead {
  1679. margin-top: -16px;
  1680. }
  1681. :deep( :where(.css-dev-only-do-not-override-16pw25h).ant-breadcrumb .ant-breadcrumb-link > .anticon + span,
  1682. :where(.css-dev-only-do-not-override-16pw25h).ant-breadcrumb .ant-breadcrumb-link > .anticon + a) {
  1683. color: black;
  1684. }
  1685. :deep( :where(.css-dev-only-do-not-override-16pw25h)[class^="ant-breadcrumb"] [class^="ant-breadcrumb"]) {
  1686. padding: 3px 10px;
  1687. }
  1688. :deep( :where(.css-dev-only-do-not-override-16pw25h)[class^="ant-breadcrumb"] [class^="ant-breadcrumb"]:hover) {
  1689. border: 1px solid #ddd;
  1690. border-radius: 4px;
  1691. cursor: pointer;
  1692. }
  1693. :deep( :where(.css-dev-only-do-not-override-16pw25h).ant-breadcrumb .ant-breadcrumb-separator) {
  1694. padding: 0px !important;
  1695. margin-inline: 2px !important;
  1696. }
  1697. :deep( :where(.css-dev-only-do-not-override-16pw25h).ant-breadcrumb .ant-breadcrumb-separator:hover) {
  1698. border: none;
  1699. cursor: none;
  1700. }
  1701. :deep(.ant-pagination-options-quick-jumper) {
  1702. margin-right: -18px !important;
  1703. }
  1704. </style>