Browse Source

fix(login): 登录模块

tangning 3 years ago
parent
commit
fd91ab5981

+ 62 - 2
src/api/product/index.ts

@@ -7,7 +7,12 @@ enum Api {
   cameraVersionList = '/newV4/service/manage/cameraVersion/list',
   upload = '/newV4/service/manage/common/upload/files',
   spaceSdkList = '/newV4/service/manage/spaceSdk/list',
+  spaceSdkUpdate = '/newV4/service/manage/spaceSdk/update',
+  spaceSdkOnline = '/newV4/service/manage/spaceSdk/online',
+  spaceSdkTop = '/newV4/service/manage/spaceSdk/top',
+  spaceSdkDel = '/newV4/service/manage/spaceSdk/delete',
   addAndUpload = '/newV4/service/manage/cameraVersion/addAndUpload',
+  editAndUpload = '/newV4/service/manage/cameraVersion/update',
 }
 
 /**
@@ -25,6 +30,9 @@ export const CameraList = (params: PageParams) =>
     },
   });
 
+/**
+ * @description: 新增固件
+ */
 export const AddAndUpload = (params: PageParams) =>{
   return defHttp.uploadFile<Result>(
     {
@@ -34,11 +42,39 @@ export const AddAndUpload = (params: PageParams) =>{
     params
   );
 }
+/**
+ * @description: 编辑固件
+ */
+
+export const EditAndUpload = (params: PageParams) =>
+defHttp.post<Result>({
+  url: Api.editAndUpload,
+  params,
+  // data: params,
+  headers: {
+    // @ts-ignore
+    ignoreCancelToken: true,
+  },
+});
 
 
-export const SpaceSdkList = (params: PageParams) =>
+/**
+ * @description: 编辑固件
+ */
+ export const DelAndUpload = (params: PageParams) =>
+ defHttp.post<Result>({
+   url: Api.editAndUpload,
+   params,
+   // data: params,
+   headers: {
+     // @ts-ignore
+     ignoreCancelToken: true,
+   },
+ });
+
+export const SpaceSdkOnline = (params: PageParams) =>
   defHttp.post<Result>({
-    url: Api.spaceSdkList,
+    url: Api.spaceSdkOnline,
     params: params,
     // data: params,
     headers: {
@@ -47,6 +83,30 @@ export const SpaceSdkList = (params: PageParams) =>
     },
   });
 
+export const SpaceSdkUpdate = (params: PageParams) =>
+  defHttp.post<Result>({
+    url: Api.spaceSdkUpdate,
+    params: params,
+    // data: params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
+
+/**
+ * @description: SDK list
+ */
+ export const SpaceSdkList = (params: PageParams) =>
+ defHttp.post<Result>({
+   url: Api.spaceSdkList,
+   params,
+   // data: params,
+   headers: {
+     // @ts-ignore
+     ignoreCancelToken: true,
+   },
+ });
 
 export function uploadApi(
   params: UploadFileParams,

+ 2 - 2
src/utils/http/axios/index.ts

@@ -52,9 +52,9 @@ const transform: AxiosTransform = {
 
     // 这里逻辑可以根据项目进行修改
     const hasSuccess = data && Reflect.has(data, 'code') && code === ResultEnum.SUCCESS;
-    console.log('hasSuccess',hasSuccess)
+    console.log('hasSuccess',hasSuccess,code,'data',data)
     if (hasSuccess) {
-      return result || data.data;
+      return result ||  data.data;
     }
 
     // 在此处根据自己项目的实际情况对不同的code执行不同的操作

+ 12 - 6
src/views/product/EditModal.vue

@@ -21,7 +21,7 @@
   import { BasicModal, useModalInner } from '/@/components/Modal';
   import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
   import { useMessage } from '/@/hooks/web/useMessage';
-  import { uploadApi, AddAndUpload } from '/@/api/product/index';
+  import { EditAndUpload, } from '/@/api/product/index';
   import { useI18n } from '/@/hooks/web/useI18n';
 
   const { t } = useI18n();
@@ -39,6 +39,15 @@
       const { createMessage } = useMessage();
       const schemas: FormSchema[] = [
         {
+          field: 'id',
+          component: 'Input',
+          label: t('routes.product.types'),
+          ifShow:false,
+          colProps: {
+            span: 24,
+          },
+          // required: true,
+        },{
           field: 'type',
           component: 'Input',
           label: t('routes.product.types'),
@@ -193,14 +202,11 @@
         try {
           const params = await validate();
           const apiData = {
-            data:{
             ...params as any,
-            type:modelRef.value,
-            file:fileFlow.file,
-            }
+            ...modelRef.value,
           }
           console.log('res', apiData);
-          const res = await AddAndUpload(apiData);
+          const res = await EditAndUpload(apiData);
           console.log('res', res);
           closeModal();
           resetFields();

+ 7 - 5
src/views/product/data.tsx

@@ -4,6 +4,7 @@ import { Time } from '/@/components/Time';
 import { useMessage } from '/@/hooks/web/useMessage';
 import { useI18n } from '/@/hooks/web/useI18n';
 import { Switch } from 'ant-design-vue';
+import { EditAndUpload, } from '/@/api/product/index';
 const { createMessage } = useMessage();
 const { t } = useI18n();
 
@@ -41,24 +42,25 @@ export const refundTimeTableSchema: BasicColumn[] = [
     },
   },{
     title: '状态',
-    dataIndex: 'isOnSale',
+    dataIndex: 'status',
     width: 80,
     customRender: ({ record }) => {
       if (!Reflect.has(record, 'pendingStatus')) {
         record.pendingStatus = false;
       }
       return h(Switch, {
-        checked: record.isOnSale === 1,
+        checked: record.status === 'A',
         checkedChildren: '启用',
         unCheckedChildren: '禁用',
         loading: false,
         onChange: async (checked: boolean) => {
           record.pendingStatus = true;
-          const newStatus = checked ? 1 : 0;
+          const newStatus = checked ? 'A' : 'I';
+          await EditAndUpload({...record,status:newStatus});
           if (checked) {
-            Reflect.set(record, 'isOnSale', newStatus);
+            Reflect.set(record, 'status', newStatus);
           } else {
-            Reflect.set(record, 'isOnSale', newStatus);
+            Reflect.set(record, 'status', newStatus);
           }
           createMessage.success(t('common.optSuccess'));
         },

+ 266 - 0
src/views/product/firmware/AddModal.vue

@@ -0,0 +1,266 @@
+<template>
+  <BasicModal
+    v-bind="$attrs"
+    @register="register"
+    title="新增相机"
+    @visible-change="handleVisibleChange"
+    @cancel="resetFields"
+    @ok="handleSubmit"
+  >
+    <div class="pt-2px pr-3px">
+      <BasicForm @register="registerForm" :model="model" >
+        <template #text="{ model, field }">
+          {{ model[field]  }}
+        </template>
+      </BasicForm>
+    </div>
+  </BasicModal>
+</template>
+<script lang="ts">
+  import { defineComponent, ref, nextTick, onMounted, reactive } from 'vue';
+  import { BasicModal, useModalInner } from '/@/components/Modal';
+  import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import { uploadApi, AddAndUpload } from '/@/api/product/index';
+  import { useI18n } from '/@/hooks/web/useI18n';
+
+  const { t } = useI18n();
+  export default defineComponent({
+    components: { BasicModal, BasicForm },
+    props: {
+      userData: { type: Object },
+    },
+    emits: ['update', 'register'],
+    setup(props, { emit }) {
+      const modelRef = ref({});
+      const fileFlow = reactive({
+        file:null
+      })
+      const { createMessage } = useMessage();
+      const schemas: FormSchema[] = [
+        {
+          field: 'type',
+          component: 'Input',
+          label: t('routes.product.types'),
+          slot: 'text',
+          colProps: {
+            span: 24,
+          },
+          // required: true,
+        },
+        {
+          field: 'version',
+          component: 'Input',
+          label: t('routes.product.version'),
+          required: true,
+          colProps: {
+            span: 24,
+          },
+          rules: [
+            {
+              required: true,
+              // @ts-ignore
+              validator: async (rule, value) => {
+                if (!value) {
+                  return Promise.reject(t('common.inputText')+t('routes.product.version'));
+                }
+                if(/.*[\u4e00-\u9fa5]+.*$/.test(value)){
+                  /* eslint-disable-next-line */
+                  return Promise.reject('不支持中文字符');
+                }
+                return Promise.resolve();
+              },
+              trigger: 'change',
+            },
+          ],
+          componentProps: {
+            maxLength: 15,
+            onChange: (data) => {
+              console.log('data', data);
+            },
+          },
+        },
+        {
+          field: 'minVersion',
+          component: 'Input',
+          label: t('routes.product.minVersion'),
+          required: true,
+          rules: [
+            {
+              required: true,
+              // @ts-ignore
+              validator: async (rule, value) => {
+                const regPos = /.*[\u4e00-\u9fa5]+.*$/; // 非中文
+                if (!value) {
+                  return Promise.reject(t('common.inputText')+t('routes.product.minVersion'));
+                }
+                if (regPos.test(value)) {
+                  /* eslint-disable-next-line */
+                  return Promise.reject('不支持中文字符');
+                }
+                return Promise.resolve();
+              },
+              trigger: 'change',
+            },
+          ],
+          colProps: {
+            span: 24,
+          },
+        },
+        {
+          field: 'description',
+          component: 'InputTextArea',
+          required: true,
+          label: t('routes.product.description'),
+          colProps: {
+            span: 24,
+          },
+        },
+        {
+          field: 'file',
+          component: 'Upload',
+          label: t('routes.product.file'),
+          required: true,
+          rules: [{ required: true, message: t('common.uploadMessge') }],
+          // helpMessage: t('routes.corporation.uploadHelp'),
+          itemProps: {
+            validateTrigger: 'onBlur',
+          },
+          componentProps: {
+            api: uploadApi,
+            maxNumber: 1,
+            maxSize: 1000,
+            fileFlow:true,
+            accept: ['4dage'],
+            afterFetch: function (data) {
+              console.log('uploadApi',data)
+              Reflect.set(data, 'url', data.file);
+              fileFlow.file = data.file
+              return data;
+            },
+          },
+
+          colProps: {
+            span: 22,
+          },
+        },
+        // {
+        //   field: 'orderSn',
+        //   component: 'Input',
+        //   label: t('routes.devices.orderSn'),
+        //   colProps: {
+        //     span: 24,
+        //   },
+        // },
+        // {
+        //   field: 'companyId',
+        //   component: 'ApiSelect',
+        //   label: t('routes.devices.companyId'),
+        //   itemProps: {
+        //     validateTrigger: 'blur',
+        //   },
+        //   componentProps: {
+        //     api: allCompanyApi,
+        //     numberToString: true,
+        //     labelField: 'name',
+        //     valueField: 'id',
+        //     immediate: true,
+        //     params: {
+        //       page: 1,
+        //       limit: 1000,
+        //     },
+        //   },
+        //   colProps: {
+        //     span: 24,
+        //   },
+        // },
+      ];
+      const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({
+        labelWidth: 120,
+        schemas,
+        showActionButtonGroup: false,
+        actionColOptions: {
+          span: 24,
+        },
+      });
+      onMounted(() => {});
+      let addListFunc = () => {};
+      const [register, { closeModal }] = useModalInner((data) => {
+        data && onDataReceive(data);
+      });
+      function renderOwnTypeLabel(type: number): string {
+        switch (type) {
+          case 2:
+            return t('routes.product.type.2');
+          case 1:
+            return t('routes.product.type.1');
+          case 3:
+            return t('routes.product.type.3');
+          default:
+            return '';
+        }
+      }
+      function rendercameraTypeLabel(cameraType: number): string {
+        switch (cameraType) {
+          case 4:
+            return t('routes.devices.cameraName.4');
+          case 1:
+            return t('routes.devices.cameraName.1');
+          case 9:
+            return t('routes.devices.cameraName.9');
+          case 10:
+            return t('routes.devices.cameraName.10');
+          case 6:
+            return t('routes.devices.cameraName.6');
+          default:
+            return '';
+        }
+      }
+      function onDataReceive(data) {
+        modelRef.value = data
+        resetFields();
+        setFieldsValue({
+          type:renderOwnTypeLabel(Number(data)),
+        });
+      }
+      const handleSubmit = async () => {
+        try {
+          const params = await validate();
+          const apiData = {
+            data:{
+            ...params as any,
+            type:modelRef.value,
+            file:fileFlow.file,
+            }
+          }
+          console.log('res', apiData);
+          const res = await AddAndUpload(apiData);
+          console.log('res', res);
+          closeModal();
+          resetFields();
+          createMessage.success(t('common.optSuccess'));
+          emit('update');
+        } catch (error) {
+          console.log('not passing', error);
+        }
+      };
+      function handleVisibleChange(v) {
+        v && props.userData && nextTick(() => onDataReceive(props.userData));
+      }
+      return {
+        register,
+        rendercameraTypeLabel,
+        renderOwnTypeLabel,
+        schemas,
+        registerForm,
+        model: modelRef,
+        fileFlow,
+        handleVisibleChange,
+        handleSubmit,
+        addListFunc,
+        resetFields,
+        t,
+      };
+    },
+  });
+</script>

+ 246 - 0
src/views/product/firmware/EditModal.vue

@@ -0,0 +1,246 @@
+<template>
+  <BasicModal
+    v-bind="$attrs"
+    @register="register"
+    title="编辑相机"
+    @visible-change="handleVisibleChange"
+    @cancel="resetFields"
+    @ok="handleSubmit"
+  >
+    <div class="pt-2px pr-3px">
+      <BasicForm @register="registerForm" :model="model" >
+        <template #text="{ model, field }">
+          {{ model[field]  }}
+        </template>
+      </BasicForm>
+    </div>
+  </BasicModal>
+</template>
+<script lang="ts">
+  import { defineComponent, ref, nextTick, onMounted, reactive } from 'vue';
+  import { BasicModal, useModalInner } from '/@/components/Modal';
+  import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import { EditAndUpload, } from '/@/api/product/index';
+  import { useI18n } from '/@/hooks/web/useI18n';
+
+  const { t } = useI18n();
+  export default defineComponent({
+    components: { BasicModal, BasicForm },
+    props: {
+      userData: { type: Object },
+    },
+    emits: ['update', 'register'],
+    setup(props, { emit }) {
+      const modelRef = ref({});
+      const fileFlow = reactive({
+        file:null
+      })
+      const { createMessage } = useMessage();
+      const schemas: FormSchema[] = [
+        {
+          field: 'id',
+          component: 'Input',
+          label: t('routes.product.types'),
+          show: false,
+          colProps: {
+            span: 24,
+          },
+        },{
+          field: 'type',
+          component: 'Input',
+          label: t('routes.product.types'),
+          show: false,
+          colProps: {
+            span: 24,
+          },
+        },{
+          field: 'name',
+          component: 'Input',
+          label: t('routes.product.types'),
+          slot: 'text',
+          colProps: {
+            span: 24,
+          },
+          // required: true,
+        },
+        {
+          field: 'version',
+          component: 'Input',
+          label: t('routes.product.version'),
+          required: true,
+          colProps: {
+            span: 24,
+          },
+          rules: [
+            {
+              required: true,
+              // @ts-ignore
+              validator: async (rule, value) => {
+                if (!value) {
+                  return Promise.reject(t('common.inputText')+t('routes.product.version'));
+                }
+                if(/.*[\u4e00-\u9fa5]+.*$/.test(value)){
+                  /* eslint-disable-next-line */
+                  return Promise.reject('不支持中文字符');
+                }
+                return Promise.resolve();
+              },
+              trigger: 'change',
+            },
+          ],
+          componentProps: {
+            maxLength: 15,
+            onChange: (data) => {
+              console.log('data', data);
+            },
+          },
+        },
+        {
+          field: 'minVersion',
+          component: 'Input',
+          label: t('routes.product.minVersion'),
+          required: true,
+          rules: [
+            {
+              required: true,
+              // @ts-ignore
+              validator: async (rule, value) => {
+                const regPos = /.*[\u4e00-\u9fa5]+.*$/; // 非中文
+                if (!value) {
+                  return Promise.reject(t('common.inputText')+t('routes.product.minVersion'));
+                }
+                if (regPos.test(value)) {
+                  /* eslint-disable-next-line */
+                  return Promise.reject('不支持中文字符');
+                }
+                return Promise.resolve();
+              },
+              trigger: 'change',
+            },
+          ],
+          colProps: {
+            span: 24,
+          },
+        },
+        {
+          field: 'description',
+          component: 'InputTextArea',
+          required: true,
+          label: t('routes.product.description'),
+          colProps: {
+            span: 24,
+          },
+        },
+        // {
+        //   field: 'file',
+        //   component: 'Upload',
+        //   label: t('routes.product.file'),
+        //   required: true,
+        //   rules: [{ required: true, message: t('common.uploadMessge') }],
+        //   itemProps: {
+        //     validateTrigger: 'onBlur',
+        //   },
+        //   componentProps: {
+        //     api: uploadApi,
+        //     maxNumber: 1,
+        //     maxSize: 1000,
+        //     fileFlow:true,
+        //     accept: ['4dage'],
+        //     afterFetch: function (data) {
+        //       console.log('uploadApi',data)
+        //       Reflect.set(data, 'url', data.file);
+        //       fileFlow.file = data.file
+        //       return data;
+        //     },
+        //   },
+      ];
+      const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({
+        labelWidth: 120,
+        schemas,
+        showActionButtonGroup: false,
+        actionColOptions: {
+          span: 24,
+        },
+      });
+      onMounted(() => {});
+      let addListFunc = () => {};
+      const [register, { closeModal }] = useModalInner((data) => {
+        data && onDataReceive(data);
+      });
+      function renderOwnTypeLabel(type: number): string {
+        switch (type) {
+          case 2:
+            return t('routes.product.type.2');
+          case 1:
+            return t('routes.product.type.1');
+          case 3:
+            return t('routes.product.type.3');
+          default:
+            return '';
+        }
+      }
+      function rendercameraTypeLabel(cameraType: number): string {
+        switch (cameraType) {
+          case 4:
+            return t('routes.devices.cameraName.4');
+          case 1:
+            return t('routes.devices.cameraName.1');
+          case 9:
+            return t('routes.devices.cameraName.9');
+          case 10:
+            return t('routes.devices.cameraName.10');
+          case 6:
+            return t('routes.devices.cameraName.6');
+          default:
+            return '';
+        }
+      }
+      function onDataReceive(data) {
+        modelRef.value = data
+        console.log('onDataReceive',data)
+        resetFields();
+        setFieldsValue({
+          ...data,
+          type:renderOwnTypeLabel(Number(data.type)),
+        });
+      }
+      const handleSubmit = async () => {
+        try {
+          const params = await validate();
+          console.log('modelRef',params)
+          const apiData = {
+            // ...modelRef.value,
+            ...params as any,
+          }
+          console.log('res', apiData);
+          const res = await EditAndUpload(apiData);
+          console.log('res', res);
+          closeModal();
+          resetFields();
+          createMessage.success(t('common.optSuccess'));
+          emit('update');
+        } catch (error) {
+          console.log('not passing', error);
+        }
+      };
+      function handleVisibleChange(v) {
+        v && props.userData && nextTick(() => onDataReceive(props.userData));
+      }
+      return {
+        register,
+        rendercameraTypeLabel,
+        renderOwnTypeLabel,
+        schemas,
+        registerForm,
+        model: modelRef,
+        fileFlow,
+        handleVisibleChange,
+        handleSubmit,
+        addListFunc,
+        resetFields,
+        t,
+      };
+    },
+  });
+</script>

+ 195 - 116
src/views/product/firmware/index.vue

@@ -8,13 +8,19 @@
       </a-tabs>
     </template>
     <div class="desc-wrap-BasicTable">
-      <BasicTable @register="registerTimeTable" >
+      <BasicTable @register="registerTimeTable">
         <template #toolbar>
-          <a-button type="primary" @click="()=>{openAddModal(true,searchInfo.type)}">{{
-            t('routes.product.addVstive')
-          }}</a-button>
-      </template>
-      <template #action="{ record }">
+          <a-button
+            type="primary"
+            @click="
+              () => {
+                openAddModal(true, searchInfo.type);
+              }
+            "
+            >{{ t('routes.product.addVstive') }}</a-button
+          >
+        </template>
+        <template #action="{ record }">
           <TableAction
             :actions="[
               {
@@ -25,11 +31,14 @@
               {
                 label: '删除',
                 icon: 'ic:outline-delete-outline',
-                onClick: handleDelete.bind(null, record),
+                popConfirm: {
+                  title: '是否确认删除',
+                  confirm: handleDelete.bind(null, record),
+                },
               },
             ]"
           />
-      </template>
+        </template>
       </BasicTable>
     </div>
     <AddModal @update="reload" @register="registerAddModal" />
@@ -37,122 +46,192 @@
   </PageWrapper>
 </template>
 <script lang="ts">
-  import { defineComponent,reactive } from 'vue';
-  import { BasicTable, useTable, FormProps,TableAction } from '/@/components/Table';
-  import { PageWrapper } from '/@/components/Page';
-  import { Divider, Card, Empty, Descriptions, Steps, Tabs } from 'ant-design-vue';
-  import { CameraList } from '/@/api/product'
-  import { useModal } from '/@/components/Modal';
-  import { refundTimeTableSchema } from '../data';
-  import { useI18n } from '/@/hooks/web/useI18n';
-  import AddModal from '../AddModal.vue';
-  import EditModal from '../EditModal.vue';
+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';
+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 searchInfo = reactive<Recordable>({
+      type: '1',
+    });
+    const [registerAddModal, { openModal: openAddModal }] = useModal();
+    const [registerEditModal, { openModal: openEditModal }] = useModal();
+    const { createMessage } = useMessage();
 
-  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 searchInfo = reactive<Recordable>({
-        type:'1'
-      });
-      const [registerAddModal, { openModal: openAddModal }] = useModal();
-      const [registerEditModal, { openModal: openEditModal }] = useModal();
-      const searchForm: Partial<FormProps> = {
-        labelWidth: 100,
-        schemas: [
-          {
-            field: 'version',
-            label: '版本号',
-            component: 'Input',
-            componentProps: {
-              maxLength: 100,
-            },
-            colProps: {
-              xl: 6,
-              xxl: 6,
-            },
+    const refundTimeTableSchema: BasicColumn[] = [
+      {
+        title: '版本号',
+        width: 150,
+        dataIndex: 'version',
+      },
+      {
+        title: '版本更新说明',
+        width: 150,
+        dataIndex: 'description',
+      },
+      {
+        title: '最低版本号',
+        width: 150,
+        dataIndex: 'minVersion',
+      },
+      {
+        title: '创建人',
+        width: 150,
+        dataIndex: 'recStatus',
+      },
+      {
+        title: '创建时间',
+        width: 150,
+        dataIndex: 'createTime',
+        customRender: ({ record }) => {
+          return (
+            record.createTime &&
+            h(Time, {
+              value: record.createTime,
+              mode: 'datetime',
+            })
+          );
+        },
+      },
+      {
+        title: '状态',
+        dataIndex: 'status',
+        width: 80,
+        customRender: ({ record }) => {
+          if (!Reflect.has(record, 'pendingStatus')) {
+            record.pendingStatus = false;
           }
-        ],
-      };
-      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',
+          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'));
+            },
+          });
         },
-        searchInfo:searchInfo,
-        // beforeFetch:(T)=>{
-        //   T.type = searchInfo.type
-        //   console.log('beforeFetch',T,searchInfo)
-        //   return T
-        // },
-        actionColumn: {
-          width: 180,
-          title: '操作',
-          dataIndex: 'action',
-          slots: { customRender: 'action' },
+      },
+    ];
+    const searchForm: Partial<FormProps> = {
+      labelWidth: 100,
+      schemas: [
+        {
+          field: 'version',
+          label: '版本号',
+          component: 'Input',
+          componentProps: {
+            maxLength: 100,
+          },
+          colProps: {
+            xl: 6,
+            xxl: 6,
+          },
         },
-        canResize: false,
+      ],
+    };
+    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: false,
+    });
+    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,
       });
-      function tabChange(val:string){
-        console.log('tabChange',val)
-        reload()
-      }
-      function handleDelete(record: Recordable) {
-        console.log('点击了删除', record);
-      }
-      function handleOpen(record: Recordable) {
-        console.log('点击了启用', record);
-      }
-      function handleEdit(record: Recordable) {
-        console.log('record', record);
-        openEditModal(true, {
-          ...record
-        });
-      }
-      return {
-        registerTimeTable,
-        handleDelete,
-        handleOpen,
-        tabChange,
-        reload,
-        registerAddModal,
-        registerEditModal,
-        openAddModal,
-        handleEdit,
-        t,
-        searchInfo,
-      };
-    },
-  });
+    }
+    return {
+      registerTimeTable,
+      handleDelete,
+      handleOpen,
+      tabChange,
+      reload,
+      registerAddModal,
+      registerEditModal,
+      openAddModal,
+      handleEdit,
+      t,
+      searchInfo,
+    };
+  },
+});
 </script>
 <style lang="less" scoped>
-.desc-wrap-BasicTable{
+.desc-wrap-BasicTable {
   background-color: #f0f2f5;
-  .vben-basic-table-form-container{
+  .vben-basic-table-form-container {
     padding: 0;
   }
 }

+ 1 - 0
src/views/product/sdk/index.vue

@@ -31,6 +31,7 @@
   import { useI18n } from '/@/hooks/web/useI18n';
   import { useMessage } from '/@/hooks/web/useMessage';
   import { InvoiceList,DownExport } from '/@/api/order'
+  import { SpaceSdkList, DelAndUpload } from '/@/api/product';
 
   export default defineComponent({
     components: {