<template>
    <div>
        <el-card :body-style="cardBodyStyle">
            <el-form :inline="true">
                <el-form-item label="生产时间" style="margin-bottom: 5px; width: 300px;">
                    <el-date-picker v-model="query.prodDt" type="monthrange" range-separator="到"
                        start-placeholder="开始时间" end-placeholder="结束结束" />
                </el-form-item>
            </el-form>
        </el-card>
        <ButtonBar @search="handleSearch" @add="handleAdd" @remove="handleRemoveBatch" @edit="handleEditBatch"
            @upload="handleUpload" @download="handleDownload" @import="handleImport" @export="handleExport"></ButtonBar>
        <el-card :body-style="cardBodyStyle">
            <el-table :data="tableData" border highlight-current-row @selection-change="handleSelectionChange">
                <el-table-column type="selection" fixed></el-table-column>
                <el-table-column type="index" label="序号" align="center" width="60">
                    <template #default="scope">
                        <span>{{ scope.$index + (currentPage - 1) * pageSize + 1 }}</span>
                    </template>
                </el-table-column>
                <el-table-column v-if="false" prop="" label="ID" width="120" header-align="center" align="center"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="false" prop="createEmpId" label="创建人id" width="300" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="false" prop="createDtm" label="创建时间" width="240" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="false" prop="modifyEmpId" label="修改人id" width="300" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="false" prop="modifyDtm" label="修改时间" width="240" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="false" prop="cancleEmpId" label="删除人ID" width="300" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="false" prop="cancleDtm" label="删除时间" width="240" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="false" prop="cancleYn" label="删除标记" width="240" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="prodDt" label="生产日期" width="110" header-align="center" align="center"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="wstonQty" label="废石量" width="70" header-align="center" align="right"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="fstonQty" label="细石量" width="70" header-align="center" align="right"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="periQty" label="外围量" width="70" header-align="center" align="right"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="rcvyQty" label="回收矿量" width="90" header-align="center" align="right"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="retuQty" label="外返矿石量" width="100" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="pileStorQty" label="矿堆入仓量" width="100" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="ballmQty1" label="1#球磨机处理量" width="130" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="ballmQty2" label="2#球磨机处理量" width="130" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="ballmQty3" label="3#球磨机处理量" width="130" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="ballmQty4" label="4#球磨机处理量" width="130" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="ballmQty5" label="5#球磨机处理量" width="130" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="ballmQty6" label="6#球磨机处理量" width="130" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="foreQty" label="粗矿粉量" width="90" header-align="center" align="right"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="crusQty" label="原矿破碎加工总量" width="140" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="fillCrusQty" label="充填破碎加工量" width="130" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppIronCcttQty" label="来料加工_铁精矿_ 实物" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppIronCcttGrd" label="来料加工_铁精矿_ 品位" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppIronMetlQty" label="来料加工_铁精矿_ 含铁" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppCoppCcttQty" label="来料加工_铜精矿_ 实物" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppCoppCcttGrd" label="来料加工_铜精矿_ 品位" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppCoppMetlQty" label="来料加工_铜精矿_ 含铜" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppCobaCcttQty" label="来料加工_钴精矿_ 实物" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppCobaCcttGrd" label="来料加工_钴精矿_ 品位" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppCobaMetlQty" label="来料加工_钴精矿_ 含钴" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppSulfCcttQty" label="来料加工_硫精矿_ 实物" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppSulfCcttGrd" label="来料加工_硫精矿_ 品位" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="suppSulfMetlQty" label="来料加工_硫精矿_ 含硫" width="170"
                    header-align="center" align="right" show-overflow-tooltip>
                </el-table-column>


                <el-table-column label="操作" header-align="center" align="center" width="200px" fixed="right">
                    <template #default="scope">
                        <el-button plain type="warning" @click="handleEdit(scope.row)">编辑</el-button>
                        <el-button plain type="danger" @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
        <el-card :body-style="cardBodyStyle">
            <el-pagination :current-page="currentPage" :page-size="pageSize" :page-sizes="pageSizes" :total="totalRows"
                background="background" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange"
                @current-change="handleCurrentChange">
            </el-pagination>
        </el-card>

        <el-dialog :close-on-click-modal="false" draggable :title="dialogName" v-model="dialogVisible" width="1200px" top="5vh"
            @open="openDialog">
            <el-form :model="form" label-width="80px" label-position="right" inline ref="ruleFormRef" :rules="rules">
                <el-card style=" margin-bottom: 10px; height: 70px;">
                    <el-row :gutter="60">
                        <el-col span="6">
                            <el-form-item label="生产日期" prop="prodDt">
                                <el-date-picker v-model="form.prodDt" type="month" placeholder="请选择时间" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>
                <el-card style=" margin-bottom: 10px; height: 120px;">
                    <el-row :gutter="80">
                        <el-col :span="1"></el-col>
                        <el-col :span="7">
                            <el-form-item label="废石量(吨)" style="white-space: nowrap;" prop="wstonQty">
                                <el-input v-model="form.wstonQty" clearable style="width: 120px"
                                    @input="crusQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="细石量(吨)" style="white-space: nowrap;" prop="fstonQty">
                                <el-input v-model="form.fstonQty" clearable style="width: 120px"
                                    @input="foreQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="外围量(吨)" style="white-space: nowrap;" prop="periQty">
                                <el-input v-model="form.periQty" clearable style="width: 120px"
                                    @input="fillCrusQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="80">
                        <el-col :span="1"></el-col>
                        <el-col :span="7">
                            <el-form-item label="回收矿量(吨)" style="white-space: nowrap;" prop="rcvyQty">
                                <el-input v-model="form.rcvyQty" clearable style="width: 120px"
                                    @input="fillCrusQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="外返矿石量(吨)" style="white-space: nowrap;" prop="retuQty">
                                <el-input v-model="form.retuQty" clearable style="width: 120px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="矿堆入仓量(吨)" style="white-space: nowrap;" prop="pileStorQty">
                                <el-input v-model="form.pileStorQty" clearable style="width: 120px"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>
                <el-card style=" margin-bottom: 10px; height: 120px;">
                    <el-row :gutter="80">
                        <el-col :span="1"></el-col>
                        <el-col :span="7">
                            <el-form-item label="1#球磨机处理量(吨)" style="white-space: nowrap;" prop="ballmQty1">
                                <el-input v-model="form.ballmQty1" clearable style="width: 120px"
                                    @input="foreQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="2#球磨机处理量(吨)" style="white-space: nowrap;" prop="ballmQty2">
                                <el-input v-model="form.ballmQty2" clearable style="width: 120px"
                                    @input="foreQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="3#球磨机处理量(吨)" style="white-space: nowrap;" prop="ballmQty3">
                                <el-input v-model="form.ballmQty3" clearable style="width: 120px"
                                    @input="foreQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="80">
                        <el-col :span="1"></el-col>
                        <el-col :span="7">
                            <el-form-item label="4#球磨机处理量(吨)" style="white-space: nowrap;" prop="ballmQty4">
                                <el-input v-model="form.ballmQty4" clearable style="width: 120px"
                                    @input="foreQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="5#球磨机处理量(吨)" style="white-space: nowrap;" prop="ballmQty5">
                                <el-input v-model="form.ballmQty5" clearable style="width: 120px"
                                    @input="foreQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="6#球磨机处理量(吨)" style="white-space: nowrap;" prop="ballmQty6">
                                <el-input v-model="form.ballmQty6" clearable style="width: 120px"
                                    @input="foreQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>
                <el-card style=" margin-bottom: 10px; height: 70px;">
                    <el-row :gutter="80">
                        <el-col :span="1"></el-col>
                        <el-col :span="7">
                            <el-form-item label="粗矿粉量(吨)" style="white-space: nowrap;">
                                <el-input v-model="form.foreQty" clearable style="width: 120px" disabled></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="原矿破碎加工总量(吨)" style="white-space: nowrap;">
                                <el-input v-model="form.crusQty" clearable style="width: 120px" disabled></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="充填破碎加工量(吨)" style="white-space: nowrap;">
                                <el-input v-model="form.fillCrusQty" clearable style="width: 120px" disabled></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>
                <el-card style=" margin-bottom: 10px; height: 220px;">
                    <el-row :gutter="80">
                        <el-col :span="1"></el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_铁精矿_ 实物" style="white-space: nowrap;" prop="suppIronCcttQty">
                                <el-input v-model="form.suppIronCcttQty" clearable style="width: 120px"
                                    @input="suppIronMetlQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_铁精矿_ 品位" style="white-space: nowrap;" prop="suppIronCcttGrd">
                                <el-input v-model="form.suppIronCcttGrd" clearable style="width: 120px"
                                    @input="suppIronMetlQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_铁精矿_ 含铁" style="white-space: nowrap;">
                                <el-input v-model="form.suppIronMetlQty" clearable style="width: 120px"
                                    disabled></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="80">
                        <el-col :span="1"></el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_铜精矿_ 实物" style="white-space: nowrap;" prop="suppCoppCcttQty">
                                <el-input v-model="form.suppCoppCcttQty" clearable style="width: 120px"
                                    @input="suppCoppMetlQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_铜精矿_ 品位" style="white-space: nowrap;" prop="suppCoppCcttGrd">
                                <el-input v-model="form.suppCoppCcttGrd" clearable style="width: 120px"
                                    @input="suppCoppMetlQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_铜精矿_ 含铜" style="white-space: nowrap;">
                                <el-input v-model="form.suppCoppMetlQty" clearable style="width: 120px"
                                    disabled></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="80">
                        <el-col :span="1"></el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_钴精矿_ 实物" style="white-space: nowrap;" prop="suppCobaCcttQty">
                                <el-input v-model="form.suppCobaCcttQty" clearable style="width: 120px"
                                    @input="suppCobaMetlQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_钴精矿_ 品位" style="white-space: nowrap;" prop="suppCobaCcttGrd">
                                <el-input v-model="form.suppCobaCcttGrd" clearable style="width: 120px"
                                    @input="suppCobaMetlQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_钴精矿_ 含钴" style="white-space: nowrap;">
                                <el-input v-model="form.suppCobaMetlQty" clearable style="width: 120px"
                                    disabled></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="80">
                        <el-col :span="1"></el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_硫精矿_ 实物" style="white-space: nowrap;" prop="suppSulfCcttQty">
                                <el-input v-model="form.suppSulfCcttQty" clearable style="width: 120px"
                                    @input="suppSulfMetlQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_硫精矿_ 品位" style="white-space: nowrap;" prop="suppSulfCcttGrd">
                                <el-input v-model="form.suppSulfCcttGrd" clearable style="width: 120px"
                                    @input="suppSulfMetlQtyValue"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="来料加工_硫精矿_ 含硫" style="white-space: nowrap;">
                                <el-input v-model="form.suppSulfMetlQty" clearable style="width: 120px"
                                    disabled></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>

            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button type="success" @click="handleSave(ruleFormRef)">保存</el-button>
                    <el-button type="danger" @click="handleCancelSave">取消</el-button>
                </div>
            </template>
        </el-dialog>


    </div>
</template>

<script setup>
import ButtonBar from '@/components/ButtonBar.vue'

import {
    ref,
    reactive,
    onMounted,
    getCurrentInstance
} from 'vue'

const {
    proxy
} = getCurrentInstance()

import SearchBox from '@/components/SearchBox.vue'
const searchBarRef = ref(null)

import tools from '@/tools'
const cardBodyStyle = ref(tools.style.card)
const inputStyle = ref(tools.style.input)

onMounted(() => {
    handleSearch()
})


//粗矿粉量
const foreQtyValue = () => {
    var fstonQty = Number(form.value.fstonQty)
    var ballmQty1 = Number(form.value.ballmQty1)
    var ballmQty2 = Number(form.value.ballmQty2)
    var ballmQty3 = Number(form.value.ballmQty3)
    var ballmQty4 = Number(form.value.ballmQty4)
    var ballmQty5 = Number(form.value.ballmQty5)
    var ballmQty6 = Number(form.value.ballmQty6)
    form.value.foreQty = fstonQty + ballmQty1 + ballmQty2 + ballmQty3 + ballmQty4 + ballmQty5 + ballmQty6
    form.value.crusQty = Number(form.value.foreQty) + Number(form.value.wstonQty)
}
//原矿破碎加工总量
const crusQtyValue = () => {
    var foreQty = Number(form.value.foreQty)
    var wstonQty = Number(form.value.wstonQty)
    form.value.crusQty = foreQty + wstonQty
    form.value.fillCrusQty = Number(form.value.fillCrusQty) + wstonQty
}
//充填破碎加工量
const fillCrusQtyValue = () => {
    var wstonQty = Number(form.value.wstonQty)
    var periQty = Number(form.value.periQty)
    var rcvyQty = Number(form.value.rcvyQty)
    form.value.fillCrusQty = periQty + wstonQty + rcvyQty
}
//来料加工_铁精矿_ 含铁
const suppIronMetlQtyValue = () => {
    var suppIronCcttQty = Number(form.value.suppIronCcttQty)
    var suppIronCcttGrd = Number(form.value.suppIronCcttGrd)
    form.value.suppIronMetlQty = suppIronCcttQty * suppIronCcttGrd
}
//来料加工_铜精矿_ 含铜
const suppCoppMetlQtyValue = () => {
    var suppCoppCcttQty = Number(form.value.suppCoppCcttQty)
    var suppCoppCcttGrd = Number(form.value.suppCoppCcttGrd)
    form.value.suppCoppMetlQty = suppCoppCcttQty * suppCoppCcttGrd
}
//来料加工_钴精矿_ 含钴
const suppCobaMetlQtyValue = () => {
    var suppCobaCcttQty = Number(form.value.suppCobaCcttQty)
    var suppCobaCcttGrd = Number(form.value.suppCobaCcttGrd)
    form.value.suppCobaMetlQty = suppCobaCcttQty * suppCobaCcttGrd
}
//来料加工_硫精矿_ 含硫
const suppSulfMetlQtyValue = () => {
    var suppSulfCcttQty = Number(form.value.suppSulfCcttQty)
    var suppSulfCcttGrd = Number(form.value.suppSulfCcttGrd)
    form.value.suppSulfMetlQty = suppSulfCcttQty * suppSulfCcttGrd
}


/**
 *   查询
 */




const query = ref({
    // prodDt: proxy.$dayjs().format('YYYY-MM-DD')
})
const tableData = ref([])
const handleSearch = () => {
    currentPage.value = 1
    getTableData()
}

const getTableData = () => {
    var url = 'prd/ReptMonth/query'
    var param = {
        page: currentPage.value,
        rows: pageSize.value,
        params: JSON.stringify(query.value)
    }
    proxy.$axios.get(url, param).then(response => {
        if (response.data.code == '0') {
            tableData.value = response.data.data.records
            totalRows.value = response.data.data.total
        } else {
            ElMessage.error('操作失败！' + response.data.msg)
        }
    })
}
/**
 *   查询
 */

/**
 * 分页
 */
const currentPage = ref(1)
const totalRows = ref(0)
const pageSizes = ref([5, 10, 20, 30, 40])
const pageSize = ref(5)
const handleSizeChange = (val) => {
    pageSize.value = val
    getTableData()
}
const handleCurrentChange = (val) => {
    currentPage.value = val
    getTableData()
}
/**
 * 分页
 */


/**
 * 新增
 */
const dialogVisible = ref(false)
const form = ref({
    prodDt: '',
    wstonQty: '',
    fstonQty: '',
    periQty: '',
    rcvyQty: '',
    retuQty: '',
    pileStorQty: '',
    ballmQty1: '',
    ballmQty2: '',
    ballmQty3: '',
    ballmQty4: '',
    ballmQty5: '',
    ballmQty6: '',
    foreQty: '',
    crusQty: '',
    fillCrusQty: '',
    suppIronCcttQty: '',
    suppIronCcttGrd: '',
    suppIronMetlQty: '',
    suppCoppCcttQty: '',
    suppCoppCcttGrd: '',
    suppCoppMetlQty: '',
    suppCobaCcttQty: '',
    suppCobaCcttGrd: '',
    suppCobaMetlQty: '',
    suppSulfCcttQty: '',
    suppSulfCcttGrd: '',
    suppSulfMetlQty: ''
})
const ruleFormRef = ref()
const rules = reactive({
    prodDt: [{ required: true, message: '请输入生产日期', trigger: 'change' | 'blur' }],
    wstonQty: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    fstonQty: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    periQty: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    rcvyQty: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    retuQty: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    pileStorQty: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    ballmQty1: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    ballmQty2: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    ballmQty3: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    ballmQty4: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    ballmQty5: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    ballmQty6: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    suppIronCcttQty: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    suppIronCcttGrd: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    suppCoppCcttQty: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    suppCoppCcttGrd: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    suppCobaCcttQty: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    suppCobaCcttGrd: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    suppSulfCcttQty: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
    suppSulfCcttGrd: [{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
}) 
const dialogName = ref('')
const handleAdd = () => {
    form.value = {
        prodDt: '',
        wstonQty: '',
        fstonQty: '',
        periQty: '',
        rcvyQty: '',
        retuQty: '',
        pileStorQty: '',
        ballmQty1: '',
        ballmQty2: '',
        ballmQty3: '',
        ballmQty4: '',
        ballmQty5: '',
        ballmQty6: '',
        foreQty: '',
        crusQty: '',
        fillCrusQty: '',
        suppIronCcttQty: '',
        suppIronCcttGrd: '',
        suppIronMetlQty: '',
        suppCoppCcttQty: '',
        suppCoppCcttGrd: '',
        suppCoppMetlQty: '',
        suppCobaCcttQty: '',
        suppCobaCcttGrd: '',
        suppCobaMetlQty: '',
        suppSulfCcttQty: '',
        suppSulfCcttGrd: '',
        suppSulfMetlQty: ''
    }
    if (ruleFormRef.value) {
            ruleFormRef.value.resetFields()
        }
    dialogName.value = '新增'
    dialogVisible.value = true
}
/**
 * 新增
 */


/**
 * 保存、修改、删除
 */

const openDialog = () => {
}

const handleSave = (ruleFormRef) => {
    ruleFormRef.validate((valid, fields) => {
        if (valid) {
            var url = 'prd/ReptMonth/save'
            var param = {
                json: JSON.stringify(form.value),
            }
            proxy.$axios.post(url, param).then(response => {
                if (response.data.code == 0) {
                    form.value = response.data.data
                    ElMessage({
                        message: '保存成功',
                        type: 'success',
                    })
                    getTableData()
                    dialogVisible.value = false
                } else {
                    // ElMessage.error('操作失败！' + response.data.msg)
                    ElMessage({
                        message: '操作失败' + response.data.msg,
                        type: 'error'
                    })
                }
            })

        } else {
            console.log('error submit!', fields)
            ElMessage.error('请输入有效数据')
        }
    })
}
const handleCancelSave = () => {
    dialogVisible.value = false
}
const handleEdit = (row) => {
    dialogName.value = '编辑'
    dialogVisible.value = true
    form.value = row
}
const handleDelete = (row) => {
    ElMessageBox.confirm(
        '确定删除本条记录?',
        '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
        draggable: true,
    }
    )
        .then(() => {
            var url = 'prd/ReptMonth/remove'
            var param = {
                id: row.id
            }
            proxy.$axios.post(url, param).then(response => {
                if (response.data.code == 0) {
                    ElMessage({
                        type: 'success',
                        message: '删除成功',
                    })
                    getTableData()
                } else {
                    ElMessage({
                        type: 'error',
                        message: '删除失败' + response.data.msg
                    });
                }
            });
        })
        .catch(() => {
            ElMessage({
                type: 'info',
                message: '已取消',
            })
        })
}

/**
 * 保存、修改、删除
 */

const multipleSelection = ref([])
const handleSelectionChange = (val) => {
    multipleSelection.value = val
}

const handleRemoveBatch = () => {
    console.log('handleRemoveBatch')

    if (multipleSelection.value.length < 1) {
        ElMessage({
            type: 'warning',
            message: '请选择要删除的数据!'
        })
        return
    }

    ElMessageBox.confirm('此操作将删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
    }).then(() => {
        var ids = []
        multipleSelection.value.forEach((item, index) => {
            ids.push(item.id)
        })
        var url = 'prd/ReptMonth/removeBatch'
        var param = {
            ids: JSON.stringify(ids)
        }
        proxy.$axios.post(url, param).then(response => {
            if (response.data.code == '0') {
                ElMessage({
                    type: 'success',
                    message: '操作成功!',
                });
                getTableData()
                dialogVisible.value = false
            } else {
                ElMessage({
                    type: 'error',
                    message: '操作失败!' + response.data.msg
                });
            }
        })
    }).catch(() => {
        ElMessage({
            type: 'info',
            message: '已取消删除'
        })
    })
}

const handleEditBatch = () => {
    console.log('handleEditBatch')
    if (multipleSelection.value.length != 1) {
        ElMessage({
            type: 'warning',
            message: '请选择一条数据编辑!'
        })
        return
    }
    handleEdit(multipleSelection.value[0])
}

const handleUpload = () => {
    console.log('handleUpload')
}

const handleDownload = () => {
    console.log('handleDownload')
}

const handleImport = () => {
    console.log('handleImport')
}

const handleExport = () => {
    console.log('handleExport')
}

</script>

<style></style>