浏览代码

fix(compiler): 售后管理新增字段和导出功能

shylock 1 天之前
父节点
当前提交
bb6b5aec23

+ 2 - 2
src/pages/AfterSales/AfterSalesManagement/deviceStatusData.tsx

@@ -75,7 +75,7 @@ const DeviceStatusData: React.FC<editProps> = (props) => {
   return (
     <Modal
       title="24小时设备状态数据"
-      width={800}
+      width={1300}
       footer={null}
       open={visible}
       onCancel={() => {
@@ -87,7 +87,7 @@ const DeviceStatusData: React.FC<editProps> = (props) => {
         dataSource={params}
         rowKey={(record) => record.record_id}
         pagination={false}
-        scroll={{ y: 500 }}
+        scroll={{ y: 700 }}
       />
     </Modal>
   );

+ 44 - 7
src/pages/AfterSales/AfterSalesManagement/index.tsx

@@ -1,12 +1,13 @@
 import React, { useEffect, useState } from 'react';
 import { PageContainer } from '@ant-design/pro-components';
-import { Button, Card, Form, Input, Space, Table } from 'antd';
+import { Button, Card, Form, Input, message, Space, Table, Tag } from 'antd';
 import type { ColumnsType } from 'antd/es/table';
 import { queryDeviceOperations, queryDeviceOperationsData } from '@/services/afterSales/afterSales';
 import DeviceStatusData from './deviceStatusData';
 import DeviceHistory from '@/pages/AfterSales/AfterSalesManagement/deviceHistory';
-import { ReloadOutlined, SearchOutlined } from '@ant-design/icons';
+import { DownloadOutlined, ReloadOutlined, SearchOutlined } from '@ant-design/icons';
 import Overwrite from '@/pages/home/overwrite';
+import { queryAfterSalesExport } from '@/services/reportHome';
 
 interface DataType {
   home_name: string;
@@ -151,6 +152,25 @@ const BannerManagement: React.FC = () => {
     getList();
   };
 
+  // 导出
+  const onExport = () => {
+    form.validateFields().then((data) => {
+      queryAfterSalesExport(data)
+        .then((res: any) => {
+          const link = document.createElement('a');
+          link.style.display = 'none';
+          link.href = window.URL.createObjectURL(new Blob([res]));
+          link.setAttribute('download', '售后管理列表.xlsx');
+          document.body.appendChild(link);
+          link.click();
+          document.body.removeChild(link);
+        })
+        .catch(() => {
+          message.error('导出失败');
+        });
+    });
+  };
+
   const columns: ColumnsType<DataType> = [
     {
       title: '序号',
@@ -168,20 +188,33 @@ const BannerManagement: React.FC = () => {
       dataIndex: 'user_name',
       key: 'user_name',
     },
+    {
+      title: '手机号',
+      dataIndex: 'phone',
+      key: 'phone',
+    },
+    {
+      title: '地区',
+      dataIndex: 'address',
+      key: 'address',
+    },
     {
       title: '设备编号',
       dataIndex: 'device_code',
       key: 'device_code',
     },
+    {
+      title: '设备类型',
+      dataIndex: 'device_type_name',
+      key: 'device_type_name',
+    },
     {
       title: '是否在线',
       dataIndex: 'is_online',
       key: 'is_online',
       render: (_, record: any) => {
         return (
-          <span style={{ color: record.is_online ? 'green' : 'red' }}>
-            {record.is_online ? '在线' : '离线'}
-          </span>
+          <Tag color={record.is_online ? 'green' : 'red'}>{record.is_online ? '在线' : '离线'}</Tag>
         );
       },
     },
@@ -191,9 +224,9 @@ const BannerManagement: React.FC = () => {
       key: 'power',
       render: (_, record: any) => {
         return (
-          <span style={{ color: `${{ 0: 'red', 1: 'green' }[record.power]}` }}>
+          <Tag color={{ 0: 'red', 1: 'green' }[record.power]}>
             {{ 0: '关', 1: '开' }[record.power]}
-          </span>
+          </Tag>
         );
       },
     },
@@ -299,6 +332,10 @@ const BannerManagement: React.FC = () => {
                 <ReloadOutlined />
                 重置
               </Button>
+              <Button type="dashed" onClick={onExport}>
+                <DownloadOutlined />
+                导出
+              </Button>
             </Space>
           </Form.Item>
         </Form>

+ 85 - 20
src/pages/SceneManagement/index.tsx

@@ -1,9 +1,10 @@
-import React, { useEffect, useState } from 'react';
+import React, { useCallback, useEffect, useState } from 'react';
 import { PageContainer } from '@ant-design/pro-components';
-import { Card, Space, Table } from 'antd';
+import { Button, Card, Form, Input, Space, Table, Select, Tag } from 'antd';
 import type { ColumnsType } from 'antd/es/table';
 import { queryScenes } from '@/services/scene';
 import SceneHistory from '@/pages/SceneManagement/sceneHistory';
+import { ReloadOutlined, SearchOutlined } from '@ant-design/icons';
 
 interface DataType {
   name: string;
@@ -19,51 +20,60 @@ interface DataType {
  * @constructor
  */
 const SceneManagement: React.FC = () => {
+  const [form] = Form.useForm();
   const [loading, setLoading] = useState(false);
   const [pagination, setPagination] = useState({ total: 0, current: 1, pageSize: 10 });
+  const { current, pageSize } = pagination;
   const [dataList, setDataList] = useState([]);
   const [visible, setVisible] = useState(false);
   const [recordId, setRecordId] = useState('');
   const weekArray = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
+  const [searchData, setSearchData] = useState<object | null>({});
 
   // 获取列表数据
-  const getList = () => {
+  const getList = useCallback(() => {
+    setLoading(true);
     const params = {
       q: 'page',
-      current: pagination.current,
-      pageSize: pagination.pageSize,
+      current,
+      pageSize,
+      ...(searchData || {}),
     };
     queryScenes(params).then((res) => {
       if (res && res.code === 0) {
         setDataList(res.data.list);
         setPagination(res.data.pagination);
-        setLoading(false);
       }
+      setLoading(false);
     });
-  };
+  }, [current, pageSize, searchData]);
 
   useEffect(() => {
-    setLoading(true);
     getList();
-  }, []);
+  }, [getList]);
 
   // 分页切换
   const tableChange = (page: any) => {
-    setLoading(true);
-    const params = {
-      q: 'page',
+    setPagination((prev) => ({
+      ...prev,
       current: page.current,
       pageSize: page.pageSize,
-    };
-    queryScenes(params).then((res) => {
-      if (res && res.code === 0) {
-        setDataList(res.data.list);
-        setPagination(res.data.pagination);
-        setLoading(false);
-      }
+    }));
+  };
+
+  // 搜索
+  const onFinish = () => {
+    form.validateFields().then((data) => {
+      setSearchData(data);
     });
   };
 
+  // 搜索重置
+  const onReset = () => {
+    form.resetFields();
+    setSearchData(null);
+  };
+
   // 跳转到历史记录弹框中
   const toHistory = (record: any) => {
     setVisible(true);
@@ -110,7 +120,7 @@ const SceneManagement: React.FC = () => {
       render: (_: any, row: any, index: number) => index + 1,
     },
     {
-      title: '房间名称',
+      title: '家庭名称',
       dataIndex: 'home_name',
       key: 'home_name',
       width: 250,
@@ -206,6 +216,15 @@ const SceneManagement: React.FC = () => {
         return <span>{{ or: '满足任一条件', and: '满足所有条件' }[v]}</span>;
       },
     },
+    {
+      title: '启用状态',
+      dataIndex: 'status',
+      key: 'status',
+      width: 250,
+      render: (v: string | number | boolean) => (
+        <Tag color={v ? 'green' : 'red'}>{v ? '启用' : '未启用'}</Tag>
+      ),
+    },
     {
       title: '创建者',
       dataIndex: 'creator_name',
@@ -241,6 +260,52 @@ const SceneManagement: React.FC = () => {
     <PageContainer>
       <div>
         <Card>
+          <Form form={form} layout="inline" onFinish={onFinish}>
+            <Form.Item name="home_name" label="家庭名称">
+              <Input placeholder="请输入家庭名称" />
+            </Form.Item>
+            <Form.Item name="name" label="场景名称">
+              <Input placeholder="请输入场景名称" />
+            </Form.Item>
+            <Form.Item name="type_code" label="场景类型">
+              <Select style={{ width: '175px' }} placeholder="请选择场景类型">
+                <Select.Option key={1} value={'oneKey'}>
+                  一键执行
+                </Select.Option>
+                <Select.Option key={2} value={'timer'}>
+                  定时
+                </Select.Option>
+                <Select.Option key={3} value={'weather'}>
+                  气象变化时
+                </Select.Option>
+                <Select.Option key={4} value={'device_status'}>
+                  设备变化时
+                </Select.Option>
+              </Select>
+            </Form.Item>
+            <Form.Item name="status" label="启用状态">
+              <Select style={{ width: '175px' }} placeholder="请选择启用状态">
+                <Select.Option key={1} value={1}>
+                  启用
+                </Select.Option>
+                <Select.Option key={2} value={2}>
+                  未启用
+                </Select.Option>
+              </Select>
+            </Form.Item>
+            <Form.Item style={{ marginBottom: '10px' }}>
+              <Space>
+                <Button type="primary" htmlType="submit">
+                  <SearchOutlined />
+                  查询
+                </Button>
+                <Button htmlType="button" onClick={onReset}>
+                  <ReloadOutlined />
+                  重置
+                </Button>
+              </Space>
+            </Form.Item>
+          </Form>
           <Table
             columns={columns}
             dataSource={dataList}

+ 0 - 5
src/pages/SceneManagement/sceneHistory.tsx

@@ -91,11 +91,6 @@ const SceneHistory: React.FC<editPros> = (props) => {
       dataIndex: 'trigger_condition',
       key: 'trigger_condition',
     },
-    {
-      title: '执行动作',
-      dataIndex: 'action',
-      key: 'action',
-    },
     {
       title: '执行结果',
       dataIndex: 'result',

+ 0 - 1
src/services/afterSales/afterSalesSupport.ts

@@ -22,7 +22,6 @@ export async function queryAfterSalesSupportDetail(record_id: string) {
  * @param params
  */
 export async function queryExport(params: any) {
-  console.log('params', params);
   return request(`/web/v1/after_sales/export?${stringify(params)}`, {
     method: 'GET',
     responseType: 'blob',

+ 12 - 2
src/services/reportHome.ts

@@ -60,13 +60,23 @@ export async function queryReportHomeDetail(id: string) {
 }
 
 /**
- * 导出
+ * 售后支持管理导出
  * @param params
  */
 export async function queryExport(params: any) {
-  console.log('params', params);
   return request(`/web/v1/reports/export?${stringify(params)}`, {
     method: 'GET',
     responseType: 'blob',
   });
 }
+
+/**
+ * 售后管理导出
+ * @param params
+ */
+export async function queryAfterSalesExport(params: any) {
+  return request(`/web/v1/device_operations/export?${stringify(params)}`, {
+    method: 'GET',
+    responseType: 'blob',
+  });
+}