RequirementDrawer.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <el-drawer
  3. v-model="showDrawer"
  4. :size="650"
  5. :before-close="(done) => {
  6. isEditing = false;
  7. done();
  8. }">
  9. <template #title>
  10. <el-row class="entry-row">
  11. <el-col :span="3">
  12. <div class="node-type">{{type}}</div>
  13. </el-col>
  14. <el-col :span="4">
  15. <template class="entry-row">
  16. <span>#{{id}}</span>
  17. </template>
  18. </el-col>
  19. <el-col :span="8">
  20. <template class="entry-row" v-if="isEditing">
  21. <el-input placeholder="请输入标题" size="mini" style="width: 200px;display: inline;" v-model="editedRequirement.title"/>
  22. </template>
  23. <template v-else><h3>{{title}}</h3></template>
  24. </el-col>
  25. <el-col :span="6" :offset="2">
  26. <el-switch
  27. v-if="activeTab ==='basic_info'"
  28. style="float: right;"
  29. v-model="isEditing"
  30. active-text="编辑"
  31. @change="(isEditing) => {
  32. isEditing && fillDefaultValue();
  33. }">
  34. </el-switch>
  35. </el-col>
  36. </el-row>
  37. </template>
  38. <template #default>
  39. <el-row type="flex" justify="center">
  40. <el-col :span="20">
  41. <el-tabs
  42. class="tabs"
  43. v-model="activeTab"
  44. @tab-click="(tab) => {
  45. if(tab.panename !== 'basic_info')
  46. isEditing = false;
  47. }"
  48. >
  49. <el-tab-pane label="基本信息" name="basic_info">
  50. <el-row class="entry-row" style="margin-top: 15px">
  51. <h4 v-if="type == '需求'">需求描述</h4>
  52. <h4 v-else-if="type == '特性'">特性描述</h4>
  53. <h4 v-else-if="type == '用户故事'">用户故事描述</h4>
  54. <h4 v-else>任务描述</h4>
  55. </el-row>
  56. <el-row class="entry-row">
  57. <div v-if="isEditing">
  58. <el-input placeholder="请输入描述"
  59. type="textarea"
  60. maxlength="120"
  61. show-word-limit
  62. :rows="3" style="width: 300px;" v-model="editedRequirement.description" />
  63. <br/>
  64. </div>
  65. <p v-else>{{description}}</p>
  66. </el-row>
  67. <!-- 状态、优先级等 -->
  68. <el-row class="entry-row" style="margin-top: 15px">
  69. <h4>详情</h4>
  70. </el-row>
  71. <el-row style="margin: 3px 20px;width: 100%">
  72. <el-col :span="12">
  73. <RowItem :label="'状态:'">
  74. <div v-if="!isEditing" class="detail-value">
  75. <StateTag :state="state"></StateTag>
  76. </div>
  77. <div v-else>
  78. <el-select style="width: 160px" size="mini" v-model="editedRequirement.state">
  79. <el-option
  80. v-for="item in stateOptions"
  81. :key="item.value"
  82. :value="item.value"
  83. :label="item.value" />
  84. </el-select>
  85. </div>
  86. </RowItem>
  87. <RowItem :label="'优先级:'">
  88. <div class="detail-value" v-if="!isEditing">
  89. <PriorityTag :priority="priority"></PriorityTag>
  90. </div>
  91. <div v-else>
  92. <el-select style="width: 160px" size="mini" v-model="editedRequirement.priority">
  93. <el-option
  94. v-for="item in priorityOptions"
  95. :key="item.value"
  96. :value="item.value"
  97. :label="item.label" />
  98. </el-select>
  99. </div>
  100. </RowItem>
  101. <RowItem :label="'经办人:'">
  102. <div class="detail-value" v-if="!isEditing">
  103. <el-tag>{{processorName}}</el-tag>
  104. </div>
  105. <div v-else>
  106. <el-select style="width: 160px" size="mini" v-model="editedRequirement.processorId" >
  107. <el-option
  108. v-for="item in userOptions"
  109. :key="item.value"
  110. :value="item.value"
  111. :label="item.label" />
  112. </el-select>
  113. </div>
  114. </RowItem>
  115. </el-col>
  116. <el-col :span="12">
  117. <RowItem :label="'工作量:'">
  118. <div class="detail-value" v-if="!isEditing">
  119. <span>{{timeToTake}}人日</span>
  120. </div>
  121. <div v-else>
  122. <el-input-number size="mini" v-model="editedRequirement.timeToTake" :min="1" :max="200">
  123. </el-input-number>
  124. </div>
  125. </RowItem>
  126. <RowItem :label="'开始时间:'"><span>{{formatter(startTime)}}</span></RowItem>
  127. <RowItem :label="'完成时间:'"><span>{{formatter(endTime)}}</span></RowItem>
  128. </el-col>
  129. </el-row>
  130. <!-- 相关需求 -->
  131. <template v-if="showSons">
  132. <el-row class="entry-row" style="margin-top: 15px">
  133. <h4>子节点</h4>
  134. </el-row>
  135. <template v-if="(childs && childs.length) || false">
  136. <el-row style="margin: 10px 25px;" v-for="item in childs" :key="item.id">
  137. <el-link @click.prevent="changeContent(item.id)" type="primary">{{item.title}}</el-link>
  138. </el-row>
  139. </template>
  140. <template v-else>
  141. <el-row style="margin: 0px 25px;">
  142. 没有子节点
  143. </el-row>
  144. </template>
  145. </template>
  146. <el-row v-if="isEditing" class="entry-row" style="margin-top: 15px">
  147. <el-button @click="submitEdit" v-loading="confirmLoading" size="mini" type="primary">提交</el-button>
  148. <el-button @click="cancelEdit" size="mini">取消</el-button>
  149. </el-row>
  150. </el-tab-pane>
  151. <template v-if="type==='任务'">
  152. <el-tab-pane label="历史提交" name="commit_history">
  153. <!-- 相关提交 -->
  154. <el-row class="entry-row" style="margin-top: 15px">
  155. <el-table :data="commits">
  156. <el-table-column type="expand">
  157. <template #default="scope">
  158. <RowItem :label="'ID:'" :label-span="5" :value-span="19">{{scope.row.id}}</RowItem>
  159. <RowItem :label="'信息:'" :label-span="5" :value-span="19">{{scope.row.message}}</RowItem>
  160. <RowItem :label="'时间:'" :label-span="5" :value-span="19">{{formatter(scope.row.timestamp)}}</RowItem>
  161. </template>
  162. </el-table-column>
  163. <el-table-column
  164. label="ID"
  165. align="center"
  166. :formatter="(row)=>row.id.substr(0,7)"
  167. >
  168. </el-table-column>
  169. <el-table-column
  170. prop="gitlabUsername"
  171. label="用户"
  172. align="center"
  173. >
  174. </el-table-column>
  175. </el-table>
  176. </el-row>
  177. </el-tab-pane>
  178. </template>
  179. </el-tabs>
  180. </el-col>
  181. </el-row>
  182. </template>
  183. </el-drawer>
  184. </template>
  185. <script>
  186. import { RequirementAPI } from '@/api';
  187. import PriorityTag from '@/components/PriorityTag.vue';
  188. import StateTag from '@/components/StateTag.vue';
  189. import { priorityOptions, stateOptions } from '@/utils/constants';
  190. import { formatter } from '@/utils/time';
  191. import RowItem from './RowItem.vue';
  192. export default {
  193. name: 'RequirementDrawers',
  194. components: { RowItem, PriorityTag, StateTag },
  195. emits: ['change', 'requirement-update'],
  196. props: {
  197. id: Number,
  198. type: String,
  199. title: String,
  200. description: String,
  201. state: String,
  202. priority: String,
  203. processorId: Number,
  204. processorName: String,
  205. timeToTake: Number,
  206. startTime: String,
  207. endTime: String,
  208. childs: Array,
  209. parentId: Number,
  210. commits: Array,
  211. showSons: {
  212. type: Boolean,
  213. default: true,
  214. },
  215. },
  216. data() {
  217. return {
  218. activeTab: 'basic_info',
  219. showDrawer: false,
  220. isEditing: false,
  221. editedRequirement: {
  222. title: null,
  223. description: null,
  224. state: null,
  225. timeToTake: null,
  226. priority: null,
  227. processorId: null,
  228. processorName: null,
  229. },
  230. confirmLoading: false,
  231. stateOptions,
  232. priorityOptions,
  233. };
  234. },
  235. computed: {
  236. userOptions() {
  237. return this.$store.getters.userOptions;
  238. },
  239. },
  240. methods: {
  241. formatter,
  242. show() {
  243. this.showDrawer = true;
  244. },
  245. fillDefaultValue() {
  246. this.editedRequirement.title = this.title;
  247. this.editedRequirement.description = this.description;
  248. this.editedRequirement.state = this.state;
  249. this.editedRequirement.timeToTake = this.timeToTake;
  250. this.editedRequirement.priority = this.priority;
  251. this.editedRequirement.processorId = this.processorId;
  252. this.editedRequirement.processorName = this.processorName;
  253. },
  254. submitEdit() {
  255. this.confirmLoading = true;
  256. const param = {
  257. id: this.id,
  258. title: this.editedRequirement.title,
  259. description: this.editedRequirement.description,
  260. state: this.editedRequirement.state,
  261. timeToTake: this.editedRequirement.timeToTake,
  262. priority: this.editedRequirement.priority,
  263. processorId: this.editedRequirement.processorId,
  264. };
  265. RequirementAPI.updateTreeNode(param).then((res) => {
  266. this.isEditing = false;
  267. this.$emit('requirement-update');
  268. this.showDrawer = false;
  269. });
  270. this.confirmLoading = false;
  271. },
  272. cancelEdit() {
  273. this.isEditing = false;
  274. this.fillDefaultValue();
  275. },
  276. changeContent(id) {
  277. this.$emit('change', id);
  278. },
  279. },
  280. };
  281. </script>
  282. <style lang="scss" scoped>
  283. .entry-row{
  284. width: 100%;
  285. margin: 3px 20px;
  286. display: flex;
  287. flex-direction: row;
  288. align-items: center;
  289. justify-content: flex-start;
  290. h3, h4{
  291. color: #172b4d
  292. }
  293. }
  294. .detail-row{
  295. display: flex;
  296. flex-direction: row;
  297. align-items: center;
  298. line-height: 24px;
  299. margin: 3px 0;
  300. }
  301. .detail-value{
  302. display: flex;
  303. flex-direction: row;
  304. align-items: center;
  305. }
  306. .node-type{
  307. color: #FFFFFF;
  308. border-radius: 3px;
  309. font-size: 14px;
  310. background-color: #42b983;
  311. text-align: center;
  312. }
  313. .state-entry{
  314. border-radius: 5px;
  315. background-color: cornflowerblue;
  316. font-size: 12px;
  317. color: #FFFFFF;
  318. padding: 0px 4px;
  319. cursor: pointer
  320. }
  321. </style>