马宇豪
2023-04-12 8d14fec97344df49d58db115852c03b466482bc6
src/views/experiment/developing/index.vue
@@ -4,17 +4,17 @@
            <el-row class="homeCard">
                <div class="basic-line">
                    <span>实验名称:</span>
                    <el-input v-model="projectState.searchQuery.searchParams.experimentName" clearable filterable class="input-box" placeholder="实验名称">
                    <el-input v-model="developState.searchQuery.searchParams.experimentName" clearable filterable class="input-box" placeholder="实验名称">
                    </el-input>
                </div>
                <div class="basic-line">
                    <span>实验类型:</span>
                    <el-select v-model="projectState.searchQuery.searchParams.experimentType" clearable filterable class="input-box" placeholder="实验类型">
                        <el-option v-for="item in projectState.experimentTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                    <el-select v-model="developState.searchQuery.searchParams.experimentType" clearable filterable class="input-box" placeholder="实验类型">
                        <el-option v-for="item in developState.experimentTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                </div>
                <div style="padding-bottom: 10px">
                    <el-button type="primary" @click="getProjectData">查询</el-button>
                    <el-button type="primary" @click="getdevelopData">查询</el-button>
                    <el-button plain @click="reset">重置</el-button>
                </div>
            </el-row>
@@ -22,35 +22,81 @@
                <div class="main-card">
                    <el-row class="cardTop">
                        <el-col :span="12" class="mainCardBtn">
                            <el-button type="primary" :icon="Plus" size="default" @click="openProjectDialog('新增', {})">新增</el-button>
                            <el-button type="primary" :icon="Plus" size="default" @click="openProjectDialog('新增', {})">录入实验信息</el-button>
                            <!--                            <el-button type="danger" :icon="Delete" size="default" plain>删除</el-button>-->
                        </el-col>
<!--                        <el-button type="primary" :icon="Refresh" size="default" />-->
                    </el-row>
                    <el-table ref="multipleTableRef" :data="projectState.projectData" style="width: 100%" height="calc(100% - 100px)" :header-cell-style="{ background: '#fafafa' }">
                    <el-table ref="multipleTableRef" :data="developState.developData" style="width: 100%" height="calc(100% - 100px)" :header-cell-style="{ background: '#fafafa' }">
                        <el-table-column prop="experimentCode" label="实验编号"/>
                        <el-table-column prop="expectStartTime" label="立项时间" />
                        <el-table-column prop="experimentName" label="实验名称"/>
                        <el-table-column prop="createExperimentTime" label="立项时间">
                          <template #default="scope">
                            <span>{{scope.row.createExperimentTime?scope.row.createExperimentTime.substring(0,16):'--'}}</span>
                          </template>
                        </el-table-column>
                        <el-table-column prop="startTime" label="开展时间" show-overflow-tooltip>
                          <template #default="scope">
                            <span>{{scope.row.startTime?scope.row.startTime.substring(0,16):'--'}}</span>
                          </template>
                        </el-table-column>
                        <el-table-column prop="liabilityUser" label="负责人"/>
                        <el-table-column prop="createTime" label="创建时间" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="createByUserName" label="创建人" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="updateTime" label="最后修改时间" show-overflow-tooltip></el-table-column>
                        <el-table-column prop="updateByUserName" label="最后修改人" show-overflow-tooltip></el-table-column>
                        <el-table-column label="操作" width="250">
                        <el-table-column prop="siteList" label="实验场所" show-overflow-tooltip>
                          <template #default="scope">
                            <span>{{scope.row.siteList.map(i=>i.siteName).join(',')}}</span>
                          </template>
                        </el-table-column>
                        <el-table-column prop="experimentType" label="实验类别">
                          <template #default="scope">
                            <span>{{developState.experimentTypeList.find(i=>i.id == scope.row.experimentType)?.name}}</span>
                          </template>
                        </el-table-column>
                        <el-table-column prop="status" label="评估申请">
                          <template #default="scope">
                            <span>{{scope.row.status == 1?'未申请':scope.row.status == 2?'已申请':'--'}}</span>
                          </template>
                        </el-table-column>
                        <el-table-column prop="status" label="评估申请时间" show-overflow-tooltip>
                          <template #default="scope">
                            <span>{{scope.row.assessApplyTime?scope.row.assessApplyTime.substring(0,16):'--'}}</span>
                          </template>
                        </el-table-column>
                        <el-table-column prop="stage" label="评估状态">
                          <template #default="scope">
                            <el-tag :type="scope.row.stage == 4?'success':scope.row.stage == 1?'info':''">
                              {{scope.row.stage == 1?'未评估':scope.row.status == 2?'评估中':scope.row.status == 3?'评估完成':scope.row.status == 4?'生成报告':'--'}}
                            </el-tag>
                          </template>
                        </el-table-column>
                        <el-table-column prop="assessLevel" label="风险等级">
                          <template #default="scope">
                            <el-tag :type="scope.row.assessLevel == 4?'danger':scope.row.assessLevel == 3 || scope.row.assessLevel == 2?'warning':''">
                              {{scope.row.assessLevel == 1?'低风险':scope.row.assessLevel == 2?'一般风险':scope.row.assessLevel == 3?'较大风险':scope.row.assessLevel == 4?'重大风险':'--'}}
                            </el-tag>
                          </template>
                        </el-table-column>
<!--                        <el-table-column prop="createTime" label="创建时间" show-overflow-tooltip></el-table-column>-->
<!--                        <el-table-column prop="createByUserName" label="创建人" show-overflow-tooltip></el-table-column>-->
<!--                        <el-table-column prop="updateTime" label="最后修改时间" show-overflow-tooltip></el-table-column>-->
<!--                        <el-table-column prop="updateByUserName" label="最后修改人" show-overflow-tooltip></el-table-column>-->
                        <el-table-column label="操作" width="250" fixed="right">
                            <template #default="scope">
                                <el-button size="small" text type="primary" :icon="View" @click="openProjectDialog('查看', scope.row)">查看</el-button>
                                <el-button size="small" text type="primary" :icon="Edit" @click="applyAccess( scope.row)">申请评估</el-button>
                                <el-button size="small" :disabled="scope.row.status == 2 ? true : false" text type="primary" :icon="Edit" @click="applyAccess( scope.row)">申请评估</el-button>
                                <el-button size="small" :disabled="(scope.row.status == 2 && scope.row.stage == 1) ? false : true" text type="warning" :icon="RefreshLeft" @click="cancelAccess( scope.row)">撤销评估</el-button>
                                <el-button size="small" type="warning" v-if="scope.row.rectifyStatus == 1" text :icon="Edit" @click="openProjectDialog('整改', scope.row)">整改</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div class="pageBtn">
                        <el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="projectState.searchQuery.pageIndex" background v-model:page-size="projectState.searchQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="projectState.total" class="page-position"> </el-pagination>
                        <el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="developState.searchQuery.pageIndex" background v-model:page-size="developState.searchQuery.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="developState.total" class="page-position"> </el-pagination>
                    </div>
                </div>
            </div>
        </div>
        <project-dialog ref="ProjectDialogRef" @refresh="getProjectData"></project-dialog>
        <develop-dialog ref="DevelopDialogRef" @refresh="getdevelopData"></develop-dialog>
<!--        <apply-start ref="ApplyStartRef"></apply-start>-->
        <test ref="ApplyStartRef" @refresh="getProjectData"></test>
        <test ref="ApplyStartRef" @refresh="getdevelopData"></test>
    </div>
</template>
@@ -58,17 +104,17 @@
import {defineAsyncComponent, onMounted, reactive, ref} from "vue";
import {projectApi} from "/@/api/experiment/project";
import {ElMessage, ElMessageBox} from "element-plus";
import { View,Edit, Plus, Delete } from '@element-plus/icons-vue';
import { View,Edit, Plus, RefreshLeft } from '@element-plus/icons-vue';
import {roomApi} from "/@/api/basic/room";
const ProjectDialog = defineAsyncComponent(() => import('./components/projectDialog.vue'));
const DevelopDialog = defineAsyncComponent(() => import('./components/developDialog.vue'));
const Test = defineAsyncComponent(() => import('./components/applyDialog.vue'))
const ProjectDialogRef = ref();
const DevelopDialogRef = ref();
const ApplyStartRef = ref();
const projectState = reactive<ProjectStateType>({
    projectData: [],
const developState = reactive<ProjectStateType>({
    developData: [],
    searchQuery: {
        pageIndex: 1,
        pageSize: 10,
@@ -89,11 +135,11 @@
    allRoomList: []
})
const getProjectData = async () => {
    let res = await projectApi().getProjectByList(projectState.searchQuery);
const getdevelopData = async () => {
    let res = await projectApi().getDevelopByList(developState.searchQuery);
    if(res.data.code === 100){
        projectState.projectData = res.data.data;
        projectState.total = res.data.total;
        developState.developData = res.data.data;
        developState.total = res.data.total;
    }else{
        ElMessage({
            type: 'warning',
@@ -103,12 +149,11 @@
};
const openProjectDialog = (title: string, value: ProjectType) => {
    ProjectDialogRef.value.showProjectDialog(title, value, projectState.allRoomList);
    DevelopDialogRef.value.showDevelopDialog(title, value, developState.allRoomList);
};
const applyAccess = (val: ProjectType) => {
    debugger
    ElMessageBox.confirm(`此操作将申请评估该实验:“${val.experimentCode}”,是否继续?`, '提示', {
    ElMessageBox.confirm(`此操作将申请评估该实验:“${val.experimentName}”,是否继续?`, '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
@@ -121,7 +166,7 @@
                    duration: 2000,
                    message: '申请成功'
                });
                await getProjectData();
                await getdevelopData();
            } else {
                ElMessage({
                    type: 'warning',
@@ -131,6 +176,32 @@
        })
        .catch((error) => {
        });
}
const cancelAccess = (val: ProjectType) => {
  ElMessageBox.confirm(`此操作将撤销评估该实验:“${val.experimentName}”,是否继续?`, '提示', {
    confirmButtonText: '确认',
    cancelButtonText: '取消',
    type: 'warning'
  })
      .then(async () => {
        let res = await projectApi().cancelProject([val.id]);
        if (res.data.code === 100) {
          ElMessage({
            type: 'success',
            duration: 2000,
            message: '撤销成功'
          });
          await getdevelopData();
        } else {
          ElMessage({
            type: 'warning',
            message: res.data.msg
          });
        }
      })
      .catch((error) => {
      });
}
const onDelProject = (val: ProjectType) => {
@@ -148,7 +219,7 @@
                    duration: 2000,
                    message: '删除成功'
                });
                await getProjectData();
                await getdevelopData();
            } else {
                ElMessage({
                    type: 'warning',
@@ -161,17 +232,17 @@
}
const onHandleSizeChange = (val: number) => {
    projectState.searchQuery.pageSize = val;
    getProjectData();
    developState.searchQuery.pageSize = val;
    getdevelopData();
};
const onHandleCurrentChange = (val: number) => {
    projectState.searchQuery.pageIndex = val;
    getProjectData();
    developState.searchQuery.pageIndex = val;
    getdevelopData();
};
const reset = () => {
    projectState.searchQuery = {
    developState.searchQuery = {
        pageIndex: 1,
        pageSize: 10,
        searchParams: {
@@ -184,7 +255,7 @@
const getRoomData = async () => {
    let res = await roomApi().getAllRoom();
    if(res.data.code === 100){
        projectState.allRoomList = JSON.parse(JSON.stringify(res.data.data));
        developState.allRoomList = JSON.parse(JSON.stringify(res.data.data));
    }else{
        ElMessage({
            type: 'warning',
@@ -194,7 +265,7 @@
};
onMounted(() => {
    getProjectData();
    getdevelopData();
    getRoomData();
})