|
@@ -1,40 +1,29 @@
|
|
<template>
|
|
<template>
|
|
<div class="p-4">
|
|
<div class="p-4">
|
|
- <BasicTable
|
|
|
|
- ref="tableRef"
|
|
|
|
- @register="registerTable"
|
|
|
|
- :bordered="true"
|
|
|
|
- rowKey="id"
|
|
|
|
- >
|
|
|
|
|
|
+ <BasicTable ref="tableRef" @register="registerTable" :bordered="true" rowKey="id">
|
|
<template #action="{ record, column }">
|
|
<template #action="{ record, column }">
|
|
<TableAction :actions="createActions(record, column)" />
|
|
<TableAction :actions="createActions(record, column)" />
|
|
</template>
|
|
</template>
|
|
- <!-- <template #action="{ record, column }">
|
|
|
|
- </template> -->
|
|
|
|
- <template #form-custom > custom-slot </template>
|
|
|
|
|
|
+ <template #form-custom> custom-slot </template>
|
|
|
|
|
|
<template #toolbar>
|
|
<template #toolbar>
|
|
<Upload>
|
|
<Upload>
|
|
- <!-- action="http://localhost:8000/api/upload/" -->
|
|
|
|
- <!-- method="POST" -->
|
|
|
|
- <!-- :showUploadList="false" -->
|
|
|
|
- <!-- class="upload-modal-toolbar__btn" -->
|
|
|
|
- <a-button type="primary">
|
|
|
|
- t('component.upload.uploadBtn')
|
|
|
|
- </a-button>
|
|
|
|
- </Upload>
|
|
|
|
|
|
+ <a-button type="primary"> t('component.upload.upload') </a-button>
|
|
|
|
+ </Upload>
|
|
</template>
|
|
</template>
|
|
</BasicTable>
|
|
</BasicTable>
|
|
- <!-- <Model @register="addRegister" :modelData="modelData" /> -->
|
|
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
import { defineComponent, reactive, ref, unref } from 'vue';
|
|
import { defineComponent, reactive, ref, unref } from 'vue';
|
|
import { useModal } from '/@/components/Modal';
|
|
import { useModal } from '/@/components/Modal';
|
|
- // import { createTableColumns, createPreviewActionColumn } from '/@/components/myData/imageData';
|
|
|
|
|
|
+ import {
|
|
|
|
+ createTableColumns,
|
|
|
|
+ createPreviewActionColumn,
|
|
|
|
+ } from '/@/components/customComponents/imageData';
|
|
|
|
+ import { createImgPreview } from '/@/components/Preview/index';
|
|
import { FileItem } from '/@/components/Upload/src/types';
|
|
import { FileItem } from '/@/components/Upload/src/types';
|
|
- // import { Upload, Alert } from 'ant-design-vue';
|
|
|
|
- // import Upload from '/@/components/myData/upload.vue'
|
|
|
|
|
|
+ import Upload from '/@/components/customComponents/upload.vue';
|
|
import {
|
|
import {
|
|
BasicTable,
|
|
BasicTable,
|
|
useTable,
|
|
useTable,
|
|
@@ -45,79 +34,56 @@
|
|
TableActionType,
|
|
TableActionType,
|
|
} from '/@/components/Table';
|
|
} from '/@/components/Table';
|
|
|
|
|
|
-
|
|
|
|
- // const columns: BasicColumn[] = [
|
|
|
|
- // {
|
|
|
|
- // title: 'id',
|
|
|
|
- // dataIndex: 'id',
|
|
|
|
- // editRow: true,
|
|
|
|
- // // 默认必填校验
|
|
|
|
- // editRule: true,
|
|
|
|
- // width: 200,
|
|
|
|
- // },
|
|
|
|
- // {
|
|
|
|
- // title: '姓名',
|
|
|
|
- // dataIndex: 'name',
|
|
|
|
- // edit: true, // 点击修改当前单元格
|
|
|
|
- // editComponentProps: {
|
|
|
|
- // prefix: '$',
|
|
|
|
- // },
|
|
|
|
- // width: 200,
|
|
|
|
- // },
|
|
|
|
- // {
|
|
|
|
- // title: '地址',
|
|
|
|
- // dataIndex: 'addr',
|
|
|
|
- // editRow: true,
|
|
|
|
- // width: 200,
|
|
|
|
- // },
|
|
|
|
- // {
|
|
|
|
- // title: '年龄',
|
|
|
|
- // dataIndex: 'age',
|
|
|
|
- // editRow: true,
|
|
|
|
- // width: 200,
|
|
|
|
- // },
|
|
|
|
- // {
|
|
|
|
- // title: '开关',
|
|
|
|
- // dataIndex: 'name6',
|
|
|
|
- // editRow: true,
|
|
|
|
- // editComponent: 'Switch',
|
|
|
|
- // editValueMap: (value) => {
|
|
|
|
- // return value ? '开' : '关';
|
|
|
|
- // },
|
|
|
|
- // width: 200,
|
|
|
|
- // },
|
|
|
|
- // ];
|
|
|
|
-
|
|
|
|
interface ModelData {
|
|
interface ModelData {
|
|
- title: string,
|
|
|
|
|
|
+ title: string;
|
|
}
|
|
}
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
components: { BasicTable, TableAction, Upload },
|
|
components: { BasicTable, TableAction, Upload },
|
|
setup() {
|
|
setup() {
|
|
- const modelData = reactive<ModelData>({
|
|
|
|
|
|
+ const modelData = reactive<ModelData>({
|
|
title: '',
|
|
title: '',
|
|
- })
|
|
|
|
|
|
+ });
|
|
const tableRef = ref<Nullable<TableActionType>>(null);
|
|
const tableRef = ref<Nullable<TableActionType>>(null);
|
|
const currentEditKeyRef = ref('');
|
|
const currentEditKeyRef = ref('');
|
|
const [registerTable] = useTable({
|
|
const [registerTable] = useTable({
|
|
- title: "基础示例",
|
|
|
|
- titleHelpMessage: "温馨提醒",
|
|
|
|
|
|
+ title: '基础示例',
|
|
|
|
+ titleHelpMessage: '温馨提醒',
|
|
rowSelection: { type: 'checkbox' },
|
|
rowSelection: { type: 'checkbox' },
|
|
columns: createTableColumns(),
|
|
columns: createTableColumns(),
|
|
clickToRowSelect: false, // 点击行不勾选
|
|
clickToRowSelect: false, // 点击行不勾选
|
|
- // showTableSetting: true,
|
|
|
|
- // columns: [{title:'Id',dataIndex:'id',width:150},{title:'姓名',dataIndex:'name',width:200},{title:'地址',dataIndex:'addr',width:250}],
|
|
|
|
- dataSource: [{id:1,name:'图片1',thumbUrl:'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1999921673,816131569&fm=26&gp=0.jpg', size: 205},
|
|
|
|
- {id:2,thumbUrl:'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2496571732,442429806&fm=26&gp=0.jpg',name:'图片2', size: 342},{id:3,name:'图片3',thumbUrl:'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg', size: 18}],
|
|
|
|
|
|
+ dataSource: [
|
|
|
|
+ {
|
|
|
|
+ id: 1,
|
|
|
|
+ name: '图片1',
|
|
|
|
+ thumbUrl:
|
|
|
|
+ 'https://dss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=1999921673,816131569&fm=26&gp=0.jpg',
|
|
|
|
+ size: 205,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ id: 2,
|
|
|
|
+ thumbUrl:
|
|
|
|
+ 'https://dss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=2496571732,442429806&fm=26&gp=0.jpg',
|
|
|
|
+ name: '图片2',
|
|
|
|
+ size: 342,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ id: 3,
|
|
|
|
+ name: '图片3',
|
|
|
|
+ thumbUrl:
|
|
|
|
+ 'https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2151136234,3513236673&fm=26&gp=0.jpg',
|
|
|
|
+ size: 18,
|
|
|
|
+ },
|
|
|
|
+ ],
|
|
showIndexColumn: false,
|
|
showIndexColumn: false,
|
|
actionColumn: createPreviewActionColumn(handleRemove, handlePreview, handleDownload),
|
|
actionColumn: createPreviewActionColumn(handleRemove, handlePreview, handleDownload),
|
|
});
|
|
});
|
|
const [addRegister] = useModal();
|
|
const [addRegister] = useModal();
|
|
const rowClick = (e: any) => {
|
|
const rowClick = (e: any) => {
|
|
- console.log(e)
|
|
|
|
- }
|
|
|
|
|
|
+ console.log(e);
|
|
|
|
+ };
|
|
|
|
|
|
- function getTableAction() { // 获取组件
|
|
|
|
|
|
+ function getTableAction() {
|
|
|
|
+ // 获取组件
|
|
const tableAction = unref(tableRef);
|
|
const tableAction = unref(tableRef);
|
|
if (!tableAction) {
|
|
if (!tableAction) {
|
|
throw new Error('tableAction is null');
|
|
throw new Error('tableAction is null');
|
|
@@ -125,32 +91,26 @@
|
|
return tableAction;
|
|
return tableAction;
|
|
}
|
|
}
|
|
|
|
|
|
- function getSelectRowList() { // 获取选中行
|
|
|
|
|
|
+ function getSelectRowList() {
|
|
|
|
+ // 获取选中行
|
|
console.log(getTableAction().getSelectRows());
|
|
console.log(getTableAction().getSelectRows());
|
|
}
|
|
}
|
|
- function getSelectRowKeyList() { // 获取选中行的key --- id
|
|
|
|
|
|
+ function getSelectRowKeyList() {
|
|
|
|
+ // 获取选中行的key --- id
|
|
console.log(getTableAction().getSelectRowKeys());
|
|
console.log(getTableAction().getSelectRowKeys());
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
function handleSubmit() {
|
|
function handleSubmit() {
|
|
- console.log('handleSubmit')
|
|
|
|
|
|
+ console.log('handleSubmit');
|
|
// console.log(data)
|
|
// console.log(data)
|
|
}
|
|
}
|
|
|
|
|
|
function deleteSelect() {
|
|
function deleteSelect() {
|
|
- console.log('删除选中行')
|
|
|
|
- let data = getTableAction().getSelectRowKeys()
|
|
|
|
- // console.log(getTableAction().getSelectRowKeys());
|
|
|
|
- data.map((item) => {
|
|
|
|
- console.log(item)
|
|
|
|
- })
|
|
|
|
|
|
+ console.log('删除选中行');
|
|
|
|
+ let data = getTableAction().getSelectRowKeys();
|
|
|
|
+ console.log(`data`, data);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
function handleCancel(record: EditRecordRow) {
|
|
function handleCancel(record: EditRecordRow) {
|
|
currentEditKeyRef.value = '';
|
|
currentEditKeyRef.value = '';
|
|
record.onEdit?.(false, false);
|
|
record.onEdit?.(false, false);
|
|
@@ -158,39 +118,37 @@
|
|
|
|
|
|
async function handleSave(record: EditRecordRow) {
|
|
async function handleSave(record: EditRecordRow) {
|
|
const pass = await record.onEdit?.(false, true);
|
|
const pass = await record.onEdit?.(false, true);
|
|
- console.log('------- 保存 ----------')
|
|
|
|
- console.log(record)
|
|
|
|
- console.log('------- 保存 ----------')
|
|
|
|
|
|
+ console.log('------- 保存 ----------');
|
|
|
|
+ console.log(record);
|
|
|
|
+ console.log('------- 保存 ----------');
|
|
if (pass) {
|
|
if (pass) {
|
|
currentEditKeyRef.value = '';
|
|
currentEditKeyRef.value = '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- // 删除
|
|
|
|
|
|
+ // 删除
|
|
function handleRemove(record: FileItem) {
|
|
function handleRemove(record: FileItem) {
|
|
- console.log('点击了删除')
|
|
|
|
- console.log(record)
|
|
|
|
- console.log('点击了删除')
|
|
|
|
|
|
+ console.log('点击了删除');
|
|
|
|
+ console.log(record);
|
|
|
|
+ console.log('点击了删除');
|
|
}
|
|
}
|
|
// 预览
|
|
// 预览
|
|
- function handlePreview(record: FileItem) {
|
|
|
|
- // const { thumbUrl = '' } = record;
|
|
|
|
- // createImgPreview({
|
|
|
|
- // imageList: [thumbUrl],
|
|
|
|
- // });
|
|
|
|
- console.log(record)
|
|
|
|
|
|
+ function handlePreview(record: FileItem) {
|
|
|
|
+ console.log(record);
|
|
|
|
+ const urlList = [record.thumbUrl] as string[];
|
|
|
|
+ createImgPreview({ imageList: urlList });
|
|
}
|
|
}
|
|
- // 下载
|
|
|
|
|
|
+ // 下载
|
|
function handleDownload(record: FileItem) {
|
|
function handleDownload(record: FileItem) {
|
|
- console.log('点击了下载')
|
|
|
|
- console.log(record)
|
|
|
|
- console.log('点击了下载')
|
|
|
|
|
|
+ console.log('点击了下载');
|
|
|
|
+ console.log(record);
|
|
|
|
+ console.log('点击了下载');
|
|
}
|
|
}
|
|
|
|
|
|
function handleDelete(record: Recordable) {
|
|
function handleDelete(record: Recordable) {
|
|
console.log('点击了删除', record);
|
|
console.log('点击了删除', record);
|
|
- const data = getTableAction().getDataSource()
|
|
|
|
- getTableAction().setTableData(data.filter(item => item.id !== record.id))
|
|
|
|
|
|
+ const data = getTableAction().getDataSource();
|
|
|
|
+ getTableAction().setTableData(data.filter((item) => item.id !== record.id));
|
|
}
|
|
}
|
|
|
|
|
|
function createActions(record: EditRecordRow, column: BasicColumn): ActionItem[] {
|
|
function createActions(record: EditRecordRow, column: BasicColumn): ActionItem[] {
|
|
@@ -234,8 +192,7 @@
|
|
getSelectRowList,
|
|
getSelectRowList,
|
|
getSelectRowKeyList,
|
|
getSelectRowKeyList,
|
|
addRegister,
|
|
addRegister,
|
|
- handleSubmit
|
|
|
|
-
|
|
|
|
|
|
+ handleSubmit,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
});
|
|
});
|