scheduleList.vue 6.9 KB

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