scheduleList.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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 '@/views/projectManage/projectList/components/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: -1,
  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. if (newV === -1) return
  134. this.listByTask(newV)
  135. },
  136. immediate: true
  137. },
  138. requiredList: {
  139. handler(newV, oldV) {
  140. this.scheduleList = newV
  141. },
  142. immediate: true
  143. },
  144. typeList: {
  145. handler(newV, oldV) {
  146. this.taskScheduleEvent = newV
  147. },
  148. immediate: true
  149. }
  150. },
  151. mounted() {
  152. this.rowDrop()
  153. },
  154. methods: {
  155. rowDrop() {
  156. const tbody = document.querySelector(`#schedule-${this.id} tbody`)
  157. const _this = this
  158. Sortable.create(tbody, {
  159. onEnd({ newIndex, oldIndex }) {
  160. const currRow = _this.scheduleList.splice(oldIndex, 1)[0]
  161. _this.scheduleList.splice(newIndex, 0, currRow)
  162. _this.sortForTask(_this.scheduleList.map(item => item.id))
  163. }
  164. })
  165. },
  166. async sortForTask(arr) {
  167. const res = await sortForTask(this.id, arr)
  168. if (res.code === 200) {
  169. this.$message({ message: '移动成功', type: 'success', duration: 1000, offset: 150 })
  170. }
  171. },
  172. getType(value) {
  173. const res = this.taskScheduleEvent.find(item => item.code === value) || {}
  174. return res.msg
  175. },
  176. async listByTask(id) { // 获取排期列表
  177. const res = this.all ? await listByRequire(id) : await listByTask(id)
  178. if (res.code === 200) {
  179. this.scheduleList = res.data.scheduleDetailRespons || []
  180. this.scheduleDetail = res.data || {}
  181. this.scheduleList = this.scheduleList.map(item => ({
  182. ...item,
  183. peopleList: item.peopleObjectList.map(item => item.name).join(',')
  184. }))
  185. }
  186. },
  187. addSchedule() {
  188. this.detailData = null
  189. this.DialogTitle = '新建排期'
  190. this.visibleSchedule = true
  191. },
  192. deleteSchedule(row) { // 删除排期
  193. this.DialogTitle = '删除排期'
  194. this.isDelete = true
  195. this.visibleSchedule = true
  196. this.detailData = row
  197. },
  198. editSchedule(row) { // 编辑排期
  199. this.DialogTitle = '编辑排期'
  200. this.visibleSchedule = true
  201. this.detailData = row
  202. }
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. .add-schedule {
  208. cursor: pointer;
  209. color: #409EFF;
  210. font-size: 14px;
  211. margin: 0 20px;
  212. padding: 20px 0;
  213. i {
  214. margin-right: 4px;
  215. }
  216. span {
  217. margin-right: 20px;
  218. }
  219. }
  220. .schedule-list {
  221. margin: 0 20px;
  222. padding: 0;
  223. }
  224. >>>.el-table, .el-table__expanded-cell{
  225. background:rgba(248,248,248,0.6);
  226. }
  227. .white {
  228. background: #ffffff;
  229. .add-schedule {
  230. padding: 0 0 20px 0;
  231. }
  232. /deep/.el-table{
  233. background: #ffffff !important;
  234. }
  235. }
  236. .bottom-detail {
  237. font-size: 14px;
  238. // width: calc(100% - 40px);
  239. margin: 0 20px;
  240. padding: 20px 0;
  241. :nth-child(2) {
  242. margin: 10px 0;
  243. }
  244. }
  245. .sortable-tip {
  246. height: 26px;
  247. width: 15px;
  248. border-radius:2px;
  249. margin: auto;
  250. justify-content: center;
  251. align-items: center;
  252. img {
  253. width: 8px;
  254. }
  255. }
  256. </style>
  257. <style>
  258. .el-tooltip__popper.is-dark {
  259. background:rgba(121,132,150,0.8);
  260. color: #FFF;
  261. }
  262. </style>