|
@@ -51,7 +51,7 @@
|
|
|
<a-col :md="!advanced && 8 || 24" :sm="24">
|
|
|
<span class="table-page-search-submitButtons" :style="advanced && { float: 'right', overflow: 'hidden' } || {} ">
|
|
|
<a-button type="primary" @click="$refs.table.refresh(true)">查询</a-button>
|
|
|
- <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
|
|
|
+ <a-button style="margin-left: 8px" @click="() => this.queryParam = {}">重置</a-button>
|
|
|
<a @click="toggleAdvanced" style="margin-left: 8px">
|
|
|
{{ advanced ? '收起' : '展开' }}
|
|
|
<a-icon :type="advanced ? 'up' : 'down'"/>
|
|
@@ -63,8 +63,7 @@
|
|
|
</div>
|
|
|
|
|
|
<div class="table-operator">
|
|
|
- <a-button type="primary" icon="plus" @click="$refs.createModal.add()">新建</a-button>
|
|
|
- <a-button type="dashed" @click="tableOption">{{ optionAlertShow && '关闭' || '开启' }} alert</a-button>
|
|
|
+ <a-button type="primary" icon="plus" @click="handleAdd">新建</a-button>
|
|
|
<a-dropdown v-action:edit v-if="selectedRowKeys.length > 0">
|
|
|
<a-menu slot="overlay">
|
|
|
<a-menu-item key="1"><a-icon type="delete" />删除</a-menu-item>
|
|
@@ -83,8 +82,8 @@
|
|
|
rowKey="key"
|
|
|
:columns="columns"
|
|
|
:data="loadData"
|
|
|
- :alert="options.alert"
|
|
|
- :rowSelection="options.rowSelection"
|
|
|
+ :alert="true"
|
|
|
+ :rowSelection="rowSelection"
|
|
|
showPagination="auto"
|
|
|
>
|
|
|
<span slot="serial" slot-scope="text, record, index">
|
|
@@ -105,7 +104,15 @@
|
|
|
</template>
|
|
|
</span>
|
|
|
</s-table>
|
|
|
- <create-form ref="createModal" @ok="handleOk" />
|
|
|
+
|
|
|
+ <create-form
|
|
|
+ ref="createModal"
|
|
|
+ :visible="visible"
|
|
|
+ :loading="confirmLoading"
|
|
|
+ :model="mdl"
|
|
|
+ @cancel="handleCancel"
|
|
|
+ @ok="handleOk"
|
|
|
+ />
|
|
|
<step-by-step-modal ref="modal" @ok="handleOk"/>
|
|
|
</a-card>
|
|
|
</page-header-wrapper>
|
|
@@ -114,9 +121,49 @@
|
|
|
<script>
|
|
|
import moment from 'moment'
|
|
|
import { STable, Ellipsis } from '@/components'
|
|
|
+import { getRoleList, getServiceList } from '@/api/manage'
|
|
|
+
|
|
|
import StepByStepModal from './modules/StepByStepModal'
|
|
|
import CreateForm from './modules/CreateForm'
|
|
|
-import { getRoleList, getServiceList } from '@/api/manage'
|
|
|
+
|
|
|
+const columns = [
|
|
|
+ {
|
|
|
+ title: '#',
|
|
|
+ scopedSlots: { customRender: 'serial' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '规则编号',
|
|
|
+ dataIndex: 'no'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '描述',
|
|
|
+ dataIndex: 'description',
|
|
|
+ scopedSlots: { customRender: 'description' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '服务调用次数',
|
|
|
+ dataIndex: 'callNo',
|
|
|
+ sorter: true,
|
|
|
+ needTotal: true,
|
|
|
+ customRender: (text) => text + ' 次'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '状态',
|
|
|
+ dataIndex: 'status',
|
|
|
+ scopedSlots: { customRender: 'status' }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '更新时间',
|
|
|
+ dataIndex: 'updatedAt',
|
|
|
+ sorter: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'action',
|
|
|
+ width: '150px',
|
|
|
+ scopedSlots: { customRender: 'action' }
|
|
|
+ }
|
|
|
+]
|
|
|
|
|
|
const statusMap = {
|
|
|
0: {
|
|
@@ -146,71 +193,27 @@ export default {
|
|
|
StepByStepModal
|
|
|
},
|
|
|
data () {
|
|
|
+ this.columns = columns
|
|
|
return {
|
|
|
- mdl: {},
|
|
|
+ // create model
|
|
|
+ visible: false,
|
|
|
+ confirmLoading: false,
|
|
|
+ mdl: null,
|
|
|
// 高级搜索 展开/关闭
|
|
|
advanced: false,
|
|
|
// 查询参数
|
|
|
queryParam: {},
|
|
|
- // 表头
|
|
|
- columns: [
|
|
|
- {
|
|
|
- title: '#',
|
|
|
- scopedSlots: { customRender: 'serial' }
|
|
|
- },
|
|
|
- {
|
|
|
- title: '规则编号',
|
|
|
- dataIndex: 'no'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '描述',
|
|
|
- dataIndex: 'description',
|
|
|
- scopedSlots: { customRender: 'description' }
|
|
|
- },
|
|
|
- {
|
|
|
- title: '服务调用次数',
|
|
|
- dataIndex: 'callNo',
|
|
|
- sorter: true,
|
|
|
- needTotal: true,
|
|
|
- customRender: (text) => text + ' 次'
|
|
|
- },
|
|
|
- {
|
|
|
- title: '状态',
|
|
|
- dataIndex: 'status',
|
|
|
- scopedSlots: { customRender: 'status' }
|
|
|
- },
|
|
|
- {
|
|
|
- title: '更新时间',
|
|
|
- dataIndex: 'updatedAt',
|
|
|
- sorter: true
|
|
|
- },
|
|
|
- {
|
|
|
- title: '操作',
|
|
|
- dataIndex: 'action',
|
|
|
- width: '150px',
|
|
|
- scopedSlots: { customRender: 'action' }
|
|
|
- }
|
|
|
- ],
|
|
|
// 加载数据方法 必须为 Promise 对象
|
|
|
loadData: parameter => {
|
|
|
- console.log('loadData.parameter', parameter)
|
|
|
- return getServiceList(Object.assign(parameter, this.queryParam))
|
|
|
+ const requestParameters = Object.assign({}, parameter, this.queryParam)
|
|
|
+ console.log('loadData request parameters:', requestParameters)
|
|
|
+ return getServiceList(requestParameters)
|
|
|
.then(res => {
|
|
|
return res.result
|
|
|
})
|
|
|
},
|
|
|
selectedRowKeys: [],
|
|
|
- selectedRows: [],
|
|
|
-
|
|
|
- // custom table alert & rowSelection
|
|
|
- options: {
|
|
|
- alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
|
|
|
- rowSelection: {
|
|
|
- selectedRowKeys: this.selectedRowKeys,
|
|
|
- onChange: this.onSelectChange
|
|
|
- }
|
|
|
- },
|
|
|
- optionAlertShow: false
|
|
|
+ selectedRows: []
|
|
|
}
|
|
|
},
|
|
|
filters: {
|
|
@@ -222,38 +225,74 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
created () {
|
|
|
- this.tableOption()
|
|
|
getRoleList({ t: new Date() })
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ rowSelection () {
|
|
|
+ return {
|
|
|
+ selectedRowKeys: this.selectedRowKeys,
|
|
|
+ onChange: this.onSelectChange
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
- tableOption () {
|
|
|
- if (!this.optionAlertShow) {
|
|
|
- this.options = {
|
|
|
- alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
|
|
|
- rowSelection: {
|
|
|
- selectedRowKeys: this.selectedRowKeys,
|
|
|
- onChange: this.onSelectChange,
|
|
|
- getCheckboxProps: record => ({
|
|
|
- props: {
|
|
|
- disabled: record.no === 'No 2', // Column configuration not to be checked
|
|
|
- name: record.no
|
|
|
- }
|
|
|
+ handleAdd () {
|
|
|
+ this.mdl = null
|
|
|
+ this.visible = true
|
|
|
+ },
|
|
|
+ handleEdit (record) {
|
|
|
+ this.visible = true
|
|
|
+ this.mdl = { ...record }
|
|
|
+ },
|
|
|
+ handleOk () {
|
|
|
+ const form = this.$refs.createModal.form
|
|
|
+ this.confirmLoading = true
|
|
|
+ form.validateFields((errors, values) => {
|
|
|
+ if (!errors) {
|
|
|
+ console.log('values', values)
|
|
|
+ if (values.id > 0) {
|
|
|
+ // 修改 e.g.
|
|
|
+ new Promise((resolve, reject) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ resolve()
|
|
|
+ }, 1000)
|
|
|
+ }).then(res => {
|
|
|
+ this.visible = false
|
|
|
+ this.confirmLoading = false
|
|
|
+ // 重置表单数据
|
|
|
+ form.resetFields()
|
|
|
+ // 刷新表格
|
|
|
+ this.$refs.table.refresh()
|
|
|
+
|
|
|
+ this.$message.info('修改成功')
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 新增
|
|
|
+ new Promise((resolve, reject) => {
|
|
|
+ setTimeout(() => {
|
|
|
+ resolve()
|
|
|
+ }, 1000)
|
|
|
+ }).then(res => {
|
|
|
+ this.visible = false
|
|
|
+ this.confirmLoading = false
|
|
|
+ // 重置表单数据
|
|
|
+ form.resetFields()
|
|
|
+ // 刷新表格
|
|
|
+ this.$refs.table.refresh()
|
|
|
+
|
|
|
+ this.$message.info('新增成功')
|
|
|
})
|
|
|
}
|
|
|
+ } else {
|
|
|
+ this.confirmLoading = false
|
|
|
}
|
|
|
- this.optionAlertShow = true
|
|
|
- } else {
|
|
|
- this.options = {
|
|
|
- alert: false,
|
|
|
- rowSelection: null
|
|
|
- }
|
|
|
- this.optionAlertShow = false
|
|
|
- }
|
|
|
+ })
|
|
|
},
|
|
|
+ handleCancel () {
|
|
|
+ this.visible = false
|
|
|
|
|
|
- handleEdit (record) {
|
|
|
- console.log(record)
|
|
|
- this.$refs.modal.edit(record)
|
|
|
+ const form = this.$refs.createModal.form
|
|
|
+ form.resetFields() // 清理表单数据(可不做)
|
|
|
},
|
|
|
handleSub (record) {
|
|
|
if (record.status !== 0) {
|
|
@@ -262,9 +301,6 @@ export default {
|
|
|
this.$message.error(`${record.no} 订阅失败,规则已关闭`)
|
|
|
}
|
|
|
},
|
|
|
- handleOk () {
|
|
|
- this.$refs.table.refresh()
|
|
|
- },
|
|
|
onSelectChange (selectedRowKeys, selectedRows) {
|
|
|
this.selectedRowKeys = selectedRowKeys
|
|
|
this.selectedRows = selectedRows
|