BugEditDrawer.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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="2">
  12. <div class="node-type">Bug</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="editedBugRecord.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>缺陷描述</h4>
  52. </el-row>
  53. <el-row class="entry-row">
  54. <div v-if="isEditing">
  55. <el-input placeholder="请输入描述"
  56. type="textarea"
  57. maxlength="120"
  58. show-word-limit
  59. :rows="3" style="width: 300px;" v-model="editedBugRecord.description" />
  60. <br/>
  61. </div>
  62. <p v-else>{{description}}</p>
  63. </el-row>
  64. <!-- 状态、优先级等 -->
  65. <el-row class="entry-row" style="margin-top: 15px">
  66. <h4>详情</h4>
  67. </el-row>
  68. <el-row style="margin: 3px 20px;width: 100%">
  69. <el-col :span="12">
  70. <RowItem :label="'状态:'">
  71. <div v-if="!isEditing" class="detail-value">
  72. <StateTag :state="state"></StateTag>
  73. </div>
  74. <div v-else>
  75. <el-select style="width: 160px" size="mini" v-model="editedBugRecord.state">
  76. <el-option
  77. v-for="item in stateOptions"
  78. :key="item.value"
  79. :value="item.value"
  80. :label="item.value" />
  81. </el-select>
  82. </div>
  83. </RowItem>
  84. <RowItem :label="'优先级:'">
  85. <div class="detail-value" v-if="!isEditing">
  86. <PriorityTag :priority="priority"></PriorityTag>
  87. </div>
  88. <div v-else>
  89. <el-select style="width: 160px" size="mini" v-model="editedBugRecord.priority">
  90. <el-option
  91. v-for="item in priorityOptions"
  92. :key="item.value"
  93. :value="item.value"
  94. :label="item.label" />
  95. </el-select>
  96. </div>
  97. </RowItem>
  98. <RowItem :label="'经办人:'">
  99. <div class="detail-value" v-if="!isEditing">
  100. <el-tag>{{processorName}}</el-tag>
  101. </div>
  102. <div v-else>
  103. <el-select style="width: 160px" size="mini" v-model="editedBugRecord.processorId" >
  104. <el-option
  105. v-for="item in userOptions"
  106. :key="item.value"
  107. :value="item.value"
  108. :label="item.label" />
  109. </el-select>
  110. </div>
  111. </RowItem>
  112. </el-col>
  113. <el-col :span="12">
  114. <RowItem :label="'工作量:'">
  115. <div class="detail-value" v-if="!isEditing">
  116. <span>{{timeToTake}}人日</span>
  117. </div>
  118. <div v-else>
  119. <el-input-number size="mini" v-model="editedBugRecord.timeToTake" :min="1" :max="200">
  120. </el-input-number>
  121. </div>
  122. </RowItem>
  123. <RowItem :label="'开始时间:'"><span>{{formatter(startTime)}}</span></RowItem>
  124. <RowItem :label="'完成时间:'"><span>{{formatter(endTime)}}</span></RowItem>
  125. </el-col>
  126. </el-row>
  127. <el-row v-if="isEditing" class="entry-row" style="margin-top: 15px">
  128. <el-button @click="submitEdit" size="mini" v-loading="confirmLoading" type="primary">提交</el-button>
  129. <el-button @click="cancelEdit" size="mini">取消</el-button>
  130. </el-row>
  131. </el-tab-pane>
  132. <el-tab-pane label="历史提交" name="commit_history">
  133. <!-- 相关提交 -->
  134. <el-row class="entry-row" style="margin-top: 15px">
  135. <el-table :data="commits">
  136. <el-table-column type="expand">
  137. <template #default="scope">
  138. <RowItem :label="'ID:'" :label-span="5" :value-span="19">{{scope.row.id}}</RowItem>
  139. <RowItem :label="'信息:'" :label-span="5" :value-span="19">{{scope.row.message}}</RowItem>
  140. <RowItem :label="'时间:'" :label-span="5" :value-span="19">{{formatter(scope.row.timestamp)}}</RowItem>
  141. </template>
  142. </el-table-column>
  143. <el-table-column
  144. label="ID"
  145. align="center"
  146. :formatter="(row)=>row.id.substr(0,7)"
  147. >
  148. </el-table-column>
  149. <el-table-column
  150. prop="gitlabUsername"
  151. label="用户"
  152. align="center"
  153. >
  154. </el-table-column>
  155. </el-table>
  156. </el-row>
  157. </el-tab-pane>
  158. </el-tabs>
  159. </el-col>
  160. </el-row>
  161. </template>
  162. </el-drawer>
  163. </template>
  164. <script>
  165. import { BugListAPI } from '@/api';
  166. import PriorityTag from '@/components/PriorityTag.vue';
  167. import StateTag from '@/components/StateTag.vue';
  168. import { priorityOptions, stateOptions } from '@/utils/constants';
  169. import { formatter } from '@/utils/time';
  170. import RowItem from './RowItem.vue';
  171. export default {
  172. name: 'BugEditDrawer',
  173. components: { RowItem, PriorityTag, StateTag },
  174. emits: ['bug-record-update'],
  175. props: {
  176. id: Number,
  177. title: String,
  178. description: String,
  179. state: String,
  180. priority: String,
  181. processorId: Number,
  182. processorName: String,
  183. timeToTake: Number,
  184. startTime: String,
  185. endTime: String,
  186. commits: Array,
  187. },
  188. data() {
  189. return {
  190. activeTab: 'basic_info',
  191. showDrawer: false,
  192. isEditing: false,
  193. editedBugRecord: {
  194. title: null,
  195. description: null,
  196. state: null,
  197. timeToTake: null,
  198. priority: null,
  199. processorId: null,
  200. processorName: null,
  201. },
  202. confirmLoading: false,
  203. stateOptions,
  204. priorityOptions,
  205. };
  206. },
  207. computed: {
  208. userOptions() {
  209. return this.$store.getters.userOptions;
  210. },
  211. },
  212. methods: {
  213. formatter,
  214. show() {
  215. this.showDrawer = true;
  216. },
  217. fillDefaultValue() {
  218. this.editedBugRecord.title = this.title;
  219. this.editedBugRecord.description = this.description;
  220. this.editedBugRecord.state = this.state;
  221. this.editedBugRecord.timeToTake = this.timeToTake;
  222. this.editedBugRecord.priority = this.priority;
  223. this.editedBugRecord.processorId = this.processorId;
  224. this.editedBugRecord.processorName = this.processorName;
  225. },
  226. submitEdit() {
  227. this.confirmLoading = true;
  228. const param = { id: this.id, ...this.editedBugRecord };
  229. BugListAPI.updateBugRecord(param).then((res) => {
  230. this.isEditing = false;
  231. this.$emit('bug-record-update');
  232. this.showDrawer = false;
  233. });
  234. this.confirmLoading = false;
  235. },
  236. cancelEdit() {
  237. this.isEditing = false;
  238. this.fillDefaultValue();
  239. },
  240. },
  241. };
  242. </script>
  243. <style lang="scss" scoped>
  244. .entry-row{
  245. width: 100%;
  246. margin: 3px 20px;
  247. display: flex;
  248. flex-direction: row;
  249. align-items: center;
  250. justify-content: flex-start;
  251. h3, h4{
  252. color: #172b4d
  253. }
  254. }
  255. .detail-row{
  256. display: flex;
  257. flex-direction: row;
  258. align-items: center;
  259. line-height: 24px;
  260. margin: 3px 0;
  261. }
  262. .detail-value{
  263. display: flex;
  264. flex-direction: row;
  265. align-items: center;
  266. }
  267. .node-type{
  268. color: #FFFFFF;
  269. border-radius: 3px;
  270. font-size: 14px;
  271. background-color: #42b983;
  272. text-align: center;
  273. }
  274. .state-entry{
  275. border-radius: 5px;
  276. background-color: cornflowerblue;
  277. font-size: 12px;
  278. color: #FFFFFF;
  279. padding: 0px 4px;
  280. cursor: pointer
  281. }
  282. </style>