scheduleList.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <div class="schedule-list" :class="className">
  3. <el-table
  4. :id="'schedule-'+id"
  5. :data="scheduleList"
  6. :header-cell-style="{ backgroundColor: 'rgba(232,232,232,0.4)', color: 'rgb(74, 74, 74)', fontSize: '14px', fontWeight: '500'}"
  7. style="width: 100%"
  8. show-overflow-tooltip="true"
  9. row-key="id"
  10. border
  11. stripe
  12. size="mini"
  13. >
  14. <el-table-column
  15. width="80"
  16. >
  17. <template>
  18. <el-tooltip class="item" effect="dark" content="代表移动,鼠标选中区域可以向上移动" placement="bottom">
  19. <div class="sortable-tip">
  20. <img :src="move">
  21. </div>
  22. </el-tooltip>
  23. </template>
  24. </el-table-column>
  25. <el-table-column
  26. prop="type"
  27. label="类型"
  28. width="100"
  29. >
  30. <template slot-scope="scope">
  31. {{ scope.row.name }}
  32. <div v-show="showunlock" :class="scope.row.isScheduleLocked === 0 ? 'el-icon-unlock' : 'el-icon-lock'" />
  33. </template>
  34. </el-table-column>
  35. <el-table-column
  36. prop="desc"
  37. label="描述"
  38. min-width="150"
  39. align="left"
  40. show-overflow-tooltip
  41. />
  42. <el-table-column
  43. prop="seperateDaysNoHoliday"
  44. label="排期"
  45. min-width="100"
  46. show-overflow-tooltip
  47. />
  48. <el-table-column
  49. prop="dayLength"
  50. label="时长"
  51. width="50"
  52. />
  53. <el-table-column
  54. prop="peopleList"
  55. label="参与人员"
  56. min-width="100"
  57. />
  58. <el-table-column
  59. label="关联任务"
  60. min-width="100"
  61. >
  62. <template slot-scope="scope">
  63. <el-popover
  64. placement="bottom"
  65. title="关联的任务"
  66. width="450"
  67. trigger="click"
  68. popper-class="synchronize"
  69. >
  70. <div class="blueStr" />
  71. <div class="task-object-list">
  72. <template v-for="(item,index) in scope.row.taskObjectList">
  73. <div v-if="index<5" :key="'task-object'+index" class="task-item" @click="link(item.id)">
  74. <span class="item-id">{{ item.taskId }}</span>
  75. <span class="item-name">{{ item.name }}</span>
  76. <span>{{ item.moduleInfoName }}</span>
  77. </div>
  78. </template>
  79. </div>
  80. <div v-if="scope.row.taskObjectList" slot="reference" class="point-blue">{{ scope.row.taskObjectList.length }}</div>
  81. </el-popover>
  82. </template>
  83. </el-table-column>
  84. <el-table-column
  85. label="操作"
  86. width="200"
  87. show-overflow-tooltip
  88. >
  89. <template slot-scope="scope">
  90. <div v-if="showunlock">
  91. <el-button v-if="scope.row.isScheduleLocked === 0" type="text" size="small" @click="editSchedule(scope.row)">编辑</el-button>
  92. <el-button v-if="scope.row.isScheduleLocked === 0" type="text" size="small" @click="deleteSchedule(scope.row)">删除</el-button>
  93. </div>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. <div class="bottom-detail">
  98. <el-row>交付日期:{{ scheduleDetail.endTime }}</el-row>
  99. <el-row>排期:{{ scheduleDetail.startTime | handlerDate }} ~ {{ scheduleDetail.endTime | handlerDate }}</el-row>
  100. <el-row v-if="scheduleDetail.preOnlineVersion && scheduleDetail.preOnlineVersion.length>0">
  101. <el-col :span="2">预计上线版本:</el-col>
  102. <el-col :span="6">
  103. <span v-for="item in scheduleDetail.preOnlineVersion" :key="item">{{ item }}</span><br>
  104. </el-col>
  105. </el-row>
  106. <el-row v-else>预计上线版本:</el-row>
  107. </div>
  108. <modify-schedule
  109. v-if="visibleSchedule"
  110. :visible.sync="visibleSchedule"
  111. :is-delete.sync="isDelete"
  112. :detail-data="detailData"
  113. :title="DialogTitle"
  114. @update="listByTask(id)"
  115. />
  116. </div>
  117. </template>
  118. <script>
  119. import Sortable from 'sortablejs'
  120. import moment from 'moment'
  121. import 'moment/locale/zh-cn'
  122. import { listByTask, sortForTask } from '@/api/projectViewDetails'
  123. import modifySchedule from './modifySchedule'
  124. import move from '@/assets/麻将@2x.png'
  125. export default {
  126. components: {
  127. modifySchedule
  128. },
  129. filters: {
  130. handlerDate(val) {
  131. return val ? moment(val).format('YYYY-MM-DD') : ''
  132. }
  133. },
  134. props: {
  135. id: {
  136. type: Number,
  137. default: NaN,
  138. required: true
  139. },
  140. typeList: {
  141. type: Array,
  142. default: () => [],
  143. required: false
  144. },
  145. className: {
  146. type: String,
  147. default: '',
  148. required: false
  149. },
  150. showunlock: {
  151. type: Boolean,
  152. default: false,
  153. required: false
  154. }
  155. },
  156. data() {
  157. return {
  158. move: move,
  159. scheduleList: [],
  160. scheduleDetail: {},
  161. visibleSchedule: false,
  162. detailData: null,
  163. taskScheduleEvent: [], // 排期类型
  164. DialogTitle: '新建排期',
  165. isDelete: false // 删除排期操作
  166. }
  167. },
  168. watch: {
  169. id: {
  170. handler(newV, oldV) {
  171. this.$nextTick(() => {
  172. this.listByTask(newV)
  173. })
  174. },
  175. immediate: true
  176. },
  177. typeList: {
  178. handler(newV, oldV) {
  179. this.scheduleList = newV
  180. this.taskScheduleEvent = newV
  181. },
  182. immediate: true
  183. }
  184. },
  185. mounted() {
  186. this.rowDrop()
  187. },
  188. methods: {
  189. rowDrop() {
  190. const tbody = document.querySelector(`#schedule-${this.id} tbody`)
  191. const _this = this
  192. Sortable.create(tbody, {
  193. onEnd({ newIndex, oldIndex }) {
  194. const currRow = _this.scheduleList.splice(oldIndex, 1)[0]
  195. _this.scheduleList.splice(newIndex, 0, currRow)
  196. _this.sortForTask(_this.scheduleList.map(item => item.id))
  197. }
  198. })
  199. },
  200. async sortForTask(arr) {
  201. const res = await sortForTask(this.id, arr)
  202. if (res.code === 200) {
  203. this.$message({ message: '移动成功', type: 'success', duration: 1000, offset: 150 })
  204. }
  205. },
  206. // getType(value) {
  207. // const res = this.taskScheduleEvent.find(item => item.code === value) || {}
  208. // return res.msg
  209. // },
  210. async listByTask(id) { // 获取排期列表
  211. const res = await listByTask(id)
  212. if (res.code === 200) {
  213. this.scheduleList = res.data.scheduleDetailRespons || []
  214. this.scheduleDetail = res.data || {}
  215. this.scheduleList = this.scheduleList.map(item => ({
  216. ...item,
  217. peopleList: item.peopleObjectList.map(item => item.name).join(',')
  218. }))
  219. this.$emit('updataData')
  220. }
  221. },
  222. addSchedule() {
  223. this.detailData = null
  224. this.DialogTitle = '新建排期'
  225. this.visibleSchedule = true
  226. },
  227. deleteSchedule(row) { // 删除排期
  228. this.DialogTitle = '删除排期'
  229. this.isDelete = true
  230. this.visibleSchedule = true
  231. this.detailData = row
  232. },
  233. editSchedule(row) { // 编辑排期
  234. this.DialogTitle = '编辑排期'
  235. this.visibleSchedule = true
  236. this.detailData = row
  237. },
  238. link(id) {
  239. const newTab = this.$router.resolve({ name: '任务详情', query: { id: id }})
  240. window.open(newTab.href, '_blank')
  241. }
  242. }
  243. }
  244. </script>
  245. <style lang="scss" scoped>
  246. .add-schedule {
  247. cursor: pointer;
  248. color: #409EFF;
  249. font-size: 14px;
  250. width: calc(100% - 40px);
  251. margin: 0 20px;
  252. padding: 20px 0;
  253. i {
  254. margin-right: 4px;
  255. }
  256. span {
  257. margin-right: 20px;
  258. }
  259. }
  260. .schedule-list {
  261. width: calc(100% - 40px);
  262. margin: 0 20px;
  263. padding: 0;
  264. }
  265. >>>.el-table, .el-table__expanded-cell{
  266. background:rgba(248,248,248,0.6);
  267. }
  268. .white {
  269. background: #ffffff;
  270. .add-schedule {
  271. padding: 0 0 20px 0;
  272. }
  273. /deep/.el-table{
  274. background: #ffffff !important;
  275. }
  276. }
  277. .bottom-detail {
  278. font-size: 14px;
  279. width: calc(100% - 40px);
  280. margin: 0 20px;
  281. padding: 20px 0;
  282. :nth-child(2) {
  283. margin: 10px 0;
  284. }
  285. }
  286. .sortable-tip {
  287. height: 26px;
  288. width: 15px;
  289. border-radius:2px;
  290. margin: auto;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. img {
  295. width: 8px;
  296. }
  297. }
  298. .point-blue {
  299. cursor: pointer;
  300. color: #409EFF;
  301. }
  302. .task-object-list {
  303. width: 100%;
  304. overflow: scroll;
  305. .task-item {
  306. width: 100%;
  307. white-space: nowrap;
  308. color: #999999;
  309. margin-bottom: 5px;
  310. .item-id {
  311. padding-right: 20px;
  312. }
  313. .item-name {
  314. color: #333333;
  315. padding-right: 20px;
  316. }
  317. }
  318. }
  319. .task-object-list::-webkit-scrollbar {
  320. display: none;
  321. }
  322. </style>
  323. <style lang="scss">
  324. .synchronize {
  325. .el-popover__title {
  326. color: #333333;
  327. padding: 10px 20px;
  328. }
  329. }
  330. .blueStr {
  331. width:4px;
  332. height:17px;
  333. background:#409EFF;
  334. border-radius:1px;
  335. position: absolute;
  336. top: 22px;
  337. left: 15px;
  338. }
  339. .el-tooltip__popper.is-dark {
  340. background:rgba(121,132,150,0.8);
  341. color: #FFF;
  342. }
  343. </style>