<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
            <el-form-item label="关键字" prop="searchValue">
                <el-input v-model="queryParams.searchValue" placeholder="请输入关键字" maxlength="20" clearable style="width: 240px"/>
            </el-form-item>
            <el-form-item label="所属区域" prop="areaId">
                <el-cascader v-model="queryParams.areaId"
                    :options="treeOptions" :filterable="true" style="width: 240px;" :show-all-levels="false"
                    :props="{ 
                    emitPath: false,// 若设置 false，则只返回该节点的值，只返回最后选择的id
                    checkStrictly: false,//来设置父子节点取消选中关联，从而达到选择任意一级选项的目的
                    value:'id',label:'label'
                    }" clearable>
                </el-cascader>
            </el-form-item>
            <el-form-item label="供应商" prop="supplierId"> 
                <el-select v-model="queryParams.supplierId" placeholder="请选择供应商" style="width: 240px;">
                    <el-option label="供应商1" :value="1"></el-option>
                    <el-option label="供应商2" :value="2"></el-option> 
                    <el-option label="供应商3" :value="2"></el-option> 
                </el-select> 
            </el-form-item>   
            <el-form-item>
                <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-row :gutter="10" class="mb8">
        <el-col :span="1.5">
            <el-button
            type="primary"
            plain 
            size="mini"
            @click=""
            >录入</el-button>
        </el-col>  
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table v-loading="loading" :data="tableListData" height="800">
            <el-table-column label="序号" align="center" width="80" type="index" fixed="left">
                <template slot-scope="scope">
                <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
                </template>
            </el-table-column>
            <el-table-column label="货品编码" align="center" prop="materialCode" :show-overflow-tooltip="true" width="120"/>
            <el-table-column label="货品名称" align="center" prop="materialName" :show-overflow-tooltip="true" width="120" />
            <el-table-column label="货品类别" align="center" prop="categoryName" :show-overflow-tooltip="true" width="120" />
            <el-table-column label="计量单位" align="center" prop="" :show-overflow-tooltip="true" width="120" /> 
            <el-table-column label="货品规格" align="center" prop="" :show-overflow-tooltip="true" width="120" /> 
            <el-table-column label="所属区域" align="center" prop="areaName" :show-overflow-tooltip="true" width="120"/> 
            <el-table-column label="最近一次采购" align="center">
                <el-table-column label="价格" align="center" prop="" width="100" :show-overflow-tooltip="true" >
                    <!-- <template slot-scope="scope">
                        <span>{{ (scope.row.lastOrderGoodsPrice/100).toFixed(2) }}</span>
                    </template> -->
                </el-table-column>
                 <el-table-column label="时间" align="center" prop="" width="120" :show-overflow-tooltip="true" /> 
                <el-table-column label="供应商" align="center" prop="" width="100" :show-overflow-tooltip="true" />
            </el-table-column>
            <el-table-column label="市场价格" align="center"> 
                <el-table-column label="录入/抓取时间" align="center" prop="" width="120" :show-overflow-tooltip="true" /> 
                <el-table-column label="价格" align="center" prop="" width="100" :show-overflow-tooltip="true" >
                    <!-- <template slot-scope="scope">
                        <span>{{ (scope.row.lastOrderGoodsPrice/100).toFixed(2) }}</span>
                    </template> -->
                </el-table-column>
                <el-table-column label="来源" align="center" prop="" width="100" :show-overflow-tooltip="true" /> 
            </el-table-column>
            <el-table-column label="价格浮动比(%)" align="center" prop="" :show-overflow-tooltip="true" width="120"/>  
            <el-table-column label="首选供应商" align="center" prop="" :show-overflow-tooltip="true" width="120"/> 
            <el-table-column label="当前最新中标供应商" align="center">
                <el-table-column label="供应商名称" align="center" prop="" width="100" :show-overflow-tooltip="true" />  
                <el-table-column label="中标价(元)" align="center" prop="" width="100" :show-overflow-tooltip="true" >
                    <!-- <template slot-scope="scope">
                        <span>{{ (scope.row.lastOrderGoodsPrice/100).toFixed(2) }}</span>
                    </template> -->
                </el-table-column> 
            </el-table-column>
            
            <el-table-column label="操作" align="center" width="180" class-name="small-padding fixed-width">
                <template slot-scope="scope"> 
                <el-button
                    size="mini"
                    type="text"
                    icon="el-icon-edit"
                    @click="handleView(scope.row)" 
                >历史评分</el-button> 
                </template>
            </el-table-column>
        </el-table> 
        <pagination
            v-show="total>0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
        /> 
        <!-- 添加或修改参数配置对话框 -->
        <el-dialog title="评分规则配置" :visible.sync="open" width="800px" append-to-body>
           


            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>

    </div>
</template>

<script>
import { systemAreaTreeApi } from "@/api/base/stall";
import { systemMaterialTreeApi } from "@/api/dish/material"; 

export default {
    name: "",
    dicts: [],
    data() {
        return {
            // 遮罩层
            loading: false,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            //表格数据
            tableListData: [
                {supplierName:'111',areaName:'111'},{supplierName:'222',areaName:'222'},
            ], 
            // 是否显示弹出层
            open: false, 
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,    
                supplierName: undefined,
                areaId: undefined, 
                linkman: undefined, 
                status: undefined, 
                categoryIdList: []
            },
            treeTypeOptions:[],//类别树
            treeOptions:[],//区域树 
            // 表单参数
            form: {},
            // 表单校验
            rules: { 
                areaId: [
                    { required: true, message: "所属区域不能为空", trigger: "change" }
                ], 
                ruleType: [
                    { required: true, message: "周期配置不能为空", trigger: "change" }
                ]
            },   
        };
    },
    created() { 
          this.getTypeTreeData();
          this.getTreeData();
        //   this.getList();

    }, 
    methods: {
        //类型树
        getTypeTreeData() {
            let param = {
                // categoryType:1,
            }
            systemMaterialTreeApi(param).then((response) => {
                this.treeTypeOptions = response.data;
            });
        },
        //区域树
        getTreeData() {
            systemAreaTreeApi({}).then((response) => {
                this.treeOptions = response.data;  
            });
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() { 
            this.queryParams = {
                pageNum: 1,
                pageSize: 10, 
            }
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 查询列表 */
        getList() {
            this.loading = true;
            let param = {
                "pageNum": this.queryParams.pageNum, 
                "pageSize": this.queryParams.pageSize,
                "supplierName": this.queryParams.supplierName,  
                "categoryIdList": this.queryParams.categoryIdList,  
                "areaId": this.queryParams.areaId,  
                "linkman": this.queryParams.linkman,  
                "status": this.queryParams.status
            }
            // getPageCanteenApi(param).then(response => {
            //     this.tableListData = response.rows;
            //     this.total = Number(response.total);
                this.loading = false;
            // });
        },  
         
        // 取消按钮
        cancel() {
            this.open = false; 
        },
        /** 提交按钮 */
        submitForm: function() {
            this.$refs["form"].validate(valid => {
                if (valid) {
                     
                }
            });
        }, 
        handleView(row){

        }
    }
};
</script>
