<template>
    <div class="app-container">
        <el-form
            :model="queryParams"
            ref="queryForm"
            size="small"
            :inline="true"
            v-show="showSearch"
            label-width="100px"
        >
            <el-form-item label="关键字" prop="keyWord">
                <el-input
                    v-model="queryParams.keyWord"
                    placeholder="请输入关键字"
                    clearable
                    style="width: 240px"
                />
            </el-form-item>
            <el-form-item label="退料单位" prop="unitId">
                <el-select
                    v-model="queryParams.unitId"
                    clearable
                    filterable
                    @change="getAgreementByUnit"
                    style="width: 240px"
                    placeholder="请选择"
                >
                    <el-option
                        v-for="item in unitList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="工程名称" prop="proId">
                <el-select
                    v-model="queryParams.proId"
                    clearable
                    filterable
                    @change="getAgreementByProId"
                    style="width: 240px"
                    placeholder="请选择"
                >
                    <el-option
                        v-for="item in proList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                    ></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="工机具类型" prop="typeId">
                <Tree
                    ref="mychildSon"
                    :width="240"
                    :dataList="deptList"
                    @changeId="selectDrop"
                ></Tree>
            </el-form-item>
            <el-form-item label="协议号" prop="agreementCode">
                <el-input
                    v-model="queryParams.agreementCode"
                    placeholder="请选择协议号"
                    clearable
                    style="width: 240px"
                />
            </el-form-item>
            <el-form-item label="退料状态" prop="taskStatus">
                <el-select
                    v-model="queryParams.taskStatus"
                    clearable
                    filterable
                    style="width: 240px"
                    placeholder="请选择"
                >
                    <el-option
                        v-for="item in taskStatusList"
                        :key="item.id"
                        :label="item.name"
                        :value="item.id"
                    ></el-option>
                </el-select>
            </el-form-item>

            <el-form-item label="退料申请时间" prop="timeRange">
                <el-date-picker
                    v-model="timeRange"
                    type="datetimerange"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    value-format="yyyy-MM-dd"
                    style="width: 240px"
                ></el-date-picker>
            </el-form-item>

            <el-form-item>
                <el-button
                    type="primary"
                    icon="el-icon-search"
                    size="mini"
                    @click="handleQuery"
                    >查询</el-button
                >
                <el-button
                    icon="el-icon-refresh"
                    size="mini"
                    @click="resetQuery"
                    >重置</el-button
                >
            </el-form-item>
        </el-form>

        <el-row :gutter="10" class="mb8">
            <el-col :span="1.5">
                <el-button
                    type="primary"
                    plain
                    size="mini"
                    @click="handleExam"
                    :disabled="multiple"
                    v-hasPermi="['auditing:batch']"
                    >批量审核</el-button
                >
            </el-col>
            <!-- <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          size="mini"
          @click="handleSubmit()"
          >批量提交</el-button
        >
      </el-col>-->
            <el-col :span="1.5">
                <el-button
                    type="success"
                    plain
                    icon="el-icon-download"
                    size="mini"
                    @click="handleExport"
                    >导出</el-button
                >
            </el-col>

            <right-toolbar
                :showSearch.sync="showSearch"
                @queryTable="getList"
            ></right-toolbar>
        </el-row>

        <el-table
            v-loading="loading"
            :data="typeList"
            @selection-change="handleSelectionChange"
            border
        >
            <el-table-column
                type="selection"
                width="55"
                align="center"
                :selectable="selectable"
            />
            <!-- <el-table-column
                label="序号"
                align="center"
                width="80"
                type="index"
            >
                <template scope="scope">
                    <span>{{
                        (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1
                    }}</span>
                </template>
            </el-table-column> -->
            <el-table-column
                align="center"
                label="序号"
                type="index"
                :index="
                    indexContinuation(queryParams.pageNum, queryParams.pageSize)
                "
            />
            <el-table-column
                label="退料单号"
                align="center"
                prop="code"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                label="退料单位"
                align="center"
                prop="unitName"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                label="退料工程"
                align="center"
                prop="lotName"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                label="退料机具"
                align="center"
                prop="typeName"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                label="退料人员"
                align="center"
                prop="backPerson"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                label="联系电话"
                align="center"
                prop="phone"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                label="申请时间"
                align="center"
                prop="backTime"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                label="协议号"
                align="center"
                prop="agreementCode"
                :show-overflow-tooltip="true"
            />
            <el-table-column
                label="异常退料"
                align="center"
                prop="dictName"
                :show-overflow-tooltip="true"
            >
                <template slot-scope="scope">
                    <div>
                        <!-- 暂时全部未否 -->
                        否
                    </div>
                </template>
            </el-table-column>
            <el-table-column
                label="退料状态"
                align="center"
                :show-overflow-tooltip="true"
            >
                <template slot-scope="scope">
                    <el-button type="text" v-if="scope.row.taskStatus == '37'"
                        >待审核</el-button
                    >
                    <el-button
                        type="text"
                        style="color: #67c23a"
                        v-if="scope.row.taskStatus == '38'"
                        >已审核</el-button
                    >
                    <el-button type="text" v-if="scope.row.taskStatus == '39'"
                        >退料核查</el-button
                    >
                    <el-button
                        type="text"
                        style="color: #67c23a"
                        v-if="scope.row.taskStatus == '40'"
                        >退料完成</el-button
                    >
                    <el-button
                        type="text"
                        style="color: #67c23a"
                        v-if="scope.row.taskStatus == '101'"
                        >退料驳回</el-button
                    >
                </template>
            </el-table-column>
            <el-table-column
                label="备注"
                align="center"
                prop="remark"
                :show-overflow-tooltip="true"
            />
            <el-table-column label="操作" align="center" width="180">
                <template slot-scope="scope">
                    <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-zoom-in"
                        @click="handleSee(scope.row, 'see')"
                        >查看</el-button
                    >
                    <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-edit"
                        v-if="scope.row.applyStatus == '0'"
                        v-hasPermi="['auditing']"
                        @click="handleUpdate(scope.row, 'update')"
                    >
                        审批
                    </el-button>
                    <!-- <el-button
                        size="mini"
                        type="text"
                        icon="el-icon-edit"
                        v-if="scope.row.applyStatus == '0'"
                        v-hasPermi="['receive:examine:nbry-sbfgs']"
                        @click="handleUpdate(scope.row, 'update')"
                    >
                        审批
                    </el-button> -->
                    <el-button
                        size="mini"
                        type="text"
                        @click="handlePrint(scope.row)"
                        >退料单</el-button
                    >
                </template>
            </el-table-column>
        </el-table>

        <pagination
            v-show="total > 0"
            :total="total"
            :page.sync="queryParams.pageNum"
            :limit.sync="queryParams.pageSize"
            @pagination="getList"
        />

        <!-- 添加或修改参数配置对话框 -->
        <el-dialog
            :title="title"
            :visible.sync="open"
            width="1000px"
            append-to-body
        >
            <el-form
                :model="dialogQueryParams"
                ref="queryForm1"
                size="small"
                :inline="true"
                v-show="showSearch"
                label-width="100px"
            >
                <el-row>
                    <el-form-item label="退料单位" prop="unitName">
                        <el-input
                            disabled
                            v-model="dialogQueryParams.unitName"
                            placeholder="请输入退料单位"
                            clearable
                            style="width: 240px"
                        />
                    </el-form-item>
                    <el-form-item label="退料工程" prop="lotName">
                        <el-input
                            disabled
                            v-model="dialogQueryParams.lotName"
                            placeholder="请输入退料工程"
                            clearable
                            style="width: 240px"
                        />
                    </el-form-item>
                    <el-form-item label="退料协议编号" prop="agreementCode">
                        <el-input
                            disabled
                            v-model="dialogQueryParams.agreementCode"
                            placeholder="请输入退料协议编号"
                            clearable
                            style="width: 240px"
                        />
                    </el-form-item>
                    <el-form-item label="预退料时间" prop="backTime">
                        <el-date-picker
                            style="width: 240px"
                            disabled
                            v-model="dialogQueryParams.backTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="选择时间"
                        ></el-date-picker>
                    </el-form-item>
                </el-row>
                <el-row>
                    <el-form-item label="退料人" prop="backPerson">
                        <el-input
                            disabled
                            v-model="dialogQueryParams.backPerson"
                            placeholder="请输入退料人"
                            clearable
                            style="width: 240px"
                        />
                    </el-form-item>
                    <el-form-item label="退料人电话" prop="phone">
                        <el-input
                            disabled
                            v-model="dialogQueryParams.phone"
                            placeholder="请输入退料人电话"
                            clearable
                            style="width: 240px"
                        />
                    </el-form-item>
                </el-row>

                <el-row>
                    <el-form-item label="关键字" prop="keyWord">
                        <el-input
                            v-model="dialogQueryParams.keyWord"
                            placeholder="请输入关键字"
                            clearable
                            style="width: 240px"
                        />
                    </el-form-item>
                    <el-form-item>
                        <el-button
                            type="primary"
                            icon="el-icon-search"
                            size="mini"
                            @click="handleQuery1"
                            >查询</el-button
                        >
                        <el-button
                            icon="el-icon-refresh"
                            size="mini"
                            @click="resetQuery1"
                            >重置</el-button
                        >
                    </el-form-item>
                </el-row>
            </el-form>

            <el-table v-loading="loading" :data="loadingList" height="400px">
                <el-table-column type="selection" width="55" align="center" />
                <el-table-column
                    label="序号"
                    align="center"
                    width="80"
                    type="index"
                >
                    <template slot-scope="scope">
                        <span>{{
                            (dialogQueryParams.pageNum - 1) * 10 +
                            scope.$index +
                            1
                        }}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="类型名称"
                    align="center"
                    prop="typeName"
                    :show-overflow-tooltip="true"
                />
                <el-table-column type="expand">
                    <template slot-scope="scope">
                        <div class="nested-table-container">
                            <el-table
                                :data="scope.row.maTypeDetails"
                                style="width: 100%"
                            >
                                <!-- 子表格的列 -->
                                <el-table-column
                                    label="序号"
                                    align="center"
                                    type="index"
                                />
                                <el-table-column
                                    label="类型名称"
                                    align="center"
                                    prop="typeName"
                                    :show-overflow-tooltip="true"
                                />
                                <el-table-column
                                    label="规格型号"
                                    align="center"
                                    prop="typeModelName"
                                    :show-overflow-tooltip="true"
                                />
                                <el-table-column
                                    label="单位"
                                    align="center"
                                    prop="unitName"
                                    :show-overflow-tooltip="true"
                                />
                                <el-table-column
                                    label="预领数量"
                                    align="center"
                                    prop="partNum"
                                    :show-overflow-tooltip="true"
                                />
                            </el-table>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    label="规格型号"
                    align="center"
                    prop="typeCode"
                    :show-overflow-tooltip="true"
                />
                <el-table-column
                    label="退料数量"
                    align="center"
                    class-name="small-padding fixed-width"
                    width="200"
                    prop="preNum"
                >
                    <template slot-scope="scope">
                        <el-input
                            v-if="loadingType != 'see'"
                            v-model.number="scope.row.preNum"
                            placeholder="请输入退料数量"
                            type="number"
                            min="1"
                            clearable
                            @input="checkNum(scope.row)"
                            style="width: 100%"
                        />
                        <span v-else>{{ scope.row.preNum }}</span>
                    </template>
                </el-table-column>
            </el-table>

            <pagination
                v-show="loadingTotal > 0"
                :total="loadingTotal"
                :page.sync="dialogQueryParams.pageNum"
                :limit.sync="dialogQueryParams.pageSize"
                @pagination="getDialogList"
            />

            <div
                slot="footer"
                class="dialog-footer"
                style="text-align: center"
                v-if="loadingType == 'update' && loadingList.length > 0"
            >
                <el-button type="primary" @click="submitForm">通过</el-button>
                <el-button type="danger" @click="submitForm2">不通过</el-button>
                <el-button @click="cancel">取消</el-button>
            </div>
        </el-dialog>

        <!-- 退料单 -->
        <dialogForm
            :dialogTitle="title"
            :isShowFlag.sync="isShowOneFlag"
            :rowObj="rowObj"
            :priKey="priKey"
        ></dialogForm>
        <!-- 提交 -->
        <el-dialog
            v-loading.fullscreen.lock="fullscreenLoading"
            :title="title"
            :visible.sync="openOne"
            append-to-body
            width="400px"
        >
            <div class="submit_box">
                <div>
                    <i
                        class="el-icon-circle-check"
                        style="color: #ff9900; font-size: 30px"
                    ></i>
                </div>
                <div class="submit_box_title">
                    <div>{{ openTextOne }}</div>
                    <div>{{ openTextTwo }}</div>
                </div>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button @click="cancel">返回</el-button>
                <el-button type="primary" @click="submitOpenOneForm()"
                    >确定</el-button
                >
            </div>
        </el-dialog>

        <el-dialog
            v-loading.fullscreen.lock="fullscreenLoading"
            :title="title"
            :visible.sync="openTwo"
            append-to-body
            width="400px"
        >
            <div class="submit_box_two">
                <div>
                    <i
                        class="el-icon-circle-check"
                        style="color: #00c196; font-size: 30px"
                    ></i>
                </div>
                <div class="submit_box_title">{{ openTextThree }}</div>
            </div>
            <div slot="footer" class="dialog-footer"></div>
        </el-dialog>
    </div>
</template>

<script>
import {
    listType,
    getType,
    delType,
    addType,
    updateType,
    refreshCache,
} from '@/api/system/dict/type'
import {
    getBackAuditList,
    getViewByExamine,
    ApiBackApplyAudit,
    ApiBackApplyRefuse,
} from '@/api/claimAndRefund/return.js'
import { getInfo, h } from '@/api/login'
import {
    getUnitData,
    getProData,
    getAgreementInfoById,
    auditAll,
} from '@/api/claimAndRefund/receive.js'
import dialogForm from './dialogFormExame.vue'
import { listPartTypeApi } from '@/api/repairTest/repair'
import Tree from './tree.vue'
// 10:42开始日期startTime,结束日期endTime     机具类型typeId
// http://localhost/claimAndRefund/return/returnApply
export default {
    // name: "ReturnExamine",
    dicts: ['sys_normal_disable'],
    components: { dialogForm, Tree },
    data() {
        return {
            checkResultOne: false,
            fullscreenLoading: false,
            type: '',
            isShowOneFlag: false,
            priKey: '',
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            // 字典表格数据
            typeList: [],
            // 弹出层标题
            title: '',
            // 是否显示弹出层
            open: false,
            // 日期范围
            dateRange: [],
            timeRange: [],
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                keyWord: '', //关键字
                unitId: '', //单位id
                lotId: '', //工程id
                taskStatus: '', //状态
                typeId: '', //工机具类型
                agreementCode: '', //协议
                startTime: '',
                endTime: '',
                proId: '',
            },
            dialogQueryParams: {
                pageNum: 1,
                pageSize: 10,
            },
            // 表单参数
            form: {},
            // 表单校验
            rules: {
                dictName: [
                    {
                        required: true,
                        message: '字典名称不能为空',
                        trigger: 'blur',
                    },
                ],
                dictType: [
                    {
                        required: true,
                        message: '字典类型不能为空',
                        trigger: 'blur',
                    },
                ],
            },
            openOne: false,
            openTwo: false,
            openTextOne: '',
            openTextTwo: '',
            openTextThree: '',
            companyId: '',
            deptList: [],
            unitList: [],
            proList: [],
            taskStatusList: [
                {
                    name: '待退料审核',
                    id: '37',
                },
                {
                    name: '退料审核通过',
                    id: '38',
                },
                {
                    name: '退料核查中',
                    id: '39',
                },
                {
                    name: '退料完成',
                    id: '40',
                },
                {
                    name: '退料审核驳回',
                    id: '101',
                },
            ],
            loadingList: [],
            loadingTotal: 0,
            rowObj: {},
            loadingType: '',
            idList: [],
        }
    },
    created() {
        this.initSelectData()
        this.InitIGetInfo()
        this.getList()
        this.getTree()
    },
    methods: {
        // claimAndRefund/return/returnApplyAdd
        // claimAndRefund/return/returnApplyAdd
        /** 查询字典类型列表 startTime,结束日期endTime  */
        async getList() {
            this.loading = true
            this.queryParams.startTime = this.timeRange ? this.timeRange[0] : ''
            this.queryParams.endTime = this.timeRange ? this.timeRange[1] : ''
            try {
                let params = {
                    companyId: this.companyId,
                    ...this.queryParams,
                }
                console.log('paramsparamsparams', params)
                const res = await getBackAuditList(params)
                this.typeList = res.data.rows
                console.log('🚀 ~ getList ~ this.typeList:', this.typeList)
                this.total = res.data.total
                this.loading = false
            } catch (error) {}
        },
        getTree() {
            listPartTypeApi().then((response) => {
                this.deptList = response.data
            })
        },
        // 取消按钮
        cancel() {
            this.open = false
            this.reset()
        },
        // 表单重置
        reset() {
            this.form = {
                dictId: undefined,
                dictName: undefined,
                dictType: undefined,
                status: '0',
                remark: undefined,
            }
            this.resetForm('form')
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1
            this.getList()
        },
        /** 重置按钮操作 */
        resetQuery() {
            this.dateRange = []
            this.timeRange = []
            // this.resetForm("queryForm");
            this.$refs.queryForm.resetFields()
            this.$refs.mychildSon.inputValue = ''
            this.initSelectData()
            this.handleQuery()
        },

        // 多选框选中数据
        handleSelectionChange(selection) {
            this.checkResultOne = selection.every(
                (item) => item.taskStatus !== '38',
            )
            this.ids = selection.map((item) => item.id)
            this.single = selection.length != 1
            this.multiple = !selection.length
            this.idList = selection.map((item) => {
                return {
                    id: item.id,
                    taskId: item.taskId,
                    agreementId: item.agreementId,
                    badId: item.badId,
                }
            })
        },
        handlePrint(row) {
            this.isShowOneFlag = true
            this.rowObj = row
        },
        /** 修改按钮操作 */
        handleUpdate(row, type) {
            this.dialogQueryParams.unitName = row.unitName
            this.dialogQueryParams.lotName = row.lotName
            this.dialogQueryParams.agreementCode = row.agreementCode
            this.dialogQueryParams.backPerson = row.backPerson
            this.dialogQueryParams.backPerson = row.backPerson
            this.dialogQueryParams.phone = row.phone
            this.dialogQueryParams.backTime = row.backTime + ''
            this.$set(this.dialogQueryParams, 'keyWord', '')
            this.loadingType = type
            this.rowObj = row
            this.open = true
            this.getDialogList()
        },
        handleSee(row, type) {
            this.dialogQueryParams.unitName = row.unitName
            this.dialogQueryParams.lotName = row.lotName
            this.dialogQueryParams.agreementCode = row.agreementCode
            this.dialogQueryParams.backPerson = row.backPerson
            this.dialogQueryParams.phone = row.phone
            this.dialogQueryParams.backTime = row.backTime + ''
            this.$set(this.dialogQueryParams, 'keyWord', '')
            this.loadingType = type
            this.rowObj = row
            this.open = true
            this.getDialogList()
        },
        getDialogList() {
            let params = {
                taskId: this.rowObj.taskId,
                agreementId: this.rowObj.agreementId,
                pageNum: this.dialogQueryParams.pageNum,
                pageSize: this.dialogQueryParams.pageSize,
                keyWord: this.dialogQueryParams.keyWord,
                badId: this.rowObj.badId,
            }
            getViewByExamine(params).then((res) => {
                this.loadingList = res.rows
                this.loadingList.forEach((item) => {
                    if (!item.num) {
                        item.num = item.preNum
                    }
                })
                this.loadingTotal = res.total
            })
        },
        // 退料单
        handleUpdateOrder() {
            this.title = '查看'
            this.isShowOneFlag = true
        },
        // 提交
        handleSubmit() {
            this.title = '确认操作'
            this.openTextOne = '确认提交申请么?'
            this.openTextTwo = '确认提交申请么?'
            this.openOne = true
        },
        submitOpenOneForm() {
            this.openTextThree = '提交成功！'
            this.openTwo = true
        },
        /** 提交按钮 同意 */
        submitForm() {
            const isNum = this.loadingList.some(
                (item) => item.num == '' || item.num == undefined,
            )
            if (isNum) {
                this.$message.error('退料数量不能为空！')
                return
            }

            let params = {
                ids: this.rowObj.id,
                backApplyDetails: this.loadingList,
            }
            // console.log(params)
            ApiBackApplyAudit(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.open = false
                        this.getList()
                    }
                })
                .catch(() => {})
        },
        /** 提交按钮 拒绝 */
        submitForm2() {
            const isNum = this.loadingList.some(
                (item) => item.num == '' || item.num == undefined,
            )
            if (isNum) {
                this.$message.error('退料数量不能为空！')
                return
            }
            let params = {
                ids: this.rowObj.id,
            }
            ApiBackApplyRefuse(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.open = false
                        this.getList()
                    }
                })
                .catch(() => {})
        },
        handleAdd() {
            let params = {
                ids: this.rowObj.id,
            }
            ApiBackApplyAudit(params)
                .then((res) => {
                    if (res.code == 200) {
                        this.open = false
                        this.$message.error(res.msg)
                        this.getList()
                    }
                })
                .catch(() => {})
        },
        selectable(row) {
            if (row.taskStatus == 37) {
                return true
            } else {
                return false
            }
        },
        checkNum(row) {
            const maxNum = row.preNum
            if (row.num <= 1) {
                row.num = 1
            } else if (row.num >= maxNum) {
                row.num = maxNum
            }
        },
        handleExam() {
            let backApplyList = []

            // 弹窗确认
            this.$confirm('是否确认审核通过？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning',
            })
                .then(() => {
                    this.idList.map((item) => {
                        let params = {
                            taskId: item.taskId,
                            agreementId: item.agreementId,
                            badId: item.badId,
                            pageNum: this.dialogQueryParams.pageNum,
                            pageSize: this.dialogQueryParams.pageSize,
                        }
                        getViewByExamine(params).then((res) => {
                            backApplyList.push({
                                id: item.id,
                                backApplyDetails: res.rows,
                            })
                        })
                    })

                    setTimeout(() => {
                        auditAll({ backApplyList }).then((res) => {
                            this.$message.success(res.msg)
                            this.getList()
                        })
                    }, 100)
                })
                .catch(() => {
                    this.$message.info('已取消审核')
                })
        },

        /** 删除按钮操作 */
        handleDelete(row) {
            const dictIds = row.dictId || this.ids
            this.$modal
                .confirm('是否确认删除所选择的数据项？')
                .then(function () {
                    return delType(dictIds)
                })
                .then(() => {
                    this.getList()
                    this.$modal.msgSuccess('删除成功')
                })
                .catch(() => {})
        },
        /** 导出按钮操作 */
        handleExport() {
            this.download(
                'material/backApply/exportExamine',
                {
                    ...this.queryParams,
                },
                `退料审核单_${new Date().getTime()}.xlsx`,
            )
        },
        /** 刷新缓存按钮操作 */
        handleRefreshCache() {
            refreshCache().then(() => {
                this.$modal.msgSuccess('刷新成功')
                this.$store.dispatch('dict/cleanDict')
            })
        },
        InitIGetInfo() {
            getInfo().then((res) => {
                this.companyId = res.user.companyId
                this.getList()
            })
        },
        selectDrop(value) {
            this.queryParams.typeId = value
        },
        initSelectData() {
            this.GetUnitData()
            this.GetProData()
        },

        // 获取 来往单位 列表数据
        async GetUnitData() {
            const params = {}
            const res = await getUnitData(params)
            this.unitList = res.data
            console.log('GetUnitData ======================', res)
        },
        // 获取 工程名称 列表数据
        async GetProData() {
            const params = {
                id: this.queryParams.unitId,
            }
            const res = await getProData(params)
            this.proList = res.data

            console.log('GetProData ======================', res)
        },
        // 获取 工程名称 列表数据
        async InitGetAgreementInfoById() {
            const { unitId, proId } = this.queryParams
            if (!unitId || !proId) {
                return
            }
            const params = {
                unitId: unitId,
                projectId: proId,
            }
            const res = await getAgreementInfoById(params)
            // this.proList = res.data
            console.log('getAgreementInfoById ======================', res)
            this.queryParams.agreementCode = res.data.agreementCode
        },
        getAgreementByUnitAndProId() {
            this.InitGetAgreementInfoById()
        },
        getAgreementByProId() {
            this.InitGetAgreementInfoById()
        },
        getAgreementByUnit() {
            this.GetProData()
        },
        handleQuery1() {
            this.getDialogList()
        },
        resetQuery1() {
            this.dialogQueryParams.keyWord = ''
            this.getDialogList()
        },
    },
}
</script>
<style lang="scss" scoped>
.submit_box {
    display: flex;
    justify-content: flex-start;
    align-items: center;

    .submit_box_title {
        display: flex;
        flex-direction: column;
        margin-left: 15px;

        :first-child {
            font-size: 14px;
            font-weight: 600;
        }

        :last-child {
            margin-top: 6px;
            font-size: 12px;
        }
    }
}

.submit_box_two {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    margin-left: 30%;

    .submit_box_title {
        display: flex;
        flex-direction: column;
        margin-left: 10px;
        font-size: 18px;
        font-weight: 600;
    }
}

::v-deep.el-table .fixed-width .el-button--mini {
    width: 60px !important;
    margin-bottom: 10px;
}
.dialog-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}
</style>
