From a7ac91bc5ae3c2ce0badca1ae9fc7ed57af95758 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 22 十月 2024 15:15:28 +0800
Subject: [PATCH] 1. 添加子任务编辑功能(暂存)

---
 src/views/fysp/task/components/CompSubTaskList.vue |   73 +++++++++++++++++++++++++++++++-----
 1 files changed, 62 insertions(+), 11 deletions(-)

diff --git a/src/views/fysp/task/components/CompSubTaskList.vue b/src/views/fysp/task/components/CompSubTaskList.vue
index b84adbd..b678652 100644
--- a/src/views/fysp/task/components/CompSubTaskList.vue
+++ b/src/views/fysp/task/components/CompSubTaskList.vue
@@ -2,7 +2,7 @@
   <el-row justify="space-between">
     <el-text>鍗曟棩璁″垝</el-text>
     <el-button
-      v-show="create && data && data.length > 0"
+      v-show="create && modelValue && modelValue.length > 0"
       type="success"
       size="small"
       @click="add"
@@ -13,17 +13,26 @@
   <div>
     <el-scrollbar v-loading="loading" :height="height">
       <el-space
-        v-if="data && data.length > 0"
+        v-if="modelValue && modelValue.length > 0"
         fill
         :fill-ratio="100"
         direction="vertical"
         style="width: 100%"
       >
-        <ItemSubTask v-for="s in data" :key="s.guid" :item="s">
+        <ItemSubTask v-for="s in modelValue" :key="s.guid" :item="s">
           <template #default="{ item }">
-            <el-button type="danger" size="small" @click="remove(item)"
-              >绉婚櫎</el-button
-            >
+            <el-space direction="vertical">
+              <el-button plain type="primary" size="small" @click="edit(item)"
+                >缂栬緫</el-button
+              >
+              <el-button
+                :disabled="item.status != '鏈墽琛�'"
+                type="default"
+                size="small"
+                @click="remove(item)"
+                >绉婚櫎</el-button
+              >
+            </el-space>
           </template>
         </ItemSubTask>
       </el-space>
@@ -37,12 +46,29 @@
       </div>
     </el-scrollbar>
   </div>
+  <el-dialog
+    v-model="dialogVisible"
+    width="600"
+    title="涓�閿垱寤烘�讳换鍔�"
+    destroy-on-close
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    :show-close="false"
+  >
+    <CompSubTaskEdit
+      v-model="activeItem"
+      @submit="dialogVisible = false"
+      @cancel="dialogVisible = false"
+    ></CompSubTaskEdit>
+  </el-dialog>
 </template>
 <script setup>
-import { ref, watch, onMounted } from 'vue';
+import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
+import { ElMessageBox, ElNotification, ElMessage } from 'element-plus';
+import CompSubTaskEdit from './CompSubTaskEdit.vue';
 
 const props = defineProps({
-  data: Array,
+  modelValue: Array,
   height: {
     type: String,
     default: '70vh'
@@ -51,15 +77,40 @@
   create: Boolean,
   loading: Boolean
 });
-const curSubTaskList = ref([]);
 
-const emit = defineEmits(['add', 'remove']);
+const dialogVisible = ref(false)
+const activeItem = ref(null)
+const data = computed(() => props.modelValue);
+
+const emit = defineEmits(['edit', 'add', 'remove', 'update:modelValue']);
 
 function remove(item) {
-  emit('remove', item);
+  if (item.status == '鏈墽琛�') {
+    ElMessageBox.confirm('鏄惁绉婚櫎鐩戠浠诲姟', `绉婚櫎纭`, {
+      confirmButtonText: '纭',
+      cancelButtonText: '鍙栨秷',
+      type: 'warning'
+    }).then(() => {
+      const index = data.value.indexOf(item);
+      data.value.splice(index, 1);
+
+      emit('update:modelValue', data.value);
+      emit('remove', item);
+    });
+  }
+}
+
+function edit(item) {
+  activeItem.value = item
+  dialogVisible.value = true
+  emit('edit');
 }
 
 function add() {
   emit('add');
 }
+
+onUnmounted(()=>{
+  dialogVisible.value = false
+})
 </script>

--
Gitblit v1.9.3