BugEditDrawer.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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="12" :offset="2">
  15. <template class="entry-row" v-if="isEditing">
  16. <el-input placeholder="请输入标题" size="mini" style="width: 200px;display: inline;" v-model="editedBugRecord.title"/>
  17. </template>
  18. <template v-else><h3>{{title}}</h3></template>
  19. </el-col>
  20. <el-col :span="6" :offset="2">
  21. <el-switch
  22. v-if="activeTab ==='basic_info'"
  23. style="float: right;"
  24. v-model="isEditing"
  25. active-text="编辑"
  26. @change="(isEditing) => {
  27. isEditing && fillDefaultValue();
  28. }">
  29. </el-switch>
  30. </el-col>
  31. </el-row>
  32. </template>
  33. <template #default>
  34. <el-row type="flex" justify="center">
  35. <el-col :span="20">
  36. <el-tabs
  37. class="tabs"
  38. v-model="activeTab"
  39. @tab-click="(tab) => {
  40. if(tab.panename !== 'basic_info')
  41. isEditing = false;
  42. }"
  43. >
  44. <el-tab-pane label="基本信息" name="basic_info">
  45. <el-row class="entry-row" style="margin-top: 15px">
  46. <h4>缺陷描述</h4>
  47. </el-row>
  48. <el-row class="entry-row">
  49. <div v-if="isEditing">
  50. <el-input placeholder="请输入描述"
  51. type="textarea"
  52. maxlength="120"
  53. show-word-limit
  54. :rows="3" style="width: 300px;" v-model="editedBugRecord.description" />
  55. <br/>
  56. </div>
  57. <p v-else>{{description}}</p>
  58. </el-row>
  59. <!-- 状态、优先级等 -->
  60. <el-row class="entry-row" style="margin-top: 15px">
  61. <h4>详情</h4>
  62. </el-row>
  63. <el-row style="margin: 3px 20px;width: 100%">
  64. <el-col :span="12">
  65. <RowItem :label="'状态:'">
  66. <div v-if="!isEditing" class="detail-value">
  67. <StateTag :state="state"></StateTag>
  68. </div>
  69. <div v-else>
  70. <el-select style="width: 160px" size="mini" v-model="editedBugRecord.state">
  71. <el-option
  72. v-for="item in stateOptions"
  73. :key="item.value"
  74. :value="item.value"
  75. :label="item.value" />
  76. </el-select>
  77. </div>
  78. </RowItem>
  79. <RowItem :label="'优先级:'">
  80. <div class="detail-value" v-if="!isEditing">
  81. <PriorityTag :priority="priority"></PriorityTag>
  82. </div>
  83. <div v-else>
  84. <el-select style="width: 160px" size="mini" v-model="editedBugRecord.priority">
  85. <el-option
  86. v-for="item in priorityOptions"
  87. :key="item.value"
  88. :value="item.value"
  89. :label="item.label" />
  90. </el-select>
  91. </div>
  92. </RowItem>
  93. <RowItem :label="'经办人:'">
  94. <div class="detail-value" v-if="!isEditing">
  95. <el-tag>{{processorName}}</el-tag>
  96. </div>
  97. <div v-else>
  98. <el-select style="width: 160px" size="mini" v-model="editedBugRecord.processorId" >
  99. <el-option
  100. v-for="item in userOptions"
  101. :key="item.value"
  102. :value="item.value"
  103. :label="item.label" />
  104. </el-select>
  105. </div>
  106. </RowItem>
  107. </el-col>
  108. <el-col :span="12">
  109. <RowItem :label="'工作量:'">
  110. <div class="detail-value" v-if="!isEditing">
  111. <span>{{timeToTake}}人日</span>
  112. </div>
  113. <div v-else>
  114. <el-input-number size="mini" v-model="editedBugRecord.timeToTake" :min="1" :max="200">
  115. </el-input-number>
  116. </div>
  117. </RowItem>
  118. <RowItem :label="'开始时间:'"><span>{{formatter(startTime)}}</span></RowItem>
  119. <RowItem :label="'完成时间:'"><span>{{formatter(endTime)}}</span></RowItem>
  120. </el-col>
  121. </el-row>
  122. <el-row v-if="isEditing" class="entry-row" style="margin-top: 15px">
  123. <el-button @click="submitEdit" size="mini" v-loading="confirmLoading" type="primary">提交</el-button>
  124. <el-button @click="cancelEdit" size="mini">取消</el-button>
  125. </el-row>
  126. </el-tab-pane>
  127. <el-tab-pane label="历史提交" name="commit_history">
  128. <!-- 相关提交 -->
  129. <el-row class="entry-row" style="margin-top: 15px">
  130. <el-table :data="commits">
  131. <el-table-column type="expand">
  132. <template #default="scope">
  133. <RowItem :label="'message:'" :label-span="5" :value-span="19">{{scope.row.message}}</RowItem>
  134. <RowItem :label="'timestamp:'" :label-span="5" :value-span="19">{{scope.row.timestamp}}</RowItem>
  135. </template>
  136. </el-table-column>
  137. <el-table-column
  138. prop="id"
  139. label="ID"
  140. align="center"
  141. >
  142. </el-table-column>
  143. <el-table-column
  144. prop="title"
  145. label="标题"
  146. align="center"
  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. });
  233. this.confirmLoading = false;
  234. },
  235. cancelEdit() {
  236. this.isEditing = false;
  237. this.fillDefaultValue();
  238. },
  239. },
  240. };
  241. </script>
  242. <style lang="scss" scoped>
  243. .entry-row{
  244. width: 100%;
  245. margin: 3px 20px;
  246. display: flex;
  247. flex-direction: row;
  248. align-items: center;
  249. justify-content: flex-start;
  250. h3, h4{
  251. color: #172b4d
  252. }
  253. }
  254. .detail-row{
  255. display: flex;
  256. flex-direction: row;
  257. align-items: center;
  258. line-height: 24px;
  259. margin: 3px 0;
  260. }
  261. .detail-value{
  262. display: flex;
  263. flex-direction: row;
  264. align-items: center;
  265. }
  266. .node-type{
  267. color: #FFFFFF;
  268. border-radius: 3px;
  269. font-size: 14px;
  270. background-color: #42b983;
  271. text-align: center;
  272. }
  273. .state-entry{
  274. border-radius: 5px;
  275. background-color: cornflowerblue;
  276. font-size: 12px;
  277. color: #FFFFFF;
  278. padding: 0px 4px;
  279. cursor: pointer
  280. }
  281. </style>