| | |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <div> |
| | | <!-- 搜索 --> |
| | | <el-input v-model="query.name" clearable placeholder="名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" /> |
| | | <el-select v-model="query.projectId" filterable clearable placeholder="所属项目" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-select v-model="query.projectId" filterable placeholder="所属项目" style="width: 400px;" class="filter-item" @change="queryByProjectId"> |
| | | <el-option |
| | | v-for="item in projects" |
| | | :key="item.id" |
| | |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.priority" filterable clearable placeholder="优先度" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[priority]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.taskClassification" filterable clearable placeholder="任务分类" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[taskClassification]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.taskStatus" filterable clearable placeholder="任务状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | </div> |
| | | <div style="margin-bottom: 20px;"> |
| | | <el-card class="box-card"> |
| | | <el-descriptions title="项目信息"> |
| | | <el-descriptions-item label="用户名">kooriookami</el-descriptions-item> |
| | | <el-descriptions-item label="手机号">18100000000</el-descriptions-item> |
| | | <el-descriptions-item label="居住地">苏州市</el-descriptions-item> |
| | | <el-descriptions-item label="备注"> |
| | | <el-tag size="small">学校</el-tag> |
| | | </el-descriptions-item> |
| | | <el-descriptions-item label="联系地址">江苏省苏州市吴中区吴中大道 1188 号</el-descriptions-item> |
| | | </el-descriptions> |
| | | </el-card> |
| | | </div> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-autocomplete v-model="query.name" class="filter-item" :fetch-suggestions="querySearch" placeholder="名称" style="width: 185px;" /> |
| | | <el-select v-model="query.taskStatus" filterable clearable placeholder="任务状态" style="width: 185px;" class="filter-item"> |
| | | <el-option |
| | | v-for="item in dict[taskStatus]" |
| | | :key="item.id" |
| | |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.performanceType" filterable clearable placeholder="绩效类型" style="width: 185px;" class="filter-item"> |
| | | <el-option |
| | | v-for="item in dict[performanceType]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.userId" filterable clearable placeholder="所属员工" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <rrOperation :crud="crud" /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission"> |
| | | <el-button |
| | | slot="right" |
| | | v-permission="permission.divide" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-share" |
| | | :disabled="crud.selections.length !== 1" |
| | | @click="toDivide(crud.selections[0])" |
| | | > |
| | | 分配 |
| | | </el-button> |
| | | <el-button |
| | | slot="right" |
| | | v-permission="permission.seeDivide" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-share" |
| | | :disabled="crud.selections.length !== 1" |
| | | style="margin-left: 4px !important;" |
| | | @click="toSeeDivide(crud.selections[0])" |
| | | > |
| | | 查看分配 |
| | | </el-button> |
| | | <el-button |
| | | slot="right" |
| | | v-permission="permission.seeDaliy" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-share" |
| | | :disabled="crud.selections.length !== 1" |
| | | style="margin-left: 4px !important;" |
| | | @click="toSeeDaliy(crud.selections[0])" |
| | | > |
| | | 查看日报 |
| | | </el-button> |
| | | </crudOperation> |
| | | <crudOperation :permission="permission" /> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="110px"> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="form.name" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="所属项目" prop="projectId"> |
| | | <el-select v-model="form.projectId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="crud.status.edit == crudStatusPrepared" @change="projectChange"> |
| | | <el-select v-model="form.projectId" disabled placeholder="请选择" style="width: 340px;" @change="projectChange"> |
| | | <el-option |
| | | v-for="item in projects" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | :disabled="item.approveStatus == approveStatusUnrecognized" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="form.name" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="父级任务"> |
| | | <el-select v-model="form.pid" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-select v-if="pidTasks" v-model="form.parent.id" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in pidTasks" |
| | | :key="item.id" |
| | |
| | | :disabled="item.id == form.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="优先度" prop="priority"> |
| | | <el-select v-model="form.priority" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in dict[priority]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | {{ form.parent.id }} |
| | | </el-form-item> |
| | | <el-form-item label="任务分类" prop="taskClassification"> |
| | | <el-select v-model="form.taskClassification" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-tag |
| | | v-for="(tag, id) in form.tags" |
| | | :key="id" |
| | | closable |
| | | :disable-transitions="false" |
| | | @close="handleClose(id)" |
| | | > |
| | | {{ tag }} |
| | | </el-tag> |
| | | <el-select |
| | | v-if="inputVisible" |
| | | ref="saveTagInput" |
| | | v-model="inputValue" |
| | | class="input-new-tag" |
| | | filterable |
| | | clearable |
| | | allow-create |
| | | default-first-option |
| | | @keyup.enter.native="handleInputConfirm" |
| | | > |
| | | <el-option |
| | | v-for="item in dict[taskClassification]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | v-for="(item, id) in tags" |
| | | :key="id" |
| | | :label="item" |
| | | :value="item" |
| | | /> |
| | | </el-select> |
| | | <el-button v-else class="button-new-tag" size="small" @click="showInput">+ New Tag</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="绩效类型" prop="performanceType"> |
| | | <el-select v-model="form.performanceType" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | |
| | | <template slot="append">小时</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="计件单金" prop="pieceRate"> |
| | | <el-input v-model="form.pieceRate" style="width: 340px;"> |
| | | <template slot="append">元</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="计划工作量" prop="planWorkload"> |
| | | <el-input v-model="form.planWorkload" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="计划工作量单位"> |
| | | <el-select v-model="form.planWorkloadUnit" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-form-item label="所属员工" prop="userId"> |
| | | <el-select v-model="form.userIdList" multiple filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in dict[standardWorkloadUnit]" |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | > |
| | | <span style="float: left">{{ item.nickName }}</span> |
| | | <span style="float: right; color: #8492a6; font-size: 13px">{{ item.levelName }}</span> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="任务状态" prop="taskStatus"> |
| | | <el-select v-model="form.taskStatus" filterable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in dict[taskStatus]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 340px;" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table |
| | | ref="table" |
| | | v-loading="crud.loading" |
| | | :data="crud.data" |
| | | size="small" |
| | | style="width: 100%;" |
| | | row-key="id" |
| | | lazy |
| | | :load="load" |
| | | :tree-props="{children: 'children', hasChildren: 'hasChildren'}" |
| | | :summary-method="getSummaries" |
| | | show-summary |
| | | :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" |
| | | @selection-change="crud.selectionChangeHandler" |
| | | > |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="name" label="名称" fixed="left" width="180" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="projectName" label="所属项目" width="140"> |
| | | <el-table-column :show-overflow-tooltip="true" label="计划工时" width="80"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.projectName }}</el-tag> |
| | | {{ scope.row.sumPlanHours }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="priority" label="优先度" width="80"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planStartTime" label="计划开始时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planEndTime" label="计划结束时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskStatus" label="任务状态" width="80"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[priority][scope.row.priority] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskClassification" label="任务分类" width="80"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[taskClassification][scope.row.taskClassification] }}</el-tag> |
| | | <el-tag>{{ dict.label[taskStatus][scope.row.taskStatus] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="performanceType" label="绩效类型" width="80"> |
| | |
| | | <el-tag>{{ dict.label[performanceType][scope.row.performanceType] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="description" label="描述" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planStartTime" label="计划开始时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planEndTime" label="计划结束时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" label="已完成 / 已分配 / 计划工时" width="160"> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskClassification" label="任务分类" width="160"> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMaxTwoDecimalPlaces(scope.row.completedHours) }} / {{ scope.row.divideHours }} / {{ scope.row.planHours }} |
| | | <el-tag>{{ dict.label[taskClassification][scope.row.taskClassification] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="已完成 / 已分配 / 计划工作量" width="180"> |
| | | <template slot-scope="scope"> |
| | | <span> |
| | | {{ crud.toMaxTwoDecimalPlaces(scope.row.completedWorkload) }} / {{ scope.row.divideWorkload }} / {{ scope.row.planWorkload == null || scope.row.planWorkload == '' ? 0 : scope.row.planWorkload }} |
| | | </span> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="planWorkloadUnit" label="计划工作量单位" width="110"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.planWorkloadUnit != null && scope.row.planWorkloadUnit != ''">{{ dict.label[standardWorkloadUnit][scope.row.planWorkloadUnit] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskStatus" label="任务状态" width="80"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ dict.label[taskStatus][scope.row.taskStatus] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="description" label="描述" width="180" /> |
| | | <el-table-column v-if="checkPer(['admin','task:divide','task:edit','task:del'])" label="操作" width="180px" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | v-if="userRolesLevelMin == roleLevelSuper || userRolesLevelMin == roleLevelGeneral || scope.row.projectLiableUserIdList.indexOf($store.state.user.user.id) != -1" |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | > |
| | | <el-button |
| | | slot="left" |
| | | v-permission="permission.divide" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-share" |
| | | @click="toDivide(scope.row)" |
| | | /> |
| | | </udOperation> |
| | | <udOperation :data="scope.row" :permission="permission" /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | <!--表单组件(分配)--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="divideClose" :visible.sync="divideStatus" title="任务分配" width="500px"> |
| | | <el-form ref="divideForm" :model="divideForm" :rules="divideRules" size="small" label-width="110px"> |
| | | <el-form-item label="项目名称" prop="projectName"> |
| | | {{ divideForm.projectName }} |
| | | </el-form-item> |
| | | <el-form-item label="任务名称" prop="taskName"> |
| | | {{ divideForm.taskName }} |
| | | </el-form-item> |
| | | <el-form-item label="分配员工" prop="userIds"> |
| | | <el-select v-model="divideForm.userIds" filterable clearable multiple placeholder="请选择" style="width: 340px;" @change="calcHour"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled || divideForm.divideUserIds.includes(item.id)" |
| | | > |
| | | <span style="float: left">{{ item.nickName }}</span> |
| | | <span style="float: right; color: #8492a6; font-size: 13px">{{ item.levelName }}</span> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="任务开始时间" prop="taskStartDate"> |
| | | <el-date-picker v-model="divideForm.taskStartDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workStartTime + ':00'" :picker-options="taskStartDatePickerOptions" style="width: 340px;" @change="calcHour" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务结束时间" prop="taskEndDate"> |
| | | <el-date-picker v-model="divideForm.taskEndDate" type="datetime" value-format="yyyy-MM-dd HH:mm:ss" :default-time="$store.state.user.user.sysRostering.workEndTime + ':00'" :picker-options="taskEndDatePickerOptions" style="width: 340px;" @change="calcHour" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务工时" prop="taskHours"> |
| | | <el-input v-model="divideForm.taskHours" style="width: 340px;"> |
| | | <template slot="append">小时</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="任务工作量" prop="taskWorkload"> |
| | | <el-input v-model="divideForm.taskWorkload" style="width: 340px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务工作量单位" prop="taskWorkloadUnit"> |
| | | <span v-if="divideForm.taskWorkloadUnit != null && divideForm.taskWorkloadUnit != ''"> |
| | | {{ dict.label[standardWorkloadUnit][divideForm.taskWorkloadUnit] }} |
| | | </span> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="divideClose">取消</el-button> |
| | | <el-button :loading="divideLoading" type="primary" @click="divideSubmit">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudTask from '@/api/task/task' |
| | | import crudTaskUser from '@/api/task/taskUser' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import constant from '../../../utils/constant' |
| | | import crudProject from '@/api/project/project' |
| | | import constant from '@/utils/constant' |
| | | import crudUser from '@/api/system/user' |
| | | import crudProject from '@/api/project/project' |
| | | |
| | | const defaultForm = { id: null, name: null, projectId: null, pid: null, priority: null, taskClassification: null, performanceType: null, description: null, planStartTime: null, planEndTime: null, planHours: null, pieceRate: 0, planWorkload: 0, planWorkloadUnit: null, taskStatus: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | const defaultForm = { id: null, name: null, projectId: null, userIdList: [], parent: { id: null }, priority: null, tags: [], performanceType: null, description: null, planStartTime: null, planEndTime: null, planHours: null, pieceRate: 0, planWorkload: 0, planWorkloadUnit: null, taskStatus: null, remarks: null, version: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'Task', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | |
| | | projectId: [ |
| | | { required: true, message: '所属项目不能为空', trigger: 'change' } |
| | | ], |
| | | priority: [ |
| | | { required: true, message: '优先度不能为空', trigger: 'change' } |
| | | ], |
| | | taskClassification: [ |
| | | { required: true, message: '任务分类不能为空', trigger: 'change' } |
| | | ], |
| | | performanceType: [ |
| | | { required: true, message: '绩效类型不能为空', trigger: 'change' } |
| | | ], |
| | |
| | | { key: 'name', display_name: '名称' }, |
| | | { key: 'projectId', display_name: '所属项目' }, |
| | | { key: 'priority', display_name: '优先度' }, |
| | | { key: 'taskClassification', display_name: '任务分类' }, |
| | | { key: 'taskStatus', display_name: '任务状态' } |
| | | ], |
| | | // 计划开始时间选项 |
| | |
| | | projects: [], |
| | | // 父级任务列表 |
| | | pidTasks: [], |
| | | // 分配表单状态 |
| | | divideStatus: false, |
| | | // 分配表单加载 |
| | | divideLoading: false, |
| | | // 分配表单数据 |
| | | divideForm: { projectId: null, projectName: null, taskId: null, taskName: null, userIds: [], divideUserIds: [], taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskStatus: null }, |
| | | // 分配表单验证 |
| | | divideRules: { |
| | | userIds: [ |
| | | { required: true, message: '分配员工不能为空', trigger: 'change' } |
| | | ], |
| | | taskStartDate: [ |
| | | { required: true, message: '任务开始时间不能为空', trigger: 'change' } |
| | | ], |
| | | taskEndDate: [ |
| | | { required: true, message: '任务结束时间不能为空', trigger: 'change' } |
| | | ], |
| | | taskHours: [ |
| | | { required: true, message: '任务工时不能为空', trigger: 'blur' }, |
| | | { validator: durationValidate, trigger: 'blur' } |
| | | ], |
| | | taskWorkload: [ |
| | | { validator: durationValidate, trigger: 'blur' } |
| | | ] |
| | | }, |
| | | // 任务开始时间选项 |
| | | taskStartDatePickerOptions: { |
| | | // 禁用日期 |
| | | disabledDate(time) { |
| | | return _this.divideForm.taskEndDate != null && _this.divideForm.taskEndDate !== '' ? time.getTime() > new Date(_this.divideForm.taskEndDate).getTime() : false |
| | | } |
| | | }, |
| | | // 任务结束时间选项 |
| | | taskEndDatePickerOptions: { |
| | | // 禁用日期 |
| | | disabledDate(time) { |
| | | return _this.divideForm.taskStartDate != null && _this.divideForm.taskStartDate !== '' ? time.getTime() < new Date(_this.divideForm.taskStartDate).getTime() - (86400000 - 1) : false |
| | | } |
| | | }, |
| | | // 员工列表 |
| | | users: [], |
| | | // 用户列表 |
| | | users: [] |
| | | tags: [], |
| | | // tag标签 |
| | | inputVisible: false, |
| | | inputValue: '' |
| | | } |
| | | }, |
| | | created() { |
| | | this.crud.optShow.reset = false |
| | | }, |
| | | mounted() { |
| | | // 获取项目 |
| | | this.getProject() |
| | | // 获取员工 |
| | | this.getUser() |
| | | this.getTags() |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | if (!this.crud.query.projectId) { |
| | | return false |
| | | } |
| | | // 用户角色级别数组 |
| | | const userRolesLevel = this.$store.state.user.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | | this.userRolesLevelMin = Math.min(...userRolesLevel) |
| | | // 获取项目 |
| | | this.getProject() |
| | | // 获取用户 |
| | | this.getUser() |
| | | return true |
| | | }, |
| | | // 获取项目 |
| | | getProject() { |
| | | // 获取项目 |
| | | crudProject.getRelevant().then(res => { |
| | | [CRUD.HOOK.beforeSubmit]() { |
| | | if (this.form.parent.id === null || this.form.parent.id === '') { |
| | | this.form.parent = null |
| | | } |
| | | return true |
| | | }, |
| | | queryByProjectId(projectId) { |
| | | this.crud.resetQuery(false) |
| | | this.crud.query.projectId = projectId |
| | | this.crud.toQuery() |
| | | }, |
| | | getTags() { |
| | | crudTask.getTags().then(res => { |
| | | // 项目列表 |
| | | this.projects = res |
| | | this.tags = res |
| | | }) |
| | | }, |
| | | // 自动计算工时 |
| | | calcHour() { |
| | | if (this.divideForm.taskEndDate && this.divideForm.taskStartDate && this.divideForm.userIds && this.divideForm.userIds.length > 0 && !this.divideForm.taskHours) { |
| | | crudTaskUser.calcHours({ userId: this.divideForm.userIds[0], taskStartDate: this.divideForm.taskStartDate, taskEndDate: this.divideForm.taskEndDate }).then(res => { |
| | | this.divideForm.taskHours = res |
| | | }) |
| | | handleClose(id) { |
| | | this.form.tags.splice(id, 1) |
| | | }, |
| | | showInput() { |
| | | this.inputVisible = true |
| | | this.$nextTick(_ => { |
| | | this.$refs.saveTagInput.focus() // .$refs.input |
| | | }) |
| | | }, |
| | | handleInputConfirm() { |
| | | const inputValue = this.inputValue |
| | | if (inputValue) { |
| | | this.form.tags.push(inputValue) |
| | | } |
| | | this.inputVisible = false |
| | | this.inputValue = '' |
| | | }, |
| | | handleSelect(item) { |
| | | this.inputValue = item.value |
| | | this.$refs.saveTagInput.$refs.input.focus() |
| | | }, |
| | | querySearchAsync(queryString, cb) { |
| | | crudTask.getTags(queryString ? { tagName: queryString } : {}).then(res => { |
| | | const tagMap = [] |
| | | res.forEach(tag => { |
| | | tagMap.push({ value: tag }) |
| | | }) |
| | | cb(tagMap) |
| | | }) |
| | | }, |
| | | // 获取用户 |
| | | getUser() { |
| | |
| | | this.users = res |
| | | }) |
| | | }, |
| | | // 获取项目 |
| | | getProject() { |
| | | // 获取项目 |
| | | crudProject.getRelevant().then(res => { |
| | | // 项目列表 |
| | | this.projects = res |
| | | }) |
| | | }, |
| | | // 树形表数据加载 |
| | | load(tree, treeNode, resolve) { |
| | | // 获取子级任务 |
| | | crudTask.getChildren({ id: tree.id }).then(res => { |
| | | // 添加 |
| | | resolve(res) |
| | | }) |
| | | }, |
| | | // 表格统计 |
| | | getSummaries(param) { |
| | | const { columns, data } = param |
| | | const sums = [] |
| | | columns.forEach((column, index) => { |
| | | // 9号单元格 |
| | | if (index === 9) { |
| | | // 已完成工时 |
| | | let completedHours = 0 |
| | | const completedHoursValues = data.map(item => Number(item['completedHours'])) |
| | | if (!completedHoursValues.every(value => isNaN(value))) { |
| | | completedHours = completedHoursValues.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return prev + curr |
| | | } else { |
| | | return prev |
| | | } |
| | | }, 0) |
| | | } |
| | | // 已分配工时 |
| | | let divideHours = 0 |
| | | const divideHoursValues = data.map(item => Number(item['divideHours'])) |
| | | if (!divideHoursValues.every(value => isNaN(value))) { |
| | | divideHours = divideHoursValues.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return prev + curr |
| | | } else { |
| | | return prev |
| | | } |
| | | }, 0) |
| | | } |
| | | // 计划工时 |
| | | let planHours = 0 |
| | | const planHoursValues = data.map(item => Number(item['planHours'])) |
| | | if (!planHoursValues.every(value => isNaN(value))) { |
| | | planHours = planHoursValues.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return prev + curr |
| | | } else { |
| | | return prev |
| | | } |
| | | }, 0) |
| | | } |
| | | sums[index] = completedHours + ' / ' + divideHours + ' / ' + planHours |
| | | } |
| | | // 10号单元格 |
| | | if (index === 10) { |
| | | // 已完成工作量 |
| | | let completedWorkload = 0 |
| | | const completedWorkloadValues = data.map(item => Number(item['completedWorkload'])) |
| | | if (!completedWorkloadValues.every(value => isNaN(value))) { |
| | | completedWorkload = completedWorkloadValues.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return prev + curr |
| | | } else { |
| | | return prev |
| | | } |
| | | }, 0) |
| | | } |
| | | // 已分配工作量 |
| | | let divideWorkload = 0 |
| | | const divideWorkloadValues = data.map(item => Number(item['divideWorkload'])) |
| | | if (!divideWorkloadValues.every(value => isNaN(value))) { |
| | | divideWorkload = divideWorkloadValues.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return prev + curr |
| | | } else { |
| | | return prev |
| | | } |
| | | }, 0) |
| | | } |
| | | // 计划工作量 |
| | | let planWorkload = 0 |
| | | const planWorkloadValues = data.map(item => Number(item['planWorkload'])) |
| | | if (!planWorkloadValues.every(value => isNaN(value))) { |
| | | planWorkload = planWorkloadValues.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return prev + curr |
| | | } else { |
| | | return prev |
| | | } |
| | | }, 0) |
| | | } |
| | | sums[index] = completedWorkload + ' / ' + divideWorkload + ' / ' + planWorkload |
| | | } |
| | | }) |
| | | return sums |
| | | resolve(tree.children) |
| | | }, |
| | | // 钩子:新建 - 之前 |
| | | [CRUD.HOOK.beforeToAdd]() { |
| | | [CRUD.HOOK.beforeToCU]() { |
| | | this.form.projectId = this.crud.query.projectId |
| | | // 父级任务列表 |
| | | this.pidTasks = [] |
| | | }, |
| | | // 钩子:编辑 - 之前 |
| | | [CRUD.HOOK.beforeToEdit]() { |
| | | // 获取父级任务 |
| | | crudTask.getAll({ projectId: this.form.projectId }).then(res => { |
| | | // 父级任务列表 |
| | | this.pidTasks = res |
| | |
| | | // 项目变更 |
| | | projectChange() { |
| | | // 表单赋值 |
| | | this.form.pid = null |
| | | this.form.parent.id = null |
| | | // 判断表单项目是否为空 |
| | | if (this.form.projectId == null || this.form.projectId === '') { |
| | | // 父级任务列表 |
| | |
| | | }) |
| | | } |
| | | }, |
| | | // 任务分配 |
| | | toDivide(data) { |
| | | // 分配表单数据 |
| | | this.divideForm.projectId = data.projectId |
| | | this.divideForm.projectName = data.projectName |
| | | this.divideForm.taskId = data.id |
| | | this.divideForm.taskName = data.name |
| | | this.divideForm.divideUserIds = data.divideUserIds |
| | | this.divideForm.taskWorkloadUnit = data.planWorkloadUnit |
| | | this.divideForm.taskStatus = constant.TASK_STATUS_NOT_STARTED |
| | | // 获取任务的计划开始时间结束时间 |
| | | if (data.planStartTime) { |
| | | this.divideForm.taskStartDate = data.planStartTime |
| | | } |
| | | if (data.planEndTime) { |
| | | this.divideForm.taskEndDate = data.planEndTime |
| | | } |
| | | // 分配表单状态 |
| | | this.divideStatus = true |
| | | }, |
| | | // 查看任务分配 |
| | | toSeeDivide(data) { |
| | | // 跳转页面 |
| | | this.$router.push({ |
| | | name: 'TaskUser', |
| | | params: { |
| | | projectId: data.projectId, |
| | | taskId: data.id |
| | | } |
| | | }) |
| | | }, |
| | | // 查看任务日报 |
| | | toSeeDaliy(data) { |
| | | // 跳转页面 |
| | | this.$router.push({ |
| | | name: 'TaskDaliy', |
| | | params: { |
| | | projectId: data.projectId, |
| | | taskId: data.id |
| | | } |
| | | }) |
| | | }, |
| | | // 分配表单关闭 |
| | | divideClose() { |
| | | // 分配表单状态 |
| | | this.divideStatus = false |
| | | // 分配表单加载 |
| | | this.divideLoading = false |
| | | // 分配表单数据 |
| | | this.divideForm = { projectId: null, projectName: null, taskId: null, taskName: null, userIds: [], divideUserIds: [], taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskStatus: null } |
| | | // 清除表单验证 |
| | | this.$nextTick(() => { |
| | | this.$refs['divideForm'].clearValidate() |
| | | }) |
| | | }, |
| | | // 分配表单提交 |
| | | divideSubmit() { |
| | | // 分配表单加载 |
| | | this.divideLoading = true |
| | | // 表单验证 |
| | | this.$refs['divideForm'].validate((valid) => { |
| | | if (valid) { |
| | | // 判断用户角色 |
| | | if (this.userRolesLevelMin !== this.roleLevelSuper && this.userRolesLevelMin !== this.roleLevelGeneral) { |
| | | // 检索选中项目信息 |
| | | const chooseProject = this.projects.filter((item) => { |
| | | return item.id === this.divideForm.projectId |
| | | }) |
| | | // 判断是否是项目责任人 |
| | | if (chooseProject.length !== 1 || chooseProject[0].liableUserIdList.indexOf(this.$store.state.user.user.id) === -1) { |
| | | // 消息提示 |
| | | this.crud.notify('您不是当前项目责任人,无法进行任务分配操作', CRUD.NOTIFICATION_TYPE.WARNING) |
| | | // 分配表单加载 |
| | | this.divideLoading = false |
| | | return false |
| | | } |
| | | } |
| | | // 分配任务 |
| | | crudTask.divide(this.divideForm).then(res => { |
| | | // 分配表单关闭 |
| | | this.divideClose() |
| | | // 消息提示 |
| | | this.crud.notify('任务分配成功', CRUD.NOTIFICATION_TYPE.SUCCESS) |
| | | // 刷新页面 |
| | | this.crud.refresh() |
| | | }) |
| | | } else { |
| | | // 分配表单加载 |
| | | this.divideLoading = false |
| | | return false |
| | | } |
| | | }) |
| | | }, |
| | | // 钩子:提交 - 之前 |
| | | [CRUD.HOOK.beforeSubmit]() { |
| | | // 判断用户角色 |
| | | if (this.userRolesLevelMin === this.roleLevelSuper || this.userRolesLevelMin === this.roleLevelGeneral) { |
| | | return true |
| | | // 输入框获取焦点时调用的方法 |
| | | async querySearch(queryString, cb) { |
| | | let results = [] |
| | | if (queryString === null || queryString === '') { |
| | | cb(results) |
| | | } else { |
| | | // 检索选中项目信息 |
| | | const chooseProject = this.projects.filter((item) => { |
| | | return item.id === this.form.projectId |
| | | }) |
| | | // 判断是否是项目责任人 |
| | | if (chooseProject.length === 1 && chooseProject[0].liableUserIdList.indexOf(this.$store.state.user.user.id) !== -1) { |
| | | return true |
| | | } else { |
| | | // 消息提示 |
| | | this.crud.notify('您不是当前项目责任人,无法添加/修改任务详情', CRUD.NOTIFICATION_TYPE.WARNING) |
| | | return false |
| | | } |
| | | results = await crudTask.getNames({ projectId: this.crud.query.projectId, name: queryString }) |
| | | cb(results) |
| | | } |
| | | } |
| | | } |
| | |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | .el-tag + .el-tag { |
| | | margin-left: 10px; |
| | | } |
| | | .button-new-tag { |
| | | margin-left: 10px; |
| | | height: 32px; |
| | | line-height: 30px; |
| | | padding-top: 0; |
| | | padding-bottom: 0; |
| | | } |
| | | .input-new-tag { |
| | | width: 90px; |
| | | margin-left: 10px; |
| | | vertical-align: bottom; |
| | | } |
| | | </style> |