import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { ProFormRadio, ProFormRate, ProFormList, ModalForm, ProCard, ProFormSelect, ProFormDependency, ProFormTextArea, } from '@ant-design/pro-components';
import { Col, message, Divider, Empty, Modal, Button, Row } from 'antd';
import { useRequest } from 'ahooks';
import { PlusOutlined } from '@ant-design/icons';
import { useRoutes, getStorage, themeMessage } from '@component/utils';
import { CardForm } from '@component/ui';
import { onSubmit, getTemplateList } from './action';
import { ExclamationCircleOutlined } from '@ant-design/icons';
import Template from './template';
import React, { useState } from 'react';
import { clone, map } from 'lodash';
import moment from 'moment';
export default function () {
    const { paramsParse, historyBack, historyPush } = useRoutes();
    const { runAsync } = useRequest(onSubmit, {
        manual: true,
        onSuccess(result) {
            themeMessage(result, historyBack);
        },
        onError(result) {
            message.error(result.message);
        },
    });
    function onFinish(values) {
        if (!values.item) {
            message.warning('考评表单不能为空!');
        }
        let params = clone(values);
        params.item = JSON.stringify(map(values === null || values === void 0 ? void 0 : values.item, (item) => {
            const item_val_name = (item === null || item === void 0 ? void 0 : item.tag) ? { item_val_name: item === null || item === void 0 ? void 0 : item.tag } : {};
            return Object.assign({ question: item === null || item === void 0 ? void 0 : item.itemName, method: item === null || item === void 0 ? void 0 : item.itemType, itemValCode: item === null || item === void 0 ? void 0 : item.item_val_code }, item_val_name);
        }));
        params.reviewName = getStorage('userName');
        params.reviewDate = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
        params.organId = paramsParse === null || paramsParse === void 0 ? void 0 : paramsParse.organId;
        Modal.confirm({
            title: '确认提交',
            icon: _jsx(ExclamationCircleOutlined, {}),
            content: '服务考评是对第三方服务机构的重要评价,您确认提交吗',
            okText: '确认',
            cancelText: '取消',
            onOk() {
                return runAsync(params);
            },
            onCancel() { },
        });
    }
    return (_jsx(_Fragment, { children: _jsxs(ModalForm, Object.assign({ title: "\u6DFB\u52A0\u8003\u8BC4", trigger: _jsxs(Button, Object.assign({ type: "primary" }, { children: [_jsx(PlusOutlined, {}), "\u6DFB\u52A0\u8003\u8BC4"] })), labelAlign: "left", width: '60%', autoFocusFirstInput: true, modalProps: {
                destroyOnClose: true,
                onCancel: () => console.log('run'),
            }, submitTimeout: 2000, onFinish: onFinish, layout: "horizontal", request: () => ({ reviewForm: list === null || list === void 0 ? void 0 : list.checkItem }) }, { children: [_jsx(ProFormSelect, { name: "template", label: "\u8003\u8BC4\u6A21\u677F", request: () => getTemplateList(paramsParse === null || paramsParse === void 0 ? void 0 : paramsParse.organId), placeholder: "\u8BF7\u5148\u9009\u62E9\u8003\u8BC4\u6A21\u677F", rules: [{ required: true, message: '请选择考评模板!' }] }), _jsx(CardForm, Object.assign({ title: "\u670D\u52A1\u8003\u8BC4\u6A21\u677F", gutter: [10, 10], noGutter: false }, { children: _jsx(ProFormDependency, Object.assign({ name: ['template'] }, { children: ({ template }) => {
                            return _jsx(Template, { templateId: template });
                        } })) })), _jsx(Divider, { className: "self-pro-divider" }), _jsx(CardForm, Object.assign({ title: "\u670D\u52A1\u8003\u8BC4\u603B\u7ED3", gutter: [10, 10], noGutter: false }, { children: _jsxs(ProCard, Object.assign({ ghost: true }, { children: [_jsxs(ProCard, Object.assign({ ghost: true, colSpan: 12 }, { children: [_jsx(ProFormRate, { labelCol: {
                                            span: 10,
                                        }, colProps: {
                                            span: 24,
                                        }, label: "\u63D0\u4F9B\u9884\u9632\u670D\u52A1\u53CA\u65F6\u6709\u6548", name: "yffwJsyx", fieldProps: { allowHalf: false }, rules: [{ required: true, message: '请选择对本项的评分!' }] }), _jsx(ProFormRate, { labelCol: {
                                            span: 10,
                                        }, colProps: {
                                            span: 24,
                                        }, label: "\u670D\u52A1\u6210\u679C\u670D\u52A1\u62A5\u544A\u8D28\u91CF", name: "ffcgBgzl", fieldProps: { allowHalf: false }, rules: [{ required: true, message: '请选择对本项的评分!' }] }), _jsx(ProFormRate, { labelCol: {
                                            span: 10,
                                        }, colProps: {
                                            span: 24,
                                        }, label: "\u4F01\u4E1A\u5BF9\u670D\u52A1\u6574\u4F53\u6EE1\u610F\u5EA6", name: "fwztmyd", fieldProps: { allowHalf: false }, rules: [{ required: true, message: '请选择对本项的评分!' }] })] })), _jsx(ProCard, Object.assign({ ghost: true, colSpan: 12 }, { children: _jsx(ProFormRadio.Group, { name: "result", label: null, rules: [{ required: true, message: '请填写您的考评结论!' }], options: [
                                        {
                                            label: '合格',
                                            value: '1',
                                        },
                                        {
                                            label: '不合格',
                                            value: '2',
                                        },
                                    ] }) }))] })) })), _jsx(ProFormTextArea, { name: "reviewRemarks", label: "\u5907\u6CE8", placeholder: "\u8BF7\u8F93\u5165\u5907\u6CE8", fieldProps: { showCount: true, maxLength: 500 } })] })) }));
}