|
@@ -4,6 +4,7 @@
|
|
@register="register"
|
|
@register="register"
|
|
:title="t('routes.devices.browserDevice')"
|
|
:title="t('routes.devices.browserDevice')"
|
|
@ok="submitModal"
|
|
@ok="submitModal"
|
|
|
|
+ width="700px"
|
|
@visible-change="handleVisibleChange"
|
|
@visible-change="handleVisibleChange"
|
|
>
|
|
>
|
|
<div class="pt-3px pr-3px">
|
|
<div class="pt-3px pr-3px">
|
|
@@ -14,52 +15,61 @@
|
|
<template #name="{ model, field }">
|
|
<template #name="{ model, field }">
|
|
{{ model[field] }}
|
|
{{ model[field] }}
|
|
</template>
|
|
</template>
|
|
|
|
+ <template #cameraNum="{ model, field }">
|
|
|
|
+ {{ model[field] }}
|
|
|
|
+ </template>
|
|
</BasicForm>
|
|
</BasicForm>
|
|
|
|
+ <BasicTable @register="registerDeviceTable" :searchInfo="searchInfo">
|
|
|
|
+ <template #activeTime="{ record }">
|
|
|
|
+ <Time v-if="record.activeTime" :value="record.activeTime" mode="datetime" />
|
|
|
|
+ </template>
|
|
|
|
+ <template #action="{ record }">
|
|
|
|
+ <TableAction
|
|
|
|
+ :actions="[
|
|
|
|
+ {
|
|
|
|
+ // icon: 'clarity:info-standard-line',
|
|
|
|
+ label: t('routes.corporation.unBind'),
|
|
|
|
+ popConfirm: {
|
|
|
|
+ title: t('routes.corporation.isUnBind'),
|
|
|
|
+ confirm: handleunbindDevice.bind(null, record),
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+ ]"
|
|
|
|
+ />
|
|
|
|
+ </template>
|
|
|
|
+ </BasicTable>
|
|
</div>
|
|
</div>
|
|
</BasicModal>
|
|
</BasicModal>
|
|
</template>
|
|
</template>
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
- import { defineComponent, ref } from 'vue';
|
|
|
|
|
|
+ import { defineComponent, ref, reactive, nextTick } from 'vue';
|
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
|
+ import { BasicTable, useTable, BasicColumn, TableAction } from '/@/components/Table';
|
|
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
- // import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
// import { AddDevice, checkDevice } from '/@/api/corporation/modal';
|
|
// import { AddDevice, checkDevice } from '/@/api/corporation/modal';
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
|
+ import { ListCompanyDeviceApi, unDeviceApi } from '/@/api/corporation/list';
|
|
|
|
+ import { Time } from '/@/components/Time';
|
|
|
|
+
|
|
export default defineComponent({
|
|
export default defineComponent({
|
|
- components: { BasicModal, BasicForm },
|
|
|
|
|
|
+ components: { BasicModal, BasicForm, BasicTable, Time, TableAction },
|
|
props: {
|
|
props: {
|
|
userData: { type: Object },
|
|
userData: { type: Object },
|
|
},
|
|
},
|
|
- emits: ['register'],
|
|
|
|
- setup() {
|
|
|
|
|
|
+ emits: ['register', 'ok'],
|
|
|
|
+ setup(_, { emit }) {
|
|
// const modelRef = ref({});
|
|
// const modelRef = ref({});
|
|
const num = ref(0);
|
|
const num = ref(0);
|
|
const { t } = useI18n();
|
|
const { t } = useI18n();
|
|
- // const { createMessage } = useMessage();
|
|
|
|
- // const { success, error } = createMessage;
|
|
|
|
|
|
+ const { createMessage } = useMessage();
|
|
|
|
+
|
|
|
|
+ const searchInfo = reactive<Recordable>({});
|
|
|
|
|
|
- const [register] = useModalInner((data) => {
|
|
|
|
|
|
+ const [register, { closeModal }] = useModalInner((data) => {
|
|
data && onDataReceive(data);
|
|
data && onDataReceive(data);
|
|
});
|
|
});
|
|
|
|
|
|
- // const handlevalidator = async (_, value) => {
|
|
|
|
- // console.log('handlevalidator', value);
|
|
|
|
- // if (!value) {
|
|
|
|
- // return Promise.resolve();
|
|
|
|
- // }
|
|
|
|
- // try {
|
|
|
|
- // let res = await checkDevice({
|
|
|
|
- // childName: value,
|
|
|
|
- // });
|
|
|
|
- // if (res.message) {
|
|
|
|
- // return Promise.reject(res.message);
|
|
|
|
- // } else {
|
|
|
|
- // return Promise.resolve();
|
|
|
|
- // }
|
|
|
|
- // } catch (err) {
|
|
|
|
- // return Promise.reject(err);
|
|
|
|
- // }
|
|
|
|
- // };
|
|
|
|
const schemas: FormSchema[] = [
|
|
const schemas: FormSchema[] = [
|
|
{
|
|
{
|
|
field: 'userName',
|
|
field: 'userName',
|
|
@@ -73,8 +83,14 @@
|
|
slot: 'name',
|
|
slot: 'name',
|
|
component: 'Input',
|
|
component: 'Input',
|
|
},
|
|
},
|
|
|
|
+ {
|
|
|
|
+ field: 'cameraNum',
|
|
|
|
+ label: t('routes.corporation.cameraNum'),
|
|
|
|
+ slot: 'cameraNum',
|
|
|
|
+ component: 'Input',
|
|
|
|
+ },
|
|
];
|
|
];
|
|
- // let schemasList = []
|
|
|
|
|
|
+
|
|
const [
|
|
const [
|
|
registerForm,
|
|
registerForm,
|
|
{
|
|
{
|
|
@@ -93,22 +109,74 @@
|
|
span: 24,
|
|
span: 24,
|
|
},
|
|
},
|
|
});
|
|
});
|
|
|
|
+ const columns: BasicColumn[] = [
|
|
|
|
+ {
|
|
|
|
+ title: 'ID',
|
|
|
|
+ dataIndex: 'id',
|
|
|
|
+ fixed: 'left',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('routes.corporation.deviceId'),
|
|
|
|
+ dataIndex: 'childName',
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ title: t('routes.corporation.activeTime'),
|
|
|
|
+ dataIndex: 'activeTime',
|
|
|
|
+ slots: { customRender: 'activeTime' },
|
|
|
|
+ width: 100,
|
|
|
|
+ },
|
|
|
|
+ ];
|
|
|
|
|
|
|
|
+ const [registerDeviceTable, { reload }] = useTable({
|
|
|
|
+ title: '',
|
|
|
|
+ api: ListCompanyDeviceApi,
|
|
|
|
+ columns: columns,
|
|
|
|
+ useSearchForm: false,
|
|
|
|
+ // formConfig: searchForm,
|
|
|
|
+ showTableSetting: false,
|
|
|
|
+ showIndexColumn: false,
|
|
|
|
+ immediate: false,
|
|
|
|
+ rowKey: 'id',
|
|
|
|
+ pagination: false,
|
|
|
|
+ fetchSetting: {
|
|
|
|
+ pageField: 'pageNum',
|
|
|
|
+ sizeField: 'pageSize',
|
|
|
|
+ listField: 'list',
|
|
|
|
+ totalField: 'totalCount',
|
|
|
|
+ },
|
|
|
|
+ actionColumn: {
|
|
|
|
+ width: 100,
|
|
|
|
+ title: t('common.operation'),
|
|
|
|
+ dataIndex: 'action',
|
|
|
|
+ slots: { customRender: 'action' },
|
|
|
|
+ },
|
|
|
|
+ });
|
|
function onDataReceive(data) {
|
|
function onDataReceive(data) {
|
|
// 方式1;
|
|
// 方式1;
|
|
resetFields();
|
|
resetFields();
|
|
setFieldsValue({
|
|
setFieldsValue({
|
|
- ...data.record,
|
|
|
|
|
|
+ ...data,
|
|
});
|
|
});
|
|
- console.log('data', data);
|
|
|
|
- // // 方式2
|
|
|
|
- // modelRef.value = { ...data.record };
|
|
|
|
|
|
+
|
|
|
|
+ searchInfo.userName = data.userName;
|
|
|
|
+ nextTick(reload);
|
|
}
|
|
}
|
|
|
|
|
|
- async function submitModal() {}
|
|
|
|
|
|
+ async function submitModal() {
|
|
|
|
+ emit('ok');
|
|
|
|
+ closeModal();
|
|
|
|
+ }
|
|
|
|
|
|
- function handleVisibleChange() {
|
|
|
|
- // v && props.userData && nextTick(() => onDataReceive(props.userData));
|
|
|
|
|
|
+ function handleVisibleChange() {}
|
|
|
|
+ async function handleunbindDevice(record: Recordable) {
|
|
|
|
+ console.log('record');
|
|
|
|
+ await unDeviceApi({
|
|
|
|
+ childName: record.childName,
|
|
|
|
+ });
|
|
|
|
+ createMessage.success(t('common.optSuccess'));
|
|
|
|
+ nextTick(reload);
|
|
}
|
|
}
|
|
return {
|
|
return {
|
|
register,
|
|
register,
|
|
@@ -121,6 +189,9 @@
|
|
num,
|
|
num,
|
|
// errorMsg: error,
|
|
// errorMsg: error,
|
|
t,
|
|
t,
|
|
|
|
+ registerDeviceTable,
|
|
|
|
+ searchInfo,
|
|
|
|
+ handleunbindDevice,
|
|
};
|
|
};
|
|
},
|
|
},
|
|
});
|
|
});
|