CustomClassName.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <a-card :bordered="false">
  3. <div v-show="visible">
  4. <div class="table-page-search-wrapper" @keyup.enter="handleEnter">
  5. <a-form layout="inline">
  6. <a-row :gutter="48">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="关键字">
  9. <a-input v-model="queryParam.keyword" placeholder="请输入名称/类型名称" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6 || 24" :sm="24">
  13. <span class="table-page-search-submitButtons">
  14. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  15. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  16. </span>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </div>
  21. <div class="table-operator" style="margin-bottom: 8px;">
  22. <a-row>
  23. <a-col :md="16">
  24. <a-button type="primary" icon="plus" @click="handleAdd()">新增</a-button>
  25. <a-button style="margin-left: 8px" type="primary" icon="download" @click="doExport">导出</a-button>
  26. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 ">
  27. <a-menu slot="overlay">
  28. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  29. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  30. </a-popconfirm>
  31. </a-menu>
  32. <a-button style="margin-left: 8px">
  33. 批量操作 <a-icon type="down" />
  34. </a-button>
  35. </a-dropdown>
  36. </a-col>
  37. </a-row>
  38. </div>
  39. <s-table ref="table" size="default" rowKey="id" :columns="columns" :data="loadData" :alert="options.alert" :rowSelection="options.rowSelection" showPagination="auto">
  40. <span slot="action" slot-scope="record">
  41. <template>
  42. <a @click="handleView(record)">查看</a>
  43. <operation-button @click="handleEdit(record)">修改</operation-button>
  44. <operation-button :type="2" title="是否要删除该条数据?" @confirm="batchDelete(record.id)">删除</operation-button>
  45. </template>
  46. </span>
  47. </s-table>
  48. </div>
  49. <base-form ref="baseModal" @ok="handleOk" />
  50. <detail ref="detailModal" @ok="handleOk" />
  51. </a-card>
  52. </template>
  53. <script>
  54. import { STable, Ellipsis } from '@/components'
  55. import BaseForm from './modules/BaseForm'
  56. import Detail from './modules/Detail'
  57. import {
  58. getCustomClassNamePage,
  59. deleteCustomClassNames,
  60. fetchCustomClassName,
  61. exportCustomClassName,
  62. } from '@/api/custom/className'
  63. export default {
  64. name: 'CustomClassNameList',
  65. components: {
  66. STable,
  67. Ellipsis,
  68. BaseForm,
  69. Detail,
  70. },
  71. data() {
  72. return {
  73. advanced: false,
  74. visible: true,
  75. // 查询参数
  76. queryParam: {},
  77. // 表头
  78. columns: [
  79. {
  80. title: '序号',
  81. dataIndex: 'index',
  82. width: 80,
  83. checked: true,
  84. align: 'center',
  85. customRender: (text, record, index) => {
  86. return `${
  87. (this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1
  88. }`
  89. },
  90. },
  91. {
  92. title: '配置类型',
  93. width: 120,
  94. checked: true,
  95. align: 'center',
  96. dataIndex: 'code',
  97. customRender: (text, record, index) => {
  98. return this.classNameCodeMap[text]
  99. },
  100. },
  101. {
  102. title: '名称',
  103. dataIndex: 'title',
  104. width: 120,
  105. checked: true,
  106. align: 'center',
  107. },
  108. {
  109. title: '名称编码',
  110. dataIndex: 'titleCode',
  111. width: 120,
  112. checked: true,
  113. align: 'center',
  114. },
  115. {
  116. title: '具体列名',
  117. width: 120,
  118. checked: true,
  119. align: 'center',
  120. dataIndex: 'titleColumnName',
  121. },
  122. {
  123. title: '具体列编码',
  124. width: 120,
  125. checked: true,
  126. align: 'center',
  127. dataIndex: 'titleColumnCode',
  128. },
  129. {
  130. title: '处理类',
  131. width: 120,
  132. checked: true,
  133. align: 'center',
  134. dataIndex: 'handleName',
  135. },
  136. {
  137. title: '处理类编码',
  138. width: 120,
  139. checked: true,
  140. align: 'center',
  141. dataIndex: 'handleCode',
  142. },
  143. {
  144. title: '方法名称',
  145. dataIndex: 'methodName',
  146. width: 120,
  147. checked: true,
  148. align: 'center',
  149. },
  150. {
  151. title: '方法名称编码',
  152. width: 120,
  153. checked: true,
  154. align: 'center',
  155. dataIndex: 'methodCode',
  156. },
  157. {
  158. title: '备注简介',
  159. width: 120,
  160. checked: true,
  161. align: 'center',
  162. dataIndex: 'remark',
  163. },
  164. {
  165. title: '操作',
  166. key: 'action',
  167. width: '200px',
  168. align: 'center',
  169. fixed: 'right',
  170. checked: true,
  171. scopedSlots: { customRender: 'action' },
  172. },
  173. ],
  174. // 下拉框map
  175. // 加载数据方法 必须为 Promise 对象
  176. loadData: (parameter) => {
  177. parameter = {
  178. ...parameter,
  179. ...this.queryParam,
  180. dataScope: {
  181. sortBy: 'desc',
  182. sortName: 'update_time',
  183. },
  184. }
  185. return getCustomClassNamePage(Object.assign(parameter, this.queryParam)).then((res) => {
  186. return res.data
  187. })
  188. },
  189. selectedRowKeys: [],
  190. selectedRows: [],
  191. options: {
  192. alert: {
  193. show: true,
  194. clear: () => {
  195. this.selectedRowKeys = []
  196. },
  197. },
  198. rowSelection: {
  199. selectedRowKeys: this.selectedRowKeys,
  200. onChange: this.onSelectChange,
  201. },
  202. },
  203. optionAlertShow: false,
  204. classNameCodeMap: {},
  205. }
  206. },
  207. created() {
  208. // 下拉框map
  209. this.tableOption()
  210. this.classNameCodeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.CLASS_NAME_CODE)
  211. },
  212. methods: {
  213. tableOption() {
  214. if (!this.optionAlertShow) {
  215. this.options = {
  216. alert: {
  217. show: true,
  218. clear: () => {
  219. this.selectedRowKeys = []
  220. },
  221. },
  222. rowSelection: {
  223. selectedRowKeys: this.selectedRowKeys,
  224. onChange: this.onSelectChange,
  225. getCheckboxProps: (record) => ({
  226. props: {
  227. disabled: false,
  228. name: record.id,
  229. },
  230. }),
  231. },
  232. }
  233. this.optionAlertShow = true
  234. } else {
  235. this.options = {
  236. alert: false,
  237. rowSelection: null,
  238. }
  239. this.optionAlertShow = false
  240. }
  241. },
  242. batchDelete(id) {
  243. let ids = []
  244. if (this.BaseTool.String.isBlank(id)) {
  245. const length = this.selectedRows.length
  246. if (length === 0) {
  247. this.$message.info('请选择要删除的记录')
  248. return
  249. }
  250. ids = this.selectedRows.map((item) => item.id)
  251. } else {
  252. ids = [id]
  253. }
  254. deleteCustomClassNames(ids).then((res) => {
  255. this.$message.info('删除成功')
  256. this.handleOk()
  257. this.$refs.table.clearSelected()
  258. })
  259. },
  260. handleAdd() {
  261. this.visible = false
  262. const modal = this.$refs.baseModal
  263. modal.base()
  264. },
  265. handleEdit(record) {
  266. this.visible = false
  267. fetchCustomClassName({ id: record.id }).then((res) => {
  268. const modal = this.$refs.baseModal
  269. modal.base(res.data)
  270. })
  271. },
  272. handleView(record) {
  273. this.visible = false
  274. fetchCustomClassName({ id: record.id }).then((res) => {
  275. const modal = this.$refs.detailModal
  276. modal.base(res.data)
  277. })
  278. },
  279. handleOk(values) {
  280. this.visible = true
  281. this.$refs.table.refresh()
  282. },
  283. onSelectChange(selectedRowKeys, selectedRows) {
  284. this.selectedRowKeys = selectedRowKeys
  285. this.selectedRows = selectedRows
  286. },
  287. resetSearchForm() {
  288. this.queryParam = {}
  289. this.$refs.table.refresh(true)
  290. },
  291. doExport() {
  292. const parameter = {
  293. ...this.queryParam,
  294. }
  295. exportCustomClassName(parameter).then((file) => {
  296. this.BaseTool.Util.downLoadExportExcel(file)
  297. })
  298. },
  299. handleEnter() {
  300. this.$refs.table.refresh(true)
  301. },
  302. },
  303. }
  304. </script>