requireDrawer.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <el-drawer :title="Statistics.label" :visible.sync="drawer_" :direction="direction" :modal="false" :class="{'drawer-box': showClass}" size="100%" :before-close="handleClose">
  3. <div style="height: calc(100vh - 200px); overflow: scroll; overflow-x: hidden;">
  4. <el-table :data="tableData" style="width: 100%;" :header-cell-style="{ 'color':'rgba(74,74,74,1)','font-size':'14px','font-weight':'500' }" class="integration-num">
  5. <el-table-column label="优先级" min-width="100">
  6. <template slot-scope="scope">
  7. <div class="div_priority" :style="{background: priorityColors[scope.row.priority % priorityColors.length]}">{{ 'P'+scope.row.priority }}</div>
  8. </template>
  9. </el-table-column>
  10. <el-table-column :label="Statistics.typeStr + '名称'" min-width="250">
  11. <template slot-scope="scope">
  12. <div v-if="Statistics.typeStr === '缺陷'" class="drawer-id">{{ scope.row.bugId }}</div>
  13. <div v-if="Statistics.typeStr === '任务'" class="drawer-id">{{ scope.row.taskIdSting }}</div>
  14. <div v-if="Statistics.typeStr === '需求'" class="drawer-id">{{ scope.row.requirementDisplayId }}</div>
  15. <el-tooltip v-if="Statistics.typeStr === '需求' && scope.row.name.length >= 15 || Statistics.typeStr === '任务' && scope.row.name.length >= 15" class="item" effect="dark" :content="scope.row.name" placement="top">
  16. <div class="drawer-name" @click="jumper(scope.row)">{{ scope.row.name | ellipsis }}</div>
  17. </el-tooltip>
  18. <div v-else class="drawer-name" @click="jumper(scope.row)">{{ scope.row.name | ellipsis }}</div>
  19. <el-tooltip v-if="Statistics.typeStr === '缺陷' && scope.row.bugName.length >= 15" class="item" effect="dark" :content="scope.row.bugName" placement="top">
  20. <div class="drawer-name" @click="jumper(scope.row)">{{ scope.row.bugName | ellipsis }}</div>
  21. </el-tooltip>
  22. <div v-else class="drawer-name" @click="jumper(scope.row)">{{ scope.row.bugName | ellipsis }}</div>
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="状态" min-width="100">
  26. <template slot-scope="scope">
  27. <div v-if="Statistics.typeStr === '需求'">{{ scope.row.statusName }}</div>
  28. <div v-if="Statistics.typeStr === '任务'">{{ scope.row.statusString }}</div>
  29. <div v-if="Statistics.typeStr === '缺陷'">{{ querySatus(scope.row.status) }}</div>
  30. </template>
  31. </el-table-column>
  32. </el-table>
  33. </div>
  34. <el-pagination
  35. style="text-align: center;"
  36. :current-page.sync="currentPage"
  37. :page-size="10"
  38. layout="total, prev, pager, next, jumper"
  39. :total="total"
  40. @size-change="handleSizeChange"
  41. @current-change="handleCurrentChange"
  42. />
  43. </el-drawer>
  44. </template>
  45. <script>
  46. import { EncryptId } from '@/utils/crypto-js.js'
  47. import { getRequirement } from '@/api/requirement.js'
  48. import { taskList } from '@/api/taskIndex'
  49. import { bugList, bugGetEnum } from '@/api/defectManage'
  50. export default {
  51. filters: {
  52. ellipsis(value) {
  53. if (!value) return ''
  54. if (value.length > 15) {
  55. return value.slice(0, 15) + '...'
  56. }
  57. return value
  58. }
  59. },
  60. props: {
  61. data: { type: Object, required: true },
  62. drawer: { type: Boolean, default: false }
  63. },
  64. data() {
  65. return {
  66. priorityColors: ['#F56C6C', '#FF8952', '#F5E300', '#7ED321', '#61D3B8', '#69B3FF', '#BDBDBD'],
  67. Statistics: {}, // title
  68. direction: 'rtl',
  69. showClass: false,
  70. bugList: [],
  71. currentPage: 1,
  72. total: 0,
  73. paging: {
  74. curIndex: 1, // 分页
  75. pageSize: 10 // 分页
  76. },
  77. tableData: []
  78. }
  79. },
  80. computed: {
  81. drawer_: {
  82. get() { return this.drawer },
  83. set(v) {
  84. this.$emit('clone', v)
  85. }
  86. }
  87. },
  88. watch: {
  89. data: {
  90. handler(newV, oldV) {
  91. this.Statistics = newV
  92. this.currentPage = 1
  93. this.paging = {
  94. curIndex: 1, // 分页
  95. pageSize: 10 // 分页
  96. }
  97. this.getTableData()
  98. },
  99. immediate: true
  100. }
  101. },
  102. created() {
  103. this.bugGetEnum()
  104. },
  105. methods: {
  106. async getTableData() {
  107. if (this.Statistics.idList !== undefined && this.Statistics.idList.length > 0) {
  108. this.paging.ids = this.Statistics.idList
  109. if (this.Statistics.typeStr === '需求') {
  110. const res = await getRequirement(this.paging)
  111. if (res.code === 200) {
  112. this.tableData = res.data.list
  113. this.total = res.data.total
  114. }
  115. } else if (this.Statistics.typeStr === '任务') {
  116. const res = await taskList(this.paging)
  117. if (res.code === 200) {
  118. this.tableData = res.data
  119. this.total = res.total
  120. }
  121. } else if (this.Statistics.typeStr === '缺陷') {
  122. const res = await bugList(this.paging)
  123. if (res.code === 200) {
  124. this.tableData = res.data
  125. this.total = res.total
  126. }
  127. }
  128. } else {
  129. this.tableData = []
  130. }
  131. },
  132. querySatus(val) {
  133. let data = ''
  134. this.bugList.map(item => {
  135. if (val === item.code) {
  136. data = item.name
  137. }
  138. })
  139. return data
  140. },
  141. jumper(val) {
  142. const bizId_id = EncryptId(`${val.bizId}_${val.id}`)
  143. const newTab = this.$router.resolve({ name: this.Statistics.typeStr + '详情', query: { bizId_id: bizId_id }})
  144. window.open(newTab.href, '_blank')
  145. },
  146. async bugGetEnum() {
  147. const res = await bugGetEnum()
  148. if (res.code === 200) {
  149. this.bugList = res.data.bugEnumList
  150. this.showClass = true
  151. }
  152. },
  153. handleSizeChange(val) {
  154. this.paging.pageSize = val
  155. this.getTableData()
  156. },
  157. handleCurrentChange(val) {
  158. this.paging.curIndex = val
  159. this.getTableData()
  160. },
  161. handleClose(done) {
  162. this.$emit('clone')
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. >>> :focus{outline:0;}
  169. .integration-num {
  170. margin: 20px;
  171. }
  172. .drawer-name:hover {
  173. color: #409eff;
  174. cursor: pointer;
  175. }
  176. .div_priority {
  177. color: #ffffff;
  178. width:fit-content;
  179. padding: 0 12px;
  180. border-radius: 4px;
  181. margin-left: 4px;
  182. }
  183. .drawer-id {
  184. color: rgb(167, 174, 188);
  185. font-size: 10px;
  186. }
  187. >>>.el-drawer__header {
  188. color: #444;
  189. font-size: 20px;
  190. font-weight: 500;
  191. margin-bottom: 0px;
  192. padding: 20px 30px 0;
  193. }
  194. .drawer-box {
  195. box-shadow: 0 8px 10px -5px rgba(0,0,0,.2), 0 16px 24px 2px rgba(0,0,0,.14), 0 6px 30px 5px rgba(0,0,0,.12);
  196. }
  197. .el-drawer__wrapper {
  198. width: 100%;
  199. position: fixed;
  200. top: 0;
  201. right: 0;
  202. bottom: 0;
  203. left: 50%;
  204. overflow: hidden;
  205. margin: 0;
  206. // box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
  207. }
  208. >>>.el-drawer__container {
  209. left: 0;
  210. right: 0;
  211. width: 50%;
  212. }
  213. >>>.el-table td, .el-table th {
  214. padding: 5px 0;
  215. }
  216. </style>