scheduleList.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div class="schedule-list" :class="className">
  3. <!-- <el-col align="right" class="add-schedule"><span @click="addSchedule()"><i class="el-icon-circle-plus-outline" />添加排期</span></el-col> -->
  4. <el-table
  5. :id="'schedule-'+id"
  6. :data="scheduleList"
  7. :header-cell-style="{ backgroundColor: 'rgba(232,232,232,0.4)', color: 'rgb(74, 74, 74)', fontSize: '14px', fontWeight: '500'}"
  8. :row-style="{'background-color': 'transparent'}"
  9. style="width: 100%"
  10. show-overflow-tooltip="true"
  11. row-key="id"
  12. >
  13. <el-table-column
  14. width="80"
  15. align="center"
  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. align="center"
  30. >
  31. <template slot-scope="scope">
  32. {{ scope.row.name }}
  33. <img class="public_image" :src="scope.row.isScheduleLocked === 0 ? Unlock : lock">
  34. </template>
  35. </el-table-column>
  36. <el-table-column
  37. prop="desc"
  38. label="描述"
  39. min-width="150"
  40. align="left"
  41. show-overflow-tooltip
  42. />
  43. <el-table-column
  44. prop="seperateDaysNoHoliday"
  45. label="排期"
  46. min-width="200"
  47. align="center"
  48. show-overflow-tooltip
  49. />
  50. <el-table-column
  51. prop="dayLength"
  52. label="时长"
  53. width="50"
  54. align="center"
  55. />
  56. <el-table-column
  57. prop="peopleList"
  58. label="参与人员"
  59. min-width="100"
  60. align="center"
  61. />
  62. <el-table-column
  63. label="操作"
  64. width="200"
  65. align="center"
  66. show-overflow-tooltip
  67. >
  68. <template slot-scope="scope">
  69. <el-button v-if="scope.row.isScheduleLocked === 0" type="text" size="small" @click="editSchedule(scope.row)">编辑</el-button>
  70. <el-button v-if="scope.row.isScheduleLocked === 0" type="text" size="small" @click="deleteSchedule(scope.row)">删除</el-button>
  71. </template>
  72. </el-table-column>
  73. </el-table>
  74. <div class="bottom-detail">
  75. <el-row>排期总汇:{{ scheduleDetail.startTime | handlerDate }} ~ {{ scheduleDetail.endTime | handlerDate }}</el-row>
  76. <el-row v-if="scheduleDetail.preOnlineVersion && scheduleDetail.preOnlineVersion.length>0">
  77. <el-col :span="2">预计上线版本:</el-col>
  78. <el-col :span="6">
  79. <span v-for="item in scheduleDetail.preOnlineVersion" :key="item">{{ item }}</span><br>
  80. </el-col>
  81. </el-row>
  82. <el-row v-else>预计上线版本:</el-row>
  83. </div>
  84. <modify-schedule
  85. v-if="visibleSchedule"
  86. :visible.sync="visibleSchedule"
  87. :is-delete.sync="isDelete"
  88. :detail-data="detailData"
  89. :title="DialogTitle"
  90. @update="listByTask(id)"
  91. />
  92. </div>
  93. </template>
  94. <script>
  95. import Sortable from 'sortablejs'
  96. import moment from 'moment'
  97. import 'moment/locale/zh-cn'
  98. import { listByTask, sortForTask } from '@/api/projectViewDetails'
  99. import modifySchedule from './modifySchedule'
  100. import move from '@/assets/麻将@2x.png'
  101. import lock from '@/assets/lock.png' // 排期锁定图标
  102. import Unlock from '@/assets/Unlock.png' // 排期锁定图标
  103. export default {
  104. components: {
  105. modifySchedule
  106. },
  107. filters: {
  108. handlerDate(val) {
  109. return val ? moment(val).format('YYYY-MM-DD') : ''
  110. }
  111. },
  112. props: {
  113. id: {
  114. type: Number,
  115. default: NaN,
  116. required: true
  117. },
  118. typeList: {
  119. type: Array,
  120. default: () => [],
  121. required: false
  122. },
  123. className: {
  124. type: String,
  125. default: '',
  126. required: false
  127. }
  128. },
  129. data() {
  130. return {
  131. Unlock: Unlock, // 解锁排期
  132. lock: lock, // 锁定排期
  133. move: move,
  134. scheduleList: [],
  135. scheduleDetail: {},
  136. visibleSchedule: false,
  137. detailData: null,
  138. taskScheduleEvent: [], // 排期类型
  139. DialogTitle: '新建排期',
  140. isDelete: false // 删除排期操作
  141. }
  142. },
  143. watch: {
  144. id: {
  145. handler(newV, oldV) {
  146. this.listByTask(newV)
  147. },
  148. immediate: true
  149. },
  150. typeList: {
  151. handler(newV, oldV) {
  152. this.scheduleList = newV
  153. this.taskScheduleEvent = newV
  154. },
  155. immediate: true
  156. }
  157. },
  158. mounted() {
  159. this.rowDrop()
  160. },
  161. methods: {
  162. rowDrop() {
  163. const tbody = document.querySelector(`#schedule-${this.id} tbody`)
  164. const _this = this
  165. Sortable.create(tbody, {
  166. onEnd({ newIndex, oldIndex }) {
  167. const currRow = _this.scheduleList.splice(oldIndex, 1)[0]
  168. _this.scheduleList.splice(newIndex, 0, currRow)
  169. _this.sortForTask(_this.scheduleList.map(item => item.id))
  170. }
  171. })
  172. },
  173. async sortForTask(arr) {
  174. const res = await sortForTask(this.id, arr)
  175. if (res.code === 200) {
  176. this.$message({ message: '移动成功', type: 'success', duration: 1000, offset: 150 })
  177. }
  178. },
  179. // getType(value) {
  180. // const res = this.taskScheduleEvent.find(item => item.code === value) || {}
  181. // return res.msg
  182. // },
  183. async listByTask(id) { // 获取排期列表
  184. const res = await listByTask(id)
  185. if (res.code === 200) {
  186. this.scheduleList = res.data.schedulDetailResponses
  187. this.scheduleDetail = res.data || {}
  188. this.scheduleList = this.scheduleList.map(item => ({
  189. ...item,
  190. peopleList: item.peopleObjectList.map(item => item.name).join(',')
  191. }))
  192. }
  193. },
  194. addSchedule() {
  195. this.detailData = null
  196. this.DialogTitle = '新建排期'
  197. this.visibleSchedule = true
  198. },
  199. deleteSchedule(row) { // 删除排期
  200. this.DialogTitle = '删除排期'
  201. this.isDelete = true
  202. this.visibleSchedule = true
  203. this.detailData = row
  204. },
  205. editSchedule(row) { // 编辑排期
  206. this.DialogTitle = '编辑排期'
  207. this.visibleSchedule = true
  208. this.detailData = row
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss" scoped>
  214. .add-schedule {
  215. cursor: pointer;
  216. color: #409EFF;
  217. font-size: 14px;
  218. width: calc(100% - 40px);
  219. margin: 0 20px;
  220. padding: 20px 0;
  221. i {
  222. margin-right: 4px;
  223. }
  224. span {
  225. margin-right: 20px;
  226. }
  227. }
  228. .schedule-list {
  229. width: calc(100% - 40px);
  230. margin: 0 20px;
  231. padding: 0;
  232. background:rgba(248,248,248,0.6);
  233. }
  234. >>>.el-table, .el-table__expanded-cell{
  235. background:rgba(248,248,248,0.6);
  236. }
  237. .white {
  238. background: #ffffff;
  239. .add-schedule {
  240. padding: 0 0 20px 0;
  241. }
  242. /deep/.el-table{
  243. background: #ffffff !important;
  244. }
  245. }
  246. .bottom-detail {
  247. font-size: 14px;
  248. width: calc(100% - 40px);
  249. margin: 0 20px;
  250. padding: 20px 0;
  251. :first-child {
  252. margin-bottom: 10px;
  253. }
  254. }
  255. .sortable-tip {
  256. height: 26px;
  257. width: 15px;
  258. border-radius:2px;
  259. margin: auto;
  260. display: flex;
  261. justify-content: center;
  262. align-items: center;
  263. img {
  264. width: 8px;
  265. }
  266. }
  267. </style>
  268. <style>
  269. .el-tooltip__popper.is-dark {
  270. background:rgba(121,132,150,0.8);
  271. color: #FFF;
  272. }
  273. </style>