<template>
|
<div class="list">
|
<TableCustom :queryForm="form" :tableData="tableData" :total="total" @handlePageChange="handlePageChange" @handleSizeChange="handleSizeChange">
|
<template #search>
|
<el-form :model="form" labelWidth="auto" inline>
|
<el-form-item label="项目课题方案名称:">
|
<el-input v-model="form.projectName" placeholder="请输入"></el-input>
|
</el-form-item>
|
<el-form-item label="实验编号:">
|
<el-input v-model="form.experimentCode" placeholder="请输入"></el-input>
|
</el-form-item>
|
<el-form-item label="创建时间:">
|
<el-date-picker
|
v-model="form.createTime"
|
type="daterange"
|
range-separator="至"
|
start-placeholder="开始日期"
|
end-placeholder="结束日期"
|
value-format="yyyy-MM-dd"
|
@change="handleDateChange"
|
></el-date-picker>
|
</el-form-item>
|
<el-form-item label="状态:">
|
<el-select v-model="form.status" placeholder="请选择">
|
<el-option label="全部" value=""></el-option>
|
<el-option label="草稿" :value="-1"></el-option>
|
<el-option label="已发送" :value="1"></el-option>
|
<el-option label="申请中止待审核" :value="2"></el-option>
|
<el-option label="申请中止已通过" :value="3"></el-option>
|
<el-option label="申请中止已驳回" :value="4"></el-option>
|
<el-option label="已封存" :value="5"></el-option>
|
</el-select>
|
</el-form-item>
|
<el-form-item label="">
|
<el-button type="default" @click="resetForm">重置</el-button>
|
<el-button type="primary" @click="handleSearch" style="margin-left: 10px;">查询</el-button>
|
</el-form-item>
|
</el-form>
|
</template>
|
<template #setting>
|
<div class="tableTitle">
|
<div class="flex a-center flex-wrap">
|
<div
|
class="title"
|
:class="{active:currentType === 'list'}"
|
@click="handleTypeChange('list')"
|
>项目课题方案列表</div>
|
<div
|
v-if="userRole == '3'"
|
class="drafts"
|
:class="{active:currentType === 'draft'}"
|
@click="handleTypeChange('draft')"
|
>草稿箱</div>
|
</div>
|
<el-button
|
v-if="userRole == '3'"
|
@click="handleAddPlan"
|
class="el-icon-plus"
|
type="primary"
|
>新增实验方案</el-button>
|
</div>
|
</template>
|
<template #table>
|
<el-table-column
|
prop="projectName"
|
label="项目课题方案名称"
|
></el-table-column>
|
<el-table-column
|
prop="experimentCode"
|
label="实验编号"
|
></el-table-column>
|
<el-table-column prop="experimentName" label="实验名称"></el-table-column>
|
<el-table-column prop="experimentDate" label="实验日期"></el-table-column>
|
<el-table-column prop="experimentSchemePersons" label="实验员"></el-table-column>
|
<el-table-column prop="createTime" label="创建日期"></el-table-column>
|
<el-table-column prop="createBy" label="创建人"></el-table-column>
|
<el-table-column prop="status" label="当前状态">
|
<template slot-scope="scope">
|
<el-tag :type="getStatusType(scope.row.status)">
|
{{ getStatusText(scope.row.status) }}
|
</el-tag>
|
</template>
|
</el-table-column>
|
<el-table-column label="操作" width="250">
|
<template slot-scope="scope">
|
<!-- 超级管理员(1)和审批人(2) -->
|
<template v-if="userRole == '1' || userRole == '2'">
|
<el-button type="text" @click="handleDetail(scope.row)">详情</el-button>
|
</template>
|
|
<!-- 工艺工程师(3) -->
|
<template v-if="userRole == '3'">
|
<!-- <el-button type="text" @click="handleEdit(scope.row)" >编辑</el-button> -->
|
<el-button type="text" @click="handleDetail(scope.row)">详情</el-button>
|
</template>
|
|
<!-- 实验员(5) -->
|
<template v-if="userRole == '5'">
|
<el-button type="text" @click="handleEdit(scope.row)" v-if="scope.row.status == 1">编辑</el-button>
|
</template>
|
</template>
|
</el-table-column>
|
</template>
|
</TableCustom>
|
<!-- 审批弹窗 -->
|
<approval-dialog
|
:visible.sync="approvalDialogVisible"
|
:type="approvalDialogType"
|
:data="currentApprovalData"
|
@approve="handleApproveSubmit"
|
@reject="handleRejectSubmit"
|
/>
|
</div>
|
</template>
|
|
<script>
|
import ApprovalDialog from './components/approvalDialog.vue'
|
import {getList} from './service'
|
|
export default {
|
name: "ProjectList",
|
components: {
|
ApprovalDialog
|
},
|
data() {
|
return {
|
currentType: 'list', // 当前显示类型:list-列表,draft-草稿箱
|
form: {
|
projectName: "",
|
experimentCode: "",
|
createTime: [],
|
status: "",
|
startTime: "",
|
endTime: "",
|
pageNum: 1,
|
pageSize: 10
|
},
|
tableData: [],
|
total: 0,
|
approvalDialogVisible: false,
|
approvalDialogType: 'view',
|
currentApprovalData: null,
|
userRole: '',
|
};
|
},
|
created() {
|
const userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}');
|
this.userRole = userInfo.roleType || '';
|
|
if (this.userRole == '4') {
|
this.$router.push('/403');
|
return;
|
}
|
|
this.getTableData();
|
},
|
methods: {
|
handlePageChange(page) {
|
this.form.pageNum = page;
|
// 当处于草稿箱模式时,强制将状态设置为-1
|
if (this.currentType === 'draft') {
|
this.form.status = -1;
|
}
|
this.getTableData();
|
},
|
handleSizeChange(size) {
|
this.form.pageSize = size;
|
this.form.pageNum = 1;
|
// 当处于草稿箱模式时,强制将状态设置为-1
|
if (this.currentType === 'draft') {
|
this.form.status = -1;
|
}
|
this.getTableData();
|
},
|
resetForm() {
|
this.form = {
|
projectName: "",
|
experimentCode: "",
|
createTime: [],
|
status: "",
|
startTime: "",
|
endTime: "",
|
pageNum: 1,
|
pageSize: 10
|
};
|
// 当处于草稿箱模式时,强制将状态设置为-1
|
if (this.currentType === 'draft') {
|
this.form.status = -1;
|
}
|
this.getTableData();
|
},
|
handleSearch() {
|
this.form.pageNum = 1;
|
// 当处于草稿箱模式时,强制将状态设置为-1
|
if (this.currentType === 'draft') {
|
this.form.status = -1;
|
}
|
this.getTableData();
|
},
|
getStatusType(status) {
|
const statusMap = {
|
'-1': "info",
|
'1': "warning",
|
'2': "warning",
|
'3': "success",
|
'4': "danger",
|
'5': "info",
|
'6':'success'
|
};
|
return statusMap[status] || "info";
|
},
|
getStatusText(status) {
|
const statusMap = {
|
'-1': "草稿",
|
'1': "已发送",
|
'2': "申请中止待审核",
|
'3': "申请中止已通过",
|
'4': "申请中止已驳回",
|
'5': "已封存",
|
'6':'实验员已提交'
|
};
|
return statusMap[status] || "未知";
|
},
|
handleDateChange(val) {
|
if (val) {
|
this.form.startTime = val[0];
|
this.form.endTime = val[1];
|
} else {
|
this.form.startTime = '';
|
this.form.endTime = '';
|
}
|
},
|
handleTypeChange(type) {
|
this.currentType = type;
|
this.form.status = type === 'draft' ? -1 : '';
|
this.form.pageNum = 1;
|
this.getTableData();
|
},
|
async getTableData() {
|
try {
|
// 当处于草稿箱模式时,强制将状态设置为-1
|
if (this.currentType === 'draft') {
|
this.form.status = -1;
|
}
|
const { data } = await getList(this.form);
|
this.tableData = data.records || [];
|
this.total = data.total || 0;
|
} catch (error) {
|
console.error('获取列表数据失败:', error);
|
this.$message.error('获取列表数据失败');
|
}
|
},
|
handleAddPlan() {
|
this.$router.push({
|
path: "/dataManagement/scheme-management/add",
|
});
|
},
|
handleEdit(row) {
|
this.$router.push({
|
path: "/dataManagement/scheme-management/add",
|
query: {
|
id: row.id,
|
type: 'edit'
|
}
|
});
|
},
|
handleDetail(row) {
|
this.approvalDialogType = 'view';
|
this.approvalDialogVisible = true;
|
this.currentApprovalData = row;
|
},
|
handleApproveSubmit(data) {
|
this.approvalDialogVisible = false;
|
this.$message.success('审批通过成功');
|
this.getTableData();
|
},
|
handleRejectSubmit(data) {
|
this.approvalDialogVisible = false;
|
this.$message.success('审批驳回成功');
|
this.getTableData();
|
}
|
},
|
};
|
</script>
|
|
<style scoped lang="less">
|
.list {
|
height: 100%;
|
}
|
.flex {
|
display: flex;
|
align-items: center;
|
}
|
.tableTitle {
|
display: flex;
|
padding-bottom: 20px;
|
justify-content: space-between;
|
align-items: center;
|
.title {
|
background: #fafafc;
|
border-radius: 8px 8px 0px 0px;
|
border: 1px solid #dcdfe6;
|
padding: 16px 29px;
|
font-weight: bold;
|
font-size: 18px;
|
color: #606266;
|
width: unset;
|
cursor: pointer;
|
}
|
.drafts {
|
padding: 16px 65px;
|
background: #fafafc;
|
border-radius: 8px 8px 0px 0px;
|
border: 1px solid #dcdfe6;
|
font-weight: 400;
|
font-size: 18px;
|
color: #606266;
|
margin-left: 16px;
|
cursor: pointer;
|
}
|
.active{
|
color: #049c9a;
|
background: #ffffff;
|
border-radius: 8px 8px 0px 0px;
|
border: 1px solid #049c9a;
|
}
|
}
|
</style>
|