Pārlūkot izejas kodu

任务排期列表排序

PrinceLee 5 gadi atpakaļ
vecāks
revīzija
c64ab4da81

+ 4 - 1
package.json

@@ -26,6 +26,7 @@
     "@tinymce/tinymce-vue": "^3.2.0",
     "animate.css": "^3.7.2",
     "axios": "0.18.0",
+    "core-js": "^2.6.11",
     "crypto-js": "^4.0.0",
     "dayjs": "^1.8.17",
     "echarts": "^4.2.1",
@@ -43,8 +44,10 @@
     "path-to-regexp": "2.4.0",
     "qrcodejs2": "0.0.2",
     "simditor": "^2.3.26",
+    "sortablejs": "^1.10.2",
     "swiper": "^5.3.6",
     "tinymce": "^5.2.2",
+    "tinymce-vue": "^1.0.0",
     "v-jsoneditor": "^1.2.2",
     "vue": "2.6.10",
     "vue-awesome-swiper": "^4.1.0",
@@ -65,7 +68,7 @@
     "@vue/cli-plugin-unit-jest": "3.6.3",
     "@vue/cli-service": "3.6.0",
     "@vue/test-utils": "1.0.0-beta.29",
-    "ant-design-vue": "^1.6.0",
+    "ant-design-vue": "^1.6.1",
     "autoprefixer": "^9.5.1",
     "babel-core": "7.0.0-bridge.0",
     "babel-eslint": "10.0.1",

+ 8 - 0
src/api/projectViewDetails.js

@@ -63,3 +63,11 @@ export function taskUpdate(data) {
     data
   })
 }
+// 任务排期排序
+export function sortForTask(id, data) {
+  return request({
+    url: TeamManagement + `/schedule/sortForTask?id=` + id,
+    method: 'post',
+    data
+  })
+}

+ 2 - 2
src/views/projectManage/projectList/component/needsList.vue

@@ -39,8 +39,8 @@
         </template>
       </el-table-column>
       <el-table-column label="PM" width="120" align="center" show-overflow-tooltip>
-        <template slot-scope="scope">
-          <span v-for="item in scope.row.pm" :key="item.deptid">{{ item.name }}</span>
+        <template v-if="scope.row.pm" slot-scope="scope">
+          <span>{{ scope.row.pm.name }}</span>
         </template>
       </el-table-column>
       <el-table-column label="需求来源" width="150" align="center" show-overflow-tooltip>

+ 47 - 1
src/views/projectManage/projectList/component/scheduleList.vue

@@ -2,12 +2,24 @@
   <div class="schedule-list">
     <el-col align="right" class="add-schedule"><span @click="addSchedule()"><i class="el-icon-circle-plus-outline" />添加排期</span></el-col>
     <el-table
+      :id="'schedule-'+id"
       :data="scheduleList"
       :header-cell-style="{'background-color': 'rgba(232,232,232,0.4)'}"
       :row-style="{'background-color': 'transparent'}"
       style="width: 100%"
       show-overflow-tooltip="true"
+      row-key="id"
     >
+      <el-table-column
+        width="80"
+        align="center"
+      >
+        <template>
+          <el-tooltip class="item" effect="dark" content="代表移动,鼠标选中区域可以向上移动" placement="bottom">
+            <div class="sortable-tip" />
+          </el-tooltip>
+        </template>
+      </el-table-column>
       <el-table-column
         prop="type"
         label="类型"
@@ -71,9 +83,10 @@
   </div>
 </template>
 <script>
+import Sortable from 'sortablejs'
 import moment from 'moment'
 import 'moment/locale/zh-cn'
-import { listByTask, scheduleDelete } from '@/api/projectViewDetails'
+import { listByTask, scheduleDelete, sortForTask } from '@/api/projectViewDetails'
 import modifySchedule from './modifySchedule'
 export default {
   components: {
@@ -120,7 +133,27 @@ export default {
       immediate: true
     }
   },
+  mounted() {
+    this.rowDrop()
+  },
   methods: {
+    rowDrop() {
+      const tbody = document.querySelector(`#schedule-${this.id} tbody`)
+      const _this = this
+      Sortable.create(tbody, {
+        onEnd({ newIndex, oldIndex }) {
+          const currRow = _this.scheduleList.splice(oldIndex, 1)[0]
+          _this.scheduleList.splice(newIndex, 0, currRow)
+          _this.sortForTask(_this.scheduleList.map(item => item.id))
+        }
+      })
+    },
+    async sortForTask(arr) {
+      const res = await sortForTask(this.id, arr)
+      if (res.code === 200) {
+        this.$message({ message: '移动成功', type: 'success', duration: 1000, offset: 150 })
+      }
+    },
     getType(value) {
       const res = this.taskScheduleEvent.find(item => item.code === value) || {}
       return res.msg
@@ -189,4 +222,17 @@ export default {
     margin-bottom: 10px;
   }
 }
+.sortable-tip {
+  height: 26px;
+  width: 15px;
+  border:1px solid rgba(0,0,0,0.15);
+  border-radius:2px;
+  margin: auto;
+}
+</style>
+<style>
+.el-tooltip__popper.is-dark {
+  background:rgba(121,132,150,0.8);
+  color: #FFF;
+}
 </style>