scheduleList.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div class="white">
  3. <el-table
  4. :id="'schedule-'+id"
  5. :data="scheduleList"
  6. show-overflow-tooltip="true"
  7. :show-header="false"
  8. :cell-class-name="addClass"
  9. row-key="id"
  10. border
  11. style="min-height: 90px;"
  12. size="mini"
  13. :class="{'ignore-elements': dondrop }"
  14. >
  15. <el-table-column prop="type" label="类型" min-width="70">
  16. <template slot-scope="scope">
  17. {{ scope.row.name }}
  18. <div :class="scope.row.isScheduleLocked === 1 ? 'el-icon-lock' : 'el-icon-unlock'" />
  19. </template>
  20. </el-table-column>
  21. <el-table-column prop="desc" label="描述" min-width="150" align="left" show-overflow-tooltip />
  22. <el-table-column prop="seperateDaysNoHoliday" label="排期" min-width="160" show-overflow-tooltip />
  23. <el-table-column prop="dayLength" label="时长" min-width="50" />
  24. <el-table-column prop="peopleList" label="参与人员" min-width="150" show-overflow-tooltip>
  25. <template slot-scope="scope">
  26. <div v-for="(item, index) in scope.row.peopleObjectList" :key="index" class="Layout_flex_start">{{ item.name }}</div>
  27. </template>
  28. </el-table-column>
  29. <el-table-column label="操作" width="120">
  30. <template slot-scope="scope">
  31. <div class="btn-style">
  32. <el-button v-if="scope.row.isScheduleLocked === 0" type="text" size="small" @click="editSchedule(scope.row)">编辑</el-button>
  33. <el-button v-if="scope.row.isScheduleLocked === 0" type="text" size="small" @click="deleteSchedule(scope.row)">删除</el-button>
  34. </div>
  35. </template>
  36. </el-table-column>
  37. </el-table>
  38. <modify-schedule
  39. v-if="visibleSchedule"
  40. :visible.sync="visibleSchedule"
  41. :select-task-list="selectTaskList"
  42. :is-delete.sync="isDelete"
  43. :detail-data="detailData"
  44. :title="DialogTitle"
  45. @update="listByTask(id)"
  46. />
  47. </div>
  48. </template>
  49. <script>
  50. import Sortable from 'sortablejs'
  51. import { sortForTask } from '@/api/projectViewDetails'
  52. import modifySchedule from '@/views/projectManage/requirement/components/modifySchedule.vue'
  53. import '@/styles/PublicStyle/index.scss' // 通用css
  54. export default {
  55. components: {
  56. modifySchedule
  57. },
  58. props: {
  59. id: {
  60. type: Number,
  61. default: NaN,
  62. required: true
  63. },
  64. locking: {
  65. type: Boolean,
  66. required: true
  67. },
  68. selectTaskList: { // 已选任务列表
  69. type: Array,
  70. default: () => [],
  71. required: false
  72. },
  73. requiredList: {
  74. type: Array,
  75. default: () => [],
  76. required: false
  77. },
  78. typeList: {
  79. type: Array,
  80. default: () => [],
  81. required: false
  82. }
  83. },
  84. data() {
  85. return {
  86. scheduleList: [],
  87. scheduleDetail: {},
  88. visibleSchedule: false,
  89. detailData: null,
  90. dondrop: true,
  91. taskScheduleEvent: [], // 排期类型
  92. DialogTitle: '新建排期',
  93. isDelete: false // 删除排期操作
  94. }
  95. },
  96. watch: {
  97. locking: {
  98. handler(newV, oldV) {
  99. this.dondrop = !newV
  100. },
  101. immediate: true
  102. },
  103. requiredList: {
  104. handler(newV, oldV) {
  105. this.scheduleList = newV
  106. },
  107. immediate: true
  108. },
  109. typeList: {
  110. handler(newV, oldV) {
  111. this.taskScheduleEvent = newV
  112. },
  113. immediate: true
  114. }
  115. },
  116. mounted() {
  117. this.rowDrop()
  118. },
  119. methods: {
  120. rowDrop() {
  121. const tbody = document.querySelector(`#schedule-${this.id} tbody`)
  122. const _this = this
  123. Sortable.create(tbody, {
  124. disabled: _this.dondrop,
  125. onEnd({ newIndex, oldIndex }) {
  126. const currRow = _this.scheduleList.splice(oldIndex, 1)[0]
  127. _this.scheduleList.splice(newIndex, 0, currRow)
  128. _this.sortForTask(_this.scheduleList.map(item => item.id))
  129. }
  130. })
  131. },
  132. async sortForTask(arr) {
  133. const res = await sortForTask(this.id, arr)
  134. if (res.code === 200) {
  135. this.$message({ message: '移动成功', type: 'success', duration: 1000, offset: 150 })
  136. }
  137. },
  138. getType(value) {
  139. const res = this.taskScheduleEvent.find(item => item.code === value) || {}
  140. return res.msg
  141. },
  142. async listByTask(id) { // 获取排期列表
  143. this.$emit('listByTask')
  144. },
  145. addSchedule() {
  146. this.detailData = null
  147. this.DialogTitle = '新建排期'
  148. this.visibleSchedule = true
  149. },
  150. deleteSchedule(row) { // 删除排期
  151. this.DialogTitle = '删除排期'
  152. this.isDelete = true
  153. this.visibleSchedule = true
  154. this.detailData = row
  155. },
  156. editSchedule(row) { // 编辑排期
  157. this.DialogTitle = '编辑排期'
  158. this.visibleSchedule = true
  159. this.detailData = row
  160. },
  161. addClass({ row, column, rowIndex, columnIndex }) {
  162. if (columnIndex <= 5) {
  163. return 'cell-greys'
  164. }
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .white {
  171. background: #ffffff;
  172. .add-schedule {
  173. padding: 0 0 20px 0;
  174. }
  175. /deep/.el-table{
  176. background: #ffffff !important;
  177. }
  178. }
  179. .btn-style {
  180. >>> .el-button {
  181. padding: 0;
  182. }
  183. }
  184. .add-schedule {
  185. cursor: pointer;
  186. color: #409EFF;
  187. font-size: 14px;
  188. margin: 0 20px;
  189. padding: 20px 0;
  190. i {
  191. margin-right: 4px;
  192. }
  193. span {
  194. margin-right: 20px;
  195. }
  196. }
  197. >>>.el-table, .el-table__expanded-cell{
  198. background:rgba(248,248,248,0.6);
  199. }
  200. .white {
  201. background: #ffffff;
  202. .add-schedule {
  203. padding: 0 0 20px 0;
  204. }
  205. /deep/.el-table{
  206. background: #ffffff !important;
  207. }
  208. }
  209. .sortable-tip {
  210. height: 26px;
  211. width: 15px;
  212. border-radius:2px;
  213. margin: auto;
  214. justify-content: center;
  215. align-items: center;
  216. img {
  217. width: 8px;
  218. }
  219. }
  220. </style>
  221. <style>
  222. .cell-greys .cell {
  223. margin-left: 10px !important;
  224. }
  225. .el-tooltip__popper.is-dark {
  226. background:rgba(121,132,150,0.8);
  227. color: #FFF;
  228. }
  229. </style>