scheduleList.vue 7.1 KB

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