scheduleList.vue 7.0 KB

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