<template>
    <div class="hc-page-box">
        <HcCard>
            <template #header>
                <HcTooltip keys="tentative_material_approach_add">
                    <el-button hc-btn type="primary" @click="addFormModalClick">
                        <HcIcon name="add-circle"/>
                        <span>新增</span>
                    </el-button>
                </HcTooltip>
                <HcTooltip keys="tentative_material_approach_edit">
                    <el-button :disabled="tableCheckedKeys.length <= 0" hc-btn @click="editFormModalClick">
                        <HcIcon name="edit"/>
                        <span>编辑</span>
                    </el-button>
                </HcTooltip>
                <HcTooltip keys="tentative_material_approach_copy">
                    <el-button :disabled="tableCheckedKeys.length <= 0" hc-btn @click="copyTableModalClick">
                        <HcIcon name="file-copy-2"/>
                        <span>复制</span>
                    </el-button>
                </HcTooltip>
                <HcTooltip keys="tentative_material_approach_del">
                    <el-button :disabled="tableCheckedKeys.length <= 0" hc-btn @click="delModalClick">
                        <HcIcon name="delete-bin-2"/>
                        <span>删除</span>
                    </el-button>
                </HcTooltip>
                <HcTooltip keys="tentative_material_approach_printer">
                    <el-button :disabled="tableCheckedKeys.length <= 0" :loading="printerLoading" hc-btn
                               @click="printerClick">
                        <HcIcon name="printer"/>
                        <span>打印</span>
                    </el-button>
                </HcTooltip>
                <HcTooltip keys="tentative_material_approach_import">
                    <el-button hc-btn @click="importModalClick">
                        <HcIcon name="folder-upload"/>
                        <span>导入</span>
                    </el-button>
                </HcTooltip>
            </template>
            <template #search>
                <div class="w-40">
                    <el-select v-model="searchForm.materialType" clearable placeholder="请选择材料类型">
                        <el-option v-for="item in typeData" :key="item.value" :label="item['dictValue']"
                                   :value="item['dictKey']"/>
                    </el-select>
                </div>
                <div class="w-64 ml-2">
                    <HcDatePicker :dates="betweenTime" clearable @change="betweenTimeUpdate"/>
                </div>
                <div class="w-72 ml-2">
                    <el-input v-model="searchForm.queryValue" clearable placeholder="请输入名称、规格、材料编号进行查询"
                              @keyup="keyUpEvent"/>
                </div>
                <div class="ml-2">
                    <el-button type="primary" @click="searchClick">
                        <HcIcon name="search-2"/>
                        <span>搜索</span>
                    </el-button>
                </div>
            </template>
            <HcTable ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading" isCheck
                     @selection-change="tableSelection">
                <template #materialType="{row}">{{ getRowTableMaterialType(row['materialType']) }}</template>
                <template #materialCount="{row}">{{ row.materialCount === -1 ? "" : row.materialCount }}</template>
                <template #materialPrice="{row}">{{ row.materialPrice === -1 ? "" : row.materialPrice }}</template>
                <template #action="{row}">
                    <HcTooltip keys="tentative_material_approach_annex">
                        <el-button plain size="small" type="primary" @click="viewAttachmentModalClick(row)">附件
                        </el-button>
                    </HcTooltip>
                    <HcTooltip keys="tentative_material_approach_sampling">
                        <el-button plain size="small" type="primary" @click="samplingRecordModalClick(row)">取样记录
                        </el-button>
                    </HcTooltip>
                </template>
            </HcTable>
            <template #action>
                <HcPages :pages="searchForm" @change="pageChange"/>
            </template>
        </HcCard>

        <!--新增/编辑-->
        <HcDialog :loading="addEditFormLoading" :show="addEditFormModal" :title="`${addEditFormModel.id?'编辑':'新增'}材料进场`"
                  widths="45rem" @close="addEditFormModalClose" @save="addEditFormClick">
            <el-form ref="addEditFormRef" :model="addEditFormModel" :rules="addEditFormRules" label-width="auto"
                     size="large">
                <div class="hc-form-item">
                    <el-form-item label="材料类型" prop="materialType">
                        <el-select v-model="addEditFormModel.materialType" block>
                            <el-option v-for="item in typeData" :label="item['dictValue']" :value="item['dictKey']"/>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="材料单价" prop="materialPrice">
                        <el-input v-model="addEditFormModel.materialPrice"/>
                    </el-form-item>
                </div>
                <div class="hc-form-item">
                    <el-form-item label="材料名称" prop="materialName">
                        <el-input v-model="addEditFormModel.materialName"/>
                    </el-form-item>
                    <el-form-item label="材料数量" prop="materialCount">
                        <el-input v-model="addEditFormModel.materialCount"
                                  onkeyup="value = value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g,'$1')"/>
                    </el-form-item>
                </div>
                <div class="hc-form-item">
                    <el-form-item label="规格型号" prop="specificationModel">
                        <el-input v-model="addEditFormModel.specificationModel"/>
                    </el-form-item>
                    <el-form-item label="计算单位">
                        <el-input v-model="addEditFormModel.calculationUnit"/>
                    </el-form-item>
                </div>
                <div class="hc-form-item">
                    <el-form-item label="材料编号" prop="materialNumber">
                        <el-input v-model="addEditFormModel.materialNumber"/>
                    </el-form-item>
                    <el-form-item label="生产批号">
                        <el-input v-model="addEditFormModel.batchNumber"/>
                    </el-form-item>
                </div>
                <div class="hc-form-item">
                    <el-form-item label="进场日期">
                        <el-date-picker v-model="addEditFormModel.mobilizationDate" :clearable="false" class="block"
                                        type="date" value-format="YYYY-MM-DD"/>
                    </el-form-item>
                    <el-form-item label="拟用部位">
                        <el-input v-model="addEditFormModel.proposedPosition"/>
                    </el-form-item>
                </div>
                <div class="hc-form-item">
                    <el-form-item label="供应商单位">
                        <el-input v-model="addEditFormModel.supplierUnit"/>
                    </el-form-item>
                    <el-form-item label="生产地/厂家">
                        <el-input v-model="addEditFormModel.placeOfProduction"/>
                    </el-form-item>
                </div>
                <el-form-item label="生产合格证">
                    <FormItemUpload v-model="addEditFormModel.productionCertificate"/>
                </el-form-item>
                <el-form-item label="厂家质检报告">
                    <FormItemUpload v-model="addEditFormModel.qualityInspectionReport"/>
                </el-form-item>
                <el-form-item label="其他附件">
                    <FormItemUpload v-model="addEditFormModel.otherAccessories"/>
                </el-form-item>
            </el-form>
        </HcDialog>

        <!--复制材料登记信息-->
        <HcDialog :loading="copyTableLoading" :show="copyTableModal" isTable title="复制材料登记信息" widths="60rem"
                  @close="copyTableModalClose" @save="copyTableClick">
            <HcTable :column="copyTableColumn" :datas="copyTableData">
                <template #materialNumber="{row}">
                    <el-input v-model="row.materialNumber" :class="row.isMaterialNumber?'is-error':''"
                              placeholder="请输入材料编号" @blur="materialNumberBlur(row)"/>
                </template>
                <template #action="{index}">
                    <el-button plain size="small" type="danger" @click="materialNumberDel(index)">删除</el-button>
                </template>
            </HcTable>
        </HcDialog>

        <!--导入-->
        <HcDialog :show="importModal" isRowFooter title="导入" widths="38rem" @close="importModalClose">
            <HcDragUpload ref="uploadRef" :api="'/api/blade-business/material/'" :datas="uploadData" action="mobilization/import"
                          @finished="uploadFinished" @progress="uploadprogress"/>
            <template #leftRowFooter>
                <el-button size="large" @click="downloadImportClick">
                    <HcIcon name="download-2"/>
                    <span>下载模板</span>
                </el-button>
            </template>
            <template #rightRowFooter>
                <el-button size="large" @click="importModalClose">
                    <HcIcon name="close"/>
                    <span>取消导入</span>
                </el-button>
                <el-button :loading="importModalLoading" hc-btn type="primary" @click="importModalYesClick">
                    <HcIcon name="folder-upload"/>
                    <span>确认导入</span>
                </el-button>
            </template>
        </HcDialog>

        <!--查看附件-->
        <HcDialog :footer="false" :show="viewAttachmentModal" isTable title="查看附件" widths="70rem"
                  @close="viewAttachmentModalClose">
            <template #extra>
                <HcNewSwitch :datas="tabTypeTab" :disabled="tableRowPdfDisabled" :keys="tabTypeKey"
                             @change="tabTypeChange"/>
            </template>
            <div class="hc-switch-tab-content">
                <div class="h-full w-full">
                    <div v-if="tableRowData[tabTypeKey]" style="text-align:center">
                        <iframe v-if="tableRowData[tabTypeKey]&&ispdf!==-1" :src="tableRowData[tabTypeKey]" allow="display-capture" frameborder='1'
                                height='100%' style="height:500px;width:90%"
                                width='100%'/>

                        <div v-if="ispdf==-1" class="hc-no-table-form">
                            <div class="table-form-no" style="margin-top:100px">
                                <!-- <img :src="notableform" alt=""/>
                                <div class="desc">暂无 PDF 数据，请上传</div> -->
                                <HcDragUpload :accept="'image/png,image/jpg,image/jpeg,application/pdf,.doc,.docx,application/msword'" :action="'endpoint/put-file-attach'" :formatTip="'：jpg/png/pdf/excel/word.pdf'"
                                              autoUpload
                                              @finished="tableRowPdfFinished"
                                              @progress="tableRowPdfProgress"
                                />
                                <el-link :href="tableRowData[tabTypeKey]" style="margin-top:10px" type="primary">
                                    {{ splitFileName(tableRowData[tabTypeKey]) }}
                                </el-link>
                            </div>
                        </div>

                        <el-button hc-btn size="small" type="primary" @click="deleteFile">
                            <HcIcon name="delete-bin-2"/>
                            <span>删除</span>
                        </el-button>

                    </div>

                    <div v-else class="hc-no-table-form">
                        <div class="table-form-no">
                            <img :src="notableform" alt=""/>
                            <div class="desc">暂无 文件 数据，请上传</div>
                            <HcDragUpload :accept="'image/png,image/jpg,image/jpeg,application/pdf,.doc,.docx,application/msword'" :action="'endpoint/put-file-attach'" :formatTip="'：jpg/png/pdf/excel/word.pdf'"
                                          autoUpload
                                          @finished="tableRowPdfFinished"
                                          @progress="tableRowPdfProgress"
                            />
                        </div>
                    </div>
                </div>
            </div>
        </HcDialog>

        <!--取样记录-->
        <HcDialog :footer="false" :show="samplingRecordModal" isTable title="取样记录" widths="60%"
                  @close="samplingRecordModalClose">
            <HcTable :column="samplingTableColumn" :datas="samplingTableData" :isIndex="false"
                     :loading="samplingTableLoading">
                <template #isOutsourcing="{row}">
                    <span>{{ row.isOutsourcing === 1 ? '是' : '否' }}</span>
                </template>
            </HcTable>
        </HcDialog>

    </div>
</template>

<script setup>
import {ref, onMounted} from "vue";
import {useAppStore} from "~src/store";
import HcDragUpload from "./components/HcDragUpload.vue"
import FormItemUpload from "./components/FormItemUpload.vue"
import notableform from '~src/assets/view/notableform.svg';
import approachApi from "~api/tentative/material/approach"
import {formValidate, getArrValue, arrIndex, deepClone} from "js-fast-way"
import {getDictionary} from "~api/other";

//初始变量
const useAppState = useAppStore()

//全局变量
const projectId = ref(useAppState.getProjectId);
const contractId = ref(useAppState.getContractId);

//渲染完成
onMounted(() => {
    getMaterialType()
    getTableData()
})

//获取材料类型
const typeData = ref([])
const getMaterialType = async () => {
    const {data} = await getDictionary({
        code: 'material_type'
    })
    typeData.value = getArrValue(data)
    //dictValue, dictKey
}

//获取材料类型
const getRowTableMaterialType = (type) => {
    if (type > 0) {
        const nodeData = typeData.value
        const index = arrIndex(nodeData, 'dictKey', type)
        return nodeData[index]?.dictValue ?? type
    } else {
        return ''
    }
}

//搜索表单
const searchForm = ref({
    materialType: null, startTime: null, endTime: null, queryValue: null,
    current: 1, size: 20, total: 0
})

//日期时间被选择
const betweenTime = ref(null)
const betweenTimeUpdate = ({arr}) => {
    betweenTime.value = arr
    if (arr.length > 0) {
        searchForm.value.startTime = arr[0]
        searchForm.value.endTime = arr[1]
    } else {
        searchForm.value.startTime = ''
        searchForm.value.endTime = ''
    }
}

//回车搜索
const keyUpEvent = (e) => {
    if (e.key === "Enter") {
        searchForm.value.current = 1;
        getTableData()
    }
}

//搜索
const searchClick = () => {
    searchForm.value.current = 1;
    getTableData()
}

//分页被点击
const pageChange = ({current, size}) => {
    searchForm.value.current = current
    searchForm.value.size = size
    getTableData()
}

//表格数据
const tableRef = ref(null)
const tableColumn = ref([
    {key: 'materialNumber', name: '材料编号'},
    {key: 'mobilizationDate', name: '进场日期'},
    {key: 'materialName', name: '材料名称'},
    {key: 'materialType', name: '材料类型'},
    {key: 'specificationModel', name: '规格型号'},
    {key: 'supplierUnit', name: '供应商单位'},
    {key: 'materialPrice', name: '材料单价'},
    {key: 'materialCount', name: '材料数量'},
    {key: 'calculationUnit', name: '计算单位'},
    {key: 'batchNumber', name: '生产批号'},
    {key: 'placeOfProduction', name: '生产地/厂家'},
    {key: 'proposedPosition', name: '拟用部位'},
    {key: 'userName', name: '记录人'},
    {key: 'action', name: '操作', width: 150, fixed: 'right', align: 'center'},
])
const tableRowData = ref({})

//获取数据
const tableLoading = ref(false)
const tableData = ref([])
const getTableData = async () => {
    tableLoading.value = true
    const {error, code, data} = await approachApi.queryPage({
        projectId: projectId.value,
        contractId: contractId.value,
        ...searchForm.value,
    })
    //处理数据
    tableLoading.value = false
    if (!error && code === 200) {
        tableData.value = getArrValue(data['records'])
        searchForm.value.total = data.total || 0
    } else {
        tableData.value = []
        searchForm.value.total = 0
    }
}

//多选
const tableCheckedKeys = ref([]);
const tableSelection = (rows) => {
    tableCheckedKeys.value = rows.filter((item) => {
        return (item ?? '') !== '';
    })
}

//新增 材料进场
const addEditFormModal = ref(false)
const addFormModalClick = () => {
    addEditFormModel.value = {}
    addEditFormModal.value = true
}
//编辑 材料进场
const editFormModalClick = () => {
    const keys = tableCheckedKeys.value
    if (keys.length === 1) {
        addEditFormModel.value = keys[0]
        addEditFormModel.value.materialType = addEditFormModel.value.materialType + ''
        addEditFormModel.value.materialCount = addEditFormModel.value.materialCount === -1 ? '' : addEditFormModel.value.materialCount
        addEditFormModel.value.materialPrice = addEditFormModel.value.materialPrice === -1 ? '' : addEditFormModel.value.materialPrice
        addEditFormModal.value = true
    } else if (keys.length > 1) {
        window?.$message?.warning('只能选择一条数据编辑')
    }
}
const addEditFormModalClose = () => {
    addEditFormModal.value = false
    addEditFormModel.value = {}
}

//新增/编辑 表单
const addEditFormRef = ref(null)
const addEditFormModel = ref({})
const addEditFormRules = {
    materialType: {
        required: true,
        trigger: 'change',
        message: "请选择材料类型"
    },
    materialName: {
        required: true,
        trigger: 'blur',
        message: "请输入材料名称"
    },
    specificationModel: {
        required: true,
        trigger: 'blur',
        message: "请输入规格型号"
    },
    materialNumber: {
        required: false,
        validator: async (rule, value, callback) => {
            if (!value) {
                return
            } else {
                const ver = await verification(value)
                if (!ver) {
                    callback(new Error('材料编号必须是惟一的'))
                } else {
                    callback()
                }
            }
        },
        trigger: 'blur'
    },
    materialPrice: {
        required: false,
        validator: async (rule, value, callback) => {
            if (!value) {
                return
            } else if (value.length > 8) {
                callback(new Error('材料单价长度不能超过八位数'))
            }
        },
        trigger: 'blur'
    },
    materialCount: {
        required: false,
        validator: async (rule, value, callback) => {
            if (!value) {
                callback()
            } else if (value.length > 10) {
                callback(new Error('材料数量长度不能超过10位数'))
            }
        },
        trigger: 'blur'
    }

}

//校验材料编号是否唯一
const verification = async (val) => {
    const {error, code, data} = await approachApi.verification({
        projectId: projectId.value,
        contractId: contractId.value,
        materialNumber: val,
        id: addEditFormModel.value.id ?? ''
    })
    if (!error && code === 200) {
        return !data
    } else {
        return false
    }
}

//新增/编辑 保存
const addEditFormLoading = ref(false)
const addEditFormClick = async () => {
    const validate = await formValidate(addEditFormRef.value)
    if (validate) {
        addEditFormLoading.value = true
        addEditFormModel.value.materialCount = Number(addEditFormModel.value.materialCount)
        const {error, code} = await approachApi.submitForm({
            ...addEditFormModel.value,
            projectId: projectId.value,
            contractId: contractId.value
        })
        //处理数据

        if (!error && code === 200) {
            window?.$message?.success('操作成功')
            addEditFormModal.value = false
            addEditFormLoading.value = false
            await getTableData()
        } else {
            addEditFormLoading.value = false
        }
    }
}

//复制表格
const copyTableColumn = ref([
    {key: 'materialName', name: '材料名称'},
    {key: 'materialNumber', name: '材料编号'},
    {key: 'action', name: '操作', width: 100},
])
const copyTableData = ref([])

//复制
const copyTableModal = ref(false)
const copyTableModalClick = () => {
    copyTableModal.value = true
    copyTableData.value = deepClone(tableCheckedKeys.value)
}

//效验材料编号
const materialNumberBlur = async (row) => {
    const number = row?.materialNumber ?? ''
    if (number) {
        const ver = await verification(number)
        row.isMaterialNumber = !ver
    } else {
        row.isMaterialNumber = true
    }
}

//删除
const materialNumberDel = (index) => {
    copyTableData.value.splice(index, 1);
    const rows = copyTableData.value
    if (rows.length <= 0) {
        copyTableModal.value = false
    }
}

const copyTableModalClose = () => {
    copyTableModal.value = false
}

//复制 保存
const copyTableLoading = ref(false)
const copyTableClick = () => {
    const rows = copyTableData.value
    if (rows.length > 0) {
        //判断是否满足条件
        const result = rows.every(({isMaterialNumber}) => {
            return isMaterialNumber === false
        })
        //判断状态
        if (result) {
            for (let i = 0; i < rows.length; i++) {
                rows[i].dataNumber = i
            }
            tableCopyData(rows)
        } else {
            window.$message?.warning('请先完善材料编号')
        }
    } else {
        window.$message?.warning('请先在列表勾选要复制的数据')
        copyTableModal.value = false
    }
}

//复制数据请求
const tableCopyData = async (rows) => {
    copyTableLoading.value = true
    const {error, code} = await approachApi.copyData(rows)
    //处理数据
    copyTableLoading.value = false
    if (!error && code === 200) {
        window?.$message?.success('操作成功')
        copyTableModal.value = false
        await getTableData()
    }
}

//删除
const delModalClick = () => {
    window?.$messageBox?.alert('请谨慎考虑后，确认是否需要删除？', '删除提醒', {
        showCancelButton: true,
        confirmButtonText: '确认删除',
        cancelButtonText: '取消',
        type: 'warning',
        callback: (action) => {
            if (action === 'confirm') {
                tableRemoveData()
            }
        }
    })
}

//批量删除
const tableRemoveData = async () => {
    const rows = tableCheckedKeys.value
    if (rows.length > 0) {
        const ids = rowsToId(rows)
        //删除请求
        const {error, code} = await approachApi.removeData({
            projectId: projectId.value,
            contractId: contractId.value,
            ids: ids,
        })
        //处理数据
        if (!error && code === 200) {
            window?.$message?.success('操作成功')
            searchClick()
        }
    }
}

//打印
const printerLoading = ref(false)
const printerClick = async () => {
    const rows = tableCheckedKeys.value
    if (rows.length > 0) {
        printerLoading.value = true
        const ids = rowsToId(rows)
        //删除请求
        const {error, code, data} = await approachApi.exportPdf({
            projectId: projectId.value,
            contractId: contractId.value,
            ids: ids,
        })
        //处理数据
        printerLoading.value = false
        if (!error && code === 200) {
            window.open(data, '_blank')
        }
    }
}

//导入
const uploadRef = ref(null)
const uploadData = ref({})

//导入弹窗
const importModal = ref(false)
const importModalClick = () => {
    importModal.value = true
    uploadData.value = {
        contractId: contractId.value,
        isCovered: 1
    }
}

//上传进度
const uploadprogress = (res) => {
    importModalLoading.value = res
}

//确认导入
const importModalLoading = ref(false)
const importModalYesClick = () => {
    uploadRef.value?.submit()
}

//上传完成
const uploadFinished = () => {
    importModal.value = false
    getTableData()
}


//关闭导入
const importModalClose = () => {
    importModal.value = false
}


//查看附件
const viewAttachmentModal = ref(false)
const viewAttachmentModalClick = (row) => {
    tableRowData.value = row
    viewAttachmentModal.value = true
    tabTypeKey.value = 'productionCertificate'
    const key = tabTypeKey.value
    ispdf.value = getCaption(row[key])
}

//类型tab数据和相关处理
const tabTypeKey = ref('')
const tabTypeKeyType = ref(1)
const ispdf = ref(-1)
const tabTypeTab = ref([
    {key: 'productionCertificate', name: '生产合格证', type: 1},
    {key: 'qualityInspectionReport', name: '厂家质检报告', type: 2},
    {key: 'otherAccessories', name: '其他文件', type: 3},
]);
const tabTypeChange = (item) => {
    tabTypeKey.value = item?.key
    tabTypeKeyType.value = item?.type
    const row = tableRowData.value, key = tabTypeKey.value
    ispdf.value = getCaption(row[key])
}
//截取文件名称
const splitFileName = (str) => {
    // if(str.indexOf("https://bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload") != -1){
    if (str.indexOf("https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload") != -1) {
        let a = str.split('//')[2].split('/')[2]
        return a
    } else {
        return str
    }

}
//上传进度
const tableRowPdfDisabled = ref(false)
const tableRowPdfProgress = (res) => {
    tableRowPdfDisabled.value = res
}

//上传完成
const tableRowPdfFinished = async (data1) => {
    console.log(data1, 'data');
    tableRowPdfDisabled.value = true
    const row = tableRowData.value, key = tabTypeKey.value
    row[key] = data1?.link
    console.log(row, 'row');
    ispdf.value = getCaption(row[key])
    // //保存请求
    // const { error, code } = await approachApi.submitForm({
    //     ...row,
    //     projectId: projectId.value,
    //     contractId: contractId.value
    // })
    // //处理数据
    // tableRowData.value = row
    // tableRowPdfDisabled.value = false
    // if (!error && code === 200) {
    //     window?.$message?.success('操作成功')
    //     await getTableData()
    // }
    const {error, code, data} = await approachApi.updateMobilizationFile(
        {
            id: row.id,
            type: tabTypeKeyType.value,
            url: data1?.link,

        })
    //处理数据
    tableRowData.value = row
    tableRowPdfDisabled.value = false
    if (!error && code === 200) {
        // window?.$message?.success('操作成功')
        await getTableData()
    }
}
const getCaption = (obj) => {
    const index = obj.lastIndexOf("pdf")

    return index
}

//删除上传附件
const deleteFile = () => {
    console.log('删除');
    console.log(tableRowData.value[tabTypeKey]);
    tableRowData.value[tabTypeKey.value] = ''
}
//关闭查看附件
const viewAttachmentModalClose = () => {
    viewAttachmentModal.value = false
}


//取样记录
const samplingRecordModal = ref(false)
const samplingRecordModalClick = async (row) => {
    samplingRecordModal.value = true
    samplingTableLoading.value = true
    const {data} = await approachApi.samplingRecord({
        projectId: projectId.value,
        contractId: contractId.value,
        id: row.id,
    })
    samplingTableLoading.value = false
    samplingTableData.value = getArrValue(data)
}

//取样记录数据
const samplingTableColumn = ref([
    {key: 'specificationNumber', name: '样品编号'},
    {key: 'materialName', name: '样品名称'},
    {key: 'samplingDate', name: '取样日期'},
    {key: 'userName', name: '取样人'},
    {key: 'materialCount', name: '试样数量'},
    {key: 'isOutsourcing', name: '是否外委'},
])
const samplingTableData = ref([])
const samplingTableLoading = ref(false)

//关闭取样记录
const samplingRecordModalClose = () => {
    samplingRecordModal.value = false
}

//下载导入模板
const downloadImportClick = () => {
    window.open('https://bladex-test-info.oss-cn-chengdu.aliyuncs.com//upload/20221109/fea12aaee9d964d2d9f894cc6bf4a2f6.xlsx', '_blank')
}

//拼接ID
const rowsToId = (rows) => {
    return rows.map((obj) => {
        return obj.id;
    }).join(",")
}
</script>

<style lang="scss" scoped>
@import "../../../styles/tentative/material/approach.scss";
</style>
