import { PlusOutlined } from '@ant-design/icons'; import { ActionType, ProColumns, ProFormInstance, ProFormSelect, ProFormText, ProFormUploadButton, ProFormDependency, } from '@ant-design/pro-components'; import { ModalForm, PageContainer, ProTable } from '@ant-design/pro-components'; import '@umijs/max'; import { Button, message } from 'antd'; import { Select } from 'antd'; import { createStyles } from 'antd-style'; import dayjs from 'dayjs'; import React, { useEffect, useMemo, useRef, useState } from 'react'; import { CITY_OPTIONS } from '@/constants/city'; import { TIME_FORMAT } from '@/constants/global'; import { uploadFileWx } from '@/services/file'; import { deleteCityOperator, getAllStaffList, getCityOpratorList, getProductList, updateCityOperator, } from '@/services/list'; const useStyles = createStyles(({ token }) => { return { img: { width: 100, height: 100, }, delete: { color: token.colorError, }, button: { marginRight: '8px', }, }; }); const calcPrice = (productSpecId: string, specList: API.ProductSpecListItem[]) => { const product = specList.find(o => o.productSpecId === productSpecId); return { price: product?.showPrice, originalPrice: product?.originalPrice, sendCount: product?.count }; }; const TableList: React.FC = () => { const [updateModalOpen, handleUpdateModalOpen] = useState(false); const [specList, setSpecList] = useState([]); const [currentRow, setCurrentRow] = useState(); const actionRef = useRef(); const formRef = useRef(); const [staffOptions, setStaffOptions] = useState>([]); const defaultStaff = useMemo(() => { return staffOptions.find(it => it.isDefault) || staffOptions[0]; }, [staffOptions]); const { styles } = useStyles(); const specOptions = useMemo( () => specList.map(it => ({ value: it.productSpecId, label: it.title, })), [specList], ); const getAllStaffOptions = async () => { try { const results = await getAllStaffList(); setStaffOptions( results.map(it => ({ label: `${it.staffName}${it.isDefault ? ' (默认)' : ''}`, isDefault: Boolean(it.isDefault), value: it.id, })), ); } catch (e) { } finally { } }; const getAllSpectList = async () => { const list = await getProductList('GROUP_BATCH_PUSH'); setSpecList(list); }; const handleDelete = async (id: number) => { await deleteCityOperator(id); message.success('操作成功'); actionRef.current?.reload(); }; const handleUpload = async (file: File) => { const url = await uploadFileWx({ file, id: currentRow?.id }); return url; }; useEffect(() => { getAllStaffOptions(); getAllSpectList(); }, []); const columns: ProColumns[] = [ { title: '城市', dataIndex: 'cityCode', valueType: 'textarea', render: (_text, record) => record.cityName, renderFormItem() { return (