<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="110" 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="dutyId" label="司机" width="110" header-align="center" align="center"
                    show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="operRecd" label="运行记录" width="130" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="handOver" label="交班事项" width="130" header-align="center"
                    align="center" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="unldQty1" label="1#机卸车数量" width="120" header-align="center"
                    align="right" 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="stopTm1" label="1#机停车时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="repaTm1" label="1#机检修时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="accdTm1" label="1#机事故时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="unldQty2" label="2#机卸车数量" width="120" 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="stopTm2" label="2#机停车时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="repaTm2" label="2#机检修时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="accdTm2" label="2#机事故时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="unldQty3" label="3#机卸车数量" width="120" header-align="center"
                    align="right" 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="stopTm3" label="3#机停车时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="repaTm3" label="3#机检修时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="accdTm3" label="3#机事故时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="unldQty4" label="4#机卸车数量" width="120" 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="stopTm4" label="4#机停车时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="repaTm4" label="4#机检修时间" width="120" header-align="center"
                    align="right" show-overflow-tooltip>
                </el-table-column>
                <el-table-column v-if="true" prop="accdTm4" label="4#机事故时间" width="120" 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="1400px"
            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: 140px; ">
                    <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" clearable></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-col span="6">
                            <el-form-item label="司机" prop="dutyId">
                                <el-input v-model="form.dutyId" clearable style="width: 190px"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-form-item label="运行记录" prop="operRecd">
                            <el-input v-model="form.operRecd" style="width: 495px; font-size: 16px;" :rows="2"
                                show-word-limit maxlength="75" type="textarea" />
                        </el-form-item>
                        <el-form-item label="交班事项" prop="handOver">
                            <el-input v-model="form.handOver" style="width: 495px; font-size: 16px;"  :rows="2"
                                show-word-limit maxlength="75" type="textarea" />
                        </el-form-item>
                    </el-row>
                </el-card>
                <el-card style="margin-bottom: 10px; margin-top: 10px; height: 100px;">
                    <el-row><el-tag style="font-size: 20px; margin-bottom: 10px; ">1#压滤机运转信息</el-tag></el-row>
                    <el-row :gutter="70">
                        <el-col :span="1"></el-col>
                        <el-col span="5">
                            <el-form-item label="1#机卸车数量(车)" style="white-space: nowrap;" prop="unldQty1">
                                <el-input v-model="form.unldQty1" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="1#机运转时间(小时)" style="white-space: nowrap;" prop="operTm1">
                                <el-input v-model="form.operTm1" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="1#机停车时间(小时)" style="white-space: nowrap;" prop="stopTm1">
                                <el-input v-model="form.stopTm1" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="4">
                            <el-form-item label="1#机检修时间(小时)" style="white-space: nowrap;" prop="repaTm1">
                                <el-input v-model="form.repaTm1" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="4">
                            <el-form-item label="1#机事故时间(小时)" style="white-space: nowrap;" prop="accdTm1">
                                <el-input v-model="form.accdTm1" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>

                <el-card style="margin-bottom: 10px; height: 100px;">
                    <el-row><el-tag style="font-size: 20px; margin-bottom: 10px; ">2#压滤机运转信息</el-tag></el-row>
                    <el-row :gutter="70">
                        <el-col :span="1"></el-col>
                        <el-col span="5">
                            <el-form-item label="2#机卸车数量(车)" style="white-space: nowrap;" prop="unldQty2">
                                <el-input v-model="form.unldQty2" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="2#机运转时间(小时)" style="white-space: nowrap;" prop="operTm2">
                                <el-input v-model="form.operTm2" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="2#机停车时间(小时)" style="white-space: nowrap;" prop="stopTm2">
                                <el-input v-model="form.stopTm2" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="4">
                            <el-form-item label="2#机检修时间(小时)" style="white-space: nowrap;" prop="repaTm2">
                                <el-input v-model="form.repaTm2" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="4">
                            <el-form-item label="2#机事故时间(小时)" style="white-space: nowrap;" prop="accdTm2">
                                <el-input v-model="form.accdTm2" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>
                <el-card style="margin-bottom: 10px; height: 100px;">
                    <el-row><el-tag style="font-size: 20px; margin-bottom: 10px; ">3#压滤机运转信息</el-tag></el-row>
                    <el-row :gutter="70">
                        <el-col :span="1"></el-col>
                        <el-col span="5">
                            <el-form-item label="3#机卸车数量(车)" style="white-space: nowrap;" prop="unldQty3">
                                <el-input v-model="form.unldQty3" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="3#机运转时间(小时)" style="white-space: nowrap;" prop="operTm3">
                                <el-input v-model="form.operTm3" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="3#机停车时间(小时)" style="white-space: nowrap;" prop="stopTm3">
                                <el-input v-model="form.stopTm3" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="4">
                            <el-form-item label="3#机检修时间(小时)" style="white-space: nowrap;" prop="repaTm3">
                                <el-input v-model="form.repaTm3" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="4">
                            <el-form-item label="3#机事故时间(小时)" style="white-space: nowrap;" prop="accdTm3">
                                <el-input v-model="form.accdTm3" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-card>
                <el-card style="margin-bottom: 10px; height: 110px;">
                    <el-row><el-tag style="font-size: 20px; margin-bottom: 10px; ">4#压滤机运转信息</el-tag></el-row>
                    <el-row :gutter="70">
                        <el-col :span="1"></el-col>
                        <el-col span="5">
                            <el-form-item label="4#机卸车数量(车)" style="white-space: nowrap;" prop="unldQty4">
                                <el-input v-model="form.unldQty4" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="4#机运转时间(小时)" style="white-space: nowrap;" prop="operTm4">
                                <el-input v-model="form.operTm4" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="5">
                            <el-form-item label="4#机停车时间(小时)" style="white-space: nowrap;" prop="stopTm4">
                                <el-input v-model="form.stopTm4" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="4">
                            <el-form-item label="4#机检修时间(小时)" style="white-space: nowrap;" prop="repaTm4">
                                <el-input v-model="form.repaTm4" clearable style="width: 80px"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col span="4">
                            <el-form-item label="4#机事故时间(小时)" style="white-space: nowrap;" prop="accdTm4">
                                <el-input v-model="form.accdTm4" clearable style="width: 80px"></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/FilpRecd/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: '', 
        dutyId: '', 
        operRecd: '', 
        handOver: '', 
        unldQty1: '', 
        operTm1: '', 
        stopTm1: '', 
        repaTm1: '', 
        accdTm1: '', 
        unldQty2: '', 
        operTm2: '', 
        stopTm2: '', 
        repaTm2: '', 
        accdTm2: '', 
        unldQty3: '', 
        operTm3: '', 
        stopTm3: '', 
        repaTm3: '', 
        accdTm3: '', 
        unldQty4: '', 
        operTm4: '', 
        stopTm4: '', 
        repaTm4: '', 
        accdTm4: ''
    })
    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' }], 
        dutyId: [{ required: true, message: '请输入值班人', trigger: 'change' | 'blur' },
        { max: 20, message: '值班人超过有效长度', trigger: 'change' | 'blur' }],
        operRecd:[{ max: 75, message: '运行记录超过有效长度', trigger: 'change' | 'blur' }],
        handOver:[{ max: 75, message: '交班事项超过有效长度', trigger: 'change' | 'blur' }],
        unldQty1:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        operTm1:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        stopTm1:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        repaTm1:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        accdTm1:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        unldQty2:[{ 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'}],
        stopTm2:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        repaTm2:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        accdTm2:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        unldQty3:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        operTm3:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        stopTm3:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        repaTm3:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        accdTm3:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        unldQty4:[{ 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'}],
        stopTm4:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        repaTm4:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        accdTm4:[{ pattern: /^[0-9]{1,15}(\.[0-9]{1,10})?$/, message: '请输入有效的数字', trigger: 'blur' | 'change'}],
        

        
    })

    const dialogName = ref('')
    const handleAdd = () => {
        form.value = {
            operDt: '', 
            operShift: '', 
            operGrp: '', 
            dutyId: '', 
            operRecd: '', 
            handOver: '', 
            unldQty1: '', 
            operTm1: '', 
            stopTm1: '', 
            repaTm1: '', 
            accdTm1: '', 
            unldQty2: '', 
            operTm2: '', 
            stopTm2: '', 
            repaTm2: '', 
            accdTm2: '', 
            unldQty3: '', 
            operTm3: '', 
            stopTm3: '', 
            repaTm3: '', 
            accdTm3: '', 
            unldQty4: '', 
            operTm4: '', 
            stopTm4: '', 
            repaTm4: '', 
            accdTm4: ''
        }
        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/FilpRecd/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/FilpRecd/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/FilpRecd/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>