TabGridEdit.vue 54 KB

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