Browse Source

工作要点

ZaiZai 1 year ago
parent
commit
48025e56f5
1 changed files with 26 additions and 5 deletions
  1. 26 5
      src/views/project/gist/create.vue

+ 26 - 5
src/views/project/gist/create.vue

@@ -38,15 +38,15 @@
         </template>
         <template #action>
             <el-button v-if="formInfo.id" type="info" @click="cancelClick">取消</el-button>
-            <el-button v-if="!formInfo.id" color="#20C98B" type="primary" class="text-white" @click="saveClick">创建工作要点</el-button>
-            <el-button v-else type="warning" @click="saveClick">保存</el-button>
+            <el-button v-if="!formInfo.id" :loading="saveLoading" color="#20C98B" type="primary" class="text-white" @click="saveClick">创建工作要点</el-button>
+            <el-button v-else :loading="saveLoading" type="warning" @click="saveClick">保存</el-button>
         </template>
     </hc-card>
 </template>
 
 <script setup>
 import { onMounted, ref, watch } from 'vue'
-import { deepClone, formValidate, getArrValue, getRandom } from 'js-fast-way'
+import { deepClone, formValidate, getArrValue } from 'js-fast-way'
 import { getDictionaryData } from '~src/utils/tools'
 import mainApi from '~api/project/gist'
 
@@ -129,7 +129,7 @@ const gistFormRules = {
 //新增工作重点
 const addGistList = () => {
     const list = getArrValue(workFocusEntityList.value)
-    list.push({ id: getRandom() })
+    list.push({})
 }
 
 //删除工作重点
@@ -149,6 +149,7 @@ const cancelClick = () => {
 }
 
 //创建 保存
+const saveLoading = ref(false)
 const saveClick = async () => {
     //验证基础表单
     const isForm = await formValidate(baseFormRef.value)
@@ -160,9 +161,29 @@ const saveClick = async () => {
         if (!form) isGistForm = false
     }
     if (!isForm || !isGistForm) return
+    saveLoading.value = true
     //处理表单数据
     const form = baseForm.value, gist = workFocusEntityList.value
-    console.log(form, gist)
+    let newWorkForm = []
+    for (let i = 0; i < gist.length; i++) {
+        newWorkForm.push({
+            ...form,
+            ...gist[i],
+        })
+    }
+    //发起请求
+    const { error, code, msg } = await mainApi.submit({
+        workFocusEntityList: newWorkForm,
+    })
+    //判断状态
+    saveLoading.value = false
+    if (!error && code === 200) {
+        window?.$message?.success(msg)
+        baseForm.value = {}
+        workFocusEntityList.value = [{}]
+    } else {
+        window.$message.error(msg ?? '操作失败')
+    }
 }
 </script>