<!--  -->
<template>
    <div class="hc-page-box">
        <HcNewCard ui="bgGray" style="overflow-y: auto;">
            <template #extra>
                <el-button
                    hc-btn
                    color="rgb(154, 154, 154)"
                    style="color: white;"
                    @click="goBack"
                >
                    <HcIcon name="arrow-go-back" />
                    <span>返回</span>
                </el-button>
                <el-button
                    v-if="type !== 'view' && type !== 'review' && type !== 'changeRow'"
                    hc-btn
                    color="#e54d42"
                    style="color: white;"
                    @click="clearInfo"
                >
                    <HcIcon name="delete-bin-3" />
                    <span>清空数据</span>
                </el-button>
                <el-button
                    v-if="type === 'add'"
                    hc-btn
                    color="#12C060"
                    style="color: white;"
                    :loading="saveLoading"
                    @click="saveInfo"
                >
                    <HcIcon name="save" />
                    <span>保存数据</span>
                </el-button>
                <el-button
                    v-if="type === 'changeRow'"
                    hc-btn
                    color="#12C060"
                    style="color: white;"
                    :loading="changeRowLoaing"
                    @click="changeRowInfo"
                >
                    <HcIcon name="save" />
                    <span>提交整改记录</span>
                </el-button>
                <el-button
                    v-if="type === 'confirmChange'"
                    hc-btn
                    color="#12C060"
                    style="color: white;"
                    :loading="updateLoaing"
                    @click="updateInfo"
                >
                    <HcIcon name="save" />
                    <span>确认修改</span>
                </el-button>
                <el-button
                    v-if="type === 'review'"
                    hc-btn
                    color="#12C060"
                    style="color: white;"
                    :loading="reviewInspectLoaing"
                    @click="reviewInspect(2)"
                >
                    <HcIcon name="save" />
                    <span>复核检查通过</span>
                </el-button>
                <el-button
                    v-if="type === 'review'"
                    hc-btn
                    color="rgb(189, 49, 36)"
                    style="color: white;"
                    :loading="reviewInspectLoaing1"
                    @click="reviewInspect(1)"
                >
                    <HcIcon name="save" />
                    <span>复核检查未通过</span>
                </el-button>
            </template>
            <el-form ref="addFormRef" :model="addForm" :rules="addRules" label-width="auto" size="large" label-position="left">
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item label="检查名称" prop="inspectName">
                            <el-input v-model="addForm.inspectName" placeholder="请输入" :disabled="type === 'changeRow' || type === 'review' || type === 'view'" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="检查类别" prop="inspectType">
                            <el-select v-model="addForm.inspectType" placeholder="请选择" clearable style="width:100%" :disabled="type === 'changeRow' || type === 'review' || type === 'view'">
                                <el-option v-for="item in typeOptions" :key="item.id" :label="item.dictValue" :value="item.dictKey" />
                            </el-select>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="20">
                    <el-col :span="12">
                        <el-form-item label="是否需要整改" prop="isRectify">
                            <el-radio-group v-model="addForm.isRectify" class="ml-4" :disabled="type === 'view' || type === 'changeRow'">
                                <el-radio :label="1" size="large">需要整改</el-radio>
                                <el-radio :label="2" size="large">不要整改</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="addForm.isRectify === 1" :gutter="20">
                    <el-col :span="12">
                        <el-form-item label="整改日期" prop="rectifyDate">
                            <el-date-picker
                                v-model="addForm.rectifyDate"
                                type="date"
                                value-format="YYYY-MM-DD"
                                placeholder="请选择整改日期"
                                :disabled="type === 'changeRow' || type === 'review' || type === 'view'"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row v-if="addForm.isRectify === 1" :gutter="20">
                    <el-col :span="8">
                        <el-form-item label="整改人" prop="rectifyUser">
                            <HcTasksUser
                                v-if="isShowUser" :disabled="type === 'changeRow' || type === 'review' || type === 'view'"
                                :is-change-popele="true" :contract-id="contractId" :project-id="projectId"
                                :users="peoples" ui="w-full"
                                @change="tasksUserChange"
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-divider border-style="dashed" style="border: 1px dashed #cdd4e3;" />
                <el-row :gutter="20">
                    <el-col :span="4">
                        <el-form-item label="检查部位" prop="list">
                            <el-button
                                hc-btn
                                type="primary"
                                :disabled="type === 'changeRow' || type === 'review' || type === 'view'"
                                @click="linksRelateModalClick"
                            >
                                <HcIcon name="add" />
                                <span>点击选择</span>
                            </el-button>
                        </el-form-item>
                    </el-col>
                </el-row>
                <div style="position: relative; margin-top: 20px;">
                    <HcTable :column="tableColumn" :datas="processDataList">
                        <template #inspectProject="{ row }">
                            <hc-table-input v-model="row.inspectProject" type="textarea" :disabled="type === 'changeRow' || type === 'review' || type === 'view'" />
                        </template>
                        <template #inspectContent="{ row }">
                            <hc-table-input v-model="row.inspectContent" type="textarea" :disabled="type === 'changeRow' || type === 'review' || type === 'view'" />
                        </template>
                        <template #deductionStandard="{ row }">
                            <hc-table-input v-model="row.deductionStandard" type="textarea" :disabled="type === 'review' || type === 'view'" />
                        </template>
                        <template #rectifyFeedback="{ row }">
                            <hc-table-input v-model="row.rectifyFeedback" type="textarea" :disabled="type === 'review' || type === 'view'" />
                        </template>
                        <template #rectifyAttachment="{ row, index }">
                            <template v-if="row?.rectifyAttachment">
                                <el-link v-if=" type === 'changeRow' || type === 'add'" type="primary" @click="clickAttachment(row, index)">{{ row.rectifyAttachmentName }}</el-link>
                                <el-link v-else @click="openAttachment(row)">{{ row.rectifyAttachmentName }}</el-link>
                            </template>
                              
                            <el-link v-else type="primary" :disabled="type === 'review' || type === 'view'" @click="clickAttachment(row, index)">
                                上传
                            </el-link>
                        </template>
                        <template #inspectUserName="{ row }">
                            <hc-table-input v-model="row.inspectUserName" type="textarea" :disabled="type === 'review' || type === 'view'" />
                        </template>
                        <template #inspectPdfUrl="{ row, index }">
                            <el-link v-if="row?.isShowImage == 0" type="primary" :disabled="type === 'review' || type === 'view'" @click="clickUploadInspect(row, index)">上传</el-link>
                            <template v-else>
                                <el-image v-if="type === 'confirmChange' || type === 'add'" style="width: 100px; height: 100px;cursor: pointer;" :src="row?.inspectPdfUrl" @click="clickUploadInspect(row, index)" />
                                <el-image v-else style="width: 100px; height: 100px;cursor: pointer;" :src="row?.inspectPdfUrl" :preview-src-list="[row?.inspectPdfUrl]" :initial-index="0" hide-on-click-modal preview-teleported />
                            </template>
                        </template>
                        <template #rectifyPdfUrl="{ row, index }">
                            <el-link v-if="!row.rectifyPdfUrl" type="primary" :disabled="type === 'review' || type === 'view'" @click="clickRectifyPdfUrl(row, index)">上传</el-link>
                            <template v-else>
                                <el-image v-if="type === 'changeRow' || type === 'add' || type === 'confirmChange'" style="width: 100px; height: 100px;cursor: pointer;" :src="row.rectifyPdfUrl" @click="clickRectifyPdfUrl(row, index)" />
                                <el-image v-else style="width: 100px; height: 100px;cursor: pointer;" :src="row?.rectifyPdfUrl" :preview-src-list="[row?.rectifyPdfUrl]" :initial-index="0" hide-on-click-modal preview-teleported />
                            </template>
                        </template>
                        <template #action="{ row, index }">
                            <el-link type="danger" :disabled="type === 'view' || type === 'changeRow'" @click="deleProcess(row, index)">删除</el-link>
                        </template>
                    </HcTable>
                </div>
            </el-form>
        </HcNewCard>
        <hc-new-dialog :show="linksRelateModal" is-table save-text="确认关联" title="关联工程用途及部位" widths="50rem" @close="linksRelateModalClose" @save="linksRelateModalSave">
            <div class="hc-tree-box1">
                <div class="hc-search-tree-val">
                    <el-input v-model="searchTreeVal" block clearable placeholder="请输入名称关键词检索" @keyup="searchTreeKeyUp">
                        <template #suffix>
                            <HcIcon name="search-2" ui="text-xl iscusor" @click="searchTreeClick" />
                        </template>
                    </el-input>
                </div>
                <div id="hc-tree-scrollbar" v-loading="treeLoading" class="hc-tree-scrollbar" element-loading-text="获取数据中...">
                    <el-scrollbar v-show="isSearchTree" class="scroll-bar-right-16">
                        <div class=" node-many-tree">
                            <HcDataTree
                                :datas="searchTreeData"
                                show-checkbox
                                default-expand-all
                                :default-checked-keys="defaultChecked"
                                :auto-expand-keys="TreeAutoExpandKeys"
                                check-strictly
                                @nodeTap="wbsElTreeClick"
                                @check="divisionTreeCheck"
                                @check-change="divisionTreeCheckChange"
                            >
                                <template #default="{ node, data }">
                                    <span style="font-size: 16px;">{{ data.title }}</span>
                                </template>
                            </HcDataTree>
                        </div>
                    </el-scrollbar>
                    <el-scrollbar v-show="!isSearchTree" class="scroll-bar-right-16">
                        <div class=" node-many-tree">
                            <HcLazyTree
                                ref="processElTree"
                                show-checkbox
                                :default-checked-keys="defaultChecked"
                                :auto-expand-keys="TreeAutoExpandKeys"
                                check-strictly
                                @check-change="divisionTreeCheckChange"
                                @check="divisionTreeCheck"
                                @load="treeLoadNode"
                                @nodeTap="wbsElTreeClick"
                            >
                                <template #default="{ node, data }">
                                    <span style="font-size: 16px;">{{ data.title }}</span>
                                </template>
                            </HcLazyTree>
                        </div>
                    </el-scrollbar>
                </div>
            </div>
        </hc-new-dialog>
        <HcUploadFile
            ref="HcUploadFileRef"
            :options="UploadFileOptions"
            :params="uploadFileParams"
            :echo-params="uploadFileEchoParams"
            @progress="HcUploadFileProgress"
            @success="HcUploadFileSuccess"
            @change="HcUploadFileChange"
            @finish="HcUploadFileFinish"
        />
    </div>
</template>

<script setup>
import { onActivated, ref } from 'vue'
import { useAppStore } from '~src/store'
import queryApi from '~api/data-fill/query'
import { arrToKey, formValidate, getArrValue, getObjValue } from 'js-fast-way'
import { useRoute, useRouter } from 'vue-router'
import { getTokenHeader } from '~src/api/request/header'
import patrolApi from '~api/patrol/patrol'
import { getDictionary } from '~api/other'

//初始变量
const router = useRouter()
const useAppState = useAppStore()
const useRoutes = useRoute()
const routerQuery = useRoutes?.query
const type = ref(routerQuery?.type || 'add')
const id = ref(routerQuery?.id || '')
const projectId = ref(useAppState.getProjectId)
const contractInfo = ref(useAppState.getContractInfo)
const contractId = ref(useAppState.getContractId)
const addFormRef = ref(null)
const addForm = ref({})
const addRules = {
    inspectName: {
        required: true,
        trigger: 'blur',
        message: '请输入名称',
    },
    inspectType: {
        required: true,
        trigger: 'blur',
        message: '请选择类别',
    },
    isRectify: {
        required: true,
        trigger: 'blur',
        message: '请选择是否需要整改',
    },
    rectifyUser: {
        required: true,
        trigger: 'blur',
        message: '请选择整改人',
    },
    list: {
        required: true,
        trigger: 'blur',
        message: '请选择检查部位',
    },
    rectifyDate:{
        required: true,
        trigger: 'blur',
        message: '请选择整改时间',
    },


}

//检查类别
const typeOptions = ref([
    // { label:'安全巡检', value:1 },
    // { label:'质量巡检', value:2 },
])
//获取检查类别Data = ref([])
const getTypeOptions = async () => {
    const { data } = await getDictionary({
        code: 'inspect_type',
    })
    //处理数据
    typeOptions.value = getArrValue(data)
    typeOptions.value.forEach((ele)=>{
        ele.dictKey = Number(ele.dictKey)
    })
}
const tableColumn = ref([
{ key: 'inspectProject', name: '检查项目' },
            { key: 'inspectContent', name: '检查内容' },
            { key: 'rectifyFeedback', name: '整改反馈' },
            { key: 'rectifyAttachment', name: '整改附件', width:150 },
            { key: 'inspectPdfUrl', name: '图片', width:150 },
            { key: 'action', name: '操作', width:100 },
])
//整改显示列



const isShowUser = ref(true)
onActivated(()=>{
    getTypeOptions()
    const routerQuery = useRoutes?.query
    type.value = routerQuery?.type || 'add'
    id.value = routerQuery?.id || ''
    if (id.value.length > 0) {
        getDetail( id.value)
    } else {
        addForm.value = {}
        processDataList.value = []
        peoples.value = ''
        isShowUser.value = false
        setTimeout(() => {
            isShowUser.value = true
        }, 10)
        
    }
    if (type.value === 'changeRow') {

        tableColumn.value = [
            { key: 'inspectProject', name: '检查项目' },
            { key: 'inspectContent', name: '检查内容' },
            { key: 'rectifyFeedback', name: '整改反馈' },
            { key: 'rectifyAttachment', name: '整改附件', width:150 },
            { key: 'rectifyPdfUrl', name: '图片', width:150 },
            { key: 'action', name: '操作', width:100 },
        ]
    } else if (type.value === 'review' || type.value === 'view') {
       
        tableColumn.value = [
            { key: 'inspectProject', name: '检查项目' },
            { key: 'inspectContent', name: '检查内容' },
            { key: 'deductionStandard', name: '扣分标准' },
            { key: 'inspectUserName', name: '检查人名称' },
            { key: 'inspectPdfUrl', name: '图片', width:150 },
            { key: 'rectifyFeedback', name: '整改反馈' },
            { key: 'rectifyAttachment', name: '整改附件', width:150 },
            { key: 'rectifyPdfUrl', name: '整改后图片', width:150 },
         
        ]
    } else {
        tableColumn.value = [
        { key: 'inspectProject', name: '检查项目' },
        { key: 'inspectContent', name: '检查内容' },
        { key: 'deductionStandard', name: '扣分标准' },
        { key: 'inspectUserName', name: '检查人名称' },
        { key: 'inspectPdfUrl', name: '图片', width:150 },
        { key: 'action', name: '操作', width:100 },
        ]
    }
})

//获取巡检详情
const getDetail = async (id)=>{
    const { error, code, data } = await patrolApi.detail({
        id:id,

    })
    //判断状态
   
    if (!error && code === 200) {
        console.log(data, 'data')
        addForm.value = getObjValue(data)
        processDataList.value = addForm.value.list
        peoples.value = addForm.value.rectifyUser
    } else {
        addForm.value = {}
        processDataList.value = []
    }
}
const HcUploadFileRef = ref(null)
//上传配置
const UploadFileOptions = ref({})
//上传检查图片
const clickUploadInspect = (row, index)=>{
    UploadFileOptions.value = {
            url: '/api/blade-resource/oss/endpoint/put-file',
            accept: 'image/png,image/jpg,image/jpeg',
            accept_tip: 'png、jpg、jpeg',
            headers: getTokenHeader(),
            multiple: false,
    }
    HcUploadFileRef.value?.cancelUpload()
    HcUploadFileRef.value?.selectFile()
    uploadFileEchoParams.value = { type:'image', index:index }
}
//上传整改图片
const clickRectifyPdfUrl = (row, index)=>{
    UploadFileOptions.value = {
            url: '/api/blade-resource/oss/endpoint/put-file',
            accept: 'image/png,image/jpg,image/jpeg',
            accept_tip: 'png、jpg、jpeg',
            headers: getTokenHeader(),
            multiple: false,
    }
    setTimeout(() => {
        HcUploadFileRef.value?.selectFile()
    }, 1000)
    HcUploadFileRef.value?.cancelUpload()
    // HcUploadFileRef.value?.selectFile()
    uploadFileEchoParams.value = { type:'rectify', index:index }
}
//上传整改附件
const clickAttachment = (row, index)=>{
    UploadFileOptions.value = {
            url: '/api/blade-resource/oss/endpoint/put-file',
       
          
            headers: getTokenHeader(),
            multiple: false,
    }
    HcUploadFileRef.value?.cancelUpload()
    setTimeout(() => {
        HcUploadFileRef.value?.selectFile()
    }, 500)
    uploadFileEchoParams.value = { type:'attachment', index:index }
}

const openAttachment = (row)=>{
    if (row?.rectifyAttachment) {
        window.open(row?.rectifyAttachment, '_blank')
    } else {
        window.$message?.warning('获取PDF失败')
    }
}
const uploadFileParams = ref({})
const uploadFileEchoParams = ref({})
// 文件上传进度
const HcUploadFileProgress = (res) => {
    console.log('文件上传进度', res)
}
// 文件上传成功的回调
const HcUploadFileSuccess = ({ echoParams, resData }) => {
   
    if (echoParams['type'] === 'image' && resData?.link) {
        setUploadImage(echoParams, resData)
    } else if (echoParams['type'] === 'attachment' && resData?.link) {
        setAttchment(echoParams, resData)
    } else if (echoParams['type'] === 'rectify' && resData?.link) {
        setRectify(echoParams, resData)
    }
}
//设置上传图片
const setUploadImage = (echoParams, resData)=>{
        processDataList.value[echoParams['index']].isShowImage = 1
        processDataList.value[echoParams['index']].inspectPdfUrl = resData?.link
}
//这种上传整改图片
const setRectify = (echoParams, resData)=>{
    console.log(resData, 'resData11111')
        processDataList.value[echoParams['index']].rectifyPdfUrl = resData?.link
}
//设置上传附件
const setAttchment = (echoParams, resData)=>{
    console.log(resData, 'resData11111')
        processDataList.value[echoParams['index']].rectifyAttachmentName = resData?.originalName
        processDataList.value[echoParams['index']].rectifyAttachment = resData?.link
}

// 文件全部上传成功
const HcUploadFileChange = () => {
    console.log('文件全部上传成功')

}
const HcUploadFileFinish = ()=>{
    HcUploadFileRef.value?.setModalShow(false)
}

//选择整改人
const peoples = ref('')
//任务人选择改变
const tasksUserChange = (a, b, users) => {
    addForm.value.rectifyUser = users
}
//关联工程用途及部位
const linksRelateModal = ref(false)
const linksRelateModalClick = ()=>{
    TreeAutoExpandKeys.value = processDataList.value[0]?.autoExpandKeys || []
    linksRelateModal.value = true
    isSearchTree.value = false
    newPushArr.value = []
   
    defaultChecked.value = arrToKey(processDataList.value, 'primaryKeyId', ',').split(',')
}
const linksRelateModalClose = ()=>{
    linksRelateModal.value = false
}
const processDataList = ref([])

    //获取展开节点
const linksRelateModalSave = ()=>{
    let arr = []//当前选中的节点
    processDataList.value.forEach((ele)=>{
        defaultChecked.value.forEach((ele1)=>{
            if (ele.primaryKeyId === ele1) {
                arr.push(ele)
            }
        })
    })
        const keys = processElTree.value.treeRef.getCheckedKeys()
        for (let index = 0; index < keys.length; index++) {
        let node = processElTree.value.treeRef.getNode(keys[index])

        let pathArr = []
        getKeys(node, pathArr)
        TreeAutoExpandKeys.value = pathArr
  
    }
    newPushArr.value.forEach((ele)=>{
        arr.push({
            inspectProject:ele.title,
            primaryKeyId: ele.primaryKeyId,
            autoExpandKeys:TreeAutoExpandKeys.value,
            isShowImage:0,
            contractId:ele.contractId,
  
        })
    })
    processDataList.value = arr
    addForm.value.list = arr
     linksRelateModal.value = false
   
}
    const getKeys = (node, pathArr) => {
    if (node.parent) {
        pathArr.unshift(node.data?.primaryKeyId.replace(/(^\s*)|(\s*$)/g, '')) //去掉头尾空格
        getKeys(node.parent, pathArr)
    } else {
        return //根节点结束
    }
}
const getNorepeatArr = (tempArr)=> {
    let newArr = []
    for (let i = 0; i < tempArr.length; i++) {
        if (newArr.indexOf(tempArr[i].primaryKeyId) == -1) {
            newArr.push(tempArr[i].primaryKeyId)
        } else {
            tempArr.splice(i, 1)
            i--
        }
    }
    return tempArr

}

//移除工序
const deleProcess = (row, index) => {
    const linkTabIds = processDataList.value
    linkTabIds.splice(index, 1)

    processDataList.value = linkTabIds
}
const searchTreeVal = ref('')
const isSearchTree = ref(false)
const searchTreeHeight = ref()
//回车
const searchTreeKeyUp = (e) => {
    if (e.key === 'Enter') {
        searchTreeClick()
    }
}

const searchTreeClick = async () => {
    if (searchTreeVal.value) {
        searchTreeHeight.value = document.getElementById('hc-tree-scrollbar').offsetHeight
        isSearchTree.value = true
        //treeLoading.value = true
        getSearchTreeData().then()
    } else {
        isSearchTree.value = false
    }
}
//回车
const searchTreeData = ref([])
const treeLoading = ref(false)
const getSearchTreeData = async () => {
    treeLoading.value = true
    const { error, code, data } = await queryApi.getTreeNodeByQueryValueAndContractId({
        contractId: contractId.value,
        queryValue: searchTreeVal.value,
        tableOwner:1,
    })
    //判断状态
    if (!error && code === 200) {
        let treedata = getArrValue(data)
        searchTreeData.value = treedata
        treeLoading.value = false

    } else {
        treeLoading.value = false

        searchTreeData.value = []
    }

}
const wbsElTreeClick = ({ node, data, keys })=>{
    console.log(keys, 'keys')
    TreeAutoExpandKeys.value = keys || []
}
const { contractType } = contractInfo.value
const classType = ref(contractType === 2 ? '2' : '1')
//懒加载的数据
const treeLoadNode = async ({ node, item, level }, resolve) => {
    let contractIdRelation = '', parentId = '', primaryKeyId = ''
    if (level !== 0) {
        const nodeData = getObjValue(item)
        contractIdRelation = nodeData?.contractIdRelation || ''
        parentId = contractIdRelation ? nodeData?.primaryKeyId : nodeData?.id
        primaryKeyId = nodeData?.id || ''
    }
    //获取数据
    const { data } = await queryApi.queryWbsTreeData({
        contractId: contractId.value || '',
        contractIdRelation,
        primaryKeyId,
        parentId,
        // classifyType: contractTypeTabKey.value,
         classifyType:classType.value,
         tableOwner:classType.value,

    })
    resolve(getArrValue(data))
}

const divisionTreeCheck = (data, { checkedNodes, checkedKeys }) => {
}
const newPushArr = ref([])
const divisionTreeCheckChange = (data, ischeck, data1)=>{
    if (!ischeck) {
        defaultChecked.value.forEach((ele, index)=>{
            if (ele === data.primaryKeyId) {
                defaultChecked.value.splice(index, 1)
            }
        })
    } else {
        defaultChecked.value.push(data.primaryKeyId)
        newPushArr.value.push(data)
    }
}


const defaultChecked = ref([]) //默认选中
const TreeAutoExpandKeys = ref([])//默认展开
const processElTree = ref(null)
const goList = ()=>{
    router.push({
        path: '/patrol/safe',
    
    })
}
const goBack = ()=>{
    router.back()
}

//保存数据
const saveLoading = ref(false)
const saveInfo = async ()=>{
    const validate = await formValidate(addFormRef.value)
    if (validate) {
        console.log(addForm.value, '数据')
        addForm.value.projectId = projectId.value
        addForm.value.contractId = contractId.value
        addForm.value.list = processDataList.value
        saveLoading.value = true
        const { error, code } = await patrolApi.add(
          addForm.value,
        )
        saveLoading.value = false
        if (!error && code === 200) {
            window?.$message?.success('操作成功')
      
            goList()
        }
    }
}
//修改数据
const updateLoaing = ref(false)
const updateInfo = async ()=>{
    const validate = await formValidate(addFormRef.value)
    if (validate) {
        console.log(addForm.value, '数据')
        addForm.value.projectId = projectId.value
        addForm.value.list = processDataList.value
        updateLoaing.value = true
        const { error, code } = await patrolApi.update(
          addForm.value,
        )
        updateLoaing.value = false
        if (!error && code === 200) {
            window?.$message?.success('操作成功')
            goList()
        }
    }
}
//清除数据
const clearInfo = ()=>{
   processDataList.value = []
   addForm.value = {}
   peoples.value = ''
   addForm.value.id = id.value
}
//提交整改记录
const changeRowLoaing = ref(false)
const changeRowInfo = async ()=>{
    const validate = await formValidate(addFormRef.value)
    if (validate) {
        console.log(addForm.value, '数据')
        addForm.value.projectId = projectId.value
        addForm.value.list = processDataList.value
        changeRowLoaing.value = true
        const { error, code } = await patrolApi.submitRectify(
          addForm.value,
        )
        changeRowLoaing.value = false
        if (!error && code === 200) {
            window?.$message?.success('操作成功')
            router.push({
                path: '/patrol/manage',
            
            })
        }
    }
}
//复核检测
const reviewInspectLoaing = ref(false)
const reviewInspectLoaing1 = ref(false)
const reviewInspect = async (type)=>{
    if (type === 2) {
        reviewInspectLoaing.value = true
    } else if (type === 1) {
        reviewInspectLoaing1.value = false
    }

        const { error, code } = await patrolApi.reviewInspect(
            { id:id.value,
            status:type },
        )
        reviewInspectLoaing.value = false
        reviewInspectLoaing1.value = false
        if (!error && code === 200) {
            window?.$message?.success('操作成功')
            goList()
        }
    
}
</script>

<style lang='scss' scoped>
.bgGray{
    background-color: rgba(32, 77, 161, 0.08);;
}

.hc-table-form-content .hc-content-box .hc-table-forem-box .hc-fixed-page {
    .el-button {
        display: block;
        margin: 20px;
    }
}
</style>

<style  lang='scss'>
.hc-tree-box1 .el-tree-node {
    .el-checkbox {
        margin-right: 8px;
        .el-checkbox__inner {
            display: inline-block !important;
        }
    }
    .is-leaf + .el-checkbox {
        margin-right: 8px;
        .el-checkbox__inner {
            display: inline-block;
        }
    }
}
</style>