123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- <template>
- <PageWrapper contentBackground>
- <div class="desc-wrap-BasicTable">
- <BasicTable @register="registerTable">
- </BasicTable>
- </div>
- </PageWrapper>
- </template>
- <script lang="ts">
- import { defineComponent, h, onMounted } from 'vue';
- import {
- BasicTable,
- useTable,
- TableAction,
- BasicColumn,
- TableImg,
- FormProps,
- } from '/@/components/Table';
- import { PageWrapper } from '/@/components/Page';
- import { Descriptions } from 'ant-design-vue';
- import { useI18n } from '/@/hooks/web/useI18n';
- import { useMessage } from '/@/hooks/web/useMessage';
- import { cameraList } from '/@/api/customer';
- import { cameraDelete } from '/@/api/device';
- import { useRouter } from 'vue-router';
- import { UnbindCameraApi } from '/@/api/account';
- import { usePermissionStore } from '/@/store/modules/permission';
- export default defineComponent({
- components: {
- BasicTable,
- TableAction,
- PageWrapper,
- TableImg,
- [Descriptions.name]: Descriptions,
- [Descriptions.Item.name]: Descriptions.Item,
- },
- setup() {
- const { t } = useI18n();
- const { createMessage, createConfirm } = useMessage();
- const permissionStore = usePermissionStore();
- const { getCheckPerm } = permissionStore;
- const router = useRouter();
- const companyId: Number = router.currentRoute.value.params.id - 0;
- onMounted(() => {
- // console.log(router.currentRoute.value.params.id);
- });
- const columns: BasicColumn[] = [
- {
- title: t('routes.device.snCode'),
- dataIndex: 'snCode',
- width: 180,
- },
- {
- title: t('routes.device.wifiName'),
- dataIndex: 'wifiName',
- width: 150,
- },
- {
- title: t('routes.device.deviceType'),
- dataIndex: 'type',
- ellipsis: false,
- width: 80,
- customRender: ({ record }) => {
- let typeObj ={
- '0':t('routes.device.type.0'),
- '1':t('routes.device.type.1'),
- '2':t('routes.device.type.2'),
- '9':t('routes.device.type.9'),
- '10':t('routes.device.type.10'),
- }
- return typeObj[record.type]
- }
- },
- {
- title: t('routes.device.activatedTime'),
- dataIndex: 'activatedTime',
- width: 180,
- },
- {
- title: t('routes.device.userName'),
- dataIndex: 'userName',
- width: 180,
- customRender({ record }) {
- return record.userName?record.userName:'-'
- },
- },
- ];
- const searchForm: Partial<FormProps> = {
- labelWidth: 80,
- autoAdvancedLine:1,
- actionColOptions: {
- span: 24,
- },
- schemas: [
- {
- field: 'snCode',
- component: 'Input',
- label: t('routes.device.snCode'),
- colProps: {
- xl: 6,
- xxl: 6,
- },
- },{
- field: 'type',
- component: 'Select',
- label: t('routes.device.deviceType'),
- colProps: {
- xl: 6,
- xxl: 6,
- },
- componentProps: {
- options: [
- {
- // label: t('routes.device.type.0'),
- // value: 0,
- // key: '0',
- // },{
- label: t('routes.device.type.1'),
- value: 1,
- key: '1',
- },{
- label: t('routes.device.type.2'),
- value: 9,
- key: '9',
- },{
- label: t('routes.device.type.3'),
- value: 10,
- key: '10',
- },
- ],
- },
- },
- {
- field: 'userName',
- component: 'Input',
- label: t('routes.device.userName'),
- colProps: {
- xl: 6,
- xxl: 6,
- },
- },
- ],
- };
- const [registerTable, { reload }] = useTable({
- api: cameraList,
- columns: columns,
- searchInfo: { companyId },
- useSearchForm: true,
- formConfig: searchForm,
- showTableSetting: true,
- showIndexColumn:false,
- rowKey: 'id',
- beforeFetch:(T)=>{
- if(T.ctivated){
- T.activatedStartTime = T.ctivated[0]
- T.activatedEndTime = T.ctivated[1]
- }
- return T
- },
- fetchSetting: {
- pageField: 'pageNum',
- sizeField: 'pageSize',
- listField: 'list',
- totalField: 'total',
- },
- canResize: false,
- });
- async function handleUnbind(record: Recordable) {
- createConfirm({
- iconType: 'warning',
- title: () => h('span', t('common.optSuccess')),
- content: '解绑后用户将看不到该相机拍摄的场景。<br/>确定解绑吗?',
- onOk: async () => {
- await UnbindCameraApi({cameraId:record.id})
- createMessage.success(t('common.optSuccess'));
- reload()
- },
- });
- }
- async function handleDelete(record: Recordable){
- createConfirm({
- iconType: 'warning',
- title: () => h('span', t('common.optSuccess')),
- content: '删除设备后需要重新入库<br/>确定删除吗?',
- onOk: async () => {
- await cameraDelete({id:record.id})
- createMessage.success(t('common.optSuccess'));
- reload()
- },
- });
- }
- return {
- registerTable,
- handleUnbind,
- reload,
- handleDelete,
- getCheckPerm,
- };
- },
- });
- </script>
- <style lang="less" scoped>
- .desc-wrap-BasicTable {
- background-color: #f0f2f5;
- .vben-basic-table-form-container {
- padding: 0;
- }
- }
- </style>
|