|
@@ -49,200 +49,200 @@
|
|
|
</PageWrapper>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
-import { defineComponent, reactive, h } from 'vue';
|
|
|
-import { BasicTable, useTable, FormProps, TableAction, BasicColumn } from '/@/components/Table';
|
|
|
-import { PageWrapper } from '/@/components/Page';
|
|
|
-import { Divider, Card, Empty, Descriptions, Steps, Tabs } from 'ant-design-vue';
|
|
|
-import { CameraList, DelAndUpload, EditAndUpload } from '/@/api/product';
|
|
|
-import { useModal } from '/@/components/Modal';
|
|
|
-import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
-import AddModal from './AddModal.vue';
|
|
|
-import EditModal from './EditModal.vue';
|
|
|
-import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
-import { Switch } from 'ant-design-vue';
|
|
|
-import { Time } from '/@/components/Time';
|
|
|
-import { usePermissionStore } from '/@/store/modules/permission';
|
|
|
-export default defineComponent({
|
|
|
- components: {
|
|
|
- BasicTable,
|
|
|
- AddModal,
|
|
|
- EditModal,
|
|
|
- TableAction,
|
|
|
- PageWrapper,
|
|
|
- [Divider.name]: Divider,
|
|
|
- [Card.name]: Card,
|
|
|
- Empty,
|
|
|
- [Descriptions.name]: Descriptions,
|
|
|
- [Descriptions.Item.name]: Descriptions.Item,
|
|
|
- [Steps.name]: Steps,
|
|
|
- [Steps.Step.name]: Steps.Step,
|
|
|
- [Tabs.name]: Tabs,
|
|
|
- [Tabs.TabPane.name]: Tabs.TabPane,
|
|
|
- },
|
|
|
- setup() {
|
|
|
- const { t } = useI18n();
|
|
|
- const permissionStore = usePermissionStore();
|
|
|
- const { getCheckPerm } = permissionStore;
|
|
|
- const searchInfo = reactive<Recordable>({
|
|
|
- type: 9,
|
|
|
- });
|
|
|
- const [registerAddModal, { openModal: openAddModal }] = useModal();
|
|
|
- const [registerEditModal, { openModal: openEditModal }] = useModal();
|
|
|
- const { createMessage } = useMessage();
|
|
|
+ import { defineComponent, reactive, h } from 'vue';
|
|
|
+ import { BasicTable, useTable, FormProps, TableAction, BasicColumn } from '/@/components/Table';
|
|
|
+ import { PageWrapper } from '/@/components/Page';
|
|
|
+ import { Divider, Card, Empty, Descriptions, Steps, Tabs } from 'ant-design-vue';
|
|
|
+ import { CameraList, DelAndUpload, EditAndUpload } from '/@/api/product';
|
|
|
+ import { useModal } from '/@/components/Modal';
|
|
|
+ import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
+ import AddModal from './AddModal.vue';
|
|
|
+ import EditModal from './EditModal.vue';
|
|
|
+ import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
+ import { Switch } from 'ant-design-vue';
|
|
|
+ import { Time } from '/@/components/Time';
|
|
|
+ import { usePermissionStore } from '/@/store/modules/permission';
|
|
|
+ export default defineComponent({
|
|
|
+ components: {
|
|
|
+ BasicTable,
|
|
|
+ AddModal,
|
|
|
+ EditModal,
|
|
|
+ TableAction,
|
|
|
+ PageWrapper,
|
|
|
+ [Divider.name]: Divider,
|
|
|
+ [Card.name]: Card,
|
|
|
+ Empty,
|
|
|
+ [Descriptions.name]: Descriptions,
|
|
|
+ [Descriptions.Item.name]: Descriptions.Item,
|
|
|
+ [Steps.name]: Steps,
|
|
|
+ [Steps.Step.name]: Steps.Step,
|
|
|
+ [Tabs.name]: Tabs,
|
|
|
+ [Tabs.TabPane.name]: Tabs.TabPane,
|
|
|
+ },
|
|
|
+ setup() {
|
|
|
+ const { t } = useI18n();
|
|
|
+ const permissionStore = usePermissionStore();
|
|
|
+ const { getCheckPerm } = permissionStore;
|
|
|
+ const searchInfo = reactive<Recordable>({
|
|
|
+ type: 1,
|
|
|
+ });
|
|
|
+ const [registerAddModal, { openModal: openAddModal }] = useModal();
|
|
|
+ const [registerEditModal, { openModal: openEditModal }] = useModal();
|
|
|
+ const { createMessage } = useMessage();
|
|
|
|
|
|
- const refundTimeTableSchema: BasicColumn[] = [
|
|
|
- {
|
|
|
- title: '版本号',
|
|
|
- width: 150,
|
|
|
- dataIndex: 'version',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '版本更新说明',
|
|
|
- width: 150,
|
|
|
- dataIndex: 'description',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '最低版本号',
|
|
|
- width: 150,
|
|
|
- dataIndex: 'minVersion',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '创建人',
|
|
|
- width: 150,
|
|
|
- dataIndex: 'createName',
|
|
|
- },
|
|
|
- {
|
|
|
- title: '创建时间',
|
|
|
- width: 150,
|
|
|
- dataIndex: 'createTime',
|
|
|
- customRender: ({ record }) => {
|
|
|
- return (
|
|
|
- record.createTime &&
|
|
|
- h(Time, {
|
|
|
- value: record.createTime,
|
|
|
- mode: 'datetime',
|
|
|
- })
|
|
|
- );
|
|
|
+ const refundTimeTableSchema: BasicColumn[] = [
|
|
|
+ {
|
|
|
+ title: '版本号',
|
|
|
+ width: 150,
|
|
|
+ dataIndex: 'version',
|
|
|
},
|
|
|
- },
|
|
|
- {
|
|
|
- title: '状态',
|
|
|
- dataIndex: 'status',
|
|
|
- width: 80,
|
|
|
- ifShow: getCheckPerm('firmware-enable'),
|
|
|
- customRender: ({ record }) => {
|
|
|
- if (!Reflect.has(record, 'pendingStatus')) {
|
|
|
- record.pendingStatus = false;
|
|
|
- }
|
|
|
- return h(Switch, {
|
|
|
- checked: record.status === 'A',
|
|
|
- checkedChildren: '启用',
|
|
|
- unCheckedChildren: '禁用',
|
|
|
- loading: false,
|
|
|
- onChange: async (checked: boolean) => {
|
|
|
- record.pendingStatus = true;
|
|
|
- const newStatus = checked ? 'A' : 'I';
|
|
|
- await EditAndUpload({ ...record, status: newStatus });
|
|
|
- if (checked) {
|
|
|
- Reflect.set(record, 'status', newStatus);
|
|
|
- } else {
|
|
|
- Reflect.set(record, 'status', newStatus);
|
|
|
- }
|
|
|
- reload()
|
|
|
- createMessage.success(t('common.optSuccess'));
|
|
|
- },
|
|
|
- });
|
|
|
+ {
|
|
|
+ title: '版本更新说明',
|
|
|
+ width: 150,
|
|
|
+ dataIndex: 'description',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '最低版本号',
|
|
|
+ width: 150,
|
|
|
+ dataIndex: 'minVersion',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '创建人',
|
|
|
+ width: 150,
|
|
|
+ dataIndex: 'createName',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '创建时间',
|
|
|
+ width: 150,
|
|
|
+ dataIndex: 'createTime',
|
|
|
+ customRender: ({ record }) => {
|
|
|
+ return (
|
|
|
+ record.createTime &&
|
|
|
+ h(Time, {
|
|
|
+ value: record.createTime,
|
|
|
+ mode: 'datetime',
|
|
|
+ })
|
|
|
+ );
|
|
|
+ },
|
|
|
},
|
|
|
- },
|
|
|
- ];
|
|
|
- const searchForm: Partial<FormProps> = {
|
|
|
- labelWidth: 100,
|
|
|
- autoSubmitOnEnter:true,
|
|
|
- schemas: [
|
|
|
{
|
|
|
- field: 'version',
|
|
|
- label: '版本号',
|
|
|
- component: 'Input',
|
|
|
- componentProps: {
|
|
|
- maxLength: 100,
|
|
|
+ title: '状态',
|
|
|
+ dataIndex: 'status',
|
|
|
+ width: 80,
|
|
|
+ ifShow: getCheckPerm('firmware-enable'),
|
|
|
+ customRender: ({ record }) => {
|
|
|
+ if (!Reflect.has(record, 'pendingStatus')) {
|
|
|
+ record.pendingStatus = false;
|
|
|
+ }
|
|
|
+ return h(Switch, {
|
|
|
+ checked: record.status === 'A',
|
|
|
+ checkedChildren: '启用',
|
|
|
+ unCheckedChildren: '禁用',
|
|
|
+ loading: false,
|
|
|
+ onChange: async (checked: boolean) => {
|
|
|
+ record.pendingStatus = true;
|
|
|
+ const newStatus = checked ? 'A' : 'I';
|
|
|
+ await EditAndUpload({ ...record, status: newStatus });
|
|
|
+ if (checked) {
|
|
|
+ Reflect.set(record, 'status', newStatus);
|
|
|
+ } else {
|
|
|
+ Reflect.set(record, 'status', newStatus);
|
|
|
+ }
|
|
|
+ reload();
|
|
|
+ createMessage.success(t('common.optSuccess'));
|
|
|
+ },
|
|
|
+ });
|
|
|
},
|
|
|
- colProps: {
|
|
|
- xl: 6,
|
|
|
- xxl: 6,
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ const searchForm: Partial<FormProps> = {
|
|
|
+ labelWidth: 100,
|
|
|
+ autoSubmitOnEnter: true,
|
|
|
+ schemas: [
|
|
|
+ {
|
|
|
+ field: 'version',
|
|
|
+ label: '版本号',
|
|
|
+ component: 'Input',
|
|
|
+ componentProps: {
|
|
|
+ maxLength: 100,
|
|
|
+ },
|
|
|
+ colProps: {
|
|
|
+ xl: 6,
|
|
|
+ xxl: 6,
|
|
|
+ },
|
|
|
},
|
|
|
+ ],
|
|
|
+ };
|
|
|
+ const [registerTimeTable, { reload }] = useTable({
|
|
|
+ api: CameraList,
|
|
|
+ title: '固件列表',
|
|
|
+ columns: refundTimeTableSchema,
|
|
|
+ useSearchForm: true,
|
|
|
+ formConfig: searchForm,
|
|
|
+ showTableSetting: true,
|
|
|
+ rowKey: 'id',
|
|
|
+ fetchSetting: {
|
|
|
+ pageField: 'pageNum',
|
|
|
+ sizeField: 'pageSize',
|
|
|
+ listField: 'list',
|
|
|
+ totalField: 'total',
|
|
|
},
|
|
|
- ],
|
|
|
- };
|
|
|
- const [registerTimeTable, { reload }] = useTable({
|
|
|
- api: CameraList,
|
|
|
- title: '固件列表',
|
|
|
- columns: refundTimeTableSchema,
|
|
|
- useSearchForm: true,
|
|
|
- formConfig: searchForm,
|
|
|
- showTableSetting: true,
|
|
|
- rowKey: 'id',
|
|
|
- fetchSetting: {
|
|
|
- pageField: 'pageNum',
|
|
|
- sizeField: 'pageSize',
|
|
|
- listField: 'list',
|
|
|
- totalField: 'total',
|
|
|
- },
|
|
|
- searchInfo: searchInfo,
|
|
|
- // beforeFetch:(T)=>{
|
|
|
- // T.type = searchInfo.type
|
|
|
- // console.log('beforeFetch',T,searchInfo)
|
|
|
- // return T
|
|
|
- // },
|
|
|
- actionColumn: {
|
|
|
- width: 180,
|
|
|
- title: '操作',
|
|
|
- dataIndex: 'action',
|
|
|
- slots: { customRender: 'action' },
|
|
|
- },
|
|
|
- canResize: true,
|
|
|
- });
|
|
|
- function tabChange(val: string) {
|
|
|
- console.log('tabChange', val);
|
|
|
- reload();
|
|
|
- }
|
|
|
- async function handleDelete(record: Recordable) {
|
|
|
- console.log('点击了删除', record);
|
|
|
- await DelAndUpload({ id: record.id });
|
|
|
- createMessage.success(t('common.optSuccess'));
|
|
|
- reload();
|
|
|
- }
|
|
|
- function handleOpen(record: Recordable) {
|
|
|
- console.log('点击了启用', record);
|
|
|
- }
|
|
|
- function handleEdit(record: Recordable) {
|
|
|
- console.log('record', record);
|
|
|
- openEditModal(true, {
|
|
|
- ...record,
|
|
|
- type:searchInfo.type
|
|
|
+ searchInfo: searchInfo,
|
|
|
+ // beforeFetch:(T)=>{
|
|
|
+ // T.type = searchInfo.type
|
|
|
+ // console.log('beforeFetch',T,searchInfo)
|
|
|
+ // return T
|
|
|
+ // },
|
|
|
+ actionColumn: {
|
|
|
+ width: 180,
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'action',
|
|
|
+ slots: { customRender: 'action' },
|
|
|
+ },
|
|
|
+ canResize: true,
|
|
|
});
|
|
|
- }
|
|
|
- return {
|
|
|
- registerTimeTable,
|
|
|
- handleDelete,
|
|
|
- handleOpen,
|
|
|
- tabChange,
|
|
|
- reload,
|
|
|
- registerAddModal,
|
|
|
- registerEditModal,
|
|
|
- openAddModal,
|
|
|
- handleEdit,
|
|
|
- getCheckPerm,
|
|
|
- t,
|
|
|
- searchInfo,
|
|
|
- };
|
|
|
- },
|
|
|
-});
|
|
|
+ function tabChange(val: string) {
|
|
|
+ console.log('tabChange', val);
|
|
|
+ reload();
|
|
|
+ }
|
|
|
+ async function handleDelete(record: Recordable) {
|
|
|
+ console.log('点击了删除', record);
|
|
|
+ await DelAndUpload({ id: record.id });
|
|
|
+ createMessage.success(t('common.optSuccess'));
|
|
|
+ reload();
|
|
|
+ }
|
|
|
+ function handleOpen(record: Recordable) {
|
|
|
+ console.log('点击了启用', record);
|
|
|
+ }
|
|
|
+ function handleEdit(record: Recordable) {
|
|
|
+ console.log('record', record);
|
|
|
+ openEditModal(true, {
|
|
|
+ ...record,
|
|
|
+ type: searchInfo.type,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ registerTimeTable,
|
|
|
+ handleDelete,
|
|
|
+ handleOpen,
|
|
|
+ tabChange,
|
|
|
+ reload,
|
|
|
+ registerAddModal,
|
|
|
+ registerEditModal,
|
|
|
+ openAddModal,
|
|
|
+ handleEdit,
|
|
|
+ getCheckPerm,
|
|
|
+ t,
|
|
|
+ searchInfo,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ });
|
|
|
</script>
|
|
|
<style lang="less" scoped>
|
|
|
-.desc-wrap-BasicTable {
|
|
|
- background-color: #f0f2f5;
|
|
|
- .vben-basic-table-form-container {
|
|
|
- padding: 0;
|
|
|
+ .desc-wrap-BasicTable {
|
|
|
+ background-color: #f0f2f5;
|
|
|
+ .vben-basic-table-form-container {
|
|
|
+ padding: 0;
|
|
|
+ }
|
|
|
}
|
|
|
-}
|
|
|
</style>
|