Your Name
2022-09-08 5a1616f169d75ece07d2d12a8edac3e5f660a920
src/views/facilityManagement/keyEquipment/index.vue
@@ -0,0 +1,449 @@
<template>
    <div>
        <el-form ref="ruleFormRef" :model="ruleForm" status-icon label-width="20px" class="topTitle">
            <el-row>
                <el-col :span="4">
                    <el-form-item size="default">
                        <el-input v-model="ruleForm.searchParams.name" placeholder="装置/部位名称"/>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-button size="default" type="primary" @click="listApi">查询</el-button>
                        <el-button size="default" @click="resetForm">重置</el-button>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <el-row>
            <el-col :span="4">
                <el-input v-model="filterText" style="height: 30px" placeholder="请输入关键字"/>
                <div class="tree">
                    <!--               <el-input v-model="filterText" style="height: 30px" placeholder="Filter keyword" />-->
                    <el-tree ref="treeRef" :data="data" :props="props" @node-click="handleNodeClick"
                             :filter-node-method="filterNode"/>
                </div>
            </el-col>
            <el-col :span="20">
                <div class="btns">
                    <div>
                        <el-button size="default" type="primary" :icon="Plus" @click="openD('新建')">新建</el-button>
                        <el-button size="default" :disabled="warning" type="warning" plain :icon="EditPen"
                                   @click="openD('修改', deletAll[0])">修改</el-button>
                        <el-button size="default" :disabled="danger" type="danger" :icon="Delete" @click="onDeleteAll"
                                   plain>删除
                        </el-button>
                    </div>
                    <div>
                        <!-- <el-button size="default" :icon="Upload" @click="openUp"></el-button>
                        <el-button size="default" :icon="Download"></el-button>
                        <el-button size="default" :icon="Refresh"></el-button> -->
                    </div>
                </div>
                <div style="padding-left: 10px">
                    <el-table ref="multipleTableRef" :data="tableData" @selection-change="handleSelectionChange"
                              style="width: 100%">
                        <el-table-column type="selection" align="center" width="55"/>
                        <el-table-column type="expand">
                            <template #default="scope">
                                <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick"
                                         style="margin: 0 5%">
                                    <el-tab-pane label="设备保养" name="first">
                                        <el-table ref="multipleTableRef" :data="scope.row.takecareDetailList"
                                                  style="width: 100%">
                                            <el-table-column property="takecareMemo" align="center" label="保养情况"
                                                             sortable/>
                                            <el-table-column property="leadingPersonName" align="center" label="保养负责人"
                                                             sortable/>
                                            <el-table-column property="takecareDate" align="center"
                                                             :formatter="timeDate" label="保养日期" sortable/>
                                            <el-table-column property="leadingPersonDepartmentName" align="center"
                                                             label="保养负责人单位" sortable/>
                                        </el-table>
                                    </el-tab-pane>
                                    <el-tab-pane label="设备检查" name="second"
                                    >
                                        <el-table ref="multipleTableRef" :data="scope.row.checkDetailList"
                                                  style="width: 100%">
                                            <el-table-column property="testPersonName" align="center" label="检查人"
                                                             sortable/>
                                            <el-table-column property="testDate" align="center" :formatter="timeDate"
                                                             label="检查日期" sortable/>
                                            <el-table-column property="testPersonDepartmentName" align="center" label="检查人部门" sortable/>
                                            <el-table-column property="testResult" align="center" label="检查结果"
                                                             sortable>
                                                <template #default="scope">
                                                    <span v-if="scope.row.testResult == 1">成功</span>
                                                    <span v-if="scope.row.testResult == 2">失败</span>
                                                </template>
                                            </el-table-column>
                                            <el-table-column property="testStatus" align="center" label="检查状态" sortable/>
                                        </el-table
                                        >
                                    </el-tab-pane>
                                    <el-tab-pane label="设备检测" name="third">
                                        <el-table ref="multipleTableRef" :data="scope.row.testDetailList"
                                                  style="width: 100%">
                                            <el-table-column property="repairPersonName" align="center" label="检测人"
                                                             sortable/>
                                            <el-table-column property="repairStarDate" align="center" :formatter="timeDate"
                                                             label="检测日期" sortable/>
                                            <el-table-column property="repairPersonDepartmentName" align="center"
                                                             label="检测人单位" sortable/>
                                            <el-table-column property="testMemo" align="center" label="检测内容" sortable/>
                                            <el-table-column property="testResult" align="center" label="检测结果"
                                                             sortable/>
                                            <el-table-column property="testStatus" align="center" label="检测状态"
                                                             sortable/>
                                        </el-table>
                                    </el-tab-pane>
                                    <el-tab-pane label="设备维修" name="fourth">
                                        <el-table ref="multipleTableRef" :data="scope.row.repaireDetailList"
                                                  style="width: 100%">
                                            <el-table-column property="exceptionInfo" align="center" label="设施异常项"
                                                             sortable/>
                                            <el-table-column property="repairStatus" align="center" label="维修状态"
                                                             sortable>
                                                <template #default="scope">
                                                    <span v-if="scope.row.repairStatus == 1">维修中</span>
                                                    <span v-if="scope.row.repairStatus == 2">已维修</span>
                                                </template>
                                            </el-table-column>
                                            <el-table-column property="repairMemo" align="center" label="维修情况"
                                                             sortable/>
                                            <el-table-column property="repairPersonName" align="center" label="维修负责人"
                                                             sortable/>
                                            <el-table-column property="repairPersonDepartmentName" align="center"
                                                             label="维修负责人单位" sortable/>
                                            <el-table-column property="repairStartDate" align="center"
                                                             :formatter="timeDate" label="维修开始日期" sortable/>
                                            <el-table-column property="repairEndDate" align="center"
                                                             :formatter="timeDate" label="维修结束日期" sortable/>
                                        </el-table>
                                    </el-tab-pane>
                                </el-tabs>
                            </template>
                        </el-table-column>
                        <el-table-column property="equipmentTypeName" align="center" label="类型/类别外键" sortable/>
                        <el-table-column property="name" align="center" label="装置/部位名称" sortable/>
                        <el-table-column property="departmentName" label="所属部门" align="center" sortable
                                         show-overflow-tooltip/>
                        <el-table-column property="position" label="具体位置" align="center" sortable
                                         show-overflow-tooltip/>
                        <el-table-column property="leadingPersonName" label="负责人姓名" align="center" sortable
                                         show-overflow-tooltip/>
                        <el-table-column property="partType" label="装置部位分类" align="center" sortable
                                         show-overflow-tooltip>
                            <template #default="scope">
                                <span v-if="scope.row.partType == 1">关键装置</span>
                                <span v-if="scope.row.partType == 2">重点部位</span>
                            </template>
                        </el-table-column>
                        <el-table-column label="操作" align="center" width="250">
                            <template #default="scope">
                                <el-button link type="primary" size="default" :icon="View"
                                           @click="openD('查看', scope.row.id)">查看
                                </el-button>
                                <el-button link type="primary" size="default" :icon="EditPen"
                                           @click="openD('修改', scope.row.id)">修改
                                </el-button>
                                <el-button link type="primary" size="default" :icon="Delete"
                                           @click="onDelete(scope.row.id)">删除
                                </el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="pages">
                        <el-pagination
                                v-model:currentPage="currentPage4"
                                v-model:page-size="pageSize4"
                                :page-sizes="[10, 20, 30, 40]"
                                layout="total, sizes, prev, pager, next, jumper"
                                :total="total"
                                @size-change="handleSizeChange"
                                @current-change="handleCurrentChange"
                        />
                    </div>
                </div>
            </el-col>
        </el-row>
        <!--      <updata ref="Show"></updata>-->
        <DailogS ref="ShowD" @navAddorUpdata="onAddorUpdata"></DailogS>
    </div>
</template>
<script lang="ts">
    import {defineComponent, ref, reactive, watch, onMounted} from 'vue';
    // import updata from '/@/components/updata/updata.vue'
    import DailogS from '/@/components/equipmentDailog/DailogS.vue';
    import {ElTree, TabsPaneContext, ElMessage, ElMessageBox} from 'element-plus';
    import {EditPen, Plus, Delete, Download, Refresh, Upload, View} from '@element-plus/icons-vue';
    import {facilityManagementApi} from '/@/api/facilityManagement';
    import {timeDate} from '/@/assets/index.ts'
    interface Tree {
        label: string;
        children?: Tree[];
    }
    export default defineComponent({
        components: {
            // updata,
            DailogS,
        },
        setup() {
            const ruleForm = reactive({
                pageSize: 10,
                pageIndex: 1,
                searchParams: {
                    // equipmentTypeId: '', ////类型/类别外键
                    name: '', ////装置/部位名称
                    // departmentId: '',////所属部门
                    // position: '', ////具体位置
                    // leadingPersonName: '', ////负责人姓名
                    // connectPersonId: '',////装置部位分类
                    // infoTpe: 0, ////具体类型(页面左侧的导航栏使用) 0:仪器仪表信息 1:生产设备设施 2:安全设备设施  3:重点监管装置/设备
                    equipmentTypeId: ''
                },
            });
            // 重置
            const resetForm = () => {
                ruleForm.searchParams.equipmentTypeId = '';
                listApi();
            };
            const listApi = () => {
                // delete ruleForm.qName
                facilityManagementApi()
                    .getkeypointEquipmentInfoAddOrList(ruleForm)
                    .then((res) => {
                        if (res.data.code == 200) {
                            tableData.value = res.data.data;
                            currentPage4.value = res.data.pageIndex;
                            pageSize4.value = res.data.pageSize;
                            total.value = res.data.total;
                        } else {
                            ElMessage.error(res.data.msg);
                        }
                    });
            };
            onMounted(() => {
                listApi();
            });
            const onAddorUpdata = () => {
                listApi();
            };
            const tableData = ref();
            const currentPage4 = ref();
            const pageSize4 = ref();
            const total = ref();
            const handleSizeChange = (val: number) => {
                // console.log(`${val} items per page`);
                ruleForm.pageSize = val;
                listApi();
            };
            const handleCurrentChange = (val: number) => {
                // console.log(`current page: ${val}`);
                ruleForm.pageIndex = val;
                listApi();
            };
            const filterText = ref('');
            const treeRef = ref<InstanceType<typeof ElTree>>();
            // 树形
            const listApiTree = () => {
                facilityManagementApi()
                    .getequipmentTypeMngTreeData()
                    .then((res) => {
                        if (res.data.code == 200) {
                            console.log(res.data.data);
                            data.value = res.data.data;
                        } else {
                            ElMessage({
                                showClose: true,
                                message: res.data.msg,
                                type: 'error',
                            });
                        }
                    });
            };
            const props = {
                label: 'typeName',
                children: 'childList',
                value: 'id',
            }
            watch(filterText, (val) => {
                treeRef.value!.filter(val);
            });
            const filterNode = (value: string, data: Tree) => {
                if (!value) return true;
                return data.typeName.includes(value);
            };
            const handleNodeClick = (data: Tree) => {
                console.log(data)
                ruleForm.searchParams.equipmentTypeId = data.id;
                listApi();
            };
            const data = ref([]);
            onMounted(() => {
                listApiTree();
            });
            // 删除
            const onDelete = (id: number) => {
                let arr = []
                arr.push(id)
                ElMessageBox.confirm('确定删除所选项吗?', 'Warning', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                })
                    .then(() => {
                        facilityManagementApi()
                            .getkeypointEquipmentInfoDetele(arr)
                            .then((res) => {
                                if (res.data.code == 200) {
                                    ElMessage({
                                        message: res.data.msg,
                                        type: 'success',
                                    });
                                    listApi();
                                } else {
                                    ElMessage.error(res.data.msg);
                                }
                            });
                    })
                    .catch(() => {
                        ElMessage({
                            type: 'info',
                            message: 'Delete canceled',
                        });
                    });
            };
            // 批量删除
            // const warning = ref(true);
            const danger = ref(true);
            const deletAll = ref();
            const handleSelectionChange = (val: any) => {
                let valId = JSON.parse(JSON.stringify(val));
                let arr = [];
                for (let i = 0; i < valId.length; i++) {
                    arr.push(valId[i].id);
                }
                deletAll.value = arr;
                if (val.length == 1) {
                    // warning.value = false;
                    danger.value = false;
                } else if (val.length == 0) {
                    // warning.value = true;
                    danger.value = true;
                } else {
                    // warning.value = true;
                    danger.value = false;
                }
            };
            const onDeleteAll = () => {
                ElMessageBox.confirm('确定删除所选项吗?', 'Warning', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                })
                    .then(() => {
                        facilityManagementApi()
                            .getkeypointEquipmentInfoDetele(deletAll.value)
                            .then((res) => {
                                if (res.data.code == 200) {
                                    ElMessage({
                                        message: res.data.msg,
                                        type: 'success',
                                    });
                                    listApi();
                                } else {
                                    ElMessage.error(res.data.msg);
                                }
                            });
                    })
                    .catch(() => {
                        // ElMessage({
                        //    type: 'info',
                        //    message: 'Delete canceled',
                        // });
                    });
            };
            const activeName = ref('first');
            const handleClick = (tab: TabsPaneContext, event: Event) => {
                console.log(tab, event);
            };
            // const Show=ref()
            // const openUp=()=>{
            //    Show.value.openDialog()
            // }
            // 新增弹窗
            const ShowD = ref();
            const openD = (title: String, id: number) => {
                ShowD.value.openDailog(title, false, id, 2);
            };
            return {
                activeName,
                handleClick,
                ruleForm,
                filterText,
                treeRef,
                props,
                filterNode,
                data,
                tableData,
                // Show,
                // openUp,
                ShowD,
                danger,
                openD,
                // openEdit,
                Plus,
                EditPen,
                listApiTree,
                Delete,
                View,
                Download,
                Refresh,
                Upload,
                resetForm,
                listApi,
                handleCurrentChange,
                handleSizeChange,
                onAddorUpdata,
                total,
                currentPage4,
                pageSize4,
                onDelete,
                // warning,
                handleSelectionChange,
                onDeleteAll,
                handleNodeClick,
                timeDate,
                deletAll
            };
        },
    });
</script>
<style scoped>
    .topTitle {
        background-color: #fff;
        padding: 20px 0px 20px 0px;
        margin-bottom: 10px;
    }
    .tree {
        height: 750px;
        background-color: #fff;
        overflow: hidden;
        overflow-y: auto;
    }
    .btns {
        padding: 10px 0px 10px 10px;
        display: flex;
        justify-content: space-between;
        background-color: #fff;
    }
</style>