d4902e268de0e188d07e842b00c429bfa7a7834f.svn-base 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <a-card :bordered="false">
  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 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">查询</a-button>
  53. <a-button style="margin-left: 8px" @click="resetSearchForm">重置</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="() => this.handleModalVisible(true)">新建</a-button>
  65. <a-dropdown 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. <s-table
  77. ref="table"
  78. size="default"
  79. :columns="columns"
  80. :data="loadData"
  81. :showAlertInfo="true"
  82. @onSelect="onChange"
  83. >
  84. <span slot="action" slot-scope="text, record">
  85. <a @click="handleEdit(record)">编辑</a>
  86. <a-divider type="vertical" />
  87. <a-dropdown>
  88. <a class="ant-dropdown-link">
  89. 更多 <a-icon type="down" />
  90. </a>
  91. <a-menu slot="overlay">
  92. <a-menu-item>
  93. <a href="javascript:;">详情</a>
  94. </a-menu-item>
  95. <a-menu-item>
  96. <a href="javascript:;">禁用</a>
  97. </a-menu-item>
  98. <a-menu-item>
  99. <a href="javascript:;">删除</a>
  100. </a-menu-item>
  101. </a-menu>
  102. </a-dropdown>
  103. </span>
  104. </s-table>
  105. <a-modal
  106. title="操作"
  107. :width="800"
  108. v-model="visible"
  109. @ok="handleOk"
  110. >
  111. <a-form :autoFormCreate="(form)=>{this.form = form}">
  112. <a-form-item
  113. :labelCol="labelCol"
  114. :wrapperCol="wrapperCol"
  115. label="规则编号"
  116. hasFeedback
  117. validateStatus="success"
  118. >
  119. <a-input placeholder="规则编号" v-model="mdl.no" id="no" />
  120. </a-form-item>
  121. <a-form-item
  122. :labelCol="labelCol"
  123. :wrapperCol="wrapperCol"
  124. label="服务调用次数"
  125. hasFeedback
  126. validateStatus="success"
  127. >
  128. <a-input :min="1" id="callNo" v-model="mdl.callNo" style="width: 100%" />
  129. </a-form-item>
  130. <a-form-item
  131. :labelCol="labelCol"
  132. :wrapperCol="wrapperCol"
  133. label="状态"
  134. hasFeedback
  135. validateStatus="warning"
  136. >
  137. <a-select defaultValue="1" v-model="mdl.status">
  138. <a-select-option value="1">Option 1</a-select-option>
  139. <a-select-option value="2">Option 2</a-select-option>
  140. <a-select-option value="3">Option 3</a-select-option>
  141. </a-select>
  142. </a-form-item>
  143. <a-form-item
  144. :labelCol="labelCol"
  145. :wrapperCol="wrapperCol"
  146. label="描述"
  147. hasFeedback
  148. help="请填写一段描述"
  149. >
  150. <a-textarea :rows="5" v-model="mdl.description" placeholder="..." id="description"/>
  151. </a-form-item>
  152. <a-form-item
  153. :labelCol="labelCol"
  154. :wrapperCol="wrapperCol"
  155. label="更新时间"
  156. hasFeedback
  157. validateStatus="error"
  158. >
  159. <a-date-picker
  160. style="width: 100%"
  161. showTime
  162. format="YYYY-MM-DD HH:mm:ss"
  163. placeholder="Select Time"
  164. />
  165. </a-form-item>
  166. </a-form>
  167. </a-modal>
  168. <a-modal title="新建规则" destroyOnClose :visible="visibleCreateModal" @ok="handleCreateModalOk" @cancel="handleCreateModalCancel">
  169. <!---->
  170. <a-form style="margin-top: 8px" :autoFormCreate="(form)=>{this.createForm = form}">
  171. <a-form-item :labelCol="{ span: 5 }" :wrapperCol="{ span: 15 }" label="描述" fieldDecoratorId="description" :fieldDecoratorOptions="{rules: [{ required: true, message: '请输入至少五个字符的规则描述!', min: 5 }]}">
  172. <a-input placeholder="请输入" />
  173. </a-form-item>
  174. </a-form>
  175. </a-modal>
  176. </a-card>
  177. </template>
  178. <script>
  179. import STable from '@/components/table/'
  180. import ATextarea from "ant-design-vue/es/input/TextArea"
  181. import AInput from "ant-design-vue/es/input/Input"
  182. import moment from "moment"
  183. import axios from 'axios';
  184. import { getRoleList, getServiceList } from '@/api/manage'
  185. export default {
  186. name: "TableList",
  187. components: {
  188. AInput,
  189. ATextarea,
  190. STable
  191. },
  192. data () {
  193. return {
  194. visibleCreateModal:false,
  195. visible: false,
  196. labelCol: {
  197. xs: { span: 24 },
  198. sm: { span: 5 },
  199. },
  200. wrapperCol: {
  201. xs: { span: 24 },
  202. sm: { span: 12 },
  203. },
  204. form: null,
  205. mdl: {},
  206. // 高级搜索 展开/关闭
  207. advanced: true,
  208. // 查询参数
  209. queryParam: {},
  210. // 表头
  211. columns: [
  212. {
  213. title: '规则编号',
  214. dataIndex: 'no'
  215. },
  216. {
  217. title: '描述',
  218. dataIndex: 'description'
  219. },
  220. {
  221. title: '服务调用次数',
  222. dataIndex: 'callNo',
  223. sorter: true,
  224. needTotal: true,
  225. customRender: (text) => text + ' 次'
  226. },
  227. {
  228. title: '状态',
  229. dataIndex: 'status',
  230. needTotal: true
  231. },
  232. {
  233. title: '更新时间',
  234. dataIndex: 'updatedAt',
  235. sorter: true
  236. },
  237. {
  238. table: '操作',
  239. dataIndex: 'action',
  240. width: '150px',
  241. scopedSlots: { customRender: 'action' },
  242. }
  243. ],
  244. // 加载数据方法 必须为 Promise 对象
  245. loadData: parameter => {
  246. return getServiceList(Object.assign(parameter, this.queryParam))
  247. .then(res => {
  248. return res.result
  249. })
  250. },
  251. selectedRowKeys: [],
  252. selectedRows: []
  253. }
  254. },
  255. created () {
  256. getRoleList({ t: new Date()})
  257. },
  258. methods: {
  259. handleEdit (record) {
  260. this.mdl = Object.assign({}, record)
  261. console.log(this.mdl)
  262. this.visible = true
  263. },
  264. handleOk () {
  265. },
  266. //添加逻辑
  267. handleModalVisible(isVisible) {
  268. this.visibleCreateModal = isVisible;
  269. },
  270. handleCreateModalOk() {
  271. this.createForm.validateFields((err, fieldsValue) => {
  272. if (err) {
  273. return;
  274. }
  275. const description = this.createForm.getFieldValue('description');
  276. axios.post('/saveRule', {
  277. desc: description,
  278. }).then((res) => {
  279. this.createForm.resetFields();
  280. this.visibleCreateModal = false;
  281. this.loadRuleData();
  282. });
  283. });
  284. },
  285. handleCreateModalCancel() {
  286. this.visibleCreateModal = false;
  287. },
  288. onChange (row) {
  289. this.selectedRowKeys = row.selectedRowKeys
  290. this.selectedRows = row.selectedRows
  291. console.log(this.$refs.table)
  292. },
  293. toggleAdvanced () {
  294. this.advanced = !this.advanced
  295. },
  296. resetSearchForm () {
  297. this.queryParam = {
  298. date: moment(new Date())
  299. }
  300. }
  301. },
  302. watch: {
  303. /*
  304. 'selectedRows': function (selectedRows) {
  305. this.needTotalList = this.needTotalList.map(item => {
  306. return {
  307. ...item,
  308. total: selectedRows.reduce( (sum, val) => {
  309. return sum + val[item.dataIndex]
  310. }, 0)
  311. }
  312. })
  313. }
  314. */
  315. }
  316. }
  317. </script>