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="$router.push({ name: 'QueryListEdit' })">新建</a-button>
  65. <a-dropdown v-action:edit v-if="selectedRowKeys.length > 0">
  66. <a-menu slot="overlay">
  67. <a-menu-item key="1"><a-icon type="delete" />删除</a-menu-item>
  68. <!-- lock | unlock -->
  69. <a-menu-item key="2"><a-icon type="lock" />锁定</a-menu-item>
  70. </a-menu>
  71. <a-button style="margin-left: 8px">
  72. 批量操作 <a-icon type="down" />
  73. </a-button>
  74. </a-dropdown>
  75. </div>
  76. <div>
  77. <a-button @click="tableOption(false)" v-if="optionAlertShow">关闭 alert</a-button>
  78. </div>
  79. <s-table
  80. ref="table"
  81. size="default"
  82. :columns="columns"
  83. :data="loadData"
  84. :alert="options.alert"
  85. :rowSelection="options.rowSelection"
  86. >
  87. <span slot="serial" slot-scope="text, record, index">
  88. {{ index + 1 }}
  89. </span>
  90. <span slot="action" slot-scope="text, record">
  91. <template>
  92. <a @click="handleEdit(record)">编辑</a>
  93. <a-divider type="vertical" />
  94. </template>
  95. <a-dropdown>
  96. <a class="ant-dropdown-link">
  97. 更多 <a-icon type="down" />
  98. </a>
  99. <a-menu slot="overlay">
  100. <a-menu-item>
  101. <a href="javascript:;">详情</a>
  102. </a-menu-item>
  103. <a-menu-item v-if="$auth('table.disable')">
  104. <a href="javascript:;">禁用</a>
  105. </a-menu-item>
  106. <a-menu-item v-if="$auth('table.delete')">
  107. <a href="javascript:;">删除</a>
  108. </a-menu-item>
  109. </a-menu>
  110. </a-dropdown>
  111. </span>
  112. </s-table>
  113. </div>
  114. </template>
  115. <script>
  116. import moment from 'moment'
  117. import STable from '@/components/table/'
  118. import { getRoleList, getServiceList } from '@/api/manage'
  119. export default {
  120. name: 'TableList',
  121. components: {
  122. STable
  123. },
  124. data () {
  125. return {
  126. mdl: {},
  127. // 高级搜索 展开/关闭
  128. advanced: false,
  129. // 查询参数
  130. queryParam: {},
  131. // 表头
  132. columns: [
  133. {
  134. title: '#',
  135. scopedSlots: { customRender: 'serial' }
  136. },
  137. {
  138. title: '规则编号',
  139. dataIndex: 'no'
  140. },
  141. {
  142. title: '描述',
  143. dataIndex: 'description'
  144. },
  145. {
  146. title: '服务调用次数',
  147. dataIndex: 'callNo',
  148. sorter: true,
  149. needTotal: true,
  150. customRender: (text) => text + ' 次'
  151. },
  152. {
  153. title: '状态',
  154. dataIndex: 'status',
  155. needTotal: true
  156. },
  157. {
  158. title: '更新时间',
  159. dataIndex: 'updatedAt',
  160. sorter: true
  161. },
  162. {
  163. table: '操作',
  164. dataIndex: 'action',
  165. width: '150px',
  166. scopedSlots: { customRender: 'action' }
  167. }
  168. ],
  169. // 加载数据方法 必须为 Promise 对象
  170. loadData: 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: true
  187. }
  188. },
  189. created () {
  190. this.tableOption(true)
  191. getRoleList({ t: new Date() })
  192. },
  193. methods: {
  194. tableOption (bool) {
  195. if (bool) {
  196. this.options = {
  197. alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
  198. rowSelection: {
  199. selectedRowKeys: this.selectedRowKeys,
  200. onChange: this.onSelectChange
  201. }
  202. }
  203. } else {
  204. this.options = {
  205. alert: false,
  206. rowSelection: null
  207. }
  208. this.optionAlertShow = false
  209. }
  210. },
  211. handleEdit (record) {
  212. // Object.assign({}, record)
  213. this.$router.push({ name: 'QueryListEdit', params: { id: record.no } })
  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>