子模块
This commit is contained in:
@@ -40,55 +40,19 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- <el-row :gutter="10" class="mb8">-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="primary"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-plus"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleAdd"-->
|
||||
<!-- v-hasPermi="['project:module:add']"-->
|
||||
<!-- >新增</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="success"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="single"-->
|
||||
<!-- @click="handleUpdate"-->
|
||||
<!-- v-hasPermi="['project:module:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="danger"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="multiple"-->
|
||||
<!-- @click="handleDelete"-->
|
||||
<!-- v-hasPermi="['project:module:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="warning"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-download"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleExport"-->
|
||||
<!-- v-hasPermi="['project:module:export']"-->
|
||||
<!-- >导出</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
|
||||
<!-- </el-row>-->
|
||||
|
||||
<el-table v-loading="loading" :data="moduleList" @selection-change="handleSelectionChange">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="moduleList"
|
||||
@selection-change="handleSelectionChange"
|
||||
@row-click="handleRowClick"
|
||||
@cell-click="handleCellClick"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="模块名称" align="center" prop="moduleName" />
|
||||
<el-table-column label="模块名称" align="center" prop="moduleName">
|
||||
<template slot-scope="scope">
|
||||
<el-link type="primary" @click.stop="openSubDrawer(scope.row)">{{ scope.row.moduleName }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="所属项目" align="center" prop="projectName" />
|
||||
<el-table-column label="接取状态" align="center" prop="status">
|
||||
<template slot-scope="scope">
|
||||
@@ -221,6 +185,7 @@
|
||||
import { listModule, getModule, delModule, addModule, updateModule, assignModule, claimModule, giveupModule } from "@/api/project/module"
|
||||
import { listProject } from "@/api/project/project"
|
||||
import { listUser } from "@/api/system/user"
|
||||
import { listSubmoduleByModule, addSubmodule } from "@/api/project/submodule"
|
||||
|
||||
export default {
|
||||
name: "Module",
|
||||
@@ -250,6 +215,18 @@ export default {
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
|
||||
currentModule: null,
|
||||
// 新增子模块弹窗
|
||||
subOpen: false,
|
||||
subTitle: "新增子模块",
|
||||
subForm: {
|
||||
subName: null,
|
||||
description: null
|
||||
},
|
||||
subRules: {
|
||||
subName: [{ required: true, message: "子模块名称不能为空", trigger: "blur" }]
|
||||
},
|
||||
// 指派弹出层
|
||||
assignOpen: false,
|
||||
// 查询参数
|
||||
|
@@ -43,10 +43,14 @@
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<el-table v-loading="loading" :data="moduleList" @selection-change="handleSelectionChange">
|
||||
<el-table v-loading="loading" :data="moduleList" @selection-change="handleSelectionChange" @row-click="handleRowClick" @cell-click="handleCellClick">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="模块ID" align="center" prop="moduleId" />
|
||||
<el-table-column label="模块名称" align="center" prop="moduleName" />
|
||||
<el-table-column label="模块名称" align="center" prop="moduleName">
|
||||
<template slot-scope="scope">
|
||||
<el-link type="primary" @click.stop="openSubDrawer(scope.row)">{{ scope.row.moduleName }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="项目名称" align="center" prop="projectName" />
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template slot-scope="scope">
|
||||
@@ -137,11 +141,53 @@
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 子模块抽屉 -->
|
||||
<el-drawer :title="currentModule ? ('子模块 - ' + currentModule.moduleName) : '子模块'" :visible.sync="subDrawerOpen" size="60%" append-to-body>
|
||||
<div>
|
||||
<el-button type="primary" size="mini" icon="el-icon-plus" @click="handleOpenAddSub" v-if="currentModule && currentModule.status==='1' && (String(currentModule.assignee)===String(userId) || currentModule.assignee===userName)" style="margin-bottom: 12px;">新增子模块</el-button>
|
||||
<el-table v-loading="subLoading" :data="subList">
|
||||
<el-table-column label="子模块名称" prop="subName" />
|
||||
<el-table-column label="状态" prop="status">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.status==='0' ? 'info' : scope.row.status==='1' ? 'warning' : 'success'">
|
||||
{{ {0:'待处理',1:'进行中',2:'已完成'}[scope.row.status] }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="描述" prop="description" />
|
||||
<el-table-column label="操作" align="center" width="220">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleEditSub(scope.row)" v-if="canOperateSub()">修改</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDeleteSub(scope.row)" v-if="canOperateSub()">删除</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-check" @click="handleCompleteSub(scope.row)" v-if="canOperateSub() && scope.row.status==='1'">完成</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-drawer>
|
||||
|
||||
<!-- 新增子模块对话框 -->
|
||||
<el-dialog :title="subTitle" :visible.sync="subOpen" width="480px" append-to-body>
|
||||
<el-form ref="subForm" :model="subForm" :rules="subRules" label-width="88px">
|
||||
<el-form-item label="子模块名称" prop="subName">
|
||||
<el-input v-model="subForm.subName" placeholder="请输入子模块名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="描述" prop="description">
|
||||
<el-input v-model="subForm.description" type="textarea" placeholder="请输入描述" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitSubForm">确 定</el-button>
|
||||
<el-button @click="subOpen=false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getMyModules, claimModule, giveupModule, completeModule } from "@/api/project/module"
|
||||
import { listSubmoduleByModule, addSubmodule, updateSubmodule, delSubmodule, completeSubmodule } from "@/api/project/submodule"
|
||||
|
||||
export default {
|
||||
name: "MyModules",
|
||||
@@ -183,7 +229,16 @@ export default {
|
||||
moduleName: null,
|
||||
projectName: null,
|
||||
status: null,
|
||||
}
|
||||
},
|
||||
// 子模块抽屉/表单
|
||||
subDrawerOpen: false,
|
||||
subLoading: false,
|
||||
subList: [],
|
||||
currentModule: null,
|
||||
subOpen: false,
|
||||
subTitle: '新增子模块',
|
||||
subForm: { subName: null, description: null },
|
||||
subRules: { subName: [{ required: true, message: '子模块名称不能为空', trigger: 'blur' }] }
|
||||
};
|
||||
},
|
||||
created() {
|
||||
@@ -191,6 +246,106 @@ export default {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 打开子模块抽屉(统一入口) */
|
||||
openSubDrawer(row) {
|
||||
this.currentModule = row
|
||||
this.subDrawerOpen = true
|
||||
this.loadSubList()
|
||||
},
|
||||
/** 行点击触发展开 */
|
||||
handleRowClick(row, column) {
|
||||
if (column && column.type === 'selection') return
|
||||
this.openSubDrawer(row)
|
||||
},
|
||||
/** 单元格点击兜底触发 */
|
||||
handleCellClick(row, column) {
|
||||
if (column && column.type === 'selection') return
|
||||
if (!this.subDrawerOpen || !this.currentModule || this.currentModule.moduleId !== row.moduleId) {
|
||||
this.openSubDrawer(row)
|
||||
}
|
||||
},
|
||||
/** 拉取子模块列表 */
|
||||
loadSubList() {
|
||||
if (!this.currentModule) return
|
||||
this.subLoading = true
|
||||
listSubmoduleByModule(this.currentModule.moduleId).then(res => {
|
||||
this.subList = res.rows || []
|
||||
this.subLoading = false
|
||||
}).catch(() => { this.subLoading = false })
|
||||
},
|
||||
/** 打开新增子模块 */
|
||||
handleOpenAddSub() {
|
||||
this.subForm = { subId: null, subName: null, description: null }
|
||||
this.subOpen = true
|
||||
},
|
||||
/** 提交新增子模块 */
|
||||
submitSubForm() {
|
||||
this.$refs['subForm'].validate(valid => {
|
||||
if (!valid) return
|
||||
// 新增或修改
|
||||
if (!this.subForm.subId) {
|
||||
const payload = {
|
||||
moduleId: this.currentModule.moduleId,
|
||||
subName: this.subForm.subName,
|
||||
description: this.subForm.description,
|
||||
status: '0'
|
||||
}
|
||||
addSubmodule(payload).then(() => {
|
||||
this.$modal.msgSuccess('新增子模块成功')
|
||||
this.subOpen = false
|
||||
this.loadSubList()
|
||||
})
|
||||
} else {
|
||||
const payload = {
|
||||
subId: this.subForm.subId,
|
||||
moduleId: this.currentModule.moduleId,
|
||||
subName: this.subForm.subName,
|
||||
description: this.subForm.description
|
||||
}
|
||||
updateSubmodule(payload).then(() => {
|
||||
this.$modal.msgSuccess('修改子模块成功')
|
||||
this.subOpen = false
|
||||
this.loadSubList()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
/** 可操作判定(仅父模块接取人) */
|
||||
canOperateSub() {
|
||||
if (!this.currentModule) return false
|
||||
return String(this.currentModule.assignee) === String(this.userId) || this.currentModule.assignee === this.userName
|
||||
},
|
||||
/** 编辑子模块 */
|
||||
handleEditSub(row) {
|
||||
if (!this.canOperateSub()) return
|
||||
this.subForm = { subId: row.subId, subName: row.subName, description: row.description }
|
||||
this.subTitle = '修改子模块'
|
||||
this.subOpen = true
|
||||
},
|
||||
/** 删除子模块 */
|
||||
handleDeleteSub(row) {
|
||||
if (!this.canOperateSub()) return
|
||||
this.$modal.confirm('确认删除子模块 "' + row.subName + '" ?').then(() => {
|
||||
return delSubmodule(row.subId)
|
||||
}).then(() => {
|
||||
this.$modal.msgSuccess('删除成功')
|
||||
this.loadSubList()
|
||||
})
|
||||
},
|
||||
/** 完成子模块 */
|
||||
handleCompleteSub(row) {
|
||||
if (!this.canOperateSub()) return
|
||||
if (row.status !== '1') {
|
||||
this.$modal.msgError('仅进行中的子模块可完成')
|
||||
return
|
||||
}
|
||||
this.$modal.confirm('确认将子模块 "' + row.subName + '" 标记为完成?').then(() => {
|
||||
return completeSubmodule(row.subId)
|
||||
}).then(() => {
|
||||
this.$modal.msgSuccess('已完成')
|
||||
this.loadSubList()
|
||||
})
|
||||
},
|
||||
/** 将角色英文key转换为中文展示 */
|
||||
buildUserRolesText() {
|
||||
const roles = this.$store.state.user.roles || [];
|
||||
|
Reference in New Issue
Block a user