audit-class-table.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div>
  3. <a-modal
  4. class="modalselectmaintain"
  5. :body-style="bodyStyle"
  6. :title="title"
  7. :destroy-on-close="true"
  8. :visible="visible"
  9. :width="modalWidth"
  10. @ok="handleOk"
  11. @cancel="handleCancel"
  12. >
  13. <audit-advanced-query
  14. :expand="expand"
  15. :search-data="formData"
  16. :ref-name="searchform"
  17. :search-style="{ height: 'auto', left: '21px', top: '105px' }"
  18. :search-fun="handleSearch"
  19. @searchedClick="searchedClick"
  20. >
  21. <template>
  22. <a-col :span="12">
  23. <a-form-model-item :label="'分类编号'" prop="categoryId">
  24. <a-input v-model="formData.categoryId" allow-clear />
  25. </a-form-model-item>
  26. </a-col>
  27. <a-col :span="12">
  28. <a-form-model-item :label="'分类名称'" prop="categoryName">
  29. <a-input v-model="formData.categoryName" allow-clear />
  30. </a-form-model-item>
  31. </a-col>
  32. </template>
  33. </audit-advanced-query>
  34. <!-- 列表 -->
  35. <sd-data-table-ex
  36. ref="SJMXDataTable"
  37. :show-advance-btn="true"
  38. form-id="iamDataCategory"
  39. page-id="audit/maintain/iamDataCategory"
  40. :pagination="{ pageSize: 10 }"
  41. :filter-expressions="filterExpressions"
  42. :check-type="'checkbox'"
  43. :columns="columns"
  44. :show-advance-query="true"
  45. :search-fields="['categoryName', 'categoryId']"
  46. show-selection
  47. :process-res="processRes"
  48. @searchbtnClick="searchbtnClick"
  49. @onChange="onChange"
  50. >
  51. </sd-data-table-ex>
  52. </a-modal>
  53. </div>
  54. </template>
  55. <script>
  56. import auditAdvancedQueryMixins from '../../components/audit-advanced-query-mixins'
  57. import auditAdvancedQuery from '../../components/audit-advanced-query.vue'
  58. import sdDataTableEx from '@/common/components/sd-data-table-ex.vue'
  59. import { message } from 'ant-design-vue'
  60. const columns = [
  61. {
  62. dataIndex: 'id',
  63. sdHidden: true,
  64. },
  65. {
  66. dataIndex: 'parentId',
  67. sdHidden: true,
  68. },
  69. {
  70. title: '分类编号',
  71. dataIndex: 'categoryId',
  72. },
  73. {
  74. title: '分类名称',
  75. dataIndex: 'categoryName',
  76. scopedSlots: { customRender: 'categoryName' },
  77. },
  78. {
  79. title: '权重排序',
  80. dataIndex: 'weightNum',
  81. },
  82. {
  83. title: '分类描述',
  84. dataIndex: 'categoryDesc',
  85. },
  86. ]
  87. export default {
  88. name: 'AuditClassTable',
  89. metaInfo: {
  90. title: '数据分类选择器',
  91. },
  92. components: {
  93. auditAdvancedQuery,
  94. sdDataTableEx,
  95. },
  96. mixins: [auditAdvancedQueryMixins],
  97. props: {
  98. // 弹出窗标题
  99. title: {
  100. type: String,
  101. default: '数据分类选择器',
  102. },
  103. // 弹出窗宽度
  104. modalWidth: {
  105. type: String,
  106. default: '1200px',
  107. },
  108. // 弹出窗显示参数
  109. visible: {
  110. type: Boolean,
  111. default: false,
  112. },
  113. selectType: {
  114. type: String,
  115. default: '',
  116. },
  117. },
  118. data() {
  119. return {
  120. bodyStyle: {
  121. minHeight: '700px',
  122. },
  123. // 列表展示用
  124. columns,
  125. // 高级搜索
  126. searchform: 'searchform',
  127. expand: false,
  128. // 列表展示过滤条件
  129. filterExpressions: [],
  130. formData: {
  131. categoryName: '',
  132. categoryId: '',
  133. },
  134. period: [],
  135. }
  136. },
  137. methods: {
  138. processRes(data) {
  139. let index = 0
  140. data.data.forEach((item) => {
  141. item.id = this.$refs.SJMXDataTable.localPagination.current + '-' + index
  142. index++
  143. })
  144. return data
  145. },
  146. handleOk(e) {
  147. const rowKeys = this.$refs.SJMXDataTable.getSelectedRowKeys()
  148. if (rowKeys.length > 1 && this.selectType !== 'radio') {
  149. return message.warning('最多可选一个分类')
  150. }
  151. this.$parent.visible = !this.$parent.visible
  152. this.$parent.flTableShow = !this.$parent.flTableShow
  153. // 列表选择事件,返回选择的数据
  154. this.$emit(
  155. 'listMxSelected',
  156. this.$refs.SJMXDataTable.getSelectedRowKeys(),
  157. this.$refs.SJMXDataTable.getSelectedRows()
  158. )
  159. },
  160. handleCancel(e) {
  161. this.$parent.visible = !this.$parent.visible
  162. this.$parent.flTableShow = !this.$parent.flTableShow
  163. },
  164. // 翻页操作
  165. onChange(pagination, filters, sorter) {
  166. this.pageSize = pagination.pageSize
  167. this.startPosition = (pagination.current - 1) * pagination.pageSize
  168. },
  169. // 开启关闭
  170. searchedClick() {
  171. this.expand = false
  172. },
  173. handleSearch() {
  174. const formData = this.formData
  175. // 获取当前表格过滤条件
  176. this.filterExpressions = []
  177. // 获取高级搜索的数据
  178. // 开始修改
  179. if (formData !== null) {
  180. if (this.formData.categoryId) {
  181. this.filterExpressions.push({
  182. dataType: 'str',
  183. name: 'categoryId',
  184. op: 'like',
  185. stringValue: `${this.formData.categoryId}`,
  186. })
  187. }
  188. if (this.formData.categoryName) {
  189. this.filterExpressions.push({
  190. dataType: 'str',
  191. name: 'categoryName',
  192. op: 'like',
  193. stringValue: `${this.formData.categoryName}`,
  194. })
  195. }
  196. }
  197. },
  198. },
  199. }
  200. </script>
  201. <style module lang="scss">
  202. @use '@/common/design' as *;
  203. :global(.modalselectmaintain) {
  204. :global(.ant-modal-body) {
  205. overflow-x: hidden;
  206. }
  207. }
  208. </style>