JPopupOnlReport.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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'), { loading: true }),
  68. },
  69. props: ['multi', 'code','id', 'sorter', 'groupId', 'param', 'clickToRowSelect'],
  70. emits: ['ok', 'register'],
  71. setup(props, { emit, refs }) {
  72. const { createMessage } = useMessage();
  73. const labelCol = reactive({
  74. xs: { span: 24 },
  75. sm: { span: 6 },
  76. });
  77. const wrapperCol = reactive({
  78. xs: { span: 24 },
  79. sm: { span: 18 },
  80. });
  81. const formRef = ref();
  82. const tableRef = ref();
  83. const toggleSearchStatus = ref(false);
  84. const attrs = useAttrs();
  85. const tableScroll = ref({ x: true });
  86. const getBindValue = Object.assign({}, unref(props), unref(attrs));
  87. const [{ visibleChange, loadColumnsInfo, dynamicParamHandler, loadData,loadColumnsAndData, handleChangeInTable, combineRowKey, clickThenCheck, filterUnuseSelect, handleExport },
  88. { hrefComponent,visible, rowSelection, checkedKeys, selectRows, pagination, dataSource, columns, loading, title, iSorter, queryInfo, queryParam, dictOptions }] = usePopBiz(getBindValue);
  89. const showSearchFlag = computed(() => unref(queryInfo) && unref(queryInfo).length > 0);
  90. /**
  91. *监听code
  92. */
  93. watch(
  94. () => props.code,
  95. () => {
  96. loadColumnsAndData();
  97. },
  98. {immediate: true}
  99. );
  100. /**
  101. *监听popup动态参数 支持系统变量语法
  102. */
  103. watch(
  104. () => props.param,
  105. () => {
  106. if (visible) {
  107. dynamicParamHandler();
  108. //loadData();
  109. }
  110. },
  111. );
  112. /**
  113. *监听sorter排序字段
  114. */
  115. watchEffect(() => {
  116. if (props.sorter) {
  117. let arr = props.sorter.split('=');
  118. if (arr.length === 2 && ['asc', 'desc'].includes(arr[1].toLowerCase())) {
  119. iSorter.value = { column: arr[0], order: arr[1].toLowerCase() };
  120. // 排序字段受控
  121. unref(columns).forEach(col => {
  122. if (col.dataIndex === unref(iSorter).column) {
  123. col['sortOrder'] = unref(iSorter).order === 'asc' ? 'ascend' : 'descend';
  124. } else {
  125. col['sortOrder'] = false;
  126. }
  127. });
  128. } else {
  129. console.warn('【JPopup】sorter参数不合法');
  130. }
  131. }
  132. });
  133. function handleToggleSearch() {
  134. toggleSearchStatus.value = !unref(toggleSearchStatus);
  135. }
  136. /**
  137. * 导出excel
  138. */
  139. function onExportXls() {
  140. handleExport!()
  141. }
  142. /**
  143. * 查询
  144. */
  145. function searchQuery() {
  146. loadData(1);
  147. }
  148. /**
  149. * 重置
  150. */
  151. function searchReset() {
  152. queryParam.value = {};
  153. loadData(1);
  154. }
  155. return {
  156. attrs,
  157. tableScroll,
  158. dataSource,
  159. pagination,
  160. columns,
  161. rowSelection,
  162. checkedKeys,
  163. loading,
  164. title,
  165. hrefComponent,
  166. clickThenCheck,
  167. loadData,
  168. combineRowKey,
  169. handleChangeInTable,
  170. visibleChange,
  171. queryInfo,
  172. queryParam,
  173. tableRef,
  174. formRef,
  175. labelCol,
  176. wrapperCol,
  177. dictOptions,
  178. showSearchFlag,
  179. toggleSearchStatus,
  180. handleToggleSearch,
  181. searchQuery,
  182. searchReset,
  183. onExportXls
  184. };
  185. },
  186. });
  187. </script>
  188. <style lang="less" scoped>
  189. .jeecg-basic-table-form-container {
  190. padding: 0px;
  191. .table-page-search-submitButtons {
  192. display: block;
  193. margin-bottom: 0;
  194. white-space: nowrap;
  195. }
  196. }
  197. :deep .jeecg-basic-table .ant-table-wrapper .ant-table-title {
  198. min-height: 0;
  199. }
  200. </style>