|
@@ -11,19 +11,18 @@
|
|
|
添加
|
|
|
</a-button>
|
|
|
</template>
|
|
|
- <template #action="{ record, column }">
|
|
|
- <TableAction :actions="createActions(record, column)" />
|
|
|
+ <template #action="{ record }">
|
|
|
+ <TableAction :actions="createActions(record)" />
|
|
|
</template>
|
|
|
- <!-- <template #form-custom > custom-slot </template> -->
|
|
|
</BasicTable>
|
|
|
- <Add @register="addRegister" :modelData = "modelData" @saveData="saveData" />
|
|
|
+ <Popup @register="addRegister" :modelData="modelData" @saveData="saveData" />
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { defineComponent, reactive, ref, unref } from 'vue';
|
|
|
- import Add from './add.vue'
|
|
|
+ import Popup from './popup.vue'
|
|
|
import { useModal } from '/@/components/Modal';
|
|
|
- import { getAllMenuList } from '/@/api/sys/menu';
|
|
|
+// import { getAllMenuList } from '/@/api/sys/menu';
|
|
|
import { h } from 'vue';
|
|
|
import { Tag } from 'ant-design-vue';
|
|
|
import { getUserList, addUser, editUser,deleteUser } from '/@/api/sys/user';
|
|
@@ -61,11 +60,6 @@
|
|
|
dataIndex: 'email',
|
|
|
width: 170,
|
|
|
},
|
|
|
- // {
|
|
|
- // title: '所属组别',
|
|
|
- // dataIndex: 'password',
|
|
|
- // width: 160,
|
|
|
- // },
|
|
|
{
|
|
|
title: '状态',
|
|
|
dataIndex: 'status',
|
|
@@ -80,22 +74,37 @@
|
|
|
},
|
|
|
{
|
|
|
title: '最后登录',
|
|
|
- dataIndex: 'detail',
|
|
|
+ dataIndex: 'time',
|
|
|
width: 150,
|
|
|
}
|
|
|
];
|
|
|
+ const formData = [
|
|
|
+ {
|
|
|
+ id: 1,
|
|
|
+ username: 'test1',
|
|
|
+ nickname: '用户1',
|
|
|
+ email: 'test1@163.com',
|
|
|
+ status: 0,
|
|
|
+ time: '2020-10-20'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: 2,
|
|
|
+ username: 'test2',
|
|
|
+ nickname: '用户2',
|
|
|
+ email: 'test2@163.com',
|
|
|
+ status: 1,
|
|
|
+ time: '2020-10-20'
|
|
|
+ },
|
|
|
+ ]
|
|
|
|
|
|
export default defineComponent({
|
|
|
- components: { BasicTable, TableAction, Add },
|
|
|
+ components: { BasicTable, TableAction, Popup },
|
|
|
setup() {
|
|
|
const tableRef = ref<Nullable<TableActionType>>(null);
|
|
|
const currentEditKeyRef = ref('');
|
|
|
const modelData = reactive({
|
|
|
title: '添加',
|
|
|
treeData: [],
|
|
|
- checkedKeys: [],
|
|
|
- selectedKeys: [],
|
|
|
- expandedKeys: []
|
|
|
})
|
|
|
getTreeData()
|
|
|
const [registerTable] = useTable({
|
|
@@ -104,7 +113,8 @@
|
|
|
rowSelection: { type: 'checkbox' },
|
|
|
columns: columns,
|
|
|
clickToRowSelect: false, // 点击行不勾选
|
|
|
- api: getUserList,
|
|
|
+ // api: getUserList,
|
|
|
+ dataSource: formData,
|
|
|
actionColumn: {
|
|
|
width: 160,
|
|
|
title: '操作',
|
|
@@ -134,22 +144,17 @@
|
|
|
|
|
|
function addRole() {
|
|
|
modelData.title = '添加'
|
|
|
- modelData.checkedKeys = []
|
|
|
- modelData.selectedKeys = []
|
|
|
- modelData.expandedKeys = []
|
|
|
openAdd(true, {
|
|
|
+ id: null,
|
|
|
username: '',
|
|
|
- detail: '',
|
|
|
- menus: [],
|
|
|
- roleName: '',
|
|
|
nickname: '',
|
|
|
- status: true
|
|
|
+ email: '',
|
|
|
+ status: 1
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function handleEdit(record: EditRecordRow) {
|
|
|
currentEditKeyRef.value = record.id; // record.key
|
|
|
- console.log(record)
|
|
|
modelData.title = '编辑'
|
|
|
|
|
|
const data = getTableAction().getDataSource()
|
|
@@ -158,9 +163,6 @@
|
|
|
record = item
|
|
|
}
|
|
|
})
|
|
|
- modelData.checkedKeys = record.menus
|
|
|
- modelData.selectedKeys = []
|
|
|
- modelData.expandedKeys = []
|
|
|
openAdd(true, record);
|
|
|
}
|
|
|
|
|
@@ -195,38 +197,15 @@
|
|
|
console.log('----------edit---')
|
|
|
|
|
|
}
|
|
|
- // if (modelData.title === "添加") {
|
|
|
- // datas.map(item => {
|
|
|
- // if (info.id === 0 || info.id === item.id) {
|
|
|
- // info.id = item.id + 1
|
|
|
- // }
|
|
|
- // })
|
|
|
- // datas.push(info)
|
|
|
- // getTableAction().setTableData(datas)
|
|
|
- // } else {
|
|
|
- // console.log('编辑')
|
|
|
- // // getTableAction().setTableData(datas.filter(item => item.id !== info.id))
|
|
|
- // let dataArr:object[] = []
|
|
|
- // datas.map(item => {
|
|
|
- // if (item.id === info.id) {
|
|
|
- // item = info
|
|
|
- // }
|
|
|
- // dataArr.push(item)
|
|
|
- // })
|
|
|
- // getTableAction().setTableData(dataArr)
|
|
|
- // }
|
|
|
}
|
|
|
async function getTreeData() {
|
|
|
- let treeData = await getAllMenuList() as any
|
|
|
- modelData.treeData = JSON.parse(JSON.stringify(treeData).replace(/menuName/g,"title").replace(/id/g,"key"))
|
|
|
+ // let treeData = await getAllMenuList()
|
|
|
+ // modelData.treeData = JSON.parse(JSON.stringify(treeData).replace(/menuName/g,"title").replace(/id/g,"key"))
|
|
|
|
|
|
console.log(modelData.treeData)
|
|
|
}
|
|
|
|
|
|
- function createActions(record: EditRecordRow, column: BasicColumn): ActionItem[] {
|
|
|
- if (false) {
|
|
|
- console.log(column)
|
|
|
- }
|
|
|
+ function createActions(record: EditRecordRow,): ActionItem[] {
|
|
|
return [
|
|
|
{
|
|
|
label: '编辑',
|