DesignForm.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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" v-show="advanced">
  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-row>
  13. <a-row :gutter="48">
  14. <a-col :md="24 || 24" :sm="24" style="text-align: right">
  15. <span class="table-page-search-submitButtons">
  16. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  17. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</a-button>
  18. <a @click="()=>{ this.advanced = !this.advanced}" style="margin-left: 8px">
  19. {{ advanced ? '收起' : '展开' }}
  20. <a-icon :type="advanced ? 'up' : 'down'"/>
  21. </a>
  22. </span>
  23. </a-col>
  24. </a-row>
  25. </a-form>
  26. </div>
  27. <div class="table-operator" style="margin-bottom: 8px;">
  28. <a-row>
  29. <a-col :md="16">
  30. <a-button v-if="$auth('design-design-forms-add')" type="primary" icon="plus" @click="handleAdd()">新增</a-button>
  31. <a-button style="margin-left: 8px" v-if="$auth('design-design-forms-export')" type="primary" icon="download" @click="doExport">导出</a-button>
  32. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0 && $auth('design-design-forms-del')">
  33. <a-menu slot="overlay">
  34. <a-popconfirm title="是否要删除所选数据?" @confirm="batchDelete()">
  35. <a-menu-item key="1"><a-icon type="delete" /><a>删除</a></a-menu-item>
  36. </a-popconfirm>
  37. </a-menu>
  38. <a-button style="margin-left: 8px">
  39. 批量操作 <a-icon type="down" />
  40. </a-button>
  41. </a-dropdown>
  42. </a-col>
  43. </a-row>
  44. </div>
  45. <s-table
  46. ref="table"
  47. size="default"
  48. rowKey="id"
  49. :columns="columns"
  50. :data="loadData"
  51. :alert="options.alert"
  52. :rowSelection="options.rowSelection"
  53. showPagination="auto"
  54. >
  55. <span slot="action" slot-scope="record">
  56. <template>
  57. <a @click="handleView(record)">查看</a>
  58. <operation-button
  59. v-if="$auth('design-design-forms-edit')"
  60. @click="handleEdit(record)"
  61. >修改</operation-button>
  62. <operation-button
  63. v-if="$auth('design-design-forms-del')"
  64. :type="2"
  65. title="是否要删除该条数据?"
  66. @confirm="batchDelete(record.id)">删除</operation-button>
  67. </template>
  68. </span>
  69. </s-table>
  70. </div>
  71. <base-form ref="baseModal" @ok="handleOk"/>
  72. <detail ref="detailModal" @ok="handleOk"/>
  73. </a-card>
  74. </template>
  75. <script>
  76. import { STable, Ellipsis } from '@/components'
  77. import BaseForm from './modules/BaseForm'
  78. import Detail from './modules/Detail'
  79. import { getDesignFormPage, deleteDesignForms, fetchDesignForm, exportDesignForm } from '@/api/design/designForm'
  80. export default {
  81. name: 'DesignFormList',
  82. components: {
  83. STable,
  84. Ellipsis,
  85. BaseForm,
  86. Detail
  87. },
  88. data () {
  89. return {
  90. advanced: false,
  91. visible: true,
  92. // 查询参数
  93. queryParam: {
  94. },
  95. // 表头
  96. columns: [
  97. {
  98. title: '序号',
  99. dataIndex: 'index',
  100. customRender: (text, record, index) => {
  101. return `${(this.$refs.table.localPagination.current - 1) * this.$refs.table.localPagination.pageSize + index + 1}`
  102. }
  103. },
  104. {
  105. title: '表单代号',
  106. dataIndex: 'code'
  107. },
  108. {
  109. title: '表单名称',
  110. dataIndex: 'name'
  111. },
  112. {
  113. title: '表单类型。0:简单表单;1:复杂表单;',
  114. dataIndex: 'type'
  115. },
  116. {
  117. title: '表单主题。不配置默认为表单名称',
  118. dataIndex: 'theme'
  119. },
  120. {
  121. title: '表单设计数据。',
  122. dataIndex: 'designData'
  123. },
  124. {
  125. title: '表单js代码。仅当复杂表单才有',
  126. dataIndex: 'jsCode'
  127. },
  128. {
  129. title: '创建时间',
  130. dataIndex: 'createTime'
  131. },
  132. {
  133. title: '操作',
  134. key: 'action',
  135. width: '200px',
  136. align: 'center',
  137. scopedSlots: { customRender: 'action' }
  138. }
  139. ],
  140. // 下拉框map
  141. // 加载数据方法 必须为 Promise 对象
  142. loadData: parameter => {
  143. parameter = {
  144. ...parameter,
  145. ...this.queryParam,
  146. dataScope: {
  147. sortBy: 'desc',
  148. sortName: 'update_time'
  149. }
  150. }
  151. return getDesignFormPage(Object.assign(parameter, this.queryParam))
  152. .then(res => {
  153. return res.data
  154. })
  155. },
  156. selectedRowKeys: [],
  157. selectedRows: [],
  158. options: {
  159. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  160. rowSelection: {
  161. selectedRowKeys: this.selectedRowKeys,
  162. onChange: this.onSelectChange
  163. }
  164. },
  165. optionAlertShow: false
  166. }
  167. },
  168. created () {
  169. // 下拉框map
  170. this.tableOption()
  171. },
  172. methods: {
  173. tableOption () {
  174. if (!this.optionAlertShow) {
  175. this.options = {
  176. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  177. rowSelection: {
  178. selectedRowKeys: this.selectedRowKeys,
  179. onChange: this.onSelectChange,
  180. getCheckboxProps: record => ({
  181. props: {
  182. disabled: false,
  183. name: record.id
  184. }
  185. })
  186. }
  187. }
  188. this.optionAlertShow = true
  189. } else {
  190. this.options = {
  191. alert: false,
  192. rowSelection: null
  193. }
  194. this.optionAlertShow = false
  195. }
  196. },
  197. batchDelete (id) {
  198. let ids = []
  199. if (this.BaseTool.String.isBlank(id)) {
  200. const length = this.selectedRows.length
  201. if (length === 0) {
  202. this.$message.info('请选择要删除的记录')
  203. return
  204. }
  205. ids = this.selectedRows.map(item => item.id)
  206. } else {
  207. ids = [id]
  208. }
  209. deleteDesignForms(ids).then(res => {
  210. this.$message.info('删除成功')
  211. this.handleOk()
  212. this.$refs.table.clearSelected()
  213. })
  214. },
  215. handleAdd () {
  216. this.visible = false
  217. const modal = this.$refs.baseModal
  218. modal.base()
  219. },
  220. handleEdit (record) {
  221. this.visible = false
  222. fetchDesignForm({ id: record.id }).then(res => {
  223. const modal = this.$refs.baseModal
  224. modal.base(res.data)
  225. })
  226. },
  227. handleView (record) {
  228. this.visible = false
  229. fetchDesignForm({ id: record.id }).then(res => {
  230. const modal = this.$refs.detailModal
  231. modal.base(res.data)
  232. })
  233. },
  234. handleOk (values) {
  235. this.visible = true
  236. this.$refs.table.refresh()
  237. },
  238. onSelectChange (selectedRowKeys, selectedRows) {
  239. this.selectedRowKeys = selectedRowKeys
  240. this.selectedRows = selectedRows
  241. },
  242. resetSearchForm () {
  243. this.queryParam = {
  244. }
  245. this.$refs.table.refresh(true)
  246. },
  247. doExport () {
  248. const parameter = {
  249. ...this.queryParam
  250. }
  251. exportDesignForm(parameter).then(file => {
  252. this.BaseTool.Util.downLoadExportExcel(file)
  253. })
  254. },
  255. handleEnter () {
  256. this.$refs.table.refresh(true)
  257. }
  258. }
  259. }
  260. </script>