/* eslint-disable no-return-assign */ /* eslint-disable no-return-assign */ import React, { useEffect, useState } from "react"; import { Modal, Form, Select, InputNumber, message, Spin, Radio, Input, Button, DatePicker } from "antd"; import { saveRewardsListApi } from "../RewardsList/api"; import { useStore } from "../index"; import _ from "lodash"; import useInitail from "@/hooks/useInitail"; import { EvaGroupSetteing } from "@/pages/performance/EvaGroupSetting/interface"; import * as api from "@/pages/performance/KpiGroupSetting/EditComfirm/api"; import ShopSelectNew from "@/components/ShopSelectNew"; import PersonModal from "@/pages/performance/KpiGroupSetting/components/PersonModal"; import { transformDTO } from "../entity"; import IndivatorsTable from "./IndivatorsTable"; import RewardsTableSal from "./RewardsTableSal"; import moment from "moment"; import { getManagerRoleListApi } from "@/common/api"; const Option = Select.Option; const { RangePicker } = DatePicker; interface Props { visible: boolean; onCancel: Function; onOk: (vales: any) => void; evaItem: EvaGroupSetteing.EvalGroups; scopeType: number; setScopeType: Function; } export default function AddIndicatorsModal(props: Props) { const { postList, readOnly } = useStore(); const [roleList, setRoleList] = useState([]); const { visible, onCancel, onOk, evaItem, scopeType, setScopeType } = props; const [form] = Form.useForm(); // 选择岗位id const [postId, setPostId] = useState(); // 门店列表 const [shopList, setShopList] = useState([]); // 人员查看模块 const [personModal, setPersonModal] = useState({ visible: false, postId: undefined, shopIds: "", }); // visible变化时(修改等) useEffect(() => { getRoleList(); if (visible && evaItem.name) { if (evaItem.shop) { const shopIds = evaItem.shop.map((item) => item.value); setPersonModal({ shopIds: shopIds.join(","), visible: false, }); } if (evaItem.shop && evaItem.post) { const shopIds = evaItem.shop.map((item) => item.value); const postId = evaItem.post.value; setPersonModal({ postId, shopIds: shopIds.join(","), visible: false, }); } console.log("evaItem", evaItem); form.setFieldsValue({ ...evaItem, }); } }, [visible]); // 查询门店 useEffect(() => { if (evaItem.post) { getDealerList(evaItem.post.value); } }, [evaItem]); console.log("shopList", shopList); // 查询管理角色 function getRoleList() { getManagerRoleListApi() .then((res) => { setRoleList(res.data || []); }) .catch((e) => { message.error(e.message); }); } // 根据岗位查门店 function getDealerList(postId: number) { api .queryShopByPost(postId) .then((res) => { setShopList(res.data || []); }) .catch((e) => { message.error(e.message); }); } // 人员查看 const personView = () => { if (!personModal.postId) { message.error("请选择岗位"); return; } if (!personModal.shopIds) { message.error("请选择门店"); return; } setPersonModal({ ...personModal, visible: true }); }; function handSubmit(fieldsValue: any) { const res = transformDTO(fieldsValue); let pa = { ...res, force: true }; onOk(pa); console.log("考评组", pa); onCancel && onCancel(); } return ( { form.resetFields(); onCancel(); }} onCancel={() => onCancel()} onOk={form.submit} width={1400} >
current && current < moment().add(-1, "days").endOf("day")} /> setScopeType(e.target.value)}> 人员考评 门店考评 prevValues.scopeType !== currentValues.scopeType} > {({ getFieldValue }) => getFieldValue("scopeType") === 1 ? ( ) : null } prevValues.scopeType !== currentValues.scopeType} > {({ getFieldValue }) => { const scopeType = getFieldValue("scopeType"); return ( item.shopId) : []} type={scopeType === 1 ? 2 : 1} onChange={( shops: { key: number; label: string; value: number; }[] ) => { const shopIds = shops.map((item) => item.value).join(","); setPersonModal({ ...personModal, shopIds }); }} /> ); }} prevValues.scopeType !== currentValues.scopeType} > {({ getFieldValue }) => getFieldValue("scopeType") === 1 ? ( ) : null } prevValues.scopeType !== currentValues.scopeType} > {({ getFieldValue }) => getFieldValue("scopeType") === 2 ? ( ) : null } prevValues.rewards !== currentValues.rewards}> {({ getFieldValue }) => { const rewards = getFieldValue("rewards"); return ( 0) }]}> ); }} prevValues.indicators !== currentValues.indicators} > {({ getFieldValue }) => { const indicators = getFieldValue("indicators"); return ( 0) }]}> ); }}
); }