scheduleList.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <div class="schedule-list" :class="className">
  3. <el-table
  4. :id="'schedule-'+id"
  5. :data="scheduleList"
  6. :header-cell-style="{ backgroundColor: 'rgba(232,232,232,0.4)', color: 'rgb(74, 74, 74)', fontSize: '14px', fontWeight: '500'}"
  7. style="width: 100%"
  8. show-overflow-tooltip="true"
  9. row-key="id"
  10. border
  11. stripe
  12. size="mini"
  13. >
  14. <el-table-column
  15. width="80"
  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. >
  30. <template slot-scope="scope">
  31. {{ scope.row.name }}
  32. <div v-show="showunlock" :class="scope.row.isScheduleLocked === 0 ? 'el-icon-unlock' : 'el-icon-lock'" />
  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="100"
  46. show-overflow-tooltip
  47. />
  48. <el-table-column
  49. prop="dayLength"
  50. label="使用天数"
  51. width="80"
  52. />
  53. <el-table-column
  54. prop="peopleList"
  55. label="参与人员"
  56. min-width="100"
  57. />
  58. <el-table-column
  59. prop="manpower"
  60. label="使用人力(人日)"
  61. width="150"
  62. />
  63. <el-table-column
  64. label="关联任务"
  65. min-width="100"
  66. >
  67. <template slot-scope="scope">
  68. <el-popover
  69. placement="bottom"
  70. title="关联的任务"
  71. width="450"
  72. trigger="click"
  73. popper-class="synchronize"
  74. >
  75. <div class="blueStr" />
  76. <div class="task-object-list">
  77. <template v-for="(item,index) in scope.row.taskObjectList">
  78. <div :key="'task-object'+index" class="task-item" @click="link(item.id)">
  79. <span class="item-id">{{ item.taskId }}</span>
  80. <span class="item-name">{{ item.name }}</span>
  81. <span>{{ item.moduleInfoName }}</span>
  82. </div>
  83. </template>
  84. </div>
  85. <div v-if="scope.row.taskObjectList" slot="reference" class="point-blue">{{ scope.row.taskObjectList.length }}</div>
  86. </el-popover>
  87. </template>
  88. </el-table-column>
  89. <el-table-column
  90. label="操作"
  91. width="200"
  92. show-overflow-tooltip
  93. >
  94. <template slot-scope="scope">
  95. <div v-if="showunlock">
  96. <el-button v-if="scope.row.isScheduleLocked === 0" type="text" size="small" @click="editSchedule(scope.row)">编辑</el-button>
  97. <el-button v-if="scope.row.isScheduleLocked === 0" type="text" size="small" @click="deleteSchedule(scope.row)">删除</el-button>
  98. </div>
  99. </template>
  100. </el-table-column>
  101. </el-table>
  102. <!-- 交付日期 排期 预计上线版本 -->
  103. <online-date :data="scheduleDetail" @update="listByTask(taskId)" />
  104. <!-- 交付日期 排期 预计上线版本 -->
  105. <modify-schedule
  106. v-if="visibleSchedule"
  107. :visible.sync="visibleSchedule"
  108. :is-delete.sync="isDelete"
  109. :detail-data="detailData"
  110. :title="DialogTitle"
  111. type="task"
  112. @update="listByTask(id)"
  113. />
  114. </div>
  115. </template>
  116. <script>
  117. import { EncryptId } from '@/utils/crypto-js.js'
  118. import { mapGetters } from 'vuex'
  119. import Sortable from 'sortablejs'
  120. import 'moment/locale/zh-cn'
  121. import { listByTask, sortForTask } from '@/api/projectViewDetails'
  122. import modifySchedule from '@/views/projectManage/projectList/components/modifySchedule'
  123. import move from '@/assets/麻将@2x.png'
  124. import onlineDate from '@/views/projectManage/components/onlineTime.vue'
  125. export default {
  126. components: {
  127. modifySchedule,
  128. onlineDate
  129. },
  130. props: {
  131. id: {
  132. type: Number,
  133. default: NaN,
  134. required: true
  135. },
  136. typeList: {
  137. type: Array,
  138. default: () => [],
  139. required: false
  140. },
  141. className: {
  142. type: String,
  143. default: '',
  144. required: false
  145. },
  146. showunlock: {
  147. type: Boolean,
  148. default: false,
  149. required: false
  150. }
  151. },
  152. data() {
  153. return {
  154. taskId: '',
  155. move: move,
  156. scheduleList: [],
  157. scheduleDetail: {},
  158. visibleSchedule: false,
  159. detailData: null,
  160. taskScheduleEvent: [], // 排期类型
  161. DialogTitle: '新建排期',
  162. isDelete: false // 删除排期操作
  163. }
  164. },
  165. computed: {
  166. ...mapGetters(['bizId'])
  167. },
  168. watch: {
  169. id: {
  170. handler(newV, oldV) {
  171. if (newV === -1) return
  172. this.$nextTick(() => {
  173. this.listByTask(newV)
  174. })
  175. },
  176. immediate: true
  177. },
  178. typeList: {
  179. handler(newV, oldV) {
  180. this.scheduleList = newV
  181. this.taskScheduleEvent = newV
  182. },
  183. immediate: true
  184. }
  185. },
  186. mounted() {
  187. this.rowDrop()
  188. },
  189. methods: {
  190. rowDrop() {
  191. const tbody = document.querySelector(`#schedule-${this.id} tbody`)
  192. const _this = this
  193. Sortable.create(tbody, {
  194. onEnd({ newIndex, oldIndex }) {
  195. const currRow = _this.scheduleList.splice(oldIndex, 1)[0]
  196. _this.scheduleList.splice(newIndex, 0, currRow)
  197. _this.sortForTask(_this.scheduleList.map(item => item.id))
  198. }
  199. })
  200. },
  201. async sortForTask(arr) {
  202. const res = await sortForTask(this.id, arr)
  203. if (res.code === 200) {
  204. this.$message({ message: '移动成功', type: 'success', duration: 1000, offset: 150 })
  205. }
  206. },
  207. async listByTask(id) { // 获取排期列表
  208. this.taskId = id
  209. const res = await listByTask(id)
  210. if (res.code === 200) {
  211. this.scheduleList = res.data.scheduleDetailRespons || []
  212. this.scheduleDetail = res.data || {}
  213. this.scheduleList = this.scheduleList.map(item => ({
  214. ...item,
  215. peopleList: item.peopleObjectList.map(item => item.name).join(',')
  216. }))
  217. this.$emit('updataData')
  218. }
  219. },
  220. addSchedule() {
  221. this.detailData = null
  222. this.DialogTitle = '新建排期'
  223. this.visibleSchedule = true
  224. },
  225. deleteSchedule(row) { // 删除排期
  226. this.DialogTitle = '删除排期'
  227. this.isDelete = true
  228. this.visibleSchedule = true
  229. this.detailData = row
  230. },
  231. editSchedule(row) { // 编辑排期
  232. this.DialogTitle = '编辑排期'
  233. this.visibleSchedule = true
  234. this.detailData = row
  235. },
  236. link(id) {
  237. const bizId_id = EncryptId(`${this.bizId}_${id}`)
  238. const newTab = this.$router.resolve({ name: '任务详情', query: { bizId_id: bizId_id }})
  239. window.open(newTab.href, '_blank')
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="less" scoped>
  245. .add-schedule {
  246. cursor: pointer;
  247. color: #409EFF;
  248. font-size: 14px;
  249. width: calc(100% - 40px);
  250. margin: 0 20px;
  251. padding: 20px 0;
  252. i {
  253. margin-right: 4px;
  254. }
  255. span {
  256. margin-right: 20px;
  257. }
  258. }
  259. .schedule-list {
  260. width: calc(100% - 40px);
  261. margin: 0 20px;
  262. padding: 0;
  263. }
  264. /deep/.el-table, .el-table__expanded-cell{
  265. background:rgba(248,248,248,0.6);
  266. }
  267. .white {
  268. background: #ffffff;
  269. .add-schedule {
  270. padding: 0 0 20px 0;
  271. }
  272. /deep/.el-table{
  273. background: #ffffff !important;
  274. }
  275. }
  276. .sortable-tip {
  277. height: 26px;
  278. width: 15px;
  279. border-radius:2px;
  280. margin: auto;
  281. display: flex;
  282. justify-content: center;
  283. align-items: center;
  284. img {
  285. width: 8px;
  286. }
  287. }
  288. .point-blue {
  289. cursor: pointer;
  290. color: #409EFF;
  291. }
  292. .task-object-list {
  293. width: 100%;
  294. height: 130px;
  295. overflow: scroll;
  296. .task-item {
  297. width: 100%;
  298. white-space: nowrap;
  299. color: #999999;
  300. margin-bottom: 5px;
  301. .item-id {
  302. padding-right: 20px;
  303. }
  304. .item-name {
  305. color: #333333;
  306. padding-right: 20px;
  307. }
  308. }
  309. }
  310. .task-object-list::-webkit-scrollbar {
  311. display: none;
  312. }
  313. </style>
  314. <style lang="less">
  315. .synchronize {
  316. .el-popover__title {
  317. color: #333333;
  318. padding: 10px 20px;
  319. }
  320. }
  321. .blueStr {
  322. width:4px;
  323. height:17px;
  324. background:#409EFF;
  325. border-radius:1px;
  326. position: absolute;
  327. top: 22px;
  328. left: 15px;
  329. }
  330. .el-tooltip__popper.is-dark {
  331. background:rgba(121,132,150,0.8);
  332. color: #FFF;
  333. }
  334. </style>