index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <template>
  2. <el-container>
  3. <el-header style="margin: 2%;" class="layout_header">
  4. <div>
  5. <span style="font-size: 16px;color:#333333">{{ '需求:' + requirement.name }}</span>
  6. <el-dropdown
  7. size="mini"
  8. split-button
  9. style="margin-left: 10px"
  10. @command="updateRequirementStatus"
  11. >
  12. <span class="el-dropdown-link">{{ getStatusName() }}</span>
  13. <el-dropdown-menu slot="dropdown">
  14. <el-dropdown-item
  15. v-for="(item,index) in searchInfo.requirementStatus"
  16. :key="index"
  17. :command="item"
  18. >{{ item.msg }}</el-dropdown-item>
  19. </el-dropdown-menu>
  20. </el-dropdown>
  21. <div style="display: inline-block;float: right">
  22. <el-button size="mini" style="margin-left: 10px" @click="deleteRequirement">删除需求</el-button>
  23. <el-button type="primary" size="mini" @click="createTask">新建</el-button>
  24. </div>
  25. </div>
  26. </el-header>
  27. <el-container>
  28. <el-aside width="52%" style="margin: 0% 2% 2% 2%;" class="layout_aside">
  29. <div style="font-size: 18px">
  30. <b style="color: #409EFF">I</b>数据统计
  31. </div>
  32. <div v-loading="loading.task || loading.bug" class="div_statistics" style="margin: 2%">
  33. <el-container style="border-bottom: 1px solid #D8D8D8">
  34. <el-aside width="30%" style="border-right: 2px solid #BBBBBB">
  35. <div style="width:100%;text-align: center;">
  36. <div style="font-size: 16px;margin-top: 26px">任务数量</div>
  37. <div style="font-size: 72px">{{ statistics.task.totalCount }}</div>
  38. <div
  39. style="font-size: 14px;color: rgba(245,108,108,1);margin-bottom: 16px"
  40. >{{ '已延期'+statistics.task.delayCount+'个' }}</div>
  41. </div>
  42. </el-aside>
  43. <el-aside width="70%">
  44. <requirement-chart
  45. :chart-id="'taskCount'"
  46. :option="taskOption"
  47. style="position: relative;bottom: 30px"
  48. />
  49. </el-aside>
  50. </el-container>
  51. <el-container>
  52. <el-aside width="30%" style="border-right: 2px solid #BBBBBB">
  53. <div style="width:100%;text-align: center;">
  54. <div style="font-size: 16px;margin-top: 26px">任务数量</div>
  55. <div style="font-size: 72px">{{ statistics.bug.totalCount }}</div>
  56. <div
  57. style="font-size: 14px;color: rgba(245,108,108,1);margin-bottom: 16px"
  58. >{{ '以后修复'+statistics.bug.fixInFutureCount+'个' }}</div>
  59. </div>
  60. </el-aside>
  61. <el-aside width="70%">
  62. <requirement-chart
  63. :chart-id="'bugCount'"
  64. :option="bugOption"
  65. style="position: relative;bottom: 30px"
  66. />
  67. </el-aside>
  68. </el-container>
  69. </div>
  70. </el-aside>
  71. <el-aside width="42%" style="margin: 0% 2% 2% 0;" class="layout_aside">
  72. <div style="font-size: 18px">
  73. <b style="color: #409EFF;">I</b>基础信息
  74. </div>
  75. <div
  76. v-loading="loading.info"
  77. style="font-size: 14px;color: #666666;margin-top: 4%"
  78. class="div_requirment_info"
  79. >
  80. <el-row>
  81. <el-col :span="6">归属的项目:</el-col>
  82. <el-col :span="18">
  83. <div
  84. style="display: inline-block;color: #409EFF"
  85. >{{ requirement.belongingProjectName }}</div>
  86. <el-button
  87. style="position: absolute;top: 5px;right: 0"
  88. type="primary"
  89. size="mini"
  90. @click="updateDialogVisible = true"
  91. >修改</el-button>
  92. </el-col>
  93. </el-row>
  94. <el-row>
  95. <el-col :span="6">业务线:</el-col>
  96. <el-col :span="18">{{ requirement.bizName }}</el-col>
  97. </el-row>
  98. <el-row>
  99. <el-col :span="6">优先级:</el-col>
  100. <el-col :span="18">{{ requirement.priorityName }}</el-col>
  101. </el-row>
  102. <el-row>
  103. <el-col :span="6">需求来源:</el-col>
  104. <el-col :span="18">{{ requirement.sourceTypeName }}</el-col>
  105. </el-row>
  106. <el-row>
  107. <el-col :span="6">PM:</el-col>
  108. <el-col :span="18">{{ getPmName() }}</el-col>
  109. </el-row>
  110. <el-row>
  111. <el-col :span="6">PRD链接:</el-col>
  112. <el-col :span="18">
  113. <el-link type="primary" :href="requirement.mrdUrl">{{ requirement.mrdUrl }}</el-link>
  114. </el-col>
  115. </el-row>
  116. <el-row>
  117. <el-col :span="6">是否跟版:</el-col>
  118. <el-col :span="18">{{ requirement.dependOnRelease? '是':'否' }}</el-col>
  119. </el-row>
  120. <el-row v-if="requirement.dependOnRelease">
  121. <el-col :span="6">涉及的客户端:</el-col>
  122. <el-col :span="18">{{ getAppClientName() }}</el-col>
  123. </el-row>
  124. </div>
  125. </el-aside>
  126. </el-container>
  127. <el-main id="requirement_details" style="margin: 0 2% 0 2%;padding: 0" class="layout_main">
  128. <div style="font-size: 18px;margin: 2%">
  129. <b style="color: #409EFF;">I</b>任务
  130. </div>
  131. <el-radio-group v-model="radio" size="mini" style="float: right;margin: 0 1% 1% 0">
  132. <el-radio-button label="列表" />
  133. <el-radio-button label="甘特图" />
  134. </el-radio-group>
  135. <br>
  136. <el-table
  137. v-if="radio === '列表'"
  138. v-loading="loading.table"
  139. :data="tableData"
  140. style="width: 100%;"
  141. highlight-current-row
  142. :header-cell-style="{ background: '#6AB4FF', color: '#FFFFFF',textAlign: 'center'}"
  143. :cell-style="{textAlign: 'center'}"
  144. >
  145. <el-table-column prop="name" label="任务名" min-width="20%">
  146. <template v-slot="scope">
  147. <div style="cursor: pointer;" @click="getToTaskDetails(scope.row.id)">{{ scope.row.name }}</div>
  148. </template>
  149. </el-table-column>
  150. <el-table-column prop="beginTime" label="排期" min-width="15%">
  151. <template
  152. v-slot="scope"
  153. >{{ getSchedule(scope.row) }}</template>
  154. </el-table-column>
  155. <el-table-column prop="statusString" label="状态" min-width="10%">
  156. <template v-slot="scope">
  157. <div style="color: #FF9500">{{ scope.row.statusString }}</div>
  158. </template>
  159. </el-table-column>
  160. <el-table-column prop="stageString" label="任务健康状态" min-width="12%">
  161. <template v-slot="scope">{{ scope.row.stageString }}</template>
  162. </el-table-column>
  163. <el-table-column prop="rate" label="任务进展" min-width="15%">
  164. <template v-slot="scope">
  165. <el-progress :percentage="Number(scope.row.rate?scope.row.rate.replace(/%/g,''):0)" />
  166. </template>
  167. </el-table-column>
  168. <el-table-column prop="rdObject" label="开发负责人" min-width="10%">
  169. <template v-slot="scope">{{ scope.row.rdObject?scope.row.rdObject.name:'空' }}</template>
  170. </el-table-column>
  171. <el-table-column prop="qaObject" label="测试负责人" min-width="10%">
  172. <template v-slot="scope">{{ scope.row.qaObject?scope.row.qaObject.name:'空' }}</template>
  173. </el-table-column>
  174. <el-table-column prop="rdList" label="开发" min-width="10%">
  175. <template v-slot="scope">{{ getQaOrRdNameList(scope.row.rdList) }}</template>
  176. </el-table-column>
  177. <el-table-column prop="qaList" label="测试" min-width="10%">
  178. <template v-slot="scope">{{ getQaOrRdNameList(scope.row.qaList) }}</template>
  179. </el-table-column>
  180. </el-table>
  181. <div style="margin:0 2%;padding: 2% 0;border-bottom: 1px solid #D8D8D8;font-size: 14px;color: #333333">排期汇总:{{ getScheduleCollect() }}</div>
  182. <el-row style="margin: 2%;font-size: 14px;color: #333333">
  183. <el-col :span="8">
  184. <div v-for="(item,index) in task.preOnlineVersion" :key="index" style="margin-bottom:10px"> <span :style="{visibility: index===0?'visible ':'hidden'}">预期上线版本:</span>{{ item }}</div>
  185. </el-col>
  186. <el-col :span="16">
  187. <div v-for="(item,index) in task.preOnlineVersion" :key="index" style="margin-bottom:10px"> <span :style="{visibility: index===0?'visible ':'hidden'}">实际上线版本:</span>{{ item }}</div>
  188. </el-col>
  189. </el-row>
  190. </el-main>
  191. <el-main style="margin: 2%;" class="layout_main requirement_details_layout_main">
  192. <div style="font-size: 18px;margin-bottom: 2%">
  193. <b style="color: #409EFF;">I</b>评论
  194. </div>
  195. <div>
  196. <div v-for="(item,index) in comments" :key="index" class="animated bounceInRight">
  197. <div
  198. style="font-size:14px;color:#333B4A;display: inline-block;"
  199. >{{ item.commentInfo.name }}</div>
  200. <div
  201. style="margin-left:20px;display: inline-block;color: #9B9B9B;font-size:12px"
  202. >{{ item.commentInfo.gmtCreater }}</div>
  203. <p
  204. style="font-size:14px;color:#333B4A;margin-top: 10px;white-space: pre-line;"
  205. >{{ item.commentInfo.content }}</p>
  206. <br>
  207. </div>
  208. <el-input
  209. v-model="commentContent"
  210. type="textarea"
  211. placeholder="请输入评论内容"
  212. maxlength="300"
  213. show-word-limit
  214. :autosize="{ minRows: 3, maxRows: 5}"
  215. style="margin: 2% 0;"
  216. />
  217. <el-button type="primary" size="small" style="float: right" @click="addComment">发表评论</el-button>
  218. </div>
  219. </el-main>
  220. <requirement-update
  221. title="编辑需求"
  222. :data="requirement"
  223. :visible="updateDialogVisible"
  224. :info="searchInfo"
  225. @cancel="updateDialogVisible=false"
  226. @confirm="getRequirementById();updateDialogVisible=false"
  227. />
  228. </el-container>
  229. </template>
  230. <script>
  231. import {
  232. getRequirementById,
  233. showRequirementEnum,
  234. getTaskStatusMapInfo,
  235. getBugStatusMapInfo,
  236. getTaskByRequireId,
  237. deleteRequirement,
  238. updateRequirementStatus,
  239. getCommentList,
  240. addComment
  241. } from '@/api/requirement.js'
  242. import RequirementChart from '@/components/chart/index.vue'
  243. import RequirementUpdate from '@/views/projectManage/requirement/list/create.vue'
  244. export default {
  245. components: {
  246. RequirementChart,
  247. RequirementUpdate
  248. },
  249. props: {
  250. id: {
  251. type: String,
  252. default: '0'
  253. }
  254. },
  255. data() {
  256. return {
  257. loading: {
  258. table: true,
  259. info: true,
  260. task: true,
  261. bug: true
  262. },
  263. radio: '列表',
  264. updateDialogVisible: false,
  265. tableData: null,
  266. statistics: {
  267. task: {
  268. totalCount: 0,
  269. delayCount: 0
  270. },
  271. bug: {
  272. totalCount: 0,
  273. fixInFutureCount: 0
  274. }
  275. },
  276. belongingProject: { msg: '不存在' },
  277. status: {},
  278. requirement: {
  279. name: ''
  280. },
  281. projectOb: {},
  282. bizTypeOb: {},
  283. appClientOb: {},
  284. requirementStatusOb: {},
  285. searchInfo: {
  286. belongingProject: [],
  287. sourceType: [],
  288. bizType: [],
  289. priority: [],
  290. requirementStatus: []
  291. },
  292. taskOption: {
  293. color: ['#69B3FF'],
  294. title: {
  295. show: false
  296. },
  297. tooltip: {
  298. trigger: 'axis',
  299. axisPointer: {
  300. // 坐标轴指示器,坐标轴触发有效
  301. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  302. }
  303. },
  304. grid: {
  305. left: '3%',
  306. right: '4%',
  307. bottom: '0%',
  308. containLabel: true
  309. },
  310. xAxis: [
  311. {
  312. type: 'category',
  313. data: ['未开始', '开发中', '测试中', '已上线'],
  314. axisTick: {
  315. alignWithLabel: true,
  316. show: false
  317. },
  318. axisLine: {
  319. show: true,
  320. lineStyle: {
  321. type: 'dashed'
  322. }
  323. }
  324. }
  325. ],
  326. yAxis: [
  327. {
  328. type: 'value',
  329. axisTick: {
  330. show: false
  331. },
  332. axisLine: {
  333. show: false
  334. },
  335. axisLabel: {
  336. show: false
  337. },
  338. splitLine: {
  339. show: false
  340. }
  341. }
  342. ],
  343. series: [
  344. {
  345. type: 'bar',
  346. barWidth: '60%',
  347. label: {
  348. show: true,
  349. position: 'inside'
  350. },
  351. data: []
  352. }
  353. ]
  354. },
  355. bugOption: {
  356. color: ['#69B3FF'],
  357. title: {
  358. show: false
  359. },
  360. tooltip: {
  361. trigger: 'axis',
  362. axisPointer: {
  363. // 坐标轴指示器,坐标轴触发有效
  364. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  365. }
  366. },
  367. grid: {
  368. left: '3%',
  369. right: '4%',
  370. bottom: '0%',
  371. containLabel: true
  372. },
  373. xAxis: [
  374. {
  375. type: 'category',
  376. data: ['待开发', '开发中', '待测试', '已完成', 'Reopen'],
  377. axisTick: {
  378. alignWithLabel: true,
  379. show: false
  380. },
  381. axisLine: {
  382. show: true,
  383. lineStyle: {
  384. type: 'dashed'
  385. }
  386. }
  387. }
  388. ],
  389. yAxis: [
  390. {
  391. type: 'value',
  392. axisTick: {
  393. show: false
  394. },
  395. axisLine: {
  396. show: false
  397. },
  398. axisLabel: {
  399. show: false
  400. },
  401. splitLine: {
  402. show: false
  403. }
  404. }
  405. ],
  406. series: [
  407. {
  408. type: 'bar',
  409. barWidth: '60%',
  410. label: {
  411. show: true,
  412. position: 'inside'
  413. },
  414. data: []
  415. }
  416. ]
  417. },
  418. comments: [],
  419. commentContent: null,
  420. task: {
  421. reqStartTime: null,
  422. reqEndTime: null,
  423. preOnlineVersion: []
  424. }
  425. }
  426. },
  427. mounted() {
  428. this.showRequirementEnum().then(res => {
  429. this.getRequirementById()
  430. })
  431. this.getTaskStatusMapInfo()
  432. this.getBugStatusMapInfo()
  433. this.getTaskByRequireId()
  434. this.getCommentList()
  435. },
  436. methods: {
  437. getScheduleCollect() {
  438. if (this.task.reqStartTime && this.task.reqEndTime) {
  439. return this.task.reqStartTime.substring(0, 10).replace(/-/, '年').replace(/-/, '月') + '日' + ' ~ ' + this.task.reqEndTime.substring(0, 10).replace(/-/, '年').replace(/-/, '月') + '日'
  440. }
  441. return ''
  442. },
  443. getSchedule(row) {
  444. if (row.beginTime && row.endTime) {
  445. return row.beginTime.substring(2, 10).replace(/-/g, '/') + ' ~ ' + row.endTime.substring(2, 10).replace(/-/g, '/')
  446. }
  447. return '无'
  448. },
  449. getCommentList() {
  450. getCommentList({ type: 4, joinId: this.id }).then(res => {
  451. this.comments = res.data
  452. this.commentContent = ''
  453. })
  454. },
  455. addComment() {
  456. if (!this.commentContent) {
  457. this.$message.warning('评论不能为空')
  458. return
  459. }
  460. const user = localStorage.getItem('username')
  461. addComment({
  462. commentInfo: { joinId: this.id, type: 4, content: this.commentContent },
  463. user: { ename: user }
  464. }).then(res => {
  465. if (res.code === 200) {
  466. this.getCommentList()
  467. } else {
  468. this.$message.warning(res.msg)
  469. }
  470. })
  471. },
  472. getStatusName() {
  473. return this.requirementStatusOb[this.requirement.status]
  474. },
  475. getRequirementById() {
  476. this.loading.info = true
  477. getRequirementById({
  478. id: this.id
  479. }).then(res => {
  480. this.requirement = res.data
  481. this.loading.info = false
  482. })
  483. },
  484. getTaskStatusMapInfo() {
  485. getTaskStatusMapInfo({
  486. requireId: this.id
  487. }).then(res => {
  488. const name = []
  489. const data = []
  490. for (const i in res.data.statusInfoList) {
  491. name.push(res.data.statusInfoList[i].statusString)
  492. data.push(res.data.statusInfoList[i].count)
  493. }
  494. this.statistics.task = res.data
  495. this.taskOption.xAxis[0].data = name
  496. this.taskOption.series[0].data = data
  497. this.taskOption = JSON.parse(JSON.stringify(this.taskOption))
  498. this.loading.task = false
  499. })
  500. },
  501. getBugStatusMapInfo() {
  502. getBugStatusMapInfo({
  503. requireId: this.id
  504. }).then(res => {
  505. const name = []
  506. const data = []
  507. for (const i in res.data.statusInfoList) {
  508. name.push(res.data.statusInfoList[i].statusString)
  509. data.push(res.data.statusInfoList[i].count)
  510. }
  511. this.statistics.bug = res.data
  512. this.bugOption.xAxis[0].data = name
  513. this.bugOption.series[0].data = data
  514. this.bugOption = JSON.parse(JSON.stringify(this.bugOption))
  515. this.loading.bug = false
  516. })
  517. },
  518. getTaskByRequireId() {
  519. getTaskByRequireId({
  520. id: this.id
  521. }).then(res => {
  522. this.task = res.data
  523. this.tableData = res.data.taskDetails
  524. this.loading.table = false
  525. })
  526. },
  527. getPmName() {
  528. const names = []
  529. for (const i in this.requirement.pm) {
  530. names.push(this.requirement.pm[i].name)
  531. }
  532. return names.join(',')
  533. },
  534. getAppClientName() {
  535. const names = []
  536. for (const i in this.requirement.referredClientType) {
  537. names.push(this.appClientOb[this.requirement.referredClientType[i]])
  538. }
  539. return names.join('\n')
  540. },
  541. showRequirementEnum() {
  542. return showRequirementEnum().then(res => {
  543. this.searchInfo = res.data
  544. for (const i in this.searchInfo.belongingProject) {
  545. this.projectOb[
  546. this.searchInfo.belongingProject[i].code
  547. ] = this.searchInfo.belongingProject[i].msg
  548. }
  549. for (const i in this.searchInfo.bizType) {
  550. this.bizTypeOb[
  551. this.searchInfo.bizType[i].code
  552. ] = this.searchInfo.bizType[i].msg
  553. }
  554. for (const i in this.searchInfo.appClient) {
  555. this.appClientOb[
  556. this.searchInfo.appClient[i].code
  557. ] = this.searchInfo.appClient[i].msg
  558. }
  559. for (const i in this.searchInfo.requirementStatus) {
  560. this.requirementStatusOb[
  561. this.searchInfo.requirementStatus[i].code
  562. ] = this.searchInfo.requirementStatus[i].msg
  563. }
  564. })
  565. },
  566. deleteRequirement() {
  567. const user = localStorage.getItem('username')
  568. this.$confirm('此操作将永久删除该需求, 是否继续?', '提示', {
  569. confirmButtonText: '确定',
  570. cancelButtonText: '取消',
  571. type: 'warning'
  572. })
  573. .then(() => {
  574. deleteRequirement({
  575. id: this.id,
  576. modifier: user
  577. }).then(res => {
  578. if (res.code === 200) {
  579. this.$router.push({ name: '需求' })
  580. } else {
  581. this.$message.warning(res.msg)
  582. }
  583. })
  584. })
  585. .catch(() => {})
  586. },
  587. createTask() {},
  588. updateRequirementStatus(status) {
  589. const modifier = localStorage.getItem('username')
  590. updateRequirementStatus({ id: this.id, status: status.code, modifier: modifier }).then(
  591. res => {
  592. if (res.code === 200) {
  593. this.getRequirementById()
  594. } else {
  595. this.$message.warning(res.msg)
  596. }
  597. }
  598. )
  599. },
  600. getQaOrRdNameList(list) {
  601. const arr = []
  602. for (const i in list) {
  603. arr.push(list[i].name)
  604. }
  605. return arr.join(',')
  606. },
  607. getToTaskDetails(id) {
  608. // this.$router.push({ name: '任务', params: { id: id + '' }})
  609. }
  610. }
  611. }
  612. </script>
  613. <style scoped>
  614. .div_requirment_info .el-row .el-col {
  615. margin: 10px 0;
  616. }
  617. .layout_header,
  618. .layout_aside,
  619. .layout_main {
  620. border-radius: 8px;
  621. background-color: #ffffff;
  622. }
  623. .div_statistics > .el-container {
  624. margin: 0;
  625. }
  626. .layout_aside,
  627. .layout_main {
  628. padding: 2%;
  629. }
  630. .layout_header {
  631. line-height: 60px;
  632. }
  633. .requirement_info::before {
  634. height: 0px;
  635. }
  636. </style>
  637. <style>
  638. .requirement_details_layout_main .el-table__body tr:hover td {
  639. color: #409eff;
  640. background: #eef0f5;
  641. } /*hover时字体, 背景颜色*/
  642. </style>