浏览代码

feat(api): 临时hack 接入数据

gemercheung 3 年之前
父节点
当前提交
cd04b72d55

+ 3 - 0
src/api/bulletin/model.ts

@@ -3,6 +3,9 @@ import { BasicPageParams, BasicFetchResult } from '/@/api/model/baseModel';
  * @description: Request list interface parameters
  */
 export type PageParams = BasicPageParams;
+export interface DeleteParams {
+  id: number;
+}
 
 export interface ListItem {
   id: number;

+ 46 - 3
src/api/bulletin/rent.ts

@@ -1,18 +1,61 @@
 import { defHttp } from '/@/utils/http/axios';
-import { PageParams, RentListGetResultModel } from './model';
+import { PageParams, RentListGetResultModel, DeleteParams } from './model';
 
 enum Api {
   selectHouseByType = '/zfb-api/zfb/house/selectHouseByType',
+  deleteHouse = '/zfb-api/zfb/house/deleteHouse',
 }
 
 /**
  * @description: Get sample list value
  */
 
-export const RentListApi = (params: PageParams) =>
+export const rentListApi = (params: PageParams) =>
   defHttp.post<RentListGetResultModel>({
     url: Api.selectHouseByType,
-    params,
+    params: {
+      type: 1,
+      ...params,
+    },
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
+
+export const sellListApi = (params: PageParams) =>
+  defHttp.post<RentListGetResultModel>({
+    url: Api.selectHouseByType,
+    params: {
+      type: 2,
+      ...params,
+    },
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
+
+export const decorationListApi = (params: PageParams) =>
+  defHttp.post<RentListGetResultModel>({
+    url: Api.selectHouseByType,
+    params: {
+      type: 0,
+      ...params,
+    },
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });
+
+export const commonDeleteApi = (params: DeleteParams) =>
+  defHttp.post<RentListGetResultModel>({
+    url: Api.deleteHouse,
+    params: {
+      type: 0,
+      ...params,
+    },
     headers: {
       // @ts-ignore
       ignoreCancelToken: true,

+ 19 - 8
src/views/dashboard/bulletin/decoration.vue

@@ -2,6 +2,9 @@
   <div class="p-4">
     <BasicTable @register="registerTable">
       <template #toolbar> </template>
+      <template #createTime="{ record }">
+        <Time :value="record.createTime" mode="datetime" />
+      </template>
       <template #action>
         <TableAction
           :actions="[
@@ -36,10 +39,11 @@
   // import { Tag } from 'ant-design-vue';
   import { h } from 'vue';
   import { Switch } from 'ant-design-vue';
-  import { RentListApi } from '/@/api/bulletin/rent';
-  // param type 0
+  import { decorationListApi } from '/@/api/bulletin/rent';
+  import { Time } from '/@/components/Time';
+  // param type 1
   export default defineComponent({
-    components: { BasicTable, TableAction },
+    components: { BasicTable, TableAction, Time },
     setup() {
       const { createMessage } = useMessage();
       const columns: BasicColumn[] = [
@@ -51,7 +55,8 @@
         },
         {
           title: '发布时间',
-          dataIndex: 'name',
+          dataIndex: 'createTime',
+          slots: { customRender: 'createTime' },
           width: 230,
         },
         {
@@ -61,7 +66,7 @@
         },
         {
           title: '发布账号',
-          dataIndex: 'phone',
+          dataIndex: 'userName',
           width: 120,
         },
         {
@@ -73,7 +78,7 @@
               record.pendingStatus = false;
             }
             return h(Switch, {
-              checked: record.state === '1',
+              checked: record.state === 0,
               checkedChildren: '已启用',
               unCheckedChildren: '已禁用',
               loading: false,
@@ -157,7 +162,7 @@
       // { getForm }
       const [registerTable] = useTable({
         title: '工地装修',
-        api: RentListApi,
+        api: decorationListApi,
         columns: columns,
         useSearchForm: true,
         formConfig: searchForm,
@@ -165,8 +170,14 @@
         tableSetting: { fullScreen: true },
         showIndexColumn: false,
         rowKey: 'id',
+        fetchSetting: {
+          pageField: 'pageNum',
+          sizeField: 'pageSize',
+          listField: 'list',
+          totalField: 'total',
+        },
       });
-      // pagination.value = { pageSize: 20 };
+
       return {
         registerTable,
         createMessage,

+ 32 - 12
src/views/dashboard/bulletin/rent.vue

@@ -2,7 +2,12 @@
   <div class="p-4">
     <BasicTable @register="registerTable">
       <template #toolbar> </template>
-      <template #action>
+
+      <template #createTime="{ record }">
+        <Time :value="record.createTime" mode="datetime" />
+      </template>
+
+      <template #action="{ record }">
         <TableAction
           :actions="[
             {
@@ -18,9 +23,7 @@
               label: '删除',
               popConfirm: {
                 title: '是否确认删除',
-                confirm: () => {
-                  createMessage.info(`暂未接入`);
-                },
+                confirm: handleDelete.bind(null, record),
               },
             },
           ]"
@@ -36,10 +39,11 @@
   // import { Tag } from 'ant-design-vue';
   import { h } from 'vue';
   import { Switch } from 'ant-design-vue';
-  import { RentListApi } from '/@/api/bulletin/rent';
+  import { rentListApi, commonDeleteApi } from '/@/api/bulletin/rent';
+  import { Time } from '/@/components/Time';
   // param type 2
   export default defineComponent({
-    components: { BasicTable, TableAction },
+    components: { BasicTable, TableAction, Time },
     setup() {
       const { createMessage } = useMessage();
       const columns: BasicColumn[] = [
@@ -51,7 +55,8 @@
         },
         {
           title: '发布时间',
-          dataIndex: 'name',
+          dataIndex: 'createTime',
+          slots: { customRender: 'createTime' },
           width: 230,
         },
         {
@@ -61,7 +66,7 @@
         },
         {
           title: '发布账号',
-          dataIndex: 'phone',
+          dataIndex: 'userName',
           width: 120,
         },
         {
@@ -73,7 +78,7 @@
               record.pendingStatus = false;
             }
             return h(Switch, {
-              checked: record.state === '1',
+              checked: record.state === 0,
               checkedChildren: '已启用',
               unCheckedChildren: '已禁用',
               loading: false,
@@ -137,7 +142,7 @@
             },
           },
           {
-            field: 'phone',
+            field: 'userName',
             label: '手机号',
             component: 'Input',
             colProps: {
@@ -157,7 +162,7 @@
       // { getForm }
       const [registerTable] = useTable({
         title: '出租信息',
-        api: RentListApi,
+        api: rentListApi,
         columns: columns,
         useSearchForm: true,
         formConfig: searchForm,
@@ -165,10 +170,25 @@
         tableSetting: { fullScreen: true },
         showIndexColumn: false,
         rowKey: 'id',
+        //TODO
+        fetchSetting: {
+          pageField: 'pageNum',
+          sizeField: 'pageSize',
+          listField: 'list',
+          totalField: 'total',
+        },
       });
-      // pagination.value = { pageSize: 20 };
+
+      async function handleDelete(record: Recordable) {
+        const data = await commonDeleteApi({
+          id: record.id,
+        });
+        console.log('data', data);
+      }
+
       return {
         registerTable,
+        handleDelete,
         createMessage,
       };
     },

+ 18 - 7
src/views/dashboard/bulletin/sell.vue

@@ -2,6 +2,9 @@
   <div class="p-4">
     <BasicTable @register="registerTable">
       <template #toolbar> </template>
+      <template #createTime="{ record }">
+        <Time :value="record.createTime" mode="datetime" />
+      </template>
       <template #action>
         <TableAction
           :actions="[
@@ -36,10 +39,11 @@
   // import { Tag } from 'ant-design-vue';
   import { h } from 'vue';
   import { Switch } from 'ant-design-vue';
-  import { RentListApi } from '/@/api/bulletin/rent';
+  import { sellListApi } from '/@/api/bulletin/rent';
+  import { Time } from '/@/components/Time';
   // param type 1
   export default defineComponent({
-    components: { BasicTable, TableAction },
+    components: { BasicTable, TableAction, Time },
     setup() {
       const { createMessage } = useMessage();
       const columns: BasicColumn[] = [
@@ -51,7 +55,8 @@
         },
         {
           title: '发布时间',
-          dataIndex: 'name',
+          dataIndex: 'createTime',
+          slots: { customRender: 'createTime' },
           width: 230,
         },
         {
@@ -61,7 +66,7 @@
         },
         {
           title: '发布账号',
-          dataIndex: 'phone',
+          dataIndex: 'userName',
           width: 120,
         },
         {
@@ -73,7 +78,7 @@
               record.pendingStatus = false;
             }
             return h(Switch, {
-              checked: record.state === '1',
+              checked: record.state === 0,
               checkedChildren: '已启用',
               unCheckedChildren: '已禁用',
               loading: false,
@@ -137,7 +142,7 @@
             },
           },
           {
-            field: 'phone',
+            field: 'userName',
             label: '手机号',
             component: 'Input',
             colProps: {
@@ -157,7 +162,7 @@
       // { getForm }
       const [registerTable] = useTable({
         title: '出售信息',
-        api: RentListApi,
+        api: sellListApi,
         columns: columns,
         useSearchForm: true,
         formConfig: searchForm,
@@ -165,6 +170,12 @@
         tableSetting: { fullScreen: true },
         showIndexColumn: false,
         rowKey: 'id',
+        fetchSetting: {
+          pageField: 'pageNum',
+          sizeField: 'pageSize',
+          listField: 'list',
+          totalField: 'total',
+        },
       });
       // pagination.value = { pageSize: 20 };
       return {