<template>
    <div>
        <SearchBox ref="searchBarRef" :formName="search" :formData="query" @showPopupUser="showPop" showResetButton @reset="reset"/>
        <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="operDt" label="生产日期" width="120" header-align="center" align="center"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operShift" label="班次" width="60" header-align="center" align="center"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operGrp" label="班组" width="60" header-align="center" align="center"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="dutyId1" label="1、2系列值班人" width="130" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operRecd1" label="1、2系列运行记录" width="145" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="handOver1" label="1、2系列交班事项" width="145" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operTm1" label="1系列运转时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="phValue1" label="1系列PH值" width="100" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="oilQty1" label="1系列用油量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="medcQty1" label="1系列用药量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operTm2" label="2系列运转时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="phValue2" label="2系列PH值" width="100" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="oilQty2" label="2系列用油量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="medcQty2" label="2系列用药量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="dutyId3" label="3、4系列值班人" width="130" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operRecd3" label="3、4系列运行记录" width="145" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="handOver3" label="3、4系列交班事项" width="145" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operTm3" label="3系列运转时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="phValue3" label="3系列PH值" width="100" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="oilQty3" label="3系列用油量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="medcQty3" label="3系列用药量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operTm4" label="4系列运转时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="phValue4" label="4系列PH值" width="100" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="oilQty4" label="4系列用油量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="medcQty4" label="4系列用药量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="dutyId5" label="5、6系列值班人" width="130" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operRecd5" label="5、6系列运行记录" width="145" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="handOver5" label="5、6系列交班事项" width="145" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operTm5" label="5系列运转时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="phValue5" label="5系列PH值" width="100" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="oilQty5" label="5系列用油量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="medcQty5" label="5系列用药量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operTm6" label="6系列运转时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="phValue6" label="6系列PH值" width="100" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="oilQty6" label="6系列用油量" width="110" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="medcQty6" label="6系列用药量" width="110" 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="1300px"
            top="5vh" @open="openDialog" :before-close="handleCancelSave">
            <el-form :model="form" label-width="80px" label-position="right" inline ref="ruleFormRef" status-icon
                :rules="rules">
                <el-card style="height: 70px;">
                    <el-row>
                        <el-col span="6">
                            <el-form-item label="生产日期" prop="operDt">
                                <el-date-picker v-model="form.operDt" type="date" style="width: 190px;"
                                    value-format="YYYY-MM-DD" format="YYYY-MM-DD"></el-date-picker>
                            </el-form-item>
                        </el-col>
                        <el-col span="6">
                            <el-form-item label="班次" prop="operShift">
                                <el-select v-model="form.operShift" placeholder="请选择班次" style="width: 190px;" clearable>
                                    <el-option v-for="option in optionList" :key="option.dicCode"
                                        :label="option.dicCode" :value="option.dicCode" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col span="6">
                            <el-form-item label="班组" prop="operGrp">
                                <el-select v-model="form.operGrp" placeholder="请选择班组" style="width: 190px;" clearable>
                                    <el-option v-for="option in optionGrpList" :key="option.dicCode"
                                        :label="option.dicCode" :value="option.dicCode" />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>
                <el-card style="margin-bottom: 10px; margin-top: 10px; height: 240px;">
                    <el-row :gutter="60">
                        <el-col span="10">
                            <el-tag style="font-size: 20px;  margin-bottom: 20px;">1-2系列机器运转信息</el-tag>
                        </el-col>
                    </el-row>
                    <el-row :gutter="60">
                        <el-col :span="1"></el-col>
                        <el-col span="3">
                            <el-form-item label="1-2系列值班人" style="white-space: nowrap;" prop="dutyId1">
                                <el-input v-model="form.dutyId1" clearable style="width: 150px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="1-2系列运行记录" style="white-space: nowrap;" prop="operRecd1">
                                <el-input v-model="form.operRecd1" style="width: 300px; font-size: 16px;" clearable
                                    :rows="2" show-word-limit maxlength="75" type="textarea" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="1-2系列交班事项" style="white-space: nowrap;" prop="handOver1">
                                <el-input v-model="form.handOver1" style="width: 300px; font-size: 16px;" clearable
                                    :rows="2" show-word-limit maxlength="75" type="textarea" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="45">
                        <el-col :span="2"></el-col>
                        <el-col span="6">
                            <el-form-item label="1系列运转时间(小时)" style="white-space: nowrap;" prop="operTm1">
                                <el-input v-model="form.operTm1" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>

                        <el-col span="6">
                            <el-form-item label="1系列PH值" style="white-space: nowrap;" prop="phValue1">
                                <el-input v-model="form.phValue1" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>

                        <el-col span="5">
                            <el-form-item label="1系列用油量" style="white-space: nowrap;" prop="oilQty1">
                                <el-input v-model="form.oilQty1" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="1系列用药量" style="white-space: nowrap;" prop="medcQty1">
                                <el-input v-model="form.medcQty1" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="45">
                        <el-col :span="2"></el-col>
                        <el-col span="6">
                            <el-form-item label="2系列运转时间(小时)" style="white-space: nowrap;" prop="operTm2">
                                <el-input v-model="form.operTm2" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="6">
                            <el-form-item label="2系列PH值" style="white-space: nowrap;" prop="phValue2">
                                <el-input v-model="form.phValue2" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="6">
                            <el-form-item label="2系列用油量" style="white-space: nowrap;" prop="oilQty2">
                                <el-input v-model="form.oilQty2" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="2系列用药量" style="white-space: nowrap;" prop="medcQty2">
                                <el-input v-model="form.medcQty2" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>

                <el-card style="margin-bottom: 10px; margin-top: 10px; height: 240px;">
                    <el-row :gutter="60">
                        <el-col span="10">
                            <el-tag style="font-size: 20px;  margin-bottom: 20px;">3-4系列机器运转信息</el-tag>
                        </el-col>
                    </el-row>
                    <el-row :gutter="60">
                        <el-col :span="1"></el-col>
                        <el-col span="3">
                            <el-form-item label="3-4系列值班人" style="white-space: nowrap;" prop="dutyId3">
                                <el-input v-model="form.dutyId3" clearable style="width: 150px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="3-4系列运行记录" style="white-space: nowrap;" prop="operRecd3">
                                <el-input v-model="form.operRecd3" style="width: 300px; font-size: 16px;" clearable
                                    :rows="2" show-word-limit maxlength="75" type="textarea" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="3-4系列交班事项" style="white-space: nowrap;" prop="handOver3">
                                <el-input v-model="form.handOver3" style="width: 300px; font-size: 16px;" clearable
                                    :rows="2" show-word-limit maxlength="75" type="textarea" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="45">
                        <el-col :span="2"></el-col>
                        <el-col span="6">
                            <el-form-item label="3系列运转时间(小时)" style="white-space: nowrap;" prop="operTm3">
                                <el-input v-model="form.operTm3" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>

                        <el-col span="6">
                            <el-form-item label="3系列PH值" style="white-space: nowrap;" prop="phValue3">
                                <el-input v-model="form.phValue3" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>

                        <el-col span="5">
                            <el-form-item label="3系列用油量" style="white-space: nowrap;" prop="oilQty3">
                                <el-input v-model="form.oilQty3" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="3系列用药量" style="white-space: nowrap;" prop="medcQty3">
                                <el-input v-model="form.medcQty3" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="45">
                        <el-col :span="2"></el-col>
                        <el-col span="6">
                            <el-form-item label="4系列运转时间(小时)" style="white-space: nowrap;" prop="operTm4">
                                <el-input v-model="form.operTm4" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="6">
                            <el-form-item label="4系列PH值" style="white-space: nowrap;" prop="phValue4">
                                <el-input v-model="form.phValue4" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="6">
                            <el-form-item label="4系列用油量" style="white-space: nowrap;" prop="oilQty4">
                                <el-input v-model="form.oilQty4" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="4系列用药量" style="white-space: nowrap;" prop="medcQty4">
                                <el-input v-model="form.medcQty4" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>

                <el-card style="margin-bottom: 10px; margin-top: 10px; height: 240px;">
                    <el-row :gutter="60">
                        <el-col span="10">
                            <el-tag style="font-size: 20px;  margin-bottom: 20px;">5-6系列机器运转信息</el-tag>
                        </el-col>
                    </el-row>
                    <el-row :gutter="60">
                        <el-col :span="1"></el-col>
                        <el-col span="3">
                            <el-form-item label="5-6系列值班人" style="white-space: nowrap;" prop="dutyId5">
                                <el-input v-model="form.dutyId5" clearable style="width: 150px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="8">
                            <el-form-item label="5-6系列运行记录" style="white-space: nowrap;" prop="operRecd5">
                                <el-input v-model="form.operRecd5" style="width: 300px; font-size: 16px;" clearable
                                    :rows="2" show-word-limit maxlength="75" type="textarea" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="7">
                            <el-form-item label="5-6系列交班事项" style="white-space: nowrap;" prop="handOver5">
                                <el-input v-model="form.handOver5" style="width: 300px; font-size: 16px;" clearable
                                    :rows="2" show-word-limit maxlength="75" type="textarea" />
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="45">
                        <el-col :span="2"></el-col>
                        <el-col span="6">
                            <el-form-item label="5系列运转时间(小时)" style="white-space: nowrap;" prop="operTm5">
                                <el-input v-model="form.operTm5" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>

                        <el-col span="6">
                            <el-form-item label="5系列PH值" style="white-space: nowrap;" prop="phValue5">
                                <el-input v-model="form.phValue5" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>

                        <el-col span="5">
                            <el-form-item label="5系列用油量" style="white-space: nowrap;" prop="oilQty5">
                                <el-input v-model="form.oilQty5" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="5系列用药量" style="white-space: nowrap;" prop="medcQty5">
                                <el-input v-model="form.medcQty5" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="45">
                        <el-col :span="2"></el-col>
                        <el-col span="6">
                            <el-form-item label="6系列运转时间(小时)" style="white-space: nowrap;" prop="operTm6">
                                <el-input v-model="form.operTm6" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="6">
                            <el-form-item label="6系列PH值" style="white-space: nowrap;" prop="phValue6">
                                <el-input v-model="form.phValue6" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="6">
                            <el-form-item label="6系列用油量" style="white-space: nowrap;" prop="oilQty6">
                                <el-input v-model="form.oilQty6" clearable style="width: 130px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="6系列用药量" style="white-space: nowrap;" prop="medcQty6">
                                <el-input v-model="form.medcQty6" clearable style="width: 130px"></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 Selector from '@/components/Selector.vue'
    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()
        getDic()
        getGrp()
    })


    // 数据字典
    const optionList = ref([])
     const getDic = () => {
		var url = 'framework/Common/querySelector'
		var param = {
			type: 'PRD_OPER_SHIFT'
		}
		proxy.$axios.get(url, param).then(response => {
			if (response.data.code == '0') {
				optionList.value = response.data.data
			} else {
				ElMessage.error('操作失败！' + response.data.msg)
			}
		})
	}
    const optionGrpList = ref([])
    const getGrp = () => {
		var url = 'framework/Common/querySelector'
		var param = {
			type: 'PRD_OPER_GRP'
		}
		proxy.$axios.get(url, param).then(response => {
			if (response.data.code == '0') {
				optionGrpList.value = response.data.data
			} else {
				ElMessage.error('操作失败！' + response.data.msg)
			}
		})
	}


    /**
     *   查询
     */




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

   const getTableData = () => {
       var url = 'prd/MfloRecd/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({
        operDt: '', 
        operShift: '', 
        operGrp: '', 
        dutyId1: '', 
        operRecd1: '', 
        handOver1: '', 
        operTm1: '', 
        phValue1: '', 
        oilQty1: '', 
        medcQty1: '', 
        operTm2: '', 
        phValue2: '', 
        oilQty2: '', 
        medcQty2: '', 
        dutyId3: '', 
        operRecd3: '', 
        handOver3: '', 
        operTm3: '', 
        phValue3: '', 
        oilQty3: '', 
        medcQty3: '', 
        operTm4: '', 
        phValue4: '', 
        oilQty4: '', 
        medcQty4: '', 
        dutyId5: '', 
        operRecd5: '', 
        handOver5: '', 
        operTm5: '', 
        phValue5: '', 
        oilQty5: '', 
        medcQty5: '', 
        operTm6: '', 
        phValue6: '', 
        oilQty6: '', 
        medcQty6: ''
    })
    const ruleFormRef = ref()
    const rules = reactive({
        operDt: [{ required: true, message: '请输入生产日期', trigger: 'change' | 'blur' }], 
        operShift: [{ required: true, message: '请输入班次', trigger: 'change' | 'blur' }], 
        operGrp: [{ required: true, message: '请输入班组', trigger: 'change' | 'blur' }],
        dutyId1:[{ max: 20, message: '值班人超过有效长度', trigger: ['change', 'blur'] }],
        operRecd1:[{ max: 75, message: '运行记录超过有效长度', trigger: ['change', 'blur'] }],
        handOver1:[{ max: 75, message: '交班事项超过有效长度', trigger: ['change', 'blur'] }],
        operTm1:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        phValue1:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        oilQty1:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        medcQty1:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        operTm2:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        phValue2:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        oilQty2:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        medcQty2:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        
        dutyId3:[{ max: 20, message: '值班人超过有效长度', trigger: ['change', 'blur'] }],
        operRecd3:[{ max: 75, message: '运行记录超过有效长度', trigger: ['change', 'blur'] }],
        handOver3:[{ max: 75, message: '交班事项超过有效长度', trigger: ['change', 'blur'] }],
        operTm3:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        phValue3:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        oilQty3:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        medcQty3:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        operTm4:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        phValue4:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        oilQty4:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        medcQty4:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        
        dutyId5:[{ max: 20, message: '值班人超过有效长度', trigger: ['change', 'blur'] }],
        operRecd5:[{ max: 75, message: '运行记录超过有效长度', trigger: ['change', 'blur'] }],
        handOver5:[{ max: 75, message: '交班事项超过有效长度', trigger: ['change', 'blur'] }],
        operTm5:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        phValue5:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        oilQty5:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        medcQty5:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        operTm6:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        phValue6:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        oilQty6:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change' }],
        medcQty6:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        
        
    })

    const dialogName = ref('')
    const handleAdd = () => {
        form.value = {
            operDt: '', 
            operShift: '', 
            operGrp: '', 
            dutyId1: '', 
            operRecd1: '', 
            handOver1: '', 
            operTm1: '', 
            phValue1: '', 
            oilQty1: '', 
            medcQty1: '', 
            operTm2: '', 
            phValue2: '', 
            oilQty2: '', 
            medcQty2: '', 
            dutyId3: '', 
            operRecd3: '', 
            handOver3: '', 
            operTm3: '', 
            phValue3: '', 
            oilQty3: '', 
            medcQty3: '', 
            operTm4: '', 
            phValue4: '', 
            oilQty4: '', 
            medcQty4: '', 
            dutyId5: '', 
            operRecd5: '', 
            handOver5: '', 
            operTm5: '', 
            phValue5: '', 
            oilQty5: '', 
            medcQty5: '', 
            operTm6: '', 
            phValue6: '', 
            oilQty6: '', 
            medcQty6: ''
        }
        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/MfloRecd/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/MfloRecd/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/MfloRecd/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>