Commit 318e0f452ef6e2c4cabde459acc9f1d56a705083

Authored by 杜志良
1 parent 32033702

feat(cas): 保养配置优化

src/pages/cas/afterSaleConfiguration/maintainConfig/api.ts
1 1 import { http } from '@/typing/http';
2 2 import request from '@/utils/request';
3   -import { CAS_HOST, OOP_HOST, PMS_HOST } from '@/utils/host';
  3 +import { CAS_HOST, OOP_HOST, PMS_HOST } from '@/utils/host'; // 列表
4 4  
5 5 // 列表
6 6 export function listApi(params: Maintain.ListParams): http.PromisePageResp<Maintain.ListVO> {
... ... @@ -57,8 +57,10 @@ export interface PartItem {
57 57 partNo?: string;
58 58 /**配件数量 */
59 59 partNumber?: number;
  60 +
60 61 [key: string]: any;
61 62 }
  63 +
62 64 export interface QueryParams {
63 65 current?: number;
64 66 pageSize?: number;
... ... @@ -70,3 +72,17 @@ export interface QueryParams {
70 72 export function getPartItems(params: QueryParams): PromisePageResp<PartItem> {
71 73 return request.get(`${PMS_HOST}/erp/part/list`, { params });
72 74 }
  75 +
  76 +export interface OilItem {
  77 + oilBrandId: number; // 机油品牌id
  78 + oilBrandName: string; // 机油品牌名称
  79 + oilModel: string; // 机油型号
  80 + oilViscosity: string; // 机油粘稠度
  81 + oilLevel: string; // 机油等级
  82 + motorOilType: string; // 机油类型
  83 +}
  84 +
  85 +/** 油料组合 */
  86 +export function oilGroupListApi(): http.PromiseResp<Maintain.OilGroup[]> {
  87 + return request.get(`${CAS_HOST}/erp/basic/maintenance/config/oil/combination`);
  88 +}
... ...
src/pages/cas/afterSaleConfiguration/maintainConfig/subpages/MaintainEdit/components/EngineOilSelector/components/OilSelector.tsx 0 → 100644
  1 +import React, { useState, useEffect } from 'react';
  2 +import { Modal, Table, Spin } from 'antd';
  3 +
  4 +import useInitail from '@/hooks/useInitail';
  5 +
  6 +import { oilGroupListApi } from '@/pages/cas/afterSaleConfiguration/maintainConfig/api';
  7 +import st from './style.less';
  8 +
  9 +const Column = Table.Column;
  10 +
  11 +interface Props {
  12 + visible: boolean;
  13 + confirming?: boolean;
  14 + onCancel: () => void;
  15 + onConfirm: (selectItems: Maintain.ItemListVO[]) => void;
  16 +}
  17 +
  18 +/**
  19 + * 油料选择器
  20 + * @onConfirm workItems:选中的油料
  21 + */
  22 +export default function OilSelector({ visible, confirming = false, onCancel, onConfirm }: Props) {
  23 + const [delay, setDelay] = useState(true);
  24 + const [selectItems, setSelectItems] = useState<Maintain.OilGroup[]>([]);
  25 +
  26 + const { data, loading, setParams } = useInitail(oilGroupListApi, [], undefined, delay);
  27 +
  28 + useEffect(() => {
  29 + if (visible) {
  30 + setDelay(false);
  31 + setParams(undefined, true);
  32 + }
  33 + }, [visible]);
  34 +
  35 + return (
  36 + <Modal
  37 + title="选择作机油"
  38 + width={780}
  39 + open={visible}
  40 + confirmLoading={confirming}
  41 + okButtonProps={{ disabled: selectItems.length === 0 }}
  42 + onOk={() => onConfirm(selectItems)}
  43 + onCancel={onCancel}
  44 + destroyOnClose
  45 + >
  46 + <Spin spinning={loading}>
  47 + <Table
  48 + loading={loading}
  49 + dataSource={data}
  50 + rowClassName={st.clickableRow}
  51 + rowKey="id"
  52 + rowSelection={{
  53 + type: 'checkbox',
  54 + selectedRowKeys: selectItems.map((si) => si.id) || [],
  55 + onChange: (selectedRowKeys, selectedRows: Maintain.ItemListVO[]) => {
  56 + setSelectItems(selectedRows);
  57 + },
  58 + }}
  59 + onRow={(record) => ({
  60 + onClick: () => {
  61 + if (selectItems.some((si) => si.id === record.id)) {
  62 + setSelectItems([...selectItems.filter((si) => si.id !== record.id)]);
  63 + } else {
  64 + setSelectItems([...selectItems, record]);
  65 + }
  66 + },
  67 + })}
  68 + >
  69 + <Column title="机油名称" dataIndex="oilBrandName" />
  70 + <Column title="型号" dataIndex="oilModel" />
  71 + <Column title="粘稠度" dataIndex="oilViscosity" />
  72 + <Column title="等级" dataIndex="oilLevel" />
  73 + <Column title="类型" dataIndex="motorOilType" />
  74 + </Table>
  75 + </Spin>
  76 + </Modal>
  77 + );
  78 +}
... ...
src/pages/cas/afterSaleConfiguration/maintainConfig/subpages/MaintainEdit/components/EngineOilSelector/components/style.less 0 → 100644
  1 +.clickableRow {
  2 + cursor: pointer;
  3 +}
0 4 \ No newline at end of file
... ...
src/pages/cas/afterSaleConfiguration/maintainConfig/subpages/MaintainEdit/components/EngineOilSelector/index.tsx
... ... @@ -6,6 +6,7 @@ import { SortableContainer, SortableElement, SortableHandle } from &#39;react-sortab
6 6 import { arrayMoveImmutable } from 'array-move';
7 7  
8 8 import NewOilModal from './components/NewOilModal';
  9 +import OilSelector from './components/OilSelector';
9 10 import OilData from './components/OilData';
10 11  
11 12 import './style.less';
... ... @@ -145,13 +146,21 @@ export default function EngineOilSelector(props: Props) {
145 146 )}
146 147 />
147 148 </Table>
148   - <NewOilModal
149   - selected={[...oilGroups]}
150   - onOk={_onOk}
  149 + {/*<NewOilModal*/}
  150 + {/* selected={[...oilGroups]}*/}
  151 + {/* onOk={_onOk}*/}
  152 + {/* visible={visible}*/}
  153 + {/* onCancel={() => setVisible(false)}*/}
  154 + {/* current={current}*/}
  155 + {/* setCurrent={setCurrent}*/}
  156 + {/*/>*/}
  157 + <OilSelector
151 158 visible={visible}
152 159 onCancel={() => setVisible(false)}
153   - current={current}
154   - setCurrent={setCurrent}
  160 + onConfirm={(selectOils) => {
  161 + console.log('log=>selectOils', selectOils);
  162 + setVisible(false);
  163 + }}
155 164 />
156 165 <OilData
157 166 visible={oilData.visible}
... ...