Kaynağa Gözat

保存数据

duy 1 ay önce
ebeveyn
işleme
fde02655d8

+ 65 - 4
src/views/systemService/fromDrawer.vue

@@ -11,6 +11,8 @@
                         hc-btn
                         keys="system-service-plan-save-btn"
                         type="primary"
+                        :loading="saveLoading"
+                        @click="savePlan"
                     >
                         <HcIcon name="save" />
                         保存数据
@@ -73,6 +75,7 @@
                     :html="excelHtmlData"
                     :loading="loading"
                     :pkey="excelIdVal"
+                    :disabled="!isTableForm"
                     @render="tableFormRender"
                 />
             </div>
@@ -88,6 +91,15 @@ import { arrToKey, deepClone, isString } from 'js-fast-way'
 import HcUserModal from './hc-tasks-user/user-modal.vue'
 import { useAppStore } from '~src/store'
 import dataApi from '~api/systemService/service'
+//参数
+const props = defineProps({
+    type: {
+        type:[String, Number],
+        default:'',
+    },
+})
+const type = ref(props.type)
+
 const isShow = defineModel('modelValue', {
     default: false,
 })
@@ -101,25 +113,41 @@ const useAppState = useAppStore()
 const projectId = ref(useAppState.getProjectId)
 const contractId = ref(useAppState.getContractId)
 
-
 watch(isShow, (val) => {
-    if (val) getExcelHtml()
+   
+})
+//监听
+watch(() => [
+    props.type,
+], ([val]) => {
+    type.value = val
+
+    if (val === 1) {
+        excelIdVal.value = '1937773223861026820'
+    } else {
+        excelIdVal.value = '1937773223861026822'
+    }
+     if (val) getExcelHtml()
 })
 
 //获取模板标签数据
 
 
 const getExcelHtml = async () => {
-   
+   loading.value = true
+
         //获取数据
         const { error, code, data } = await dataApi.getServiceHtml({
             contractId: contractId.value || '',
-            type:1,
+             pkeyId:  excelIdVal.value,
             projectId: projectId.value || '',
         }, false)
+         loading.value = false
         //处理数据
         const resData = isString(data) ? data || '' : ''
+        
         if (!error && code === 200 && resData) {
+          
             excelHtmlData.value = resData
         } else {
             excelHtmlData.value = ''
@@ -153,10 +181,43 @@ const fixedUserFinish = (data) => {
     let userIdsArr = userIds.split(',')
  
 }
+//保存数据
+const saveLoading = ref(false)
+const savePlan = async ()=>{
+    console.log( tableFormData.value, 'tableFormData.value')
+    
+    let objres = {
+        ...tableFormData.value,
+        projectId: projectId.value,
+        contractId: contractId.value,
+    }
+    saveLoading.value = true
+      const { error, code, msg, data } = await dataApi.saveServiceData({
+            dataInfo: objres,
+         
+        }, false)
+      saveLoading.value = false
+        if (!error && code === 200) {
+         
+            window?.$message?.success(msg)
+           
+        } else {
+            saveLoading.value = false
+          
+          
+        }
+}
 </script>
 
 <style scoped lang="scss">
 .node-card-plan-btn{
     color:white;
 }
+.hc-table-form-box{
+
+    height: 100%;
+    overflow-y: auto;
+    overflow-x: auto;
+ 
+}
 </style>

+ 6 - 4
src/views/systemService/plan.vue

@@ -26,11 +26,11 @@
             </div>
         </template>
         <template #extra>
-            <el-button type="primary" @click="createMonthPlan">
+            <el-button type="primary" @click="createMonthPlan(1)">
                 <HcIcon name="add" />
                 <span>创建月度计划</span>
             </el-button>
-            <el-button type="primary">
+            <el-button type="primary" @click="createMonthPlan(2)">
                 <HcIcon name="add" />
                 <span>创建服务计划</span>
             </el-button>
@@ -56,7 +56,7 @@
         <template #action>
             <HcPages :pages="searchForm" @change="pageChange" />
         </template>
-        <fromDrawer v-model="isShowForm" />
+        <fromDrawer v-model="isShowForm" :type="typeVal" />
     </hc-card>
 </template>
 
@@ -148,7 +148,9 @@ const getTableData = async () => {
     }
 }
 const isShowForm = ref(false)
-const createMonthPlan = ()=>{
+const typeVal = ref('')
+const createMonthPlan = (type)=>{
     isShowForm.value = true
+    typeVal.value = type
 }
 </script>