|
@@ -8,8 +8,22 @@
|
|
|
cancelText="关闭"
|
|
|
>
|
|
|
<a-button type="primary" preIcon="mdi:reload" iconSize="20" @click="reload" />
|
|
|
- <a-button class="check-btn" type="success" @click="checked"> 选择 </a-button>
|
|
|
- <BasicTable ref="tableRef" @register="registerTable" rowKey="id" @rowDbClick="handleDetail">
|
|
|
+ <a-button
|
|
|
+ v-if="type === 'images'"
|
|
|
+ class="check-btn"
|
|
|
+ :disabled="disable_btn"
|
|
|
+ type="success"
|
|
|
+ preIcon="fa-solid:check"
|
|
|
+ @click="checkedBatches"
|
|
|
+ >{{ t('component.upload.choose') }}</a-button
|
|
|
+ >
|
|
|
+ <BasicTable
|
|
|
+ ref="tableRef"
|
|
|
+ @register="registerTable"
|
|
|
+ @selectionChange="selectionChange"
|
|
|
+ @rowClick="selectionChange"
|
|
|
+ rowKey="id"
|
|
|
+ >
|
|
|
<template #action="{ record, column }">
|
|
|
<TableAction :actions="createActions(record, column)" />
|
|
|
</template>
|
|
@@ -17,7 +31,7 @@
|
|
|
</BasicModal>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
- import { defineComponent, PropType, ref, toRefs, unref } from 'vue';
|
|
|
+ import { defineComponent, reactive, ref, toRefs, unref } from 'vue';
|
|
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
import { adapt } from '/@/utils/adapt';
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
@@ -30,68 +44,57 @@
|
|
|
TableActionType,
|
|
|
} from '/@/components/Table';
|
|
|
import { columns } from './chooseModalData';
|
|
|
- interface PopupData {
|
|
|
- title: string;
|
|
|
+ interface Btn {
|
|
|
+ disable_btn: boolean;
|
|
|
}
|
|
|
- const formData = [
|
|
|
+ const fakeData = [
|
|
|
{
|
|
|
id: 1,
|
|
|
- username: 'test1',
|
|
|
- title: '日志1',
|
|
|
- url: 'http://localhost:3100/#/permission/admin',
|
|
|
- ip: '0.0.0.0',
|
|
|
- browser: 'Mozilla/5.0',
|
|
|
- time: '2020-10-20',
|
|
|
+ imgUrl: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
|
|
+ imagewidth: 120,
|
|
|
+ imageheight: 120,
|
|
|
+ createtime: '2020-10-20 21:22:22',
|
|
|
},
|
|
|
{
|
|
|
id: 2,
|
|
|
- username: 'test2',
|
|
|
- title: '日志2',
|
|
|
- url: 'http://localhost:3100/#/permission/admin',
|
|
|
- ip: '0.0.0.0',
|
|
|
- browser: 'Mozilla/5.0',
|
|
|
- time: '2020-10-21',
|
|
|
+ imgUrl: 'http://jetbill.cn/uploads/20210713/a05d360766d30868cdb878b4c0aac77d.jpg',
|
|
|
+ imagewidth: 120,
|
|
|
+ imageheight: 120,
|
|
|
},
|
|
|
{
|
|
|
id: 3,
|
|
|
- username: 'test3',
|
|
|
- title: '日志3',
|
|
|
- url: 'http://localhost:3100/#/permission/admin',
|
|
|
- ip: '0.0.0.0',
|
|
|
- browser: 'Mozilla/5.0',
|
|
|
- time: '2020-10-21',
|
|
|
+ imgUrl: 'http://jetbill.cn/uploads/20210712/51ae92cdb0bb22a88d6e73e62bcb1cad.jpg',
|
|
|
+ imagewidth: 120,
|
|
|
+ imageheight: 120,
|
|
|
},
|
|
|
];
|
|
|
+ const props = {
|
|
|
+ value: { type: String, default: '' },
|
|
|
+ type: { type: String, default: '' },
|
|
|
+ };
|
|
|
|
|
|
export default defineComponent({
|
|
|
components: { BasicModal, BasicTable, TableAction },
|
|
|
- props: {
|
|
|
- popupData: {
|
|
|
- type: Object as PropType<PopupData>,
|
|
|
- default: () => {},
|
|
|
- },
|
|
|
- },
|
|
|
- setup(props) {
|
|
|
+ props,
|
|
|
+ emits: ['checked', 'checkedBatches'],
|
|
|
+ setup(props, { emit }) {
|
|
|
const { t } = useI18n();
|
|
|
- const popupData = props.popupData as PopupData;
|
|
|
const tableRef = ref<Nullable<TableActionType>>(null);
|
|
|
- const currentEditKeyRef = ref('');
|
|
|
- const modelRef = ref({});
|
|
|
const adaptWidth = adapt();
|
|
|
- const [register] = useModalInner((data) => {
|
|
|
- // 方式2
|
|
|
- modelRef.value = data;
|
|
|
+ const [register, { closeModal }] = useModalInner();
|
|
|
+ const btn = reactive<Btn>({
|
|
|
+ disable_btn: true,
|
|
|
});
|
|
|
const [registerTable] = useTable({
|
|
|
// title: '管理员日志',
|
|
|
// titleHelpMessage: '',
|
|
|
rowSelection: { type: 'checkbox' },
|
|
|
columns: columns,
|
|
|
- clickToRowSelect: false, // 点击行不勾选
|
|
|
+ // clickToRowSelect: false, // 点击行不勾选
|
|
|
// api: getUserList,
|
|
|
- dataSource: formData,
|
|
|
+ dataSource: fakeData,
|
|
|
actionColumn: {
|
|
|
- width: 160,
|
|
|
+ width: 80,
|
|
|
title: '操作',
|
|
|
dataIndex: 'action',
|
|
|
slots: { customRender: 'action' },
|
|
@@ -108,42 +111,33 @@
|
|
|
}
|
|
|
return tableAction;
|
|
|
}
|
|
|
-
|
|
|
- function getSelectRowList() {
|
|
|
- // 获取选中行
|
|
|
- console.log(getTableAction().getSelectRows());
|
|
|
- }
|
|
|
- function getSelectRowKeyList() {
|
|
|
- // 获取选中行的key --- id
|
|
|
- console.log(getTableAction().getSelectRowKeys());
|
|
|
+ function reload() {
|
|
|
+ console.log('========reload======');
|
|
|
}
|
|
|
|
|
|
- function handleChecked(record: EditRecordRow) {
|
|
|
- currentEditKeyRef.value = record.id; // record.key
|
|
|
-
|
|
|
- const data = getTableAction().getDataSource();
|
|
|
- data.map((item) => {
|
|
|
- if (item.id === record.id) {
|
|
|
- record = item;
|
|
|
- }
|
|
|
- });
|
|
|
+ function selectionChange() {
|
|
|
+ const keys = getTableAction().getSelectRowKeys();
|
|
|
+ if (keys.length) {
|
|
|
+ btn.disable_btn = false;
|
|
|
+ } else {
|
|
|
+ btn.disable_btn = true;
|
|
|
+ }
|
|
|
}
|
|
|
- function checked(record: EditRecordRow) {
|
|
|
- currentEditKeyRef.value = record.id; // record.key
|
|
|
|
|
|
- const data = getTableAction().getDataSource();
|
|
|
- data.map((item) => {
|
|
|
- if (item.id === record.id) {
|
|
|
- record = item;
|
|
|
- }
|
|
|
- });
|
|
|
+ function handleChecked(record) {
|
|
|
+ console.log(`record`, record);
|
|
|
+ emit('checked', record.id, closeModal);
|
|
|
+ }
|
|
|
+ async function checkedBatches() {
|
|
|
+ const keys = await getTableAction().getSelectRowKeys();
|
|
|
+ emit('checkedBatches', keys, closeModal);
|
|
|
}
|
|
|
|
|
|
function createActions(record: EditRecordRow): ActionItem[] {
|
|
|
return [
|
|
|
{
|
|
|
label: '选择',
|
|
|
- icon: 'akar-icons:eye-open',
|
|
|
+ icon: 'fa-solid:check',
|
|
|
color: 'success',
|
|
|
onClick: handleChecked.bind(null, record),
|
|
|
},
|
|
@@ -152,16 +146,17 @@
|
|
|
|
|
|
return {
|
|
|
register,
|
|
|
+ tableRef,
|
|
|
registerTable,
|
|
|
adaptWidth,
|
|
|
- checked,
|
|
|
+ checkedBatches,
|
|
|
+ selectionChange,
|
|
|
+ reload,
|
|
|
createActions,
|
|
|
getTableAction,
|
|
|
- getSelectRowList,
|
|
|
- getSelectRowKeyList,
|
|
|
- model: modelRef,
|
|
|
t,
|
|
|
- ...toRefs(popupData),
|
|
|
+ ...toRefs(btn),
|
|
|
+ ...toRefs(props),
|
|
|
};
|
|
|
},
|
|
|
});
|