scheduleList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. v-if="noMove"
  15. width="80"
  16. align="center"
  17. >
  18. <template>
  19. <el-tooltip class="item" effect="dark" content="代表移动,鼠标选中区域可以向上移动" placement="bottom">
  20. <div class="sortable-tip">
  21. <img :src="move">
  22. </div>
  23. </el-tooltip>
  24. </template>
  25. </el-table-column>
  26. <el-table-column
  27. prop="type"
  28. label="类型"
  29. width="100"
  30. align="center"
  31. >
  32. <template slot-scope="scope">
  33. {{ getType(scope.row.type) }}
  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 type="text" size="small" @click="editSchedule(scope.row)">编辑</el-button>
  70. <el-button 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" style="width: 100px">预计上线版本:</el-col>
  78. <el-col :span="6">
  79. <span v-for="item in scheduleDetail.preOnlineVersion" :key="item">{{ item }}<br></span>
  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 { listByRequire } from '@/api/requirement.js'
  99. import { listByTask, sortForTask } from '@/api/projectViewDetails'
  100. import modifySchedule from './modifySchedule'
  101. import move from '@/assets/麻将@2x.png'
  102. export default {
  103. components: {
  104. modifySchedule
  105. },
  106. filters: {
  107. handlerDate(val) {
  108. return val ? moment(val).format('YYYY-MM-DD') : ''
  109. }
  110. },
  111. props: {
  112. id: {
  113. type: Number,
  114. default: NaN,
  115. required: true
  116. },
  117. all: {
  118. type: Boolean,
  119. default: false,
  120. required: false
  121. },
  122. typeList: {
  123. type: Array,
  124. default: () => [],
  125. required: false
  126. },
  127. className: {
  128. type: String,
  129. default: '',
  130. required: false
  131. },
  132. noMove: {
  133. type: Boolean,
  134. default: true,
  135. required: false
  136. }
  137. },
  138. data() {
  139. return {
  140. move: move,
  141. scheduleList: [],
  142. scheduleDetail: {},
  143. visibleSchedule: false,
  144. detailData: null,
  145. taskScheduleEvent: [], // 排期类型
  146. DialogTitle: '新建排期',
  147. isDelete: false // 删除排期操作
  148. }
  149. },
  150. watch: {
  151. id: {
  152. handler(newV, oldV) {
  153. this.listByTask(newV)
  154. },
  155. immediate: true
  156. },
  157. typeList: {
  158. handler(newV, oldV) {
  159. this.taskScheduleEvent = newV
  160. },
  161. immediate: true
  162. }
  163. },
  164. mounted() {
  165. this.rowDrop()
  166. },
  167. methods: {
  168. rowDrop() {
  169. const tbody = document.querySelector(`#schedule-${this.id} tbody`)
  170. const _this = this
  171. Sortable.create(tbody, {
  172. onEnd({ newIndex, oldIndex }) {
  173. const currRow = _this.scheduleList.splice(oldIndex, 1)[0]
  174. _this.scheduleList.splice(newIndex, 0, currRow)
  175. _this.sortForTask(_this.scheduleList.map(item => item.id))
  176. }
  177. })
  178. },
  179. async sortForTask(arr) {
  180. const res = await sortForTask(this.id, arr)
  181. if (res.code === 200) {
  182. this.$message({ message: '移动成功', type: 'success', duration: 1000, offset: 150 })
  183. }
  184. },
  185. getType(value) {
  186. const res = this.taskScheduleEvent.find(item => item.code === value) || {}
  187. return res.msg
  188. },
  189. async listByTask(id) { // 获取排期列表
  190. const res = this.all ? await listByRequire(id) : await listByTask(id)
  191. if (res.code === 200) {
  192. this.scheduleList = res.data.schedulDetailResponses
  193. this.scheduleDetail = res.data || {}
  194. this.scheduleList = this.scheduleList.map(item => ({
  195. ...item,
  196. peopleList: item.peopleObjectList.map(item => item.name).join(',')
  197. }))
  198. }
  199. },
  200. addSchedule() {
  201. this.detailData = null
  202. this.DialogTitle = '新建排期'
  203. this.visibleSchedule = true
  204. },
  205. deleteSchedule(row) { // 删除排期
  206. this.DialogTitle = '删除排期'
  207. this.isDelete = true
  208. this.visibleSchedule = true
  209. this.detailData = row
  210. },
  211. editSchedule(row) { // 编辑排期
  212. this.DialogTitle = '编辑排期'
  213. this.visibleSchedule = true
  214. this.detailData = row
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. .add-schedule {
  221. cursor: pointer;
  222. color: #409EFF;
  223. font-size: 14px;
  224. width: calc(100% - 40px);
  225. margin: 0 20px;
  226. padding: 20px 0;
  227. i {
  228. margin-right: 4px;
  229. }
  230. span {
  231. margin-right: 20px;
  232. }
  233. }
  234. .schedule-list {
  235. width: calc(100% - 40px);
  236. margin: 0 20px;
  237. padding: 0;
  238. background:rgba(248,248,248,0.6);
  239. }
  240. >>>.el-table, .el-table__expanded-cell{
  241. background:rgba(248,248,248,0.6);
  242. }
  243. .white {
  244. background: #ffffff;
  245. .add-schedule {
  246. padding: 0 0 20px 0;
  247. }
  248. /deep/.el-table{
  249. background: #ffffff !important;
  250. }
  251. }
  252. .bottom-detail {
  253. font-size: 14px;
  254. width: calc(100% - 40px);
  255. margin: 0 20px;
  256. padding: 20px 0;
  257. :first-child {
  258. margin-bottom: 10px;
  259. }
  260. }
  261. .sortable-tip {
  262. height: 26px;
  263. width: 15px;
  264. border-radius:2px;
  265. margin: auto;
  266. justify-content: center;
  267. align-items: center;
  268. img {
  269. width: 8px;
  270. }
  271. }
  272. </style>
  273. <style>
  274. .el-tooltip__popper.is-dark {
  275. background:rgba(121,132,150,0.8);
  276. color: #FFF;
  277. }
  278. </style>