JPopupOnlReport.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <div>
  3. <div class="jeecg-basic-table-form-container" v-if="showSearchFlag">
  4. <a-form ref="formRef" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol" @keyup.enter.native="searchQuery">
  5. <a-row :gutter="24">
  6. <template v-for="(item, index) in queryInfo">
  7. <template v-if="item.hidden === '1'">
  8. <a-col :md="8" :sm="24" :key="'query' + index" v-show="toggleSearchStatus">
  9. <SearchFormItem :formElRef="formRef" :queryParam="queryParam" :item="item" :dictOptions="dictOptions"></SearchFormItem>
  10. </a-col>
  11. </template>
  12. <template v-else>
  13. <a-col :md="8" :sm="24" :key="'query' + index">
  14. <SearchFormItem :formElRef="formRef" :queryParam="queryParam" :item="item" :dictOptions="dictOptions"></SearchFormItem>
  15. </a-col>
  16. </template>
  17. </template>
  18. <a-col :md="8" :sm="8">
  19. <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
  20. <a-col :lg="6">
  21. <a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset">重置</a-button>
  22. <a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery" style="margin-left: 8px">查询</a-button>
  23. <a @click="handleToggleSearch" style="margin-left: 8px">
  24. {{ toggleSearchStatus ? '收起' : '展开' }}
  25. <Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
  26. </a>
  27. </a-col>
  28. </span>
  29. </a-col>
  30. </a-row>
  31. </a-form>
  32. </div>
  33. <BasicTable
  34. ref="tableRef"
  35. :canResize="true"
  36. :bordered="true"
  37. :loading="loading"
  38. :rowKey="combineRowKey"
  39. :columns="columns"
  40. :showIndexColumn="false"
  41. :dataSource="dataSource"
  42. :pagination="pagination"
  43. :rowSelection="rowSelection"
  44. @row-click="clickThenCheck"
  45. @change="handleChangeInTable"
  46. >
  47. <template #tableTitle>
  48. <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
  49. </template>
  50. </BasicTable>
  51. <!-- 跳转Href的动态组件方式 -->
  52. <a-modal v-bind="hrefComponent.model" v-on="hrefComponent.on">
  53. <component :is="hrefComponent.is" v-bind="hrefComponent.params" />
  54. </a-modal>
  55. </div>
  56. </template>
  57. <script lang="ts">
  58. import { defineComponent, unref, ref, watch, watchEffect, reactive, computed } from 'vue';
  59. import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent';
  60. import { useAttrs } from '/@/hooks/core/useAttrs';
  61. import { usePopBiz } from '/@/components/jeecg/OnLine/hooks/usePopBiz';
  62. import { useMessage } from '/@/hooks/web/useMessage';
  63. export default defineComponent({
  64. name: 'JPopupOnlReport',
  65. components: {
  66. SearchFormItem: createAsyncComponent(() => import('/@/components/jeecg/OnLine/SearchFormItem.vue'), { loading: true }),
  67. BasicTable: createAsyncComponent(() => import('/@/components/Table/src/BasicTable.vue'), {
  68. loading: true,
  69. }),
  70. },
  71. props: ['multi', 'code', 'id', 'sorter', 'groupId', 'param', 'clickToRowSelect'],
  72. emits: ['ok', 'register'],
  73. setup(props, { emit, refs }) {
  74. const { createMessage } = useMessage();
  75. const labelCol = reactive({
  76. xs: { span: 24 },
  77. sm: { span: 6 },
  78. });
  79. const wrapperCol = reactive({
  80. xs: { span: 24 },
  81. sm: { span: 18 },
  82. });
  83. const formRef = ref();
  84. const tableRef = ref();
  85. const toggleSearchStatus = ref(false);
  86. const attrs = useAttrs();
  87. const tableScroll = ref({ x: true });
  88. const getBindValue = Object.assign({}, unref(props), unref(attrs));
  89. const [
  90. { visibleChange, loadColumnsInfo, dynamicParamHandler, loadData, loadColumnsAndData, handleChangeInTable, combineRowKey, clickThenCheck, filterUnuseSelect, handleExport },
  91. { hrefComponent, visible, rowSelection, checkedKeys, selectRows, pagination, dataSource, columns, loading, title, iSorter, queryInfo, queryParam, dictOptions },
  92. ] = usePopBiz(getBindValue);
  93. const showSearchFlag = computed(() => unref(queryInfo) && unref(queryInfo).length > 0);
  94. /**
  95. *监听code
  96. */
  97. watch(
  98. () => props.code,
  99. () => {
  100. loadColumnsAndData();
  101. },
  102. { immediate: true }
  103. );
  104. /**
  105. *监听popup动态参数 支持系统变量语法
  106. */
  107. watch(
  108. () => props.param,
  109. () => {
  110. if (visible) {
  111. dynamicParamHandler();
  112. //loadData();
  113. }
  114. }
  115. );
  116. /**
  117. *监听sorter排序字段
  118. */
  119. watchEffect(() => {
  120. if (props.sorter) {
  121. let arr = props.sorter.split('=');
  122. if (arr.length === 2 && ['asc', 'desc'].includes(arr[1].toLowerCase())) {
  123. iSorter.value = { column: arr[0], order: arr[1].toLowerCase() };
  124. // 排序字段受控
  125. unref(columns).forEach((col) => {
  126. if (col.dataIndex === unref(iSorter).column) {
  127. col['sortOrder'] = unref(iSorter).order === 'asc' ? 'ascend' : 'descend';
  128. } else {
  129. col['sortOrder'] = false;
  130. }
  131. });
  132. } else {
  133. console.warn('【JPopup】sorter参数不合法');
  134. }
  135. }
  136. });
  137. function handleToggleSearch() {
  138. toggleSearchStatus.value = !unref(toggleSearchStatus);
  139. }
  140. /**
  141. * 导出excel
  142. */
  143. function onExportXls() {
  144. handleExport!();
  145. }
  146. /**
  147. * 查询
  148. */
  149. function searchQuery() {
  150. loadData(1);
  151. }
  152. /**
  153. * 重置
  154. */
  155. function searchReset() {
  156. queryParam.value = {};
  157. loadData(1);
  158. }
  159. return {
  160. attrs,
  161. tableScroll,
  162. dataSource,
  163. pagination,
  164. columns,
  165. rowSelection,
  166. checkedKeys,
  167. loading,
  168. title,
  169. hrefComponent,
  170. clickThenCheck,
  171. loadData,
  172. combineRowKey,
  173. handleChangeInTable,
  174. visibleChange,
  175. queryInfo,
  176. queryParam,
  177. tableRef,
  178. formRef,
  179. labelCol,
  180. wrapperCol,
  181. dictOptions,
  182. showSearchFlag,
  183. toggleSearchStatus,
  184. handleToggleSearch,
  185. searchQuery,
  186. searchReset,
  187. onExportXls,
  188. };
  189. },
  190. });
  191. </script>
  192. <style lang="less" scoped>
  193. .jeecg-basic-table-form-container {
  194. padding: 0px;
  195. .table-page-search-submitButtons {
  196. display: block;
  197. margin-bottom: 0;
  198. white-space: nowrap;
  199. }
  200. }
  201. :deep .jeecg-basic-table .ant-table-wrapper .ant-table-title {
  202. min-height: 0;
  203. }
  204. </style>