DocGenerator.vue 9.0 KB

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