List.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div>
  3. <div class="table-page-search-wrapper">
  4. <a-form layout="inline">
  5. <a-row :gutter="48">
  6. <a-col :md="8" :sm="24">
  7. <a-form-item label="规则编号">
  8. <a-input v-model="queryParam.id" placeholder=""/>
  9. </a-form-item>
  10. </a-col>
  11. <a-col :md="8" :sm="24">
  12. <a-form-item label="使用状态">
  13. <a-select v-model="queryParam.status" placeholder="请选择" default-value="0">
  14. <a-select-option value="0">全部</a-select-option>
  15. <a-select-option value="1">关闭</a-select-option>
  16. <a-select-option value="2">运行中</a-select-option>
  17. </a-select>
  18. </a-form-item>
  19. </a-col>
  20. <template v-if="advanced">
  21. <a-col :md="8" :sm="24">
  22. <a-form-item label="调用次数">
  23. <a-input-number v-model="queryParam.callNo" style="width: 100%"/>
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="8" :sm="24">
  27. <a-form-item label="更新日期">
  28. <a-date-picker v-model="queryParam.date" style="width: 100%" placeholder="请输入更新日期"/>
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md="8" :sm="24">
  32. <a-form-item label="使用状态">
  33. <a-select v-model="queryParam.useStatus" placeholder="请选择" default-value="0">
  34. <a-select-option value="0">全部</a-select-option>
  35. <a-select-option value="1">关闭</a-select-option>
  36. <a-select-option value="2">运行中</a-select-option>
  37. </a-select>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :md="8" :sm="24">
  41. <a-form-item label="使用状态">
  42. <a-select placeholder="请选择" default-value="0">
  43. <a-select-option value="0">全部</a-select-option>
  44. <a-select-option value="1">关闭</a-select-option>
  45. <a-select-option value="2">运行中</a-select-option>
  46. </a-select>
  47. </a-form-item>
  48. </a-col>
  49. </template>
  50. <a-col :md="!advanced && 8 || 24" :sm="24">
  51. <span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
  52. <a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  53. <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
  54. <a @click="toggleAdvanced" style="margin-left: 8px">
  55. {{ advanced ? '收起' : '展开' }}
  56. <a-icon :type="advanced ? 'up' : 'down'"/>
  57. </a>
  58. </span>
  59. </a-col>
  60. </a-row>
  61. </a-form>
  62. </div>
  63. <div class="table-operator">
  64. <a-button type="primary" icon="plus" @click="handleEdit(record)">新建</a-button>
  65. <a-button type="dashed" @click="tableOption">{{ optionAlertShow && '关闭' || '开启' }} alert</a-button>
  66. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0">
  67. <a-menu slot="overlay">
  68. <a-menu-item key="1"><a-icon type="delete" />删除</a-menu-item>
  69. <!-- lock | unlock -->
  70. <a-menu-item key="2"><a-icon type="lock" />锁定</a-menu-item>
  71. </a-menu>
  72. <a-button style="margin-left: 8px">
  73. 批量操作 <a-icon type="down" />
  74. </a-button>
  75. </a-dropdown>
  76. </div>
  77. <s-table
  78. ref="table"
  79. size="default"
  80. rowKey="key"
  81. :columns="columns"
  82. :data="loadData"
  83. :alert="options.alert"
  84. :rowSelection="options.rowSelection"
  85. >
  86. <span slot="serial" slot-scope="text, record, index">
  87. {{ index + 1 }}
  88. </span>
  89. <span slot="action" slot-scope="text, record">
  90. <template>
  91. <a @click="handleEdit(record)">编辑</a>
  92. <a-divider type="vertical" />
  93. </template>
  94. <a-dropdown>
  95. <a class="ant-dropdown-link">
  96. 更多 <a-icon type="down" />
  97. </a>
  98. <a-menu slot="overlay">
  99. <a-menu-item>
  100. <a href="javascript:;">详情</a>
  101. </a-menu-item>
  102. <a-menu-item v-if="$auth('table.disable')">
  103. <a href="javascript:;">禁用</a>
  104. </a-menu-item>
  105. <a-menu-item v-if="$auth('table.delete')">
  106. <a href="javascript:;">删除</a>
  107. </a-menu-item>
  108. </a-menu>
  109. </a-dropdown>
  110. </span>
  111. </s-table>
  112. </div>
  113. </template>
  114. <script>
  115. import moment from 'moment'
  116. import STable from '@/components/table/'
  117. import { getRoleList, getServiceList } from '@/api/manage'
  118. export default {
  119. name: 'TableList',
  120. components: {
  121. STable
  122. },
  123. data () {
  124. return {
  125. mdl: {},
  126. // 高级搜索 展开/关闭
  127. advanced: false,
  128. // 查询参数
  129. queryParam: {},
  130. // 表头
  131. columns: [
  132. {
  133. title: '#',
  134. scopedSlots: { customRender: 'serial' }
  135. },
  136. {
  137. title: '规则编号',
  138. dataIndex: 'no'
  139. },
  140. {
  141. title: '描述',
  142. dataIndex: 'description'
  143. },
  144. {
  145. title: '服务调用次数',
  146. dataIndex: 'callNo',
  147. sorter: true,
  148. needTotal: true,
  149. customRender: (text) => text + ' 次'
  150. },
  151. {
  152. title: '状态',
  153. dataIndex: 'status',
  154. needTotal: true
  155. },
  156. {
  157. title: '更新时间',
  158. dataIndex: 'updatedAt',
  159. sorter: true
  160. },
  161. {
  162. table: '操作',
  163. dataIndex: 'action',
  164. width: '150px',
  165. scopedSlots: { customRender: 'action' }
  166. }
  167. ],
  168. // 加载数据方法 必须为 Promise 对象
  169. loadData: parameter => {
  170. console.log('loadData.parameter', parameter)
  171. return getServiceList(Object.assign(parameter, this.queryParam))
  172. .then(res => {
  173. return res.result
  174. })
  175. },
  176. selectedRowKeys: [],
  177. selectedRows: [],
  178. // custom table alert & rowSelection
  179. options: {
  180. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  181. rowSelection: {
  182. selectedRowKeys: this.selectedRowKeys,
  183. onChange: this.onSelectChange
  184. }
  185. },
  186. optionAlertShow: false
  187. }
  188. },
  189. created () {
  190. this.tableOption()
  191. getRoleList({ t: new Date() })
  192. },
  193. methods: {
  194. tableOption () {
  195. if (!this.optionAlertShow) {
  196. this.options = {
  197. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  198. rowSelection: {
  199. selectedRowKeys: this.selectedRowKeys,
  200. onChange: this.onSelectChange
  201. }
  202. }
  203. this.optionAlertShow = true
  204. } else {
  205. this.options = {
  206. alert: false,
  207. rowSelection: null
  208. }
  209. this.optionAlertShow = false
  210. }
  211. },
  212. handleEdit (record) {
  213. this.$emit('onEdit', record)
  214. },
  215. handleOk () {
  216. },
  217. onSelectChange (selectedRowKeys, selectedRows) {
  218. this.selectedRowKeys = selectedRowKeys
  219. this.selectedRows = selectedRows
  220. },
  221. toggleAdvanced () {
  222. this.advanced = !this.advanced
  223. },
  224. resetSearchForm () {
  225. this.queryParam = {
  226. date: moment(new Date())
  227. }
  228. }
  229. }
  230. }
  231. </script>