<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="86px">
            <el-form-item prop="purchaseName">
                <el-input size="small" v-model="queryParams.purchaseName" placeholder="标题" clearable />
            </el-form-item>
            <!-- <el-form-item prop="budgetName">
                <el-input size="small" v-model="queryParams.budgetName" placeholder="预算项目" clearable />
            </el-form-item> -->
            <el-form-item class="ml20">
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="clockRecordList" stripe>
            <el-table-column label="序号" type="index" width="55" align="center" />
            <el-table-column label="标题" align="center" prop="purchaseName" />
            <el-table-column label="采购费用-元" align="center" prop="purchaseMoney" />
            <el-table-column label="期望日期" align="center" prop="budgetName" />
            <el-table-column label="预算项目" align="center" prop="budgetName" />
            <el-table-column label="申请部门" align="center" prop="deptName" />
            <el-table-column label="申请人" align="center" prop="applyUser" />
            <el-table-column label="申请时间" align="center" min-width="200px" prop="applyTime" />
            <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
                <template slot-scope="scope">
                    <el-button size="mini" type="text" icon="el-icon-edit" @click="handleEdit(scope.row)">详情
                    </el-button>
                </template>
            </el-table-column>
        </el-table>

        <!--详情对话框 -->
        <el-dialog width="1050px" :visible.sync="open" :title="title" append-to-body @close="cancel">
            <el-form ref="postForm" :model="postForm" :rules="rules" label-width="110px">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="标题">
                            <el-input v-model="postForm.purchaseName" placeholder="请输入标题"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="预算项目">
                            <el-input v-model="postForm.budgetName" placeholder="请输入预算项目"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="采购费用-元">
                            <el-input v-model="postForm.purchaseMoney" placeholder="请输入采购费用-元"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="期望日期">
                            <el-input v-model="postForm.expectedDate" placeholder="请输入期望日期"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="申请部门">
                            <el-input v-model="postForm.deptName" placeholder="请输入申请部门"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">

                        <el-form-item label="申请人">
                            <el-input v-model="postForm.applyUser" placeholder="请输入申请人"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="申请时间">
                            <el-input v-model="postForm.applyTime" placeholder="请输入申请时间"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>


    </div>
</template>

<script>
import { getListlb, getListxq } from "@/api/smartSchool/logisticsManage/detailsofFundusage.js"

export default {
    name: 'detailsofFundusage',
    data() {
        return {
            // 预算项目
            budgetName: '',
            dialogEditNote: false,
            form: {},
            // 日期范围
            dateRange: [],
            // 模糊搜索
            queryParams: {
                purchaseName: "",
                budgetName: "",
            },
            // 加载遮罩
            loading: true,
            // 记录条数
            total: 0,
            // 记录列表
            clockRecordList: [],
            // 详情
            look: false,
            // 表格
            postForm: {},
            open: false,
            title: '',
            total: 0,
            // 校验规则
            rules: {

            },
        };
    },
    // 目标页面的组件
    created() {
        // const budgetName = this.$route.query.budgetName;
        // console.log(this.$route);
        // console.log(111, budgetName); // 在控制台中输出 budgetName 的值
    },
    mounted() {
        // const budgetName = this.$route.query.budgetName;
        // console.log(this.$route);
        // console.log('budgetName', budgetName);


    },

    methods: {

        // 获取列表
        getList() {
            this.budgetName = this.$route.query.budgetName;
            this.purchaseName = this.$route.query.purchaseName == undefined ? '' : this.$route.query.purchaseName;
            console.log('this.budgetName', this.budgetName);
            const query = {
                budgetName: this.budgetName,
                purchaseName: this.purchaseName
            };
            getListlb(query).then(response => {
                console.log(111, this.budgetName);
                this.clockRecordList = response.rows;
                console.log(this.clockRecordList);
                this.total = response.total;
                this.loading = false;
            })
        },
        // 模糊搜索
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        // 重置
        resetQuery() {
            this.dateRange = [];
            this.resetForm("queryForm");
            this.handleQuery();
        },
        // 详情
        handleEdit(row) {
            this.open = true;
            const id = row.id || this.ids
            getListxq(id).then(response => {
                this.postForm = response.data;
                console.log(this.postForm);
                this.total = response.total;
                this.loading = false;
            })
        },
        // 取消按钮
        cancel() {
            this.open = false;
            this.form = {}
            this.handleQuery();
        },
        //提交备注
        submitForm() {
            this.open = false;
            submitRemark(this.form).then((res) => {
                this.form = {}
                this.handleQuery();
            })


        },

    },
    created() {
        this.getList()
    },
};
</script>
<style lang="scss">
.tabstyle {
    border-collapse: collapse;
    margin-bottom: 15px;
    font-size: 16px !important;

}

.tabstyle td,
.tabstyle th {
    border: 1px solid black;
    padding: 8px;
    position: relative;
}

.tabstyle input[type="text"] {
    border: none;
    outline: none;
    font-size: inherit;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    /* opacity: 0; */
}

.btntext {
    width: 300px;
}

.btn {
    display: flex;
    flex-direction: row;
    justify-content: end;

}

.btnup {
    margin-left: 12px;
    margin-bottom: 15px;
    padding: 9px 25px;
    border-radius: 6px;
    background-color: rgba(15, 64, 245, 1);
    color: rgba(255, 255, 255, 1);
    font-size: 13px;
    text-align: center;
    font-family: PingFang SC;

}
</style>
