index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <div>
  3. <a-modal
  4. :width='isMobile ? "100%" : "70%"'
  5. :title='title'
  6. :open='visible'
  7. :confirm-loading='confirmLoading'
  8. @ok='handleOkMain'
  9. @cancel='handleCancel'
  10. >
  11. <div v-if="!isMobile">
  12. <a-row>
  13. <a-col :span='24'>
  14. <div class='queryMain'>
  15. <div class='queryChild' v-for='(h,i) in headerQuery'>
  16. <a-input v-model:value='h.value' :placeholder='h.fieldName'></a-input>
  17. </div>
  18. <a-button class='queryBut' @click='search'>查询</a-button>
  19. </div>
  20. </a-col>
  21. </a-row>
  22. <a-row>
  23. <a-col :span='24'>
  24. <a-table :row-selection='{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }' :columns='columns'
  25. :data-source='tableData'
  26. >
  27. </a-table>
  28. </a-col>
  29. </a-row>
  30. </div>
  31. <div v-else>
  32. <a-row>
  33. <a-col :span='24' v-for='(h,i) in isFold ? headerQuery.slice(0, 1) : headerQuery'>
  34. <div class='queryMain' style="padding: 5px 0">
  35. <div class='queryChild' style="width: 100%">
  36. <a-input v-model:value='h.value' :placeholder='h.fieldName'></a-input>
  37. </div>
  38. </div>
  39. </a-col>
  40. <a-col :span='24'>
  41. <a-button class='queryBut' @click='search' type="primary">查询</a-button>
  42. <a-button class='queryBut' @click='isFold = false' style="margin-left: 10px;" v-show="isFold">
  43. <template #icon>
  44. <DownOutlined/>
  45. </template>
  46. <span>展开</span>
  47. </a-button>
  48. <a-button class='queryBut' @click='isFold = true' style="margin-left: 10px;" v-show="!isFold">
  49. <template #icon>
  50. <UpOutlined/>
  51. </template>
  52. <span>折叠</span>
  53. </a-button>
  54. </a-col>
  55. </a-row>
  56. <a-row>
  57. <a-col :span='24'>
  58. <a-table :row-selection='{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }'
  59. :columns='columns'
  60. :data-source='tableData'
  61. >
  62. </a-table>
  63. </a-col>
  64. </a-row>
  65. </div>
  66. </a-modal>
  67. </div>
  68. </template>
  69. <script>
  70. import {getPopUpData, getQueryPopupData} from '/@/api/flow/settingApi'
  71. import {isMobile} from '/@/utils'
  72. import {DownOutlined, UpOutlined} from '@ant-design/icons-vue';
  73. import {formGet} from "/@/api/flow/formApi.js";
  74. export default {
  75. data() {
  76. return {
  77. title: '数据查询',
  78. queryCode: '',//列表头
  79. queryMapField: [],
  80. columns: [],//列表头
  81. tableData: [],//列表数据
  82. visible: false,//弹出框是否可见
  83. confirmLoading: false,//数据加载
  84. selectRecord: {},//选中内容
  85. selectIndex: null,//选中index
  86. headerQuery: [],//搜索内容
  87. selectedRows: [],
  88. selectedRowKeys: [],
  89. isFold: true
  90. }
  91. },
  92. components: {
  93. DownOutlined,
  94. UpOutlined
  95. },
  96. watch: {
  97. visible(newVal, oldVal) {
  98. if (newVal == true) {
  99. this.search()
  100. }
  101. },
  102. queryCode(newVal, oldVal) {
  103. this.handleQueryCodeChange(newVal)
  104. }
  105. },
  106. computed: {
  107. rowSelection() {
  108. return {
  109. onChange: (selectedRowKeys, selectedRows) => {
  110. this.selectedRows = selectedRows
  111. },
  112. getCheckboxProps: record => ({
  113. props: {
  114. disabled: record.name === 'Disabled User',
  115. name: record.name
  116. }
  117. })
  118. }
  119. },
  120. isMobile() {
  121. return isMobile()
  122. }
  123. },
  124. mounted() {
  125. },
  126. methods: {
  127. handleToggle(code) {
  128. if (code === 'unfold') {
  129. // 展开
  130. } else {
  131. // 折叠
  132. }
  133. },
  134. onSelectChange(selectedRowKeys, selectedRows) {
  135. this.selectedRowKeys = selectedRowKeys
  136. this.selectedRows = selectedRows
  137. },
  138. handleQueryCodeChange(newQueryCode) {
  139. getPopUpData({queryCode: newQueryCode}).then((res) => {
  140. let j = res.data
  141. this.columns = j.columns
  142. this.headerQuery = j.headerQuery
  143. this.headerQuery.forEach(h => {
  144. h.value = ''
  145. })
  146. })
  147. },
  148. search() {
  149. getQueryPopupData({
  150. queryCode: this.queryCode,
  151. query: JSON.stringify(this.headerQuery),
  152. queryMapField: JSON.stringify(this.queryMapField)
  153. }
  154. ).then((res) => {
  155. this.tableData = res.data
  156. this.tableData.forEach((t, index) => {
  157. if (!t.key) {
  158. t.key = `row-${index}`; // 使用索引生成唯一的 key
  159. }
  160. })
  161. })
  162. },
  163. showModal() {
  164. this.visible = true
  165. },
  166. onSearch(r) {
  167. this.showModal()
  168. },
  169. handleChange(a, b, c) {
  170. this.$emit('change', a, b, c)
  171. },
  172. handleOkMain(e) {
  173. this.visible = false
  174. this.handleOk(e)
  175. this.selectedRows = []
  176. this.selectedRowKeys = []
  177. },
  178. handleOk(e) {
  179. }
  180. ,
  181. handleCancel(e) {
  182. this.visible = false
  183. this.selectedRows = []
  184. this.selectedRowKeys = []
  185. }
  186. }
  187. }
  188. </script>
  189. <style scoped>
  190. :deep(.active td) {
  191. background: #c8e7ff !important;
  192. }
  193. .queryMain {
  194. display: flex;
  195. flex-wrap: wrap; /* 允许项目换行 */
  196. padding: 10px;
  197. }
  198. .queryChild {
  199. margin-right: 10px;
  200. }
  201. .queryBut {
  202. }
  203. :deep(.ant-table) {
  204. height: calc(100vh - 450px);
  205. overflow: auto;
  206. }
  207. </style>