<template>
    <div class="content-main">
        <el-row>
            <el-form :inline="true" :model="formInline" class="search-bm-boder" ref="formInline">
                <el-form-item label="上报单位：" v-if="isSj">
                    <el-select
                            class="inputWidth"
                            v-model="formInline.dwid"
                            placeholder="请选择"
                    >
                        <el-option
                                v-for="item in options"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value"
                        ></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="年份：">
                    <el-date-picker
                            type="year"
                            class="inputWidth"
                            value-format="yyyy"
                            :picker-options="pickerOptions"
                            placeholder="选择日期"
                            v-model="formInline.tbnd"
                    ></el-date-picker>
                </el-form-item>

                <el-form-item>
                    <div class="search-button">
                        <span class="search-line"></span>
                        <el-button type="primary" size="small" class="iconfont iconchaxun" @click="doSearch">查询</el-button>
                        <el-button type="primary" @click="resetInfo('formInline')" size="small" class="iconfont iconzhongzhi"> 重置</el-button>
                    </div>
                </el-form-item>
            </el-form>
        </el-row>
        <el-row></el-row>
        <el-row class="addBtnBg">
            <el-button type="primary" class="iconfont iconbaocun" size="small" @click="saveSubmit()"> 保存</el-button>
            <el-button type="primary" class="iconfont icontijiao" size="small" @click="affirmSubmit()"> 提交</el-button>
            <el-button type="primary" class="iconfont icontuijian1" size="small" @click="backSubmit()"> 退回</el-button>
            <el-button type="primary" class="iconfont icondaochu11" size="small" @click="exportSubmit()"> 导出</el-button>
            <el-button type="primary" class="iconfont icondaoru1" size="small" @click="importSubmit()"> 导入</el-button>
        </el-row>
        <el-row>
            <div style="margin: 10px 0;">
                <el-button type="primary"  plain @click="changeTab('0')" v-if="tableData1 && tableData1.length"> 收购企业</el-button>
                <el-button type="primary" plain @click="changeTab('1')" v-if="tableData2 && tableData2.length"> 销售企业</el-button>
                <el-button type="primary" plain @click="changeTab('2')" v-if="tableData3 && tableData3.length"> 加工企业</el-button>
            </div>
            <div v-show="tabName == '收购企业'">
                <el-table
                        :data="tableData1"
                        stripe
                        v-loading="listLoading"
                        border
                        fit
                        highlight-current-row
                        style="width: 100%"
                        @selection-change="handleSelectionChange1">
                    <el-table-column
                            align="center"
                            type="selection"
                            width="50"
                            :selectable='selectInit'
                    ></el-table-column>
                    <el-table-column
                            prop="date"
                            :label= 'tbnd + "年粮食收购企业最低最高库存核定汇总表"'
                            align="center"
                    >
                        <el-table-column
                                prop="date"
                                label="填报单位"
                        >
                            <el-table-column
                                    prop="dwmc"
                                    label="单位名称"
                                    align="center"
                            >
                            </el-table-column>

                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label=""
                        >
                            <el-table-column
                                    prop="dwdz"
                                    label="地址"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwfr"
                                    label="法人"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwlxr"
                                    label="联系人"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwlxrdh"
                                    label="联系人电话"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwqyxz"
                                    label="企业性质"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column label="粮食" align="center">
                                <el-table-column
                                        prop="lssnd"
                                        label="上年度月均收购量"
                                        align="center"
                                >
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.lssnd" type="Number" @input="changelssnd(1,scope)" :disabled="disabledFun(scope.row.sjzt)"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        prop="lszgkc"
                                        label="核定最高库存"
                                        align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                        prop="lszdkc"
                                        label="核定最低库存"
                                        align="center"
                                >
                                </el-table-column>
                            </el-table-column>
                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label="单位：吨"
                        >
                            <el-table-column label="油料" align="center">
                                <el-table-column
                                        prop="syysnd"
                                        label="上年度月均收购量"
                                        align="center"
                                >
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.syysnd" type="Number" @input="changesyysnd(1,scope)" :disabled="disabledFun(scope.row.sjzt)"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        prop="syyzgkc"
                                        label="核定最高库存"
                                        align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                        prop="syyzdkc"
                                        label="核定最低库存"
                                        align="center"
                                >
                                </el-table-column>
                            </el-table-column>
                        </el-table-column>
                    </el-table-column>
                </el-table>
            </div>
            <div v-show="tabName == '销售企业'">
                <el-table
                        :data="tableData2"
                        stripe
                        v-loading="listLoading"
                        border
                        fit
                        highlight-current-row
                        style="width: 100%"
                        @selection-change="handleSelectionChange2">
                    <el-table-column
                            align="center"
                            type="selection"
                            width="50"
                            :selectable='selectInit'
                    ></el-table-column>
                    <el-table-column
                            prop="date"
                            label="2020年粮食收购企业最低最高库存核定汇总表"
                            align="center"
                    >
                        <el-table-column
                                prop="date"
                                label="填报单位"
                        >
                            <el-table-column
                                    prop="dwmc"
                                    label="单位名称"
                                    align="center"
                            >
                            </el-table-column>

                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label=""
                        >
                            <el-table-column
                                    prop="dwdz"
                                    label="地址"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwfr"
                                    label="法人"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwlxr"
                                    label="联系人"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwlxrdh"
                                    label="联系人电话"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwqyxz"
                                    label="企业性质"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column label="粮食" align="center">
                                <el-table-column
                                        prop="lssnd"
                                        label="上年度月均收购量"
                                        align="center"
                                >
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.lssnd" type="Number" @input="changelssnd(2,scope)" :disabled="disabledFun(scope.row.sjzt)"></el-input>
                                    </template>

                                </el-table-column>
                                <el-table-column
                                        prop="lszgkc"
                                        label="核定最高库存"
                                        align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                        prop="lszdkc"
                                        label="核定最低库存"
                                        align="center"
                                >
                                </el-table-column>
                            </el-table-column>
                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label="单位：吨"
                        >
                            <el-table-column label="食用油" align="center">
                                <el-table-column
                                        prop="syysnd"
                                        label="上年度月均收购量"
                                        align="center"
                                >
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.syysnd" type="Number" @input="changesyysnd(2,scope)" :disabled="disabledFun(scope.row.sjzt)"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        prop="syyzgkc"
                                        label="核定最高库存"
                                        align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                        prop="syyzdkc"
                                        label="核定最低库存"
                                        align="center"
                                >
                                </el-table-column>
                            </el-table-column>
                        </el-table-column>
                    </el-table-column>
                </el-table>
            </div>
            <div v-show="tabName == '加工企业'">
                <el-table
                        :data="tableData3"
                        stripe
                        v-loading="listLoading"
                        border
                        fit
                        highlight-current-row
                        style="width: 100%"
                        @selection-change="handleSelectionChange3">
                    <el-table-column
                            align="center"
                            type="selection"
                            width="50"
                            :selectable='selectInit'
                    ></el-table-column>
                    <el-table-column
                            prop="date"
                            label="2020年粮食收购企业最低最高库存核定汇总表"
                            align="center"
                    >
                        <el-table-column
                                prop="date"
                                label="填报单位"
                        >
                            <el-table-column
                                    prop="dwmc"
                                    label="单位名称"
                                    align="center"
                            >
                            </el-table-column>

                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label=""
                        >
                            <el-table-column
                                    prop="dwdz"
                                    label="地址"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwfr"
                                    label="法人"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwlxr"
                                    label="联系人"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwlxrdh"
                                    label="联系人电话"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column
                                    prop="dwqyxz"
                                    label="企业性质"
                                    align="center"
                            >
                            </el-table-column>
                            <el-table-column label="成品粮" align="center">
                                <el-table-column
                                        prop="lssnd"
                                        label="上年度月均收购量"
                                        align="center"
                                >
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.lssnd" type="Number" @input="changelssnd(3,scope)" :disabled="disabledFun(scope.row.sjzt)"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        prop="lszgkc"
                                        label="核定最高库存"
                                        align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                        prop="lszdkc"
                                        label="核定最低库存"
                                        align="center"
                                >
                                </el-table-column>
                            </el-table-column>
                            <el-table-column label="食用植物油" align="center">
                                <el-table-column
                                        prop="syysnd"
                                        label="上年度月均收购量"
                                        align="center"
                                >
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.syysnd" type="Number" @input="changesyysnd(3,scope)" :disabled="disabledFun(scope.row.sjzt)"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        prop="syyzgkc"
                                        label="核定最高库存"
                                        align="center"
                                >
                                </el-table-column>
                                <el-table-column
                                        prop="syyzdkc"
                                        label="核定最低库存"
                                        align="center"
                                >
                                </el-table-column>
                            </el-table-column>
                        </el-table-column>
                        <el-table-column
                                prop="date"
                                label="单位：吨"
                        >
                            <el-table-column label="原粮" align="center">
                                <el-table-column
                                        prop="ylsn"
                                        label="上年度月均收购量"
                                        align="center"
                                >
                                    <template slot-scope="scope">
                                        <el-input v-model="scope.row.ylsn" type="Number" @input="changeylsn(3,scope)" :disabled="disabledFun(scope.row.sjzt)"></el-input>
                                    </template>
                                </el-table-column>
                                <el-table-column
                                        prop="ylzg"
                                        label="核定最高库存"
                                        align="center"
                                >
                                </el-table-column>
                            </el-table-column>
                        </el-table-column>
                    </el-table-column>
                </el-table>
            </div>
        </el-row>
        <el-row>
            <el-pagination
                    @size-change="handleSizeChange1"
                    @current-change="handleCurrentChange1"
                    :current-page.sync="pageForm1.pageNum"
                    :page-sizes="[10,20,30,40]"
                    :page-size="pageForm1.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pageForm1.total"
                    v-show="tabName == '收购企业'"
            ></el-pagination>
            <el-pagination
                    @size-change="handleSizeChange2"
                    @current-change="handleCurrentChange2"
                    :current-page.sync="pageForm2.pageNum"
                    :page-sizes="[10,20,30,40]"
                    :page-size="pageForm2.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pageForm2.total"
                    v-show="tabName == '销售企业'"
            ></el-pagination>
            <el-pagination
                    @size-change="handleSizeChange3"
                    @current-change="handleCurrentChange3"
                    :current-page.sync="pageForm3.pageNum"
                    :page-sizes="[10,20,30,40]"
                    :page-size="pageForm3.pageSize"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="pageForm3.total"
                    v-show="tabName == '加工企业'"
            ></el-pagination>
        </el-row>
    </div>
</template>
<script>
    import {inspectionUnit, getList, updateList, backList} from "@/api/inventory/index"
    export default {
        data() {
            return {
                isSj: true,
                multipleSelection1: [],
                multipleSelection2: [],
                multipleSelection3: [],
                formInline: {
                    tbnd: null,
                    tblx: 0,
                    dwid: null,
                    dwmc: null,
                },
                tbnd: null,
                tabName: "收购企业",
                options:[],
                listLoading: false,
                tableData1: [],
                tableData2: [],
                tableData3: [],
                changeIndex1: [],
                changeIndex2: [],
                changeIndex3: [],
                pageForm1: {
                    pageNum: 1,
                    pageSize: 10,
                    total: 0
                },
                pageForm2: {
                    pageNum: 1,
                    pageSize: 10,
                    total: 0
                },
                pageForm3: {
                    pageNum: 1,
                    pageSize: 10,
                    total: 0
                },
                pickerOptions:{
                    disabledDate(time) {
                        return time.getTime() > Date.now()-8.64e7;
                    },
                },
            }
        },
        created() {
            this.formInline.tbnd = this.formatDateTime(new Date())
            this.tbnd = this.formInline.tbnd
            this.getList()
            if(sessionStorage.getItem('orgCode').length == 5){
                this.isSj = true
                this.getSbdw()
            }else{
                this.isSj = false
            }
        },
        methods: {
            selectInit(row,index){
                if(row.sjzt == '0'){
                    return false  //不可勾选
                }else{
                    return true  //可勾选
                }
            },
            disabledFun(sjzt){
                return (sessionStorage.getItem('orgCode').length == 5 && sjzt == '0')? false: true
            },
            changelssnd(type,scope){
                if(type == 1){
                    //tableData1
                    this.$set(this.tableData1[scope.$index],'lszgkc',(Number(scope.row.lssnd) * 0.3).toFixed(3))
                    this.$set(this.tableData1[scope.$index],'lszdkc',(Number(scope.row.lssnd) * 0.1).toFixed(3))
                    if(!this.changeIndex1.includes(scope.$index)){
                        this.changeIndex1.push(scope.$index)
                    }
                }else if(type == 2){
                    //tableData1
                    this.$set(this.tableData2[scope.$index],'lszgkc',(Number(scope.row.lssnd) * 0.3).toFixed(3))
                    this.$set(this.tableData2[scope.$index],'lszdkc',(Number(scope.row.lssnd) * 0.1).toFixed(3))
                    if(!this.changeIndex2.includes(scope.$index)){
                        this.changeIndex2.push(scope.$index)
                    }
                }else if(type == 3){
                    //tableData1
                    this.$set(this.tableData3[scope.$index],'lszgkc',(Number(scope.row.lssnd) * 0.2).toFixed(3))
                    this.$set(this.tableData3[scope.$index],'lszdkc',(Number(scope.row.lssnd) * 0.1).toFixed(3))
                    if(!this.changeIndex3.includes(scope.$index)){
                        this.changeIndex3.push(scope.$index)
                    }
                }
            },
            changesyysnd(type,scope){
                if(type == 1){
                    //tableData1
                    this.$set(this.tableData1[scope.$index],'syyzgkc',(Number(scope.row.syysnd) * 0.3).toFixed(3))
                    this.$set(this.tableData1[scope.$index],'syyzdkc',(Number(scope.row.syysnd) * 0.1).toFixed(3))
                    if(!this.changeIndex1.includes(scope.$index)){
                        this.changeIndex1.push(scope.$index)
                    }
                }else if(type == 2){
                    //tableData1
                    this.$set(this.tableData2[scope.$index],'syyzgkc',(Number(scope.row.syysnd) * 0.3).toFixed(3))
                    this.$set(this.tableData2[scope.$index],'syyzdkc',(Number(scope.row.syysnd) * 0.1).toFixed(3))
                    if(!this.changeIndex2.includes(scope.$index)){
                        this.changeIndex2.push(scope.$index)
                    }
                }else if(type == 3){
                    //tableData1
                    this.$set(this.tableData3[scope.$index],'syyzgkc',(Number(scope.row.syysnd) * 0.2).toFixed(3))
                    this.$set(this.tableData3[scope.$index],'syyzdkc',(Number(scope.row.syysnd) * 0.1).toFixed(3))
                    if(!this.changeIndex3.includes(scope.$index)){
                        this.changeIndex3.push(scope.$index)
                    }
                }
            },
            changeylsn(type,scope){
                this.$set(this.tableData3[scope.$index],'ylzg',Number(scope.row.ylsn).toFixed(3))
                if(!this.changeIndex3.includes(scope.$index)){
                    this.changeIndex3.push(scope.$index)
                }
            },
            //获取上报单位
            getSbdw(){
                //组织单位树 --检查单位列表
                inspectionUnit(sessionStorage.getItem("orgCode")).then(res=>{
                    if (sessionStorage.getItem("orgCode").length > 5) {
                        delete res.data.children;
                    } else {
                        for (let key in res.data) {
                            if (key == "children") {
                                for (let k = 0; k < res.data[key].length; k++) {
                                    delete res.data[key][k].children;
                                }
                            }
                        }
                        //截取16个区粮办
                        let children = res.data.children.slice(0, 16);
                        // children.forEach((item,index)=>{
                        // 	children[index].orgName = item.orgName.split("区")[0] + "区发改委"
                        // })
                        res.data.children = children;
                    }
                    this.options.push({
                        value: res.data.orgCode,
                        label: res.data.orgName,
                    });
                    if(res.data.children && res.data.children.length){
                        res.data.children.forEach(item=>{
                            this.options.push({
                                value: item.orgCode,
                                label: item.orgName,
                            });
                        })
                    }
                }).catch()
            },
            handleSelectionChange1(val) {
                this.multipleSelection1 = val
            },
            handleSelectionChange2(val) {
                this.multipleSelection2 = val
            },
            handleSelectionChange3(val) {
                this.multipleSelection3 = val
            },
            //重置
            resetInfo(){
                this.pageForm1.pageNum = 1;
                this.pageForm1.pageSize = 10;
                this.pageForm2.pageNum = 1;
                this.pageForm2.pageSize = 10;
                this.pageForm3.pageNum = 1;
                this.pageForm3.pageSize = 10;
                this.formInline.tbnd = this.formatDateTime(new Date())
                this.formInline.dwid = null
                this.formInline.dwmc = null
                this.tbnd = this.formInline.tbnd
                this.getList()
            },
            //查询
            doSearch(){
                this.pageForm1.pageNum = 1
                this.pageForm2.pageNum = 1
                this.pageForm3.pageNum = 1
                this.tbnd = this.formInline.tbnd ? this.formInline.tbnd : ''
                this.getList()
            },
            //获取列表
            getList() {
                if(this.formInline.dwid){
                    this.options.forEach(item=>{
                        if(item.value == this.formInline.dwid){
                            this.formInline.dwmc = item.label
                        }
                    })
                }
                let data1 = {
                    pageNum: this.pageForm1.pageNum,
                    pageSize: this.pageForm1.pageSize,
                    tbnd: this.formInline.tbnd,
                    tblx: '0',
                    dwid: this.formInline.dwid,
                    dwmc: this.formInline.dwmc,
                };
                getList(data1)
                    .then(res => {
                        if (res.infoCode == 200) {
                            this.tableData1 = res.data.list;
                            this.$set(this.pageForm1,"total", Number(res.data.total))
                        } else {
                            this.$message({
                                type: 'error',
                                message: res.msg
                            });
                        }
                    }).catch()
                let data2 = {
                    pageNum: this.pageForm2.pageNum,
                    pageSize: this.pageForm2.pageSize,
                    tbnd: this.formInline.tbnd,
                    tblx: '1',
                    dwid: this.formInline.dwid,
                    dwmc: this.formInline.dwmc,
                };
                getList(data2)
                    .then(res => {
                        if (res.infoCode == 200) {
                            this.tableData2 = res.data.list;
                            this.$set(this.pageForm2,"total", Number(res.data.total))
                        } else {
                            this.$message({
                                type: 'error',
                                message: res.msg
                            });
                        }
                    }).catch()
                let data3 = {
                    pageNum: this.pageForm3.pageNum,
                    pageSize: this.pageForm3.pageSize,
                    tbnd: this.formInline.tbnd,
                    tblx: '2',
                    dwid: this.formInline.dwid,
                    dwmc: this.formInline.dwmc,
                };
                getList(data3)
                    .then(res => {
                        if (res.infoCode == 200) {
                            this.tableData3 = res.data.list;
                            this.$set(this.pageForm3,"total", Number(res.data.total))
                        } else {
                            this.$message({
                                type: 'error',
                                message: res.msg
                            });
                        }
                    }).catch()

            },
            //tab按钮切换
            changeTab(type){
                if(type == '0'){
                    //收购企业
                    this.tabName = "收购企业"
                }else if(type == '1'){
                    //销售企业
                    this.tabName = "销售企业"
                }else if(type == '2'){
                    //加工企业
                    this.tabName = "加工企业"
                }
            },
            //获取此次更改的数据
            returnDataFun(){
                //收购企业要保存的数据
                let saveData1 = []
                if(this.changeIndex1.length){
                    this.tableData1.forEach((item,index)=>{
                        this.changeIndex1.forEach(val=>{
                            if(val == index){
                                saveData1.push(item)
                            }
                        })
                    })
                }
                //销售企业要保存的数据
                let saveData2 = []
                if(this.changeIndex2.length){
                    this.tableData2.forEach((item,index)=>{
                        this.changeIndex2.forEach(val=>{
                            if(val == index){
                                saveData2.push(item)
                            }
                        })
                    })
                }
                //销售企业要保存的数据
                let saveData3 = []
                if(this.changeIndex3.length){
                    this.tableData3.forEach((item,index)=>{
                        this.changeIndex3.forEach(val=>{
                            if(val == index){
                                saveData3.push(item)
                            }
                        })
                    })
                }
                let obj = {
                    sg: saveData1,
                    xs: saveData2,
                    jg: saveData3,
                }
                return obj
            },
            //保存
            saveSubmit() {
                let obj = this.returnDataFun()
                let params = []
                if(obj.sg && obj.sg.length){
                    obj.sg.forEach(item=>{
                        item.tblx = '0'
                        item.sjzt = '0' //数据状态：待提交
                        item.txdw = '0' //填写单位：企业
                        item.tbnd = this.formatDateTime(new Date())
                        params.push(item)
                    })
                }
                if(obj.xs && obj.xs.length){
                    obj.xs.forEach(item=>{
                        item.tblx = '1'
                        item.sjzt = '0' //数据状态：待提交
                        item.txdw = '0' //填写单位：企业
                        item.tbnd = this.formatDateTime(new Date())
                        params.push(item)
                    })
                }
                if(obj.jg && obj.jg.length){
                    obj.jg.forEach(item=>{
                        item.tblx = '2'
                        item.sjzt = '0' //数据状态：待提交
                        item.txdw = '0' //填写单位：企业
                        item.tbnd = this.formatDateTime(new Date())
                        params.push(item)
                    })
                }
                if(!params.length){
                    return
                }
                updateList(params).then(res=>{
                    if(res){
                        this.$message.success('保存成功')
                    }else{
                        this.$message.error('保存失败')
                    }
                }).catch()
            },
            //提交
            affirmSubmit() {
                let obj = this.returnDataFun()
                let params = []
                if(obj.sg && obj.sg.length){
                    obj.sg.forEach(item=>{
                        item.tblx = '0'
                        item.sjzt = '1' //数据状态：企业提交
                        item.txdw = '0' //填写单位：企业
                        item.tbnd = this.formatDateTime(new Date())
                        params.push(item)
                    })
                }
                if(obj.xs && obj.xs.length){
                    obj.xs.forEach(item=>{
                        item.tblx = '1'
                        item.sjzt = '1' //数据状态：企业提交
                        item.txdw = '0' //填写单位：企业
                        item.tbnd = this.formatDateTime(new Date())
                        params.push(item)
                    })
                }
                if(obj.jg && obj.jg.length){
                    obj.jg.forEach(item=>{
                        item.tblx = '2'
                        item.sjzt = '1' //数据状态：企业提交
                        item.txdw = '0' //填写单位：企业
                        item.tbnd = this.formatDateTime(new Date())
                        params.push(item)
                    })
                }
                if(!params.length){
                    return
                }
                updateList(params).then(res=>{
                    if(res){
                        this.$message.success('提交成功')
                    }else{
                        this.$message.error('提交失败')
                    }
                }).catch()
            },
            //退回
            backSubmit() {
                // this.multipleSelection1 //
                // this.multipleSelection2
                // this.multipleSelection3
                let params = []
                this.multipleSelection1.forEach(item=>{
                    params.push(item.dwid)
                })
                this.multipleSelection2.forEach(item=>{
                    params.push(item.dwid)
                })
                this.multipleSelection3.forEach(item=>{
                    params.push(item.dwid)
                })
                backList(params).then(res=>{
                    if(res.infoCode && res.infoCode == 200){
                        this.$message.success('退回成功')
                    }else{
                        this.$message.error('退回失败')
                    }
                }).catch()
            },
            //导出
            exportSubmit(){

            },
            //导入
            importSubmit(){

            },

            handleSizeChange1(val) {
                this.pageForm1.pageSize = val
                this.getList()
            },
            handleCurrentChange1(val) {
                this.pageForm1.pageNum = val
                this.getList()
            },
            handleSizeChange2(val) {
                this.pageForm2.pageSize = val
                this.getList()
            },
            handleCurrentChange2(val) {
                this.pageForm2.pageNum = val
                this.getList()
            },
            handleSizeChange3(val) {
                this.pageForm3.pageSize = val
                this.getList()
            },
            handleCurrentChange3(val) {
                this.pageForm3.pageNum = val
                this.getList()
            },
            formatDateTime(date) {
                let y = date.getFullYear();
                let m = date.getMonth() + 1;
                m = m < 10 ? "0" + m : m;
                let d = date.getDate();
                d = d < 10 ? "0" + d : d;
                let h = date.getHours();
                h = h < 10 ? "0" + h : h;
                let minute = date.getMinutes();
                minute = minute < 10 ? "0" + minute : minute;
                let second = date.getSeconds();
                second = second < 10 ? "0" + second : second;
                return y + '';
            },
        }
    }
</script>
<style scoped lang="scss">
    .content-main {
        margin: 10px 10px 0;
        padding-top: 20px;
    }

    .span-inline-block {
        float: left;
        margin-right: 5px;
        width: 80px;
        text-align: right;
        line-height: 30px;
    }

    .inputWidth {
        width:180px
    }

    .h3 {
        width: 98%;
        text-align: center;
        font-size: 1em;
        line-height: 2.5;
        color: #fff;
        background-color: #49a2fa;
        margin-bottom: 20px;
    }

    .el-form {
        overflow: hidden;
        overflow-y: auto;
    }

    .el-row {
        .el-tooltip {
            float: left;
            padding: 0 12px 0 0;
            width: 118px;
            white-space: nowrap;
            text-align: right;
            vertical-align: middle;
            color: #525357;
            font-size: 14px;
            line-height: 40px;
            box-sizing: border-box;
        }
    }
    .chb_box {
        /deep/ .el-checkbox {
            min-width: 150px;
        }
    }
    table {
        margin-bottom: 10px;
        font-size: 14px;
        border-collapse: collapse;
        color: #525357;
    }
    th {
        font-weight: 700;
        font-size: 18px;
    }
    td,
    th {
        padding: 10px;
        text-align: center;
        border: 1px solid #b0b0b0;
    }
</style>
