| | |
| | | |
| | | const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagination, scrollX } = |
| | | useNaivePaginatedTable({ |
| | | api: () => fetchGetInstrumentList(searchParams.value), |
| | | transform: response => defaultTransform(response), |
| | | onPaginationParamsChange: params => { |
| | | searchParams.value.pageNum = params.page; |
| | | searchParams.value.pageSize = params.pageSize; |
| | | }, |
| | | columns: () => [ |
| | | { |
| | | type: 'selection', |
| | | align: 'center', |
| | | width: 48 |
| | | api: () => fetchGetInstrumentList(searchParams.value), |
| | | transform: response => defaultTransform(response), |
| | | onPaginationParamsChange: params => { |
| | | searchParams.value.pageNum = params.page; |
| | | searchParams.value.pageSize = params.pageSize; |
| | | }, |
| | | { |
| | | key: 'index', |
| | | title: $t('common.index'), |
| | | align: 'center', |
| | | width: 64, |
| | | render: (_, index) => index + 1 |
| | | }, |
| | | { |
| | | key: 'instrumentCode', |
| | | title: '仪器代码', |
| | | align: 'center', |
| | | width: 120 |
| | | }, |
| | | { |
| | | key: 'instrumentName', |
| | | title: '仪器名称', |
| | | align: 'center', |
| | | width: 200 |
| | | }, |
| | | { |
| | | key: 'ifStd', |
| | | title: '接口标准', |
| | | align: 'center', |
| | | width: 120 |
| | | }, |
| | | { |
| | | key: 'isc', |
| | | title: '接口标准代码', |
| | | align: 'center', |
| | | width: 100 |
| | | }, |
| | | { |
| | | key: 'workShop', |
| | | title: '所属车间', |
| | | align: 'center', |
| | | width: 120 |
| | | }, |
| | | { |
| | | key: 'enable', |
| | | title: '启用', |
| | | align: 'center', |
| | | width: 120, |
| | | render(row) { |
| | | return <DictTag value={row.enable} dictCode="sys_yes_no" />; |
| | | } |
| | | }, |
| | | { |
| | | key: 'del', |
| | | title: '删除', |
| | | align: 'center', |
| | | width: 120 |
| | | }, |
| | | { |
| | | key: 'instrumentDes', |
| | | title: '备注', |
| | | align: 'center', |
| | | width: 300, |
| | | render: row => ( |
| | | <NTooltip trigger="hover"> |
| | | {{ |
| | | trigger: () => ( |
| | | <div |
| | | style={{ |
| | | whiteSpace: 'nowrap', |
| | | overflow: 'hidden', |
| | | textOverflow: 'ellipsis' |
| | | }} |
| | | > |
| | | {row.instrumentDes} |
| | | </div> |
| | | ), |
| | | default: () => row.instrumentDes |
| | | }} |
| | | </NTooltip> |
| | | ) |
| | | }, |
| | | { |
| | | key: 'operate', |
| | | title: $t('common.operate'), |
| | | align: 'center', |
| | | width: 130, |
| | | render: row => { |
| | | const divider = () => { |
| | | if (!hasAuth('md:instrument:edit') || !hasAuth('md:instrument:remove')) { |
| | | return null; |
| | | } |
| | | return <NDivider vertical />; |
| | | }; |
| | | columns: () => [ |
| | | { |
| | | type: 'selection', |
| | | align: 'center', |
| | | width: 48 |
| | | }, |
| | | { |
| | | key: 'index', |
| | | title: $t('common.index'), |
| | | align: 'center', |
| | | width: 64, |
| | | render: (_, index) => index + 1 |
| | | }, |
| | | { |
| | | key: 'instrumentCode', |
| | | title: '仪器代码', |
| | | align: 'center', |
| | | width: 120 |
| | | }, |
| | | { |
| | | key: 'instrumentName', |
| | | title: '仪器名称', |
| | | align: 'center', |
| | | width: 200 |
| | | }, |
| | | { |
| | | key: 'ifStd', |
| | | title: '接口标准', |
| | | align: 'center', |
| | | width: 120 |
| | | }, |
| | | { |
| | | key: 'isc', |
| | | title: '接口标准代码', |
| | | align: 'center', |
| | | width: 100 |
| | | }, |
| | | { |
| | | key: 'workShop', |
| | | title: '所属车间', |
| | | align: 'center', |
| | | width: 120 |
| | | }, |
| | | { |
| | | key: 'enable', |
| | | title: '启用', |
| | | align: 'center', |
| | | width: 120, |
| | | render(row) { |
| | | return <DictTag value={row.enable} dictCode="sys_yes_no" />; |
| | | } |
| | | }, |
| | | { |
| | | key: 'del', |
| | | title: '删除', |
| | | align: 'center', |
| | | width: 120 |
| | | }, |
| | | { |
| | | key: 'instrumentDes', |
| | | title: '备注', |
| | | align: 'center', |
| | | width: 300, |
| | | render: row => ( |
| | | <NTooltip trigger="hover"> |
| | | {{ |
| | | trigger: () => ( |
| | | <div |
| | | style={{ |
| | | whiteSpace: 'nowrap', |
| | | overflow: 'hidden', |
| | | textOverflow: 'ellipsis' |
| | | }} |
| | | > |
| | | {row.instrumentDes} |
| | | </div> |
| | | ), |
| | | default: () => row.instrumentDes |
| | | }} |
| | | </NTooltip> |
| | | ) |
| | | }, |
| | | { |
| | | key: 'operate', |
| | | title: $t('common.operate'), |
| | | align: 'center', |
| | | width: 130, |
| | | render: row => { |
| | | const divider = () => { |
| | | if (!hasAuth('md:instrument:edit') || !hasAuth('md:instrument:remove')) { |
| | | return null; |
| | | } |
| | | return <NDivider vertical />; |
| | | }; |
| | | |
| | | const editBtn = () => { |
| | | if (!hasAuth('md:instrument:edit')) { |
| | | return null; |
| | | } |
| | | const editBtn = () => { |
| | | if (!hasAuth('md:instrument:edit')) { |
| | | return null; |
| | | } |
| | | return ( |
| | | <ButtonIcon |
| | | text |
| | | type="primary" |
| | | icon="material-symbols:drive-file-rename-outline-outline" |
| | | tooltipContent={$t('common.edit')} |
| | | onClick={() => edit(row.id)} |
| | | /> |
| | | ); |
| | | }; |
| | | |
| | | const deleteBtn = () => { |
| | | if (!hasAuth('md:instrument:remove')) { |
| | | return null; |
| | | } |
| | | return ( |
| | | <ButtonIcon |
| | | text |
| | | type="error" |
| | | icon="material-symbols:delete-outline" |
| | | tooltipContent={$t('common.delete')} |
| | | popconfirmContent={$t('common.confirmDelete')} |
| | | onPositiveClick={() => handleDelete(row.id)} |
| | | /> |
| | | ); |
| | | }; |
| | | |
| | | return ( |
| | | <ButtonIcon |
| | | text |
| | | type="primary" |
| | | icon="material-symbols:drive-file-rename-outline-outline" |
| | | tooltipContent={$t('common.edit')} |
| | | onClick={() => edit(row.id)} |
| | | /> |
| | | <div class="flex-center gap-8px"> |
| | | {editBtn()} |
| | | {divider()} |
| | | {deleteBtn()} |
| | | </div> |
| | | ); |
| | | }; |
| | | |
| | | const deleteBtn = () => { |
| | | if (!hasAuth('md:instrument:remove')) { |
| | | return null; |
| | | } |
| | | return ( |
| | | <ButtonIcon |
| | | text |
| | | type="error" |
| | | icon="material-symbols:delete-outline" |
| | | tooltipContent={$t('common.delete')} |
| | | popconfirmContent={$t('common.confirmDelete')} |
| | | onPositiveClick={() => handleDelete(row.id)} |
| | | /> |
| | | ); |
| | | }; |
| | | |
| | | return ( |
| | | <div class="flex-center gap-8px"> |
| | | {editBtn()} |
| | | {divider()} |
| | | {deleteBtn()} |
| | | </div> |
| | | ); |
| | | } |
| | | } |
| | | } |
| | | ] |
| | | }); |
| | | ] |
| | | }); |
| | | |
| | | const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onBatchDeleted, onDeleted } = |
| | | useTableOperate(data, 'id', getData); |