TabGridEdit.vue 55 KB

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