DocGenerator.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <div class="grid-container-2">
  3. <div class="grid-header-2">
  4. <QueryCondition
  5. ref="queryCondition"
  6. :info-filter-fields="infoFilterFields"
  7. :show-button="true"
  8. :is-search-widget="true"
  9. @simple-search="simpleSearch()"
  10. @complex-search="complexSearch()"
  11. @refresh-search="queryInfoWindowData"
  12. @change-search="tabIndex = 1;"
  13. >
  14. <template #header>
  15. <li
  16. role="presentation"
  17. :class="{'active': tabIndex === 2}"
  18. >
  19. <a @click="$refs.queryCondition.changeSearch(1); tabIndex = 2;">{{ $t('lang.DocGenerator.selectedDatas') }}</a>
  20. </li>
  21. </template>
  22. <template #body>
  23. <div
  24. class="tab-pane"
  25. :class="{'active': tabIndex === 2}"
  26. />
  27. </template>
  28. </QueryCondition>
  29. </div>
  30. <div class="grid-content-2">
  31. <DocGeneratorGrid
  32. v-show="tabIndex === 1"
  33. ref="docGeneratorGrid"
  34. :info-window-no="infoWindowNo"
  35. :info-grid-fields="infoGridFields"
  36. :info-window-data="infoWindowData"
  37. :is-selected-by-id="isSelectedById"
  38. @refresh-search="queryInfoWindowData"
  39. @select-changed="selectChanged"
  40. />
  41. <DocGeneratorSelected
  42. v-show="tabIndex === 2"
  43. ref="docGeneratorSelected"
  44. :info-window-no="infoWindowNo"
  45. :info-grid-fields="infoGridFields"
  46. @select-changed="queryInfoWindowData"
  47. />
  48. </div>
  49. <Loading ref="loading" />
  50. </div>
  51. </template>
  52. <script>
  53. var Common = require('../../common/Common.js').default;
  54. var InfoUtil = require('./InfoUtil.js').default;
  55. var Loading = require('../../loading/src/Loading.vue').default;
  56. var QueryCondition = require('./QueryCondition.vue').default;
  57. var DocGeneratorSelected = require('./DocGeneratorSelected.vue').default;
  58. var DocGeneratorGrid = require('./DocGeneratorGrid.vue').default;
  59. export default {
  60. name: 'DocGenerator',
  61. components: {
  62. QueryCondition, Loading,
  63. DocGeneratorSelected,
  64. DocGeneratorGrid,
  65. },
  66. props: ['infoWindowNo'],
  67. data: function () {
  68. return {
  69. infoWindowDto: {},
  70. infoFilterFields: [], // 过滤字段
  71. infoGridFields: [], // 表格字段
  72. infoWindowData: [],
  73. tabIndex: 1,
  74. };
  75. },
  76. watch: {
  77. infoWindowNo: function(newValue, oldValue){
  78. this.init();
  79. },
  80. },
  81. mounted: function(){
  82. this.init();
  83. },
  84. methods: {
  85. /**
  86. * 加载查询窗口的定义
  87. * @author YangZhiJie 20210909
  88. */
  89. init: function () {
  90. var _self = this;
  91. if (_self.infoWindowNo === undefined || _self.infoWindowNo === null || _self.infoWindowNo === '') {
  92. return;
  93. }
  94. _self.$refs.loading.show();
  95. $.ajax({
  96. url: Common.getApiURL('InfoWindowResource/uniqueByNo'),
  97. type: 'GET',
  98. dataType: 'json',
  99. data: { 'infoWindowNo': _self.infoWindowNo },
  100. beforeSend: function (request) {
  101. Common.addTokenToRequest(request);
  102. },
  103. success: function (data) {
  104. _self.$refs.loading.show();
  105. _self.infoWindowDto = data;
  106. _self.$emit('showTitle', data.name);
  107. _self.$nextTick(function () {
  108. _self.initQueryPage();
  109. });
  110. },
  111. error: function (XMLHttpRequest, textStatus, errorThrown) {
  112. _self.$refs.loading.show();
  113. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  114. },
  115. });
  116. },
  117. /**
  118. * 根据用户配置更新查询窗口的定义
  119. * @author YangZhiJie 20210909
  120. */
  121. initQueryPage: function () {
  122. var _self = this;
  123. if (_self.infoWindowDto === undefined || _self.infoWindowDto === null) {
  124. return;
  125. }
  126. _self.infoWindowDto.infoGridFields.forEach(function (item) {
  127. _self.$set(item, 'width', 150);
  128. });
  129. _self.infoWindowDto.infoFilterFields.forEach(function (item) {
  130. item.value = {
  131. 'infoFilterFieldId': item.id,
  132. 'value1': '',
  133. 'value2': '',
  134. };
  135. });
  136. InfoUtil.restoreInfoFilterField(_self.infoWindowDto.no, _self.infoWindowDto.infoFilterFields);
  137. InfoUtil.restoreInfoGridField(_self.infoWindowDto.no, _self.infoWindowDto.infoGridFields);
  138. _self.infoFilterFields = _self.infoWindowDto.infoFilterFields;
  139. _self.infoGridFields = _self.infoWindowDto.infoGridFields;
  140. _self.$nextTick(function () {
  141. _self.queryInfoWindowData();
  142. });
  143. },
  144. /**
  145. * 重新开始简单查询
  146. * @author YangZhiJie 20210909
  147. */
  148. simpleSearch: function () {
  149. this.$refs.docGeneratorGrid.resetPagination();
  150. this.queryInfoWindowDataSimple();
  151. },
  152. /**
  153. * 从新开始复杂查询
  154. * @author YangZhiJie 20210909
  155. */
  156. complexSearch: function () {
  157. this.$refs.docGeneratorGrid.resetPagination();
  158. this.queryInfoWindowDataComplex();
  159. },
  160. /**
  161. * 查询窗口数据查询
  162. * @author YangZhiJie 20210909
  163. */
  164. queryInfoWindowData: function () {
  165. var isSimpleSearch = this.$refs.queryCondition.isSimpleQuery();
  166. if (isSimpleSearch) {
  167. this.queryInfoWindowDataSimple();
  168. } else {
  169. this.queryInfoWindowDataComplex();
  170. }
  171. },
  172. /**
  173. * 简单数据查询
  174. * @author YangZhiJie 20210909
  175. */
  176. queryInfoWindowDataSimple: function () {
  177. var _self = this;
  178. var infoQueryParam = this.$refs.docGeneratorGrid.getQueryParam();
  179. infoQueryParam.infoFilterFieldValues = _self.$refs.queryCondition.getQueryCondition();
  180. _self.$refs.loading.show();
  181. $.ajax({
  182. url: Common.getApiURL('InfoWindowResource/queryInfoWindowDataSimple'),
  183. type: 'post',
  184. dataType: 'json',
  185. beforeSend: function (request) {
  186. Common.addTokenToRequest(request);
  187. },
  188. contentType: 'application/json',
  189. data: JSON.stringify(infoQueryParam),
  190. success: function (data) {
  191. _self.$refs.loading.hide();
  192. console.log(data);
  193. if (data != undefined && data.range != undefined) {
  194. _self.infoWindowData = data.dataList;
  195. _self.$refs.docGeneratorGrid.setPagination(data.totalSize, Math.ceil(data.totalSize / data.range.length));
  196. }
  197. },
  198. error: function (XMLHttpRequest, textStatus, errorThrown) {
  199. _self.$refs.loading.hide();
  200. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  201. },
  202. });
  203. },
  204. /**
  205. * 复杂数据查询
  206. * @author YangZhiJie 20210909
  207. */
  208. queryInfoWindowDataComplex: function () {
  209. var _self = this;
  210. var infoQueryParam = this.$refs.docGeneratorGrid.getQueryParam();
  211. infoQueryParam.infoFilterFieldValues = _self.$refs.queryCondition.getQueryCondition();
  212. _self.$refs.loading.show();
  213. $.ajax({
  214. url: Common.getApiURL('InfoWindowResource/queryInfoWindowDataComplex'),
  215. type: 'post',
  216. dataType: 'json',
  217. beforeSend: function (request) {
  218. Common.addTokenToRequest(request);
  219. },
  220. contentType: 'application/json',
  221. data: JSON.stringify(infoQueryParam),
  222. success: function (data) {
  223. _self.$refs.loading.hide();
  224. console.log(data);
  225. if (data != undefined && data.range != undefined) {
  226. _self.infoWindowData = data.dataList;
  227. _self.$refs.docGeneratorGrid.setPagination(data.totalSize, Math.ceil(data.totalSize / data.range.length));
  228. }
  229. },
  230. error: function (XMLHttpRequest, textStatus, errorThrown) {
  231. _self.$refs.loading.hide();
  232. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  233. },
  234. });
  235. },
  236. /**
  237. * 选择的内容发生了改变
  238. * @author YangZhiJie 20210909
  239. */
  240. selectChanged: function(selectDatas){
  241. this.$refs.docGeneratorSelected.parseDataList(selectDatas);
  242. },
  243. /**
  244. * 根据id判断数据是否被选中
  245. * 供外部接口调用
  246. * @author YangZhiJie 20210909
  247. */
  248. isSelectedById: function(id){
  249. return this.$refs.docGeneratorSelected.isSelectedById(id);
  250. },
  251. /**
  252. * 获取选中的数据
  253. * 供外部接口调用
  254. * @author YangZhiJie 20210909
  255. */
  256. getSelectedData: function(){
  257. return this.$refs.docGeneratorSelected.getSelectedData();
  258. },
  259. },
  260. };
  261. </script>
  262. <style scoped>
  263. .grid-container-2 {
  264. display: grid;
  265. grid-template-columns: 100%;
  266. grid-template-rows: min-content auto;
  267. width: 100%;
  268. height: calc(100% - 10px);
  269. }
  270. .grid-header-2 {
  271. grid-row: 1 / 2;
  272. grid-column: 1 / 2;
  273. }
  274. .grid-content-2 {
  275. grid-row: 2 / 3;
  276. grid-column: 1 / 2;
  277. overflow: auto;
  278. }
  279. </style>
  280. <style scoped>
  281. /** 修复分页的样式 By YangZhiJie 2021-07-06 11:23 */
  282. nav >>> ul.pagination {
  283. margin: 0 !important;
  284. }
  285. </style>