Răsfoiți Sursa

格式更改

wangziqian 5 ani în urmă
părinte
comite
f854c28d02

+ 130 - 18
src/views/projectManage/taskList/childrenTask/addChildrenList.vue

@@ -9,7 +9,7 @@
           size="medium"
           class="child-status"
           :class="{'status0':item.status === 0,'status1':item.status === 10,'status2':item.status === 20}"
-          @change="update()"
+          @change="updateStatus(item)"
         >
           <el-option
             v-for="val in allStatus"
@@ -22,8 +22,8 @@
           <span v-if="!item.edit" @click="toDetail(item.id)">{{ item.name }}</span>
           <el-input v-if="item.edit" v-model="item.name" placeholder="请输入任务名称(必填)" size="medium" clearable />
           <div v-if="item.edit" class="footer">
-            <el-button size="mini" @click="cancelChild(index,item.newNode)">取消</el-button>
-            <el-button type="primary" size="mini" @click="confirmChild(index,item.name)">确定</el-button>
+            <el-button size="mini" @click="cancelChild(index,item)">取消</el-button>
+            <el-button type="primary" size="mini" @click="confirmChild(index,item)">确定</el-button>
           </div>
         </div>
         <div class="child-endTime">
@@ -34,7 +34,7 @@
             value-format="yyyy.MM.dd"
             size="small"
             :class="[item.endTime?'all':'icon']"
-            @change="update()"
+            @change="updateDate(item)"
           />
         </div>
         <div class="select-people">
@@ -49,19 +49,42 @@
           >
             <div class="edit-cancel">
               <p @click="editChild(index,item)">编辑</p>
-              <p @click="deleteChild(index)">删除</p>
+              <p @click="cancelChild(index,item)">删除</p>
             </div>
             <div slot="reference"><i class="el-icon-more" /></div>
           </el-popover>
         </div>
       </div>
     </div>
+    <!-- 操作 -->
+    <normal-dialog
+      v-if="deleteDialog"
+      :show-dialog.sync="deleteDialog"
+      title="删除确认"
+      width="45%"
+      :is-default-close="false"
+      buttom-type="danger"
+      @confirm="subTaskDelete()"
+      @cancel="deleteDialog = false"
+    >
+      <article>
+        <div class="danger-img">
+          <img :src="dangerImg">
+        </div>
+        <div class="danger-title">{{ nowSubTask.name }}及其所有子任务会被删除,此操作不可撤销,是否确定?</div>
+      </article>
+    </normal-dialog>
+    <change-status v-if="statusDialog" :show-dialog.sync="statusDialog" :data="noCompleteTask" @confirm="changeArea('status')" @cancel="$emit('change')" />
   </div>
 </template>
 <script>
+import { subTaskUpdate, subTaskDelete, subTaskCreate } from '@/api/taskChild'
+import changeStatus from './changeStatus'
+import normalDialog from '@/components/dialog/normalDialog'
 import selectPeople from '@/components/select/selectPeople'
+import danger from '@/assets/感叹@2x.png'
 export default {
-  components: { selectPeople },
+  components: { selectPeople, changeStatus, normalDialog },
   props: {
     list: {
       type: Array,
@@ -87,12 +110,22 @@ export default {
       type: String,
       default: 'add',
       required: false
+    },
+    add: {
+      type: Boolean,
+      default: false,
+      required: false
     }
   },
   data() {
     return {
+      dangerImg: danger,
       childrenList: this.list,
-      formData: this.data
+      formData: this.data,
+      deleteDialog: false, // 删除弹窗
+      statusDialog: false, // 状态弹框
+      noCompleteTask: [], // 当前任务中未完成的子任务
+      nowSubTask: null // 当前子任务
     }
   },
   watch: {
@@ -130,7 +163,7 @@ export default {
     addChild() { // 添加子任务
       this.childrenList.push({
         name: null,
-        bizId: this.formData.parentId,
+        bizId: this.formData.bizId,
         endTime: null,
         owner: '',
         status: 0,
@@ -144,34 +177,96 @@ export default {
         document.getElementById(id).scrollIntoView({ block: 'start', behavior: 'smooth' })
       })
     },
-    cancelChild(index, newNode) { // 取消添加子任务
-      if (newNode) {
+    cancelChild(index, item) { // 取消添加子任务
+      if (item.newNode) {
         this.childrenList.splice(index, 1)
         this.$emit('list:update', this.childrenList)
       } else {
+        if (this.add) return
+        this.nowSubTask = item
+        this.deleteDialog = true
         this.$set(this.childrenList[index], 'edit', false)
-        this.update()
       }
     },
-    deleteChild(index) {
-      this.childrenList.splice(index, 1)
-      this.update()
+    updateDate(e) { // 变更截止时间
+      if (this.add) return
+      if (e.newNode) return
+      this.nowSubTask = e
+      this.changeArea('endTime')
     },
-    confirmChild(index, name) { // 确认添加子任务
-      const value = name && name.replace(/\s*/, '')
+    updateStatus(e) { // 变更状态
+      if (this.add) return
+      if (e.newNode) return
+      this.nowSubTask = e
+      if (this.nowSubTask.status === 20) {
+        this.noCompleteTask = []
+        this.findNoComplete(this.nowSubTask.childSubTaskInfos)
+        this.noCompleteTask = this.noCompleteTask.filter(item => item.status !== 20)
+        if (this.noCompleteTask.length > 0) {
+          this.statusDialog = true
+          return
+        }
+      }
+      this.changeArea('status')
+    },
+    findNoComplete(arr) { // 查找未完成子任务
+      arr.map(item => {
+        this.noCompleteTask = this.noCompleteTask.concat(item)
+        this.findNoComplete(item.childSubTaskInfos)
+      })
+    },
+    async changeArea(e) { // area修改
+      const params = {
+        id: this.nowSubTask.id,
+        taskId: this.nowSubTask.taskId,
+        bizId: this.nowSubTask.bizId
+      }
+      params[e] = this.nowSubTask[e]
+      const res = await subTaskUpdate(params)
+      if (res.code === 200) {
+        this.$message({ message: '修改成功', type: 'success', duration: 1000, offset: 150 })
+        this.statusDialog = false
+      }
+      this.$emit('change')
+    },
+    async subTaskDelete() { // 删除
+      const res = await subTaskDelete(this.nowSubTask.id)
+      if (res.code === 200) {
+        this.$message({ message: '删除成功', type: 'success', duration: 1000, offset: 150 })
+        this.deleteDialog = false
+      }
+      this.$emit('change')
+    },
+    confirmChild(index, item) { // 确认添加子任务
+      const value = item.name && item.name.replace(/\s*/, '')
       if (value === null || value === '') {
         this.$message({ message: '请输入任务名称', type: 'error', duration: 1000, offset: 150 })
         return false
       }
       this.childrenList[index].edit = false
       this.update()
+      if (this.add) return
+      this.nowSubTask = item
+      this.createChildren(item)
+    },
+    async createChildren(item) { // 新加
+      const param = {
+        taskId: this.formData.taskId,
+        ...item
+      }
+      delete param.edit
+      delete param.newNode
+      const res = await subTaskCreate(param)
+      if (res.code === 200) {
+        this.$message({ message: '创建成功', type: 'success', duration: 1000, offset: 150 })
+      }
+      this.$emit('change')
     },
     editChild(index, item) { // 编辑子任务
       this.$set(this.childrenList[index], 'edit', true)
     },
     update() {
       this.$emit('list:update', this.childrenList)
-      this.$emit('change')
     },
     toDetail(id) {
       this.$emit('toDetail', id)
@@ -254,7 +349,7 @@ export default {
 		}
 	}
 	.child-endTime {
-		max-width: 30%;
+		width: 30%;
 		height: 36px;
 		padding-left: 20px;
 		display: flex;
@@ -321,6 +416,23 @@ export default {
     color: #409EFF
   }
 }
+.danger-img {
+  width: 100%;
+  padding: 0 60px 50px 60px;
+  margin-bottom: 50px;
+  position: relative;
+  img {
+    height: 50px;
+    width: 50px;
+    position: absolute;
+    left: 50%;
+    transform: translate(-50%,0);
+  }
+}
+.danger-title {
+	text-align: center;
+	padding-bottom: 50px;
+}
 </style>
 <style>
 .popper-control {

+ 6 - 3
src/views/projectManage/taskList/childrenTask/childDetail.vue

@@ -201,8 +201,10 @@ export default {
         this.noCompleteTask = []
         this.findNoComplete(this.formData.childSubTaskInfos)
         this.noCompleteTask = this.noCompleteTask.filter(item => item.status !== 20)
-        this.statusDialog = true
-        return
+        if (this.noCompleteTask.length > 0) {
+          this.statusDialog = true
+          return
+        }
       }
       this.changeArea('status')
     },
@@ -242,8 +244,9 @@ export default {
     },
     addChild() {
       this.formData.childSubTaskInfos.push({
+        parentId: this.formData.id,
         name: null,
-        bizId: this.formData.parentId,
+        bizId: this.formData.bizId,
         endTime: null,
         owner: '',
         status: 0,

+ 8 - 5
src/views/projectManage/taskList/childrenTask/childDrawer.vue

@@ -123,7 +123,7 @@
             :data="formData"
             :all-status="allStatus"
             @toDetail="toChild"
-            @change="changeArea('childSubTaskInfos')"
+            @change="getById()"
           />
         </div>
       </section>
@@ -228,8 +228,10 @@ export default {
         this.noCompleteTask = []
         this.findNoComplete(this.formData.childSubTaskInfos)
         this.noCompleteTask = this.noCompleteTask.filter(item => item.status !== 20)
-        this.statusDialog = true
-        return
+        if (this.noCompleteTask.length > 0) {
+          this.statusDialog = true
+          return
+        }
       }
       this.changeArea('status')
     },
@@ -275,10 +277,11 @@ export default {
         this.close()
       }
     },
-    addChild() {
+    addChild() { // 添加子任务
       this.formData.childSubTaskInfos.push({
+        parentId: this.formData.id,
         name: null,
-        bizId: this.formData.parentId,
+        bizId: this.formData.bizId,
         endTime: null,
         owner: '',
         status: 0,

+ 4 - 2
src/views/projectManage/taskList/childrenTask/childrenList.vue

@@ -94,8 +94,10 @@ export default {
         this.noCompleteTask = []
         this.findNoComplete(e.childSubTaskInfos)
         this.noCompleteTask = this.noCompleteTask.filter(item => item.status !== 20)
-        this.statusDialog = true
-        return
+        if (this.noCompleteTask.length > 0) {
+          this.statusDialog = true
+          return
+        }
       }
       this.confirmChange()
     },

+ 1 - 0
src/views/projectManage/taskList/childrenTask/createChildren.vue

@@ -72,6 +72,7 @@
         :data="formData"
         :all-status="allStatus"
         :is-title="true"
+        :add="true"
       />
     </article>
   </normal-dialog>