| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- <template>
- <el-drawer
- v-model="showDrawer"
- :size="650"
- :before-close="(done) => {
- isEditing = false;
- done();
- }">
- <template #title>
- <el-row class="entry-row">
- <el-col :span="3">
- <div class="node-type">{{type}}</div>
- </el-col>
- <el-col :span="4">
- <template class="entry-row">
- <span>#{{id}}</span>
- </template>
- </el-col>
- <el-col :span="8">
- <template class="entry-row" v-if="isEditing">
- <el-input placeholder="请输入标题" size="mini" style="width: 200px;display: inline;" v-model="editedRequirement.title"/>
- </template>
- <template v-else><h3>{{title}}</h3></template>
- </el-col>
- <el-col :span="6" :offset="2">
- <el-switch
- v-if="activeTab ==='basic_info'"
- style="float: right;"
- v-model="isEditing"
- active-text="编辑"
- @change="(isEditing) => {
- isEditing && fillDefaultValue();
- }">
- </el-switch>
- </el-col>
- </el-row>
- </template>
- <template #default>
- <el-row type="flex" justify="center">
- <el-col :span="20">
- <el-tabs
- class="tabs"
- v-model="activeTab"
- @tab-click="(tab) => {
- if(tab.panename !== 'basic_info')
- isEditing = false;
- }"
- >
- <el-tab-pane label="基本信息" name="basic_info">
- <el-row class="entry-row" style="margin-top: 15px">
- <h4 v-if="type == '需求'">需求描述</h4>
- <h4 v-else-if="type == '特性'">特性描述</h4>
- <h4 v-else-if="type == '用户故事'">用户故事描述</h4>
- <h4 v-else>任务描述</h4>
- </el-row>
- <el-row class="entry-row">
- <div v-if="isEditing">
- <el-input placeholder="请输入描述"
- type="textarea"
- maxlength="120"
- show-word-limit
- :rows="3" style="width: 300px;" v-model="editedRequirement.description" />
- <br/>
- </div>
- <p v-else>{{description}}</p>
- </el-row>
- <!-- 状态、优先级等 -->
- <el-row class="entry-row" style="margin-top: 15px">
- <h4>详情</h4>
- </el-row>
- <el-row style="margin: 3px 20px;width: 100%">
- <el-col :span="12">
- <RowItem :label="'状态:'">
- <div v-if="!isEditing" class="detail-value">
- <StateTag :state="state"></StateTag>
- </div>
- <div v-else>
- <el-select style="width: 160px" size="mini" v-model="editedRequirement.state">
- <el-option
- v-for="item in stateOptions"
- :key="item.value"
- :value="item.value"
- :label="item.value" />
- </el-select>
- </div>
- </RowItem>
- <RowItem :label="'优先级:'">
- <div class="detail-value" v-if="!isEditing">
- <PriorityTag :priority="priority"></PriorityTag>
- </div>
- <div v-else>
- <el-select style="width: 160px" size="mini" v-model="editedRequirement.priority">
- <el-option
- v-for="item in priorityOptions"
- :key="item.value"
- :value="item.value"
- :label="item.label" />
- </el-select>
- </div>
- </RowItem>
- <RowItem :label="'经办人:'">
- <div class="detail-value" v-if="!isEditing">
- <el-tag>{{processorName}}</el-tag>
- </div>
- <div v-else>
- <el-select style="width: 160px" size="mini" v-model="editedRequirement.processorId" >
- <el-option
- v-for="item in userOptions"
- :key="item.value"
- :value="item.value"
- :label="item.label" />
- </el-select>
- </div>
- </RowItem>
- </el-col>
- <el-col :span="12">
- <RowItem :label="'工作量:'">
- <div class="detail-value" v-if="!isEditing">
- <span>{{timeToTake}}人日</span>
- </div>
- <div v-else>
- <el-input-number size="mini" v-model="editedRequirement.timeToTake" :min="1" :max="200">
- </el-input-number>
- </div>
- </RowItem>
- <RowItem :label="'开始时间:'"><span>{{formatter(startTime)}}</span></RowItem>
- <RowItem :label="'完成时间:'"><span>{{formatter(endTime)}}</span></RowItem>
- </el-col>
- </el-row>
- <!-- 相关需求 -->
- <template v-if="showSons">
- <el-row class="entry-row" style="margin-top: 15px">
- <h4>子节点</h4>
- </el-row>
- <template v-if="(childs && childs.length) || false">
- <el-row style="margin: 10px 25px;" v-for="item in childs" :key="item.id">
- <el-link @click.prevent="changeContent(item.id)" type="primary">{{item.title}}</el-link>
- </el-row>
- </template>
- <template v-else>
- <el-row style="margin: 0px 25px;">
- 没有子节点
- </el-row>
- </template>
- </template>
- <el-row v-if="isEditing" class="entry-row" style="margin-top: 15px">
- <el-button @click="submitEdit" v-loading="confirmLoading" size="mini" type="primary">提交</el-button>
- <el-button @click="cancelEdit" size="mini">取消</el-button>
- </el-row>
- </el-tab-pane>
- <template v-if="type==='任务'">
- <el-tab-pane label="历史提交" name="commit_history">
- <!-- 相关提交 -->
- <el-row class="entry-row" style="margin-top: 15px">
- <el-table :data="commits">
- <el-table-column type="expand">
- <template #default="scope">
- <RowItem :label="'ID:'" :label-span="5" :value-span="19">{{scope.row.id}}</RowItem>
- <RowItem :label="'信息:'" :label-span="5" :value-span="19">{{scope.row.message}}</RowItem>
- <RowItem :label="'时间:'" :label-span="5" :value-span="19">{{formatter(scope.row.timestamp)}}</RowItem>
- </template>
- </el-table-column>
- <el-table-column
- label="ID"
- align="center"
- :formatter="(row)=>row.id.substr(0,7)"
- >
- </el-table-column>
- <el-table-column
- prop="gitlabUsername"
- label="用户"
- align="center"
- >
- </el-table-column>
- </el-table>
- </el-row>
- </el-tab-pane>
- </template>
- </el-tabs>
- </el-col>
- </el-row>
- </template>
- </el-drawer>
- </template>
- <script>
- import { RequirementAPI } from '@/api';
- import PriorityTag from '@/components/PriorityTag.vue';
- import StateTag from '@/components/StateTag.vue';
- import { priorityOptions, stateOptions } from '@/utils/constants';
- import { formatter } from '@/utils/time';
- import RowItem from './RowItem.vue';
- export default {
- name: 'RequirementDrawers',
- components: { RowItem, PriorityTag, StateTag },
- emits: ['change', 'requirement-update'],
- props: {
- id: Number,
- type: String,
- title: String,
- description: String,
- state: String,
- priority: String,
- processorId: Number,
- processorName: String,
- timeToTake: Number,
- startTime: String,
- endTime: String,
- childs: Array,
- parentId: Number,
- commits: Array,
- showSons: {
- type: Boolean,
- default: true,
- },
- },
- data() {
- return {
- activeTab: 'basic_info',
- showDrawer: false,
- isEditing: false,
- editedRequirement: {
- title: null,
- description: null,
- state: null,
- timeToTake: null,
- priority: null,
- processorId: null,
- processorName: null,
- },
- confirmLoading: false,
- stateOptions,
- priorityOptions,
- };
- },
- computed: {
- userOptions() {
- return this.$store.getters.userOptions;
- },
- },
- methods: {
- formatter,
- show() {
- this.showDrawer = true;
- },
- fillDefaultValue() {
- this.editedRequirement.title = this.title;
- this.editedRequirement.description = this.description;
- this.editedRequirement.state = this.state;
- this.editedRequirement.timeToTake = this.timeToTake;
- this.editedRequirement.priority = this.priority;
- this.editedRequirement.processorId = this.processorId;
- this.editedRequirement.processorName = this.processorName;
- },
- submitEdit() {
- this.confirmLoading = true;
- const param = {
- id: this.id,
- title: this.editedRequirement.title,
- description: this.editedRequirement.description,
- state: this.editedRequirement.state,
- timeToTake: this.editedRequirement.timeToTake,
- priority: this.editedRequirement.priority,
- processorId: this.editedRequirement.processorId,
- };
- RequirementAPI.updateTreeNode(param).then((res) => {
- this.isEditing = false;
- this.$emit('requirement-update');
- this.showDrawer = false;
- });
- this.confirmLoading = false;
- },
- cancelEdit() {
- this.isEditing = false;
- this.fillDefaultValue();
- },
- changeContent(id) {
- this.$emit('change', id);
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .entry-row{
- width: 100%;
- margin: 3px 20px;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: flex-start;
- h3, h4{
- color: #172b4d
- }
- }
- .detail-row{
- display: flex;
- flex-direction: row;
- align-items: center;
- line-height: 24px;
- margin: 3px 0;
- }
- .detail-value{
- display: flex;
- flex-direction: row;
- align-items: center;
- }
- .node-type{
- color: #FFFFFF;
- border-radius: 3px;
- font-size: 14px;
- background-color: #42b983;
- text-align: center;
- }
- .state-entry{
- border-radius: 5px;
- background-color: cornflowerblue;
- font-size: 12px;
- color: #FFFFFF;
- padding: 0px 4px;
- cursor: pointer
- }
- </style>
|