iterationDetails.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. <template>
  2. <el-container class="BackgroundCloth">
  3. <el-header class="public_header">
  4. <div class="Layout_space_between">
  5. <div class="Layout_space_between">
  6. <el-tooltip :disabled="iterationData.name && iterationData.name.length < 19 ? true : false" effect="dark" :content="iterationData.name" placement="bottom">
  7. <span class="themeName">迭代 : {{ iterationData.name | ellipsis }}</span>
  8. </el-tooltip>
  9. <el-select
  10. v-model="iterationData.status"
  11. class="public_botton"
  12. :class="{
  13. 'status_color': iterationData.status === 0,
  14. 'status_color1': iterationData.status === 1,
  15. 'status_color2': iterationData.status === 2
  16. }"
  17. size="mini"
  18. placeholder="请选择"
  19. @change="changeIterationStatus(iterationData.status)"
  20. >
  21. <el-option
  22. v-for="item in statusArr"
  23. :key="item.value"
  24. :label="item.name"
  25. :value="item.value"
  26. />
  27. </el-select>
  28. </div>
  29. <div class="Layout_space_between" style="color: #c4c3c3;">
  30. <el-button size="mini" type="primary" @click="visibleplanning = true">规划迭代</el-button>
  31. <div class="el-icon-setting partition" @click="showIteration = true" />
  32. <div class="el-icon-delete LittleHand" @click="dialogVisible = true" />
  33. </div>
  34. </div>
  35. </el-header>
  36. <el-main class="public_main">
  37. <div class="table-wrap">
  38. <div class="table-box">
  39. <el-table
  40. ref="topicTable"
  41. :data="RequirementSet"
  42. size="small"
  43. row-key="id"
  44. :expand-row-keys="expands"
  45. :header-cell-style="{ color: '#4A4A4A', fontSize: '14px', fontWeight: '550', textAlign: 'center' }"
  46. @row-click="rowClick"
  47. >
  48. <!-- <el-table
  49. ref="planTable"
  50. :data="all_task.data.list"
  51. style="width: 100%;"
  52. :header-cell-style="{ color: '#4A4A4A', fontSize: '14px', fontWeight: '550', textAlign: 'center' }"
  53. show-overflow-tooltip="true"
  54. :show-header="showHeader"
  55. @selection-change="handleSelectionChange"
  56. > -->
  57. <el-table-column min-width="30">
  58. <img style="display: inline-block; width: 14px; vertical-align: middle;" :src="image_role">
  59. </el-table-column>
  60. <el-table-column type="selection" min-width="30" align="center" />
  61. <el-table-column type="expand" min-width="25" label-class-name="use">
  62. <template slot-scope="props">
  63. <el-table
  64. :data="tableData"
  65. size="small"
  66. row-key="id"
  67. align="left"
  68. :header-cell-style="{ color: '#4A4A4A', fontSize: '14px', fontWeight: '550', textAlign: 'center' }"
  69. >
  70. <el-table-column label="优先级">
  71. <span>{{ props.row.priorityName }}</span>
  72. </el-table-column>
  73. <el-table-column label="需求名称">
  74. <span>{{ props.row.name }}</span>
  75. </el-table-column>
  76. </el-table>
  77. </template>
  78. </el-table-column>
  79. <!-- <el-table-column min-width="20" align="center">
  80. <div class="el-icon-plus" />
  81. </el-table-column> -->
  82. <el-table-column label="优先级" min-width="80" align="center">
  83. <template v-slot="scope">
  84. <div align="center">
  85. <div
  86. class="iteration_back"
  87. :class="{
  88. 'priority_color': scope.row.priority === 0,
  89. 'priority_color1': scope.row.priority === 1,
  90. 'priority_color2': scope.row.priority === 2,
  91. 'priority_color3': scope.row.priority === 3,
  92. 'priority_color4': scope.row.priority === 4,
  93. 'priority_color5': scope.row.priority === 5,
  94. 'priority_color6': scope.row.priority === 6
  95. }"
  96. >
  97. {{ scope.row.priorityName }}
  98. </div>
  99. </div>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="需求名称" min-width="250" show-overflow-tooltip align="left">
  103. <template v-slot="scope">
  104. {{ scope.row.name }}
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="状态" min-width="100" show-overflow-tooltip align="center">
  108. <template v-slot="scope">
  109. <el-select
  110. v-model="scope.row.status"
  111. :class="{
  112. 'status_color': scope.row.status === 0,
  113. 'status_color1': scope.row.status === 1,
  114. 'status_color3': scope.row.status === 3,
  115. 'status_color4': scope.row.status === 5,
  116. 'status_color2': scope.row.status === 9
  117. }"
  118. class="public_botton"
  119. size="mini"
  120. @change="updateRequirementStatus(scope.row)"
  121. >
  122. <el-option v-for="item in requiredArray" :key="item.code" :label="item.msg" :value="item.code" />
  123. </el-select>
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="PM" min-width="100" show-overflow-tooltip align="center">
  127. <template v-slot="scope">
  128. {{ scope.row.name }}
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="需求来源" min-width="100" show-overflow-tooltip align="center">
  132. <template v-slot="scope">
  133. {{ scope.row.belongingProjectName }}
  134. </template>
  135. </el-table-column>
  136. <el-table-column label="跟版客户端" min-width="100" show-overflow-tooltip align="center">
  137. <template v-slot="scope">
  138. {{ scope.row.belongingProjectName }}
  139. </template>
  140. </el-table-column>
  141. <el-table-column label="PRD链接" min-width="100" show-overflow-tooltip align="center">
  142. <template v-slot="scope">
  143. {{ scope.row.mrdUrl }}
  144. </template>
  145. </el-table-column>
  146. </el-table>
  147. </div>
  148. </div>
  149. </el-main>
  150. <el-footer class="public_footer" />
  151. <!-- 删除 dialog -->
  152. <iteration-delete :show.sync="dialogVisible" :iteration-id="iterationId" />
  153. <!-- 迭代配置 dialog -->
  154. <iteration-create title="迭代配置" width="60%" :show.sync="showIteration" :iterations="iterationData" @iteratioFilter="iteratioFilter" />
  155. <!-- 规划迭代 dialog -->
  156. <planning-iteration :show.sync="visibleplanning" :iteration-id="iterationId" />
  157. </el-container>
  158. </template>
  159. <script>
  160. import '@/styles/PublicStyle/index.scss'
  161. import iterationDelete from '@/views/projectManage/iteration/components/delete.vue'
  162. import iterationCreate from '@/views/projectManage/iteration/components/create.vue'
  163. import planningIteration from '@/views/projectManage/iteration/components/PlanningIteration.vue'
  164. import Sortable from 'sortablejs'
  165. import image_role from '@/assets/麻将@2x.png'
  166. import { iterationList, iterationUpdate, iterationRequire } from '@/api/iteration.js'
  167. import { showRequirementEnum, updateRequirementStatus } from '@/api/requirement.js'
  168. export default {
  169. components: {
  170. iterationDelete,
  171. iterationCreate,
  172. planningIteration
  173. },
  174. filters: {
  175. ellipsis(value) {
  176. if (!value) return ''
  177. if (value.length > 20) {
  178. return value.slice(0, 20) + '...'
  179. }
  180. return value
  181. }
  182. },
  183. data() {
  184. return {
  185. image_role: image_role,
  186. statusArr: [{ value: 0, name: '未开始' }, { value: 1, name: '进行中' }, { value: 2, name: '已完成' }],
  187. dialogVisible: false, // 删除(弹窗)
  188. showIteration: false, // 编辑迭代(弹窗)
  189. visibleplanning: false, // 规划迭代(弹窗)
  190. requiredArray: [], // 需求状态
  191. tableData: [
  192. {
  193. id: '1',
  194. priority: 2,
  195. priorityName: 'P2',
  196. status: 0,
  197. name: '赵捷',
  198. mrdUrl: 'www.baidu.com',
  199. belongingProjectName: '上海市普陀区金沙江路 101 弄'
  200. },
  201. {
  202. id: '2',
  203. priority: 1,
  204. priorityName: 'P1',
  205. status: 0,
  206. name: '秦志鹏',
  207. mrdUrl: 'www.baidu.com',
  208. belongingProjectName: '上海市普陀区金沙江路 102 弄'
  209. },
  210. {
  211. id: '3',
  212. priority: 1,
  213. priorityName: 'P1',
  214. status: 0,
  215. name: '廖子君',
  216. mrdUrl: 'www.baidu.com',
  217. belongingProjectName: '上海市普陀区金沙江路 103 弄'
  218. },
  219. {
  220. id: '4',
  221. priority: 1,
  222. priorityName: 'P1',
  223. status: 0,
  224. name: '王子乾',
  225. mrdUrl: 'www.baidu.com',
  226. belongingProjectName: '上海市普陀区金沙江路 104 弄'
  227. }
  228. ],
  229. expands: [],
  230. RequirementSet: [], // 迭代下的需求
  231. iterationId: this.$route.query.id, // 当前迭代的id
  232. iterationData: {}
  233. }
  234. },
  235. mounted() {
  236. this.iteratioFilter()
  237. this.rowDrop()
  238. this.setLabel()
  239. },
  240. methods: {
  241. async iteratioFilter() {
  242. const list = iterationList({ id: this.iterationId, curIndex: 1, pageSize: 15 })
  243. const requiredList = iterationRequire({ id: Number(this.iterationId), curIndex: 1, pageSize: 50 })
  244. const requirementEnum = showRequirementEnum()
  245. const listRes = await list
  246. const listRequire = await requiredList
  247. const requiredstatus = await requirementEnum
  248. this.iterationData = listRes.data.list[0]
  249. this.RequirementSet = listRequire.data.right.list
  250. this.requiredArray = requiredstatus.data.requirementStatus
  251. },
  252. changeIterationStatus(e) { // 修改状态
  253. iterationUpdate({ status: e, id: this.iterationData.id, name: this.iterationData.name }).then(res => {
  254. this.$message({ showClose: true, message: res.msg, type: 'success' })
  255. this.iteratioFilter()
  256. })
  257. },
  258. setLabel() {
  259. const _this = this
  260. this.$nextTick(() => {
  261. const cellDiv = document.getElementsByClassName('cell use')[0]
  262. cellDiv.setAttribute('style', 'cursor:pointer')
  263. const node = document.createElement('i')
  264. node.setAttribute('class', 'el-icon el-icon-arrow-right')
  265. node.setAttribute('id', 'ICON')
  266. node.setAttribute('isExpand', 'no') // 设置属性is-expand的值
  267. node.onclick = function() {
  268. // eslint-disable-next-line no-useless-call
  269. _this.cellDivClick.call(_this, node)
  270. }
  271. cellDiv.appendChild(node)
  272. })
  273. },
  274. updateRequirementStatus(val) {
  275. console.log(val, 'ddddd')
  276. const modifier = localStorage.getItem('username')
  277. updateRequirementStatus({ id: val.id, status: val.status, modifier: modifier }).then(res => {
  278. if (res.code === 200) {
  279. this.iteratioFilter()
  280. } else {
  281. this.$message.warning(res.msg)
  282. }
  283. }
  284. )
  285. },
  286. cellDivClick(ele) {
  287. console.log(ele)
  288. const expandState = ele.getAttribute('isExpand') // 获取属性is-expand的值
  289. // 关闭的情况点击
  290. if (expandState === 'no') {
  291. // 展开
  292. const $table = this.$refs.topicTable
  293. $table.data.map(item => {
  294. $table.toggleRowExpansion(item, true)
  295. })
  296. ele.setAttribute('class', 'el-icon el-icon-arrow-down')
  297. ele.setAttribute('isExpand', 'yes')
  298. } else if (expandState === 'yes') {
  299. // 展开的情况点击关闭
  300. const $table = this.$refs.topicTable
  301. $table.data.map(item => {
  302. $table.toggleRowExpansion(item, false)
  303. })
  304. ele.setAttribute('class', 'el-icon el-icon-arrow-right')
  305. ele.setAttribute('isExpand', 'no')
  306. }
  307. },
  308. // 在<table>里,我们已经设置row的key值设置为每行数据id:row-key="id"
  309. rowClick(row, event, column) {
  310. console.log(row, event, column, 'cdcscsccc')
  311. if (this.expands.indexOf(row.id) < 0) {
  312. this.expands = ['1', '2', '3', '4']
  313. } else {
  314. this.expands = []
  315. }
  316. console.log(this.expands, 'dsc')
  317. },
  318. // 行拖拽
  319. rowDrop() {
  320. const tbody = document.querySelector('.el-table__body-wrapper tbody')
  321. const _this = this
  322. Sortable.create(tbody, {
  323. onEnd({ newIndex, oldIndex }) {
  324. const currRow = _this.tableData.splice(oldIndex, 1)[0]
  325. _this.tableData.splice(newIndex, 0, currRow)
  326. }
  327. })
  328. }
  329. }
  330. }
  331. </script>
  332. <style scoped lang="scss">
  333. .BackgroundCloth {
  334. .themeName {
  335. font-size: 20px;
  336. font-family: MicrosoftYaHei;
  337. color: rgb(51, 59, 74);
  338. white-space: nowrap;
  339. padding: 0 15px;
  340. }
  341. .el-header {
  342. padding: 20px;
  343. }
  344. .iteration_back {
  345. border-radius: 4px;
  346. width: 33px;
  347. color: #FFF;
  348. }
  349. .partition {
  350. border-left: 1px solid #c4c3c3;
  351. border-right: 1px solid #c4c3c3;
  352. line-height: 26px;
  353. width: 35px;
  354. text-align: center;
  355. margin: 0 10px;
  356. cursor: pointer;
  357. }
  358. .LittleHand {
  359. cursor: pointer;
  360. }
  361. }
  362. </style>