61 lines
1.8 KiB
Vue
61 lines
1.8 KiB
Vue
<template>
|
|
<div>
|
|
<cb-advance-table ref="tableRef" title="属性列表" :search-configs="searchConfigs" :data="list" :params="params" :columns="columns" :get-list="getList" :total="total" :loading="loading">
|
|
<template #action>
|
|
<el-button type="primary" @click="handleCreate()" icon="el-icon-plus">新增</el-button>
|
|
</template>
|
|
<template #operate="val, record">
|
|
<el-button type="text" @click="handleCreate(record)"><i class="el-icon-edit"></i> 编辑</el-button>
|
|
<div class="action-divider"></div>
|
|
<el-button type="text" @click="handleDelete(record)"><i class="el-icon-delete"></i> 删除</el-button>
|
|
</template>
|
|
</cb-advance-table>
|
|
<AddDialog :dialog="addDialog" v-if="addDialog.visible" @getData="getList"></AddDialog>
|
|
</div>
|
|
</template>
|
|
<script lang="ts">
|
|
import { getPool, removePool } from 'services/pool'
|
|
import { defineComponent, reactive, toRefs, ref } from 'vue'
|
|
import AddDialog from './AddDialog.vue'
|
|
import { columns, searchConfigs } from './config'
|
|
import { useTable } from '@cmp/cmp-element'
|
|
|
|
export default defineComponent({
|
|
components: { AddDialog },
|
|
setup() {
|
|
const { list, total, params, handleDelete, loading, getList } = useTable({
|
|
getService: getPool,
|
|
removeService: removePool,
|
|
})
|
|
// 创建
|
|
const addDialog = reactive<{
|
|
visible: boolean
|
|
record: any
|
|
}>({
|
|
visible: false,
|
|
record: {},
|
|
})
|
|
const handleCreate = (data: any = {}) => {
|
|
addDialog.visible = true
|
|
addDialog.record = {
|
|
type: 'TEXTFIELD',
|
|
...data,
|
|
}
|
|
}
|
|
return {
|
|
columns,
|
|
searchConfigs,
|
|
loading,
|
|
list,
|
|
total,
|
|
params,
|
|
handleDelete,
|
|
...toRefs(addDialog),
|
|
getList,
|
|
addDialog,
|
|
handleCreate,
|
|
}
|
|
},
|
|
})
|
|
</script>
|