import React from 'react';
import { Button } from 'antd';
import '../../assets/css/system.css';
import { $http } from '../../containers/config/https';
import { $loadTemplate } from '../lodop/Common/Print.js';
export default class PrintTest extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
        }
    }
    componentDidMount() {

    }
    componentWillUnmount() {
        this.setState = (state, callback) => {
            return
        }
    }

    // 打印导诊单发票测试
    printGuideSheetAndFP = () => {
        let data = {};
        data = {
            params: [{
                hospID: "6",
                groupID: "7",
                printType: "O",
                printTemplateCode: "",
                recordIDStr: "",
                invIDStr: "1",
            }]
        }
        $http.post('urlS', this, {
            code: "05100153",
            data: data,
            success: function (res) {
                console.log("res", res)
                if (res.errorCode === '0') {
                    //加载模板
                    for (var i = 0; i < res.template.length; i++) {
                        console.log(i)

                        let templateName = res.template[i]
                        let templateData = res.data[i]
                        console.log(templateName, templateData)
                        $loadTemplate(templateName, templateData);



                    }


                }
            }
        })

    }
    accPrint = () => {
        let data = {};
        data = {
            params: [{
                hospID: "1",
                groupID: "230",
                printType: "",
                printTemplateCode: "AdvanceAmt",
                recordIDStr: "",
                accDIDStr: "20624||1||1",
            }]
        }
        $http.post('urlS', this, {
            code: "05100153",
            data: data,
            success: function (res) {
                console.log("res", res)
                if (res.errorCode === '0') {
                    //加载模板
                    for (var i = 0; i < res.template.length; i++) {
                        console.log(i)

                        let templateName = res.template[i]
                        let templateData = res.data[i]
                        console.log(templateName, "K", templateData)
                        $loadTemplate(templateName, templateData);



                    }


                }
            }
        })

    }
    //打印清单
    PrintXYPresc = () => {
        let data = {};
        data = {
            params: [{
                "printID": '166',
                "printType": 'PAY',
                "invNo": '001',
                "recordPatNum": "123",
                "name": "张三",
                "sex": "男"
            }]
        }
        $http.post('urlS', this, {
            code: "05100269",
            data: data,
            success: function (res) {
                if (res.errorCode === '0') {
                    //加载模板
                    $loadTemplate("feeDetails", res.result[0].printStr);

                }
            }
        })
    }





    render() {
        return (
            <div>
                <Button type="primary" onClick={this.printGuideSheetAndFP} style={{ marginLeft: '30px' }}>打印测试</Button>
                <Button type="primary" onClick={this.accPrint} style={{ marginLeft: '30px' }}>打印预交金</Button>
                <Button type="primary" onClick={this.PrintXYPresc} style={{ marginLeft: '30px' }}>>打印费用清单</Button>
            </div>
        )
    }
}