| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <el-select v-model="query.projectId" filterable clearable placeholder="所属项目" style="width: 185px;" class="filter-item" @change="queryProjectChange" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in projects" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.taskId" filterable clearable placeholder="所属任务" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in queryTasks" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </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> |
| | | <el-select v-model="query.taskStatus" filterable clearable placeholder="任务状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[taskStatus]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <date-range-picker v-model="query.createTime" class="date-item" /> |
| | | <rrOperation :crud="crud" /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <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="projectId"> |
| | | <el-select v-model="form.projectId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="crud.status.edit == crudStatusPrepared || userRolesLevelMin == roleLevelOrdinary" @change="formProjectChange"> |
| | | <el-row :gutter="20"> |
| | | <!--侧边部门数据--> |
| | | <el-col :span="6"> |
| | | <div class="head-container"> |
| | | <div class="tree-scroll"> |
| | | <el-select v-model="projectId" filterable clearable placeholder="请先选择所属项目" style="width:100%" class="filter-item" @change="getTaskDatas"> |
| | | <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="taskId"> |
| | | <el-select v-model="form.taskId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="crud.status.edit == crudStatusPrepared || userRolesLevelMin == roleLevelOrdinary" @change="formTaskChange"> |
| | | <el-option |
| | | v-for="item in formTasks" |
| | | v-for="item in projectDatas" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="所属员工" prop="userId"> |
| | | <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="crud.status.edit == crudStatusPrepared || userRolesLevelMin == roleLevelOrdinary" @change="calcHour"> |
| | | <el-input |
| | | v-model="taskName" |
| | | clearable |
| | | size="small" |
| | | placeholder="输入任务名称搜索" |
| | | prefix-icon="el-icon-search" |
| | | class="filter-item" |
| | | @change="getTaskDatas" |
| | | /> |
| | | </div> |
| | | </div> |
| | | <el-tree |
| | | v-loading="taskLoading" |
| | | :data="taskDatas" |
| | | :load="getTaskDatas" |
| | | :props="defaultProps" |
| | | class="flow-tree" |
| | | accordion |
| | | :expand-on-click-node="false" |
| | | lazy |
| | | @node-click="handleNodeClick" |
| | | > |
| | | <template slot-scope="{node}"> |
| | | <el-tooltip effect="dark" :content="node.label" placement="top-start" style="font-size:14px;"> |
| | | <div>{{ node.label }}</div> |
| | | </el-tooltip> |
| | | </template> |
| | | </el-tree> |
| | | </el-col> |
| | | <!--任务分配数据--> |
| | | <el-col :span="18"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div v-if="crud.props.searchToggle"> |
| | | <!-- 搜索 --> |
| | | <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" |
| | | :disabled="!item.enabled || form.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="form.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;" :disabled="userRolesLevelMin == roleLevelOrdinary" @change="calcHour" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务结束时间" prop="taskEndDate"> |
| | | <el-date-picker v-model="form.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;" :disabled="userRolesLevelMin == roleLevelOrdinary" @change="calcHour" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务工时" prop="taskHours"> |
| | | <el-input v-model="form.taskHours" style="width: 340px;" :disabled="userRolesLevelMin == roleLevelOrdinary"> |
| | | <template slot="append">小时</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="任务工作量" prop="taskWorkload"> |
| | | <el-input v-model="form.taskWorkload" style="width: 340px;" :disabled="userRolesLevelMin == roleLevelOrdinary" /> |
| | | </el-form-item> |
| | | <el-form-item label="任务工作量单位" prop="taskWorkloadUnit"> |
| | | {{ dict.label[standardWorkloadUnit][form.taskWorkloadUnit] }} |
| | | </el-form-item> |
| | | <el-form-item label="任务绩效类型" prop="taskPerformanceType"> |
| | | {{ dict.label[performanceType][form.taskPerformanceType] }} |
| | | </el-form-item> |
| | | <el-form-item label="强制更新" tool-tip prop="enable1"> |
| | | <el-tooltip content="不增减工作量的场合调整工时的话,需要选择此项。(有疑问请联系管理员,不要随便选。。。)" effect="dark" placement="bottom"> |
| | | <el-switch v-model="form.enable1" /> |
| | | </el-tooltip> |
| | | </el-form-item> |
| | | <el-form-item label="任务状态" prop="taskStatus"> |
| | | <el-select v-model="form.taskStatus" filterable placeholder="请选择" style="width: 340px;"> |
| | | <el-select v-model="query.taskStatus" filterable clearable multiple collapse-tags placeholder="任务状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[taskStatus]" |
| | | :key="item.id" |
| | |
| | | :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;" :disabled="userRolesLevelMin == roleLevelOrdinary" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="crud.cancelCU">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
| | | <rrOperation :crud="crud" /> |
| | | </div> |
| | | <crudOperation :permission="permission"> |
| | | <el-button |
| | | slot="right" |
| | | v-permission="permission.generate" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-plus" |
| | | style="margin-right: 6px;" |
| | | @click="openGenerate" |
| | | >导入</el-button> |
| | | </crudOperation> |
| | | <div> |
| | | <span style="magin: right 10px;"> 当前任务: {{ selectedTaskName }}</span> |
| | | <span v-for="item in taskTotal" :key="item._id"> |
| | | <template v-if="item._id === 'task_status_not_started'"> |
| | | <b>未开始:</b>{{ item.taskStatusCnt }}件(合计:{{ item.taskHours }}小时) |
| | | </template> |
| | | <template v-if="item._id === 'task_status_in_hand'"> |
| | | <b>进行中:</b>{{ item.taskStatusCnt }}件(合计:{{ item.taskHours }}小时) |
| | | </template> |
| | | <template v-if="item._id === 'task_status_test'"> |
| | | <b>待测试:</b>{{ item.taskStatusCnt }}件(合计:{{ item.taskHours }}小时) |
| | | </template> |
| | | <template v-if="item._id === 'task_status_stop'"> |
| | | <b>已暂停:</b>{{ item.taskStatusCnt }}件(合计:{{ item.taskHours }}小时) |
| | | </template> |
| | | <template v-if="item._id === 'task_status_completed'"> |
| | | <b>已完成:</b>{{ item.taskStatusCnt }}件(合计:{{ item.taskHours }}小时) |
| | | </template> |
| | | </span> |
| | | </div> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table |
| | | ref="table" |
| | | v-loading="crud.loading" |
| | | :data="crud.data" |
| | | size="small" |
| | | style="width: 100%;" |
| | | :summary-method="getSummaries" |
| | | show-summary |
| | | @selection-change="crud.selectionChangeHandler" |
| | | > |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="projectName" label="所属项目" fixed="left" width="140"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.projectName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskName" label="所属任务" fixed="left" width="180"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.taskName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属员工" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.userNickName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskStartDate" label="任务开始时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskEndDate" label="任务结束时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" label="消耗 / 任务工时" width="110"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.consumedHours }} / {{ scope.row.taskHours }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" label="消耗 / 任务工作量" width="120"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.consumedWorkload }} / {{ scope.row.taskWorkload == null || scope.row.taskWorkload == '' ? 0 : scope.row.taskWorkload }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskWorkloadUnit" label="任务工作量单位" width="110"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.taskWorkloadUnit != null && scope.row.taskWorkloadUnit != ''">{{ dict.label[standardWorkloadUnit][scope.row.taskWorkloadUnit] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskPerformanceType" label="任务绩效类型" width="110"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.taskPerformanceType != null && scope.row.taskPerformanceType != ''">{{ dict.label[performanceType][scope.row.taskPerformanceType] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskProgress" label="任务进度" width="80"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.taskProgress }}% |
| | | </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 v-if="checkPer(['admin','taskUser:edit','taskUser:del'])" label="操作" width="150px" 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 || scope.row.userId == $store.state.user.user.id" |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | <!--表单渲染--> |
| | | <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="taskId"> |
| | | <el-select v-model="form.taskId" filterable clearable placeholder="请选择" style="width: 340px;" :disabled="true" @change="formTaskChange"> |
| | | <el-option |
| | | v-for="item in formTasks" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="任务分类" prop="taskClassification"> |
| | | <el-select v-model="form.taskClassification" filterable clearable placeholder="请选择" style="width: 340px;"> |
| | | <el-option |
| | | v-for="item in dict[taskClassification]" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="所属员工" prop="userId"> |
| | | <el-select v-model="form.userId" filterable clearable 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 || form.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="form.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="form.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="form.taskHours" style="width: 340px;"> |
| | | <template slot="append">小时</template> |
| | | </el-input> |
| | | </el-form-item> |
| | | <el-form-item label="任务绩效类型" prop="taskPerformanceType"> |
| | | {{ dict.label[performanceType][form.taskPerformanceType] }} |
| | | </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-button type="text" @click="crud.cancelCU">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table |
| | | ref="table" |
| | | v-loading="crud.loading" |
| | | :data="crud.data" |
| | | size="small" |
| | | style="width: 100%;" |
| | | @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"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.name }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="userNickName" label="所属员工" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.userNickName }}</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> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskStartDate" label="任务开始时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskEndDate" label="任务结束时间" width="140" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskHours" label="任务工时" width="110" /> |
| | | <el-table-column :show-overflow-tooltip="true" prop="performanceType" label="任务绩效类型" width="110"> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.performanceType != null && scope.row.performanceType != ''">{{ dict.label[performanceType][scope.row.performanceType] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column :show-overflow-tooltip="true" prop="taskProgress" label="任务进度" width="80"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.row.taskDaliyList.length === 0 ? 0 : scope.row.taskDaliyList[0].taskProgress }}% |
| | | </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 v-if="checkPer(['admin','taskUser:edit','taskUser:del'])" label="操作" width="150px" align="center" fixed="right"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="closeGenerate" :visible.sync="generateStatus" title="导入任务分配信息" width="720px"> |
| | | <el-form ref="generateForm" size="small" label-width="80px"> |
| | | <upload-excel-component :on-success="handleSuccess" :before-upload="beforeUpload" /> |
| | | <el-table :data="generateForm" border highlight-current-row style="width: 100%;margin-top:20px;"> |
| | | <el-table-column v-for="item of tableHeader" :key="item.id" :prop="item.id" :label="item.name" /> |
| | | </el-table> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="closeGenerate">取消</el-button> |
| | | <el-button :loading="generateLoading" type="primary" :disabled="uploading" @click="submitGenerate">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudTaskUser from '@/api/task/taskUser' |
| | | import crudProject from '@/api/project/project' |
| | | import crudTask from '@/api/task/task' |
| | | import crudUser from '@/api/system/user' |
| | | 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 { mapGetters } from 'vuex' |
| | | import constant from '../../../utils/constant' |
| | | import crudProject from '@/api/project/project' |
| | | import crudTask from '@/api/task/task' |
| | | import crudUser from '@/api/system/user' |
| | | import DateRangePicker from '@/components/DateRangePicker' |
| | | |
| | | const defaultForm = { id: null, userId: null, projectId: null, taskId: null, taskStartDate: null, taskEndDate: null, taskHours: null, taskWorkload: null, taskStatus: null, enable1: false, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, divideUserIds: [] } |
| | | import Treeselect from '@riophae/vue-treeselect' |
| | | import { mapGetters } from 'vuex' |
| | | import constant from '@/utils/constant' |
| | | import UploadExcelComponent from '@/components/UploadExcel/index.vue' |
| | | const defaultForm = { id: null, userId: null, projectId: null, taskId: null, taskStartDate: null, taskEndDate: null, taskHours: null, taskStatus: null, enable1: false, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, divideUserIds: [] } |
| | | export default { |
| | | name: 'TaskUser', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, DateRangePicker }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | dicts: [constant.TASK_STATUS, constant.STANDARD_WORKLOAD_UNIT, constant.PERFORMANCE_TYPE], |
| | | components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker, UploadExcelComponent }, |
| | | cruds() { |
| | | return CRUD({ title: '任务分配', url: 'api/taskUser', idField: 'id', sort: 'taskStartDate,desc', crudMethod: { ...crudTaskUser }}) |
| | | return CRUD({ title: '任务分配', url: 'api/taskUser', crudMethod: { ...crudTaskUser }}) |
| | | }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | // 数据字典 |
| | | dicts: [constant.TASK_STATUS, constant.TAST_CLASSIFICATION, constant.STANDARD_WORKLOAD_UNIT, constant.PERFORMANCE_TYPE], |
| | | data() { |
| | | // 指针重指向 |
| | | const _this = this |
| | | // 时长(万内)验证 |
| | | var durationValidate = (rule, value, callback) => { |
| | | const reg = /^([0-9]|[1-9]\d{1,3})(\.\d{1,2})?$/ |
| | |
| | | } |
| | | } |
| | | return { |
| | | projectId: null, |
| | | projectDatas: [], |
| | | taskName: '', |
| | | selectedTaskName: '', |
| | | taskTotal: [], |
| | | taskDatas: [], |
| | | taskLoading: false, |
| | | defaultProps: { children: 'nodes', label: 'name', isLeaf: 'leaf' }, |
| | | permission: { |
| | | add: ['admin', 'taskUser:add'], |
| | | edit: ['admin', 'taskUser:edit'], |
| | | del: ['admin', 'taskUser:del'], |
| | | download: ['admin', 'taskUser:download'] |
| | | download: ['admin', 'taskUser:download'], |
| | | generate: ['admin', 'taskUser:add'] |
| | | }, |
| | | rules: { |
| | | projectId: [ |
| | |
| | | { required: true, message: '任务工时不能为空', trigger: 'blur' }, |
| | | { validator: durationValidate, trigger: 'blur' } |
| | | ], |
| | | taskWorkload: [ |
| | | { validator: durationValidate, trigger: 'blur' } |
| | | ], |
| | | taskStatus: [ |
| | | { required: true, message: '任务状态不能为空', trigger: 'change' } |
| | | ] |
| | | }, |
| | | queryTypeOptions: [ |
| | | { key: 'projectId', display_name: '所属项目' }, |
| | | { key: 'taskId', display_name: '所属任务' }, |
| | | { key: 'userId', display_name: '所属员工' }, |
| | | { key: 'taskStatus', display_name: '任务状态' }, |
| | | { key: 'createTime', display_name: '创建时间' } |
| | | ], |
| | | // 字典:任务状态 |
| | | taskStatus: constant.TASK_STATUS, |
| | | // 字典:任务分类 |
| | | taskClassification: constant.TAST_CLASSIFICATION, |
| | | // 字典:标准工作量单位 |
| | | standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT, |
| | | // 字典:绩效对象 |
| | | performanceType: constant.PERFORMANCE_TYPE, |
| | | // 字典:批准状态-未承认 |
| | | approveStatusUnrecognized: constant.APPROVE_STATUS_UNRECOGNIZED, |
| | | // CRUD状态 |
| | | crudStatusPrepared: CRUD.STATUS.PREPARED, |
| | | generateForm: [], |
| | | tableHeader: [], |
| | | users: [], |
| | | // 项目列表 |
| | | projects: [], |
| | | // 检索任务列表 |
| | | queryTasks: [], |
| | | // 表单任务列表 |
| | | formTasks: [], |
| | | // 生成表单状态 |
| | | generateStatus: false, |
| | | // 生成表单加载 |
| | | generateLoading: false, |
| | | uploading: true, |
| | | // 任务开始时间选项 |
| | | taskStartDatePickerOptions: { |
| | | // 禁用日期 |
| | |
| | | disabledDate(time) { |
| | | return _this.form.taskStartDate != null && _this.form.taskStartDate !== '' ? time.getTime() < new Date(_this.form.taskStartDate).getTime() - (86400000 - 1) : false |
| | | } |
| | | }, |
| | | // 字典:任务状态 |
| | | taskStatus: constant.TASK_STATUS, |
| | | // 字典:标准工作量单位 |
| | | standardWorkloadUnit: constant.STANDARD_WORKLOAD_UNIT, |
| | | // 字典:绩效对象 |
| | | performanceType: constant.PERFORMANCE_TYPE, |
| | | // 字典:批准状态-未承认 |
| | | approveStatusUnrecognized: constant.APPROVE_STATUS_UNRECOGNIZED, |
| | | // 角色级别:超级管理员 |
| | | roleLevelSuper: constant.ROLE_LEVEL_SUPER, |
| | | // 角色级别:总经理 |
| | | roleLevelGeneral: constant.ROLE_LEVEL_GENERAL, |
| | | // 角色级别:普通用户 |
| | | roleLevelOrdinary: constant.ROLE_LEVEL_ORDINARY, |
| | | // CRUD状态 |
| | | crudStatusPrepared: CRUD.STATUS.PREPARED, |
| | | // 用户最大角色级别 |
| | | userRolesLevelMin: null, |
| | | // 项目列表 |
| | | projects: [], |
| | | // 检索任务列表 |
| | | queryTasks: [], |
| | | // 表单任务列表 |
| | | formTasks: [], |
| | | // 用户列表 |
| | | users: [] |
| | | } |
| | | } |
| | | }, |
| | | computed: { |
| | |
| | | 'user' |
| | | ]) |
| | | }, |
| | | mounted() { |
| | | // const that = this |
| | | // window.onresize = function temp() { |
| | | // that.height = document.documentElement.clientHeight - 180 + 'px;' |
| | | // } |
| | | this.getAllProjectDatas() |
| | | this.getUser() |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 判断传参是否为空 |
| | | if (this.$route.params.projectId != null && this.$route.params.projectId !== '' && this.crud.query.projectId === undefined) { |
| | | // 检索条件赋值 |
| | | this.$set(this.crud.query, 'projectId', Number(this.$route.params.projectId)) |
| | | // 获取任务列表 |
| | | crudTask.getAll({ projectId: this.query.projectId }).then(res => { |
| | | // 检索任务列表 |
| | | this.queryTasks = res |
| | | }) |
| | | if (!this.query.taskId) { |
| | | return false |
| | | } |
| | | // 判断传参是否为空 |
| | | if (this.$route.params.taskId != null && this.$route.params.taskId !== '' && this.crud.query.taskId === undefined) { |
| | | // 检索条件赋值 |
| | | this.$set(this.crud.query, 'taskId', Number(this.$route.params.taskId)) |
| | | } |
| | | // 用户角色级别数组 |
| | | const userRolesLevel = this.user.roles.map(({ level }) => level) |
| | | // 用户最大角色级别 |
| | | this.userRolesLevelMin = Math.min(...userRolesLevel) |
| | | // 获取项目 |
| | | this.getProject() |
| | | // 获取用户 |
| | | this.getUser() |
| | | return true |
| | | }, |
| | | // 获取项目 |
| | | getProject() { |
| | | // 获取项目 |
| | | crudProject.getRelevant().then(res => { |
| | | // 项目列表 |
| | | this.projects = res |
| | | }) |
| | | }, |
| | | // 获取用户 |
| | | getUser() { |
| | |
| | | this.users = res |
| | | }) |
| | | }, |
| | | getAllProjectDatas() { |
| | | crudProject.getAll().then(res => { |
| | | this.projectDatas = res |
| | | }) |
| | | }, |
| | | // 获取左侧部门数据 |
| | | getTaskDatas(node, resolve) { |
| | | const sort = 'id,desc' |
| | | const params = { sort: sort } |
| | | if (!this.projectId) { |
| | | return |
| | | } else { |
| | | params['projectId'] = this.projectId |
| | | } |
| | | if (typeof node === 'object' && node.level !== 0) { |
| | | params['pid'] = node.data.id |
| | | } else { |
| | | params['isTop'] = true |
| | | } |
| | | if (this.taskName) { |
| | | params['name'] = this.taskName |
| | | } |
| | | this.taskLoading = true |
| | | setTimeout(() => { |
| | | crudTask.getChildren(params).then(res => { |
| | | if (resolve) { |
| | | resolve(res) |
| | | } else { |
| | | this.taskDatas = res |
| | | } |
| | | this.taskLoading = false |
| | | }).catch(() => { |
| | | this.taskLoading = false |
| | | }) |
| | | }, 100) |
| | | }, |
| | | // 切换任务 |
| | | handleNodeClick(data) { |
| | | if (data.pid === 0) { |
| | | this.query.taskId = null |
| | | this.query.taskStatus = [] |
| | | this.selectedTaskName = null |
| | | this.taskTotal = [] |
| | | } else { |
| | | this.query.taskId = data.id |
| | | this.query.taskStatus = ['task_status_not_started', 'task_status_in_hand', 'task_status_test', 'task_status_stop'] |
| | | this.selectedTaskName = data.name |
| | | crudTaskUser.getSum({ 'taskId': this.query.taskId }).then(res => { |
| | | this.taskTotal = res |
| | | }) |
| | | } |
| | | this.crud.toQuery() |
| | | }, |
| | | beforeUpload(file) { |
| | | const isLt1M = file.size / 1024 / 1024 < 1 |
| | | if (isLt1M) { |
| | | return true |
| | | } |
| | | this.$message({ |
| | | message: '请不要上传大于1m的文件.', |
| | | type: 'warning' |
| | | }) |
| | | return false |
| | | }, |
| | | handleSuccess({ results, header }) { |
| | | this.uploading = false |
| | | this.generateForm = results |
| | | console.log('this.generateForm : ', results) |
| | | this.tableHeader = header |
| | | }, |
| | | // 生成表单打开 |
| | | openGenerate() { |
| | | // 生成表单数据 |
| | | this.generateForm = [] |
| | | // 生成表单状态 |
| | | this.generateStatus = true |
| | | }, |
| | | // 生成表单关闭 |
| | | closeGenerate() { |
| | | // 生成表单状态 |
| | | this.generateStatus = false |
| | | }, |
| | | // 生成表单提交 |
| | | submitGenerate() { |
| | | if (!this.generateForm.file.size) { |
| | | this.$message.warning('请选择上传的文件') |
| | | return |
| | | } |
| | | // 生成表单加载 |
| | | this.generateLoading = true |
| | | this.uploading = true |
| | | console.log('3333333333333333333 : ', this.generateForm) |
| | | // crudUserInsurance.generate(this.generateForm).then(res => { |
| | | // // 生成表单关闭 |
| | | // this.closeGenerate() |
| | | // // 生成表单加载 |
| | | // this.generateLoading = true |
| | | // // 搜索:刷新表格 |
| | | // this.crud.toQuery() |
| | | // this.crud.notify('生成成功', CRUD.NOTIFICATION_TYPE.SUCCESS) |
| | | // }).catch(err=>{ |
| | | // this.uploading = false |
| | | // // 生成表单加载 |
| | | // this.generateLoading = false |
| | | // }) |
| | | }, |
| | | // 自动计算工时 |
| | | calcHour() { |
| | | if (this.form.taskEndDate && this.form.taskStartDate && this.form.userId && !this.form.taskHours) { |
| | | crudTaskUser.calcHours({ userId: this.form.userId, taskStartDate: this.form.taskStartDate, taskEndDate: this.form.taskEndDate }).then(res => { |
| | | this.form.taskHours = res |
| | | }) |
| | | } |
| | | }, |
| | | // 检索项目变更 |
| | | queryProjectChange() { |
| | | // 检索赋值 |
| | | this.$set(this.query, 'taskId', null) |
| | | // 判断检索项目是否为空 |
| | | if (this.query.projectId == null || this.query.projectId === '') { |
| | | // 检索任务列表 |
| | | this.queryTasks = [] |
| | | } else { |
| | | // 获取任务列表 |
| | | crudTask.getAll({ projectId: this.query.projectId }).then(res => { |
| | | // 检索任务列表 |
| | | this.queryTasks = res |
| | | }) |
| | | } |
| | | }, |
| | | // 表格统计 |
| | | getSummaries(param) { |
| | | const { columns, data } = param |
| | | const sums = [] |
| | | columns.forEach((column, index) => { |
| | | // 6号单元格 |
| | | if (index === 6) { |
| | | // 消耗工时 |
| | | let consumedHours = 0 |
| | | const consumedHoursValues = data.map(item => Number(item['consumedHours'])) |
| | | if (!consumedHoursValues.every(value => isNaN(value))) { |
| | | consumedHours = consumedHoursValues.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return prev + curr |
| | | } else { |
| | | return prev |
| | | } |
| | | }, 0) |
| | | } |
| | | // 任务工时 |
| | | let taskHours = 0 |
| | | const taskHoursValues = data.map(item => Number(item['taskHours'])) |
| | | if (!taskHoursValues.every(value => isNaN(value))) { |
| | | taskHours = taskHoursValues.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return prev + curr |
| | | } else { |
| | | return prev |
| | | } |
| | | }, 0) |
| | | } |
| | | sums[index] = consumedHours + ' / ' + taskHours |
| | | } |
| | | // 7号单元格 |
| | | if (index === 7) { |
| | | // 消耗工作量 |
| | | let consumedWorkload = 0 |
| | | const consumedWorkloadValues = data.map(item => Number(item['consumedWorkload'])) |
| | | if (!consumedWorkloadValues.every(value => isNaN(value))) { |
| | | consumedWorkload = consumedWorkloadValues.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return prev + curr |
| | | } else { |
| | | return prev |
| | | } |
| | | }, 0) |
| | | } |
| | | // 任务工作量 |
| | | let taskWorkload = 0 |
| | | const taskWorkloadValues = data.map(item => Number(item['taskWorkload'])) |
| | | if (!taskWorkloadValues.every(value => isNaN(value))) { |
| | | taskWorkload = taskWorkloadValues.reduce((prev, curr) => { |
| | | const value = Number(curr) |
| | | if (!isNaN(value)) { |
| | | return prev + curr |
| | | } else { |
| | | return prev |
| | | } |
| | | }, 0) |
| | | } |
| | | sums[index] = consumedWorkload + ' / ' + taskWorkload |
| | | } |
| | | }) |
| | | return sums |
| | | }, |
| | | // 钩子:新建 - 之前 |
| | | [CRUD.HOOK.beforeToAdd]() { |
| | | // 表单赋值 |
| | | this.form.taskWorkloadUnit = null |
| | | this.form.taskPerformanceType = null |
| | | // 表单任务列表 |
| | | this.formTasks = [] |
| | | }, |
| | | // 钩子:编辑 - 之前 |
| | | [CRUD.HOOK.beforeToEdit]() { |
| | | // 获取父级任务 |
| | | crudTask.getAll({ projectId: this.form.projectId }).then(res => { |
| | | // 表单任务列表 |
| | | this.formTasks = res |
| | | // // 表单任务变更 |
| | | // this.formTaskChange() |
| | | }) |
| | | }, |
| | | // 表单项目变更 |
| | | formProjectChange() { |
| | | // 表单赋值 |
| | | this.form.taskId = null |
| | | // 判断表单项目是否为空 |
| | | if (this.form.projectId == null || this.form.projectId === '') { |
| | | // 表单任务列表 |
| | | this.formTasks = [] |
| | | } else { |
| | | // 获取父级任务 |
| | | crudTask.getAll({ projectId: this.form.projectId }).then(res => { |
| | | // 表单任务列表 |
| | | this.formTasks = res |
| | | }) |
| | | } |
| | | }, |
| | |
| | | this.form.taskPerformanceType = null |
| | | } |
| | | } |
| | | // 判断是否是否是新增 |
| | | if (this.crud.status.add === CRUD.STATUS.PREPARED) { |
| | | // 表单赋值 |
| | | this.form.userId = null |
| | | } |
| | | // 查询任务分配用户 |
| | | crudTaskUser.getTaskUserIds({ taskId: this.form.taskId }).then(res => { |
| | | // 表单赋值 |
| | | this.form.divideUserIds = res |
| | | }) |
| | | }, |
| | | // 钩子:提交 - 之前 |
| | | [CRUD.HOOK.beforeSubmit]() { |
| | | this.form.enable = this.form.enable1 |
| | | // 判断用户角色 |
| | | if (this.userRolesLevelMin === this.roleLevelSuper || this.userRolesLevelMin === this.roleLevelGeneral) { |
| | | return true |
| | | } 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) || this.form.userId === this.$store.state.user.user.id) { |
| | | return true |
| | | } else { |
| | | // 消息提示 |
| | | this.crud.notify('您不是当前项目责任人,无法添加/修改任务分配', CRUD.NOTIFICATION_TYPE.WARNING) |
| | | return false |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | <style rel="stylesheet/scss" lang="scss" scoped> |
| | | .tree-scroll { |
| | | height: 100%; |
| | | width: 100%; |
| | | } |
| | | |
| | | .flow-tree { |
| | | overflow-x: hidden; |
| | | overflow-y: auto; |
| | | max-height: 600px; |
| | | width: 100%; |
| | | |
| | | >>>.el-tree-node { |
| | | // height:40px; |
| | | > .el-tree-node__children { |
| | | overflow-y: visible !important; |
| | | } |
| | | > .el-tree-node__content { |
| | | height: 100%; |
| | | } |
| | | } |
| | | } |
| | | ::v-deep .vue-treeselect__control,::v-deep .vue-treeselect__placeholder,::v-deep .vue-treeselect__single-value { |
| | | height: 40px; |
| | | line-height: 40px; |
| | | } |
| | | </style> |