iZaiZaiA пре 2 година
родитељ
комит
0e0cf1dff9

+ 9 - 3
src/global/components/hc-dialog/index.vue

@@ -1,5 +1,5 @@
 <template>
-    <el-dialog v-model="isShow" :title="title" :width="isWidth" class="hc-modal-border" :class="ui" draggable destroy-on-close @closed="dialogClosed">
+    <el-dialog v-model="isShow" :title="title" :width="isWidth" class="hc-modal-border" :class="ui" :style="isBgColor?'--el-dialog-bg-color:' + isBgColor:''" draggable destroy-on-close @closed="dialogClosed">
         <template #header v-if="isSlotHeader">
             <slot name='header'/>
         </template>
@@ -51,25 +51,31 @@ const props = defineProps({
         type: [String,Number],
         default: '提交'
     },
+    bgColor: {
+        type: [String,Number],
+        default: ''
+    },
 })
 
 //变量
 const isShow = ref(props.show)
 const isWidth = ref(props.widths)
 const isLoading = ref(props.loading)
+const isBgColor = ref(props.bgColor)
 
 //监听
 watch(() => [
     props.show,
     props.widths,
     props.loading,
-], ([show, width, loading]) => {
+    props.bgColor,
+], ([show, width, loading, bgColor]) => {
     isShow.value = show
     isWidth.value = width
     isLoading.value = loading
+    isBgColor.value = bgColor
 })
 
-
 //判断<slot>是否有传值
 const slots = useSlots()
 const isSlotHeader = ref(!!slots.header);

+ 0 - 3
src/plugins/HTableForm.js

@@ -64,9 +64,6 @@ export const HTableForm = ({template, tableForm, appId, onRight}) => {
             //删除上传的文件
             delTableFormFile(key) {
                 this.formData[key] = ''
-            },
-            upFormData() {
-
             }
         }
     })

+ 103 - 67
src/views/ledger/components/table-form.vue

@@ -62,7 +62,7 @@
                 </el-button>
             </HcTooltip>
             <HcTooltip keys="ledger_query_time_form">
-                <el-button hc-btn :disabled="!isTableForm">
+                <el-button hc-btn :disabled="!isTableForm" @click="copyTimeLogModal">
                     <HcIcon name="file-copy-2"/>
                     <span>复制任意时间</span>
                 </el-button>
@@ -83,6 +83,12 @@
             </div>
         </HcDialog>
 
+        <!--复制任意时间-->
+        <HcDialog :show="copyTimeModal" title="复制任意时间" widths="360px" bg-color="#f1f5f8" saveText="复制" @close="copyTimeModal = false" :loading="copyTimeLoading" @save="copyTimeSaveClick">
+            <DateCalendar :dateData="dateData" @choice-date="copyTimeChoice"/>
+            <el-alert title="请选择一个日期复制" type="warning" show-icon/>
+        </HcDialog>
+
     </div>
 </template>
 
@@ -136,11 +142,9 @@ nextTick(() => {
 
 //获取相关数据
 const getQueryData = () => {
-    const item = menuItem.value
-    const eid = item?.excelId > 0 ? item?.excelId + '' : ''
-    excelIdVal.value = eid
-    getExcelHtmlData(eid)
-    getSubmitLogDateList(item?.primaryKeyId)
+    const {excelId, primaryKeyId} = menuItem.value
+    excelIdVal.value = excelId > 0 ? excelId + '' : ''
+    getSubmitLogDateList(primaryKeyId)
 }
 
 //获取日期记录
@@ -163,21 +167,59 @@ const getSubmitLogDateList = async (pid) => {
 const recordTime = ref('')
 const dateCalendarChoice = ({choices}) => {
     recordTime.value = choices
-    queryCurrentLogSelectProcessList(choices)
+    getExcelHtml(excelIdVal.value)
     getTheLogBusinessData(excelIdVal.value, choices)
+    queryCurrentLogSelectProcessList(choices)
 }
 
-//表格表单渲染
+//获取模板标签数据
 const isTableForm = ref(false)
-const getExcelHtmlData = async (excelId) => {
+const excelHtmlData = ref('')
+const getExcelHtml = async (excelId) => {
     if (excelId) {
-        getExcelHtml(excelId)
+        //获取数据
+        const { error, code, data } = await queryApi.getExcelHtml({
+            pkeyId: excelId
+        }, false)
+        //处理数据
+        const resData = isString(data) ? data || '' : ''
+        excelHtmlData.value = resData
+        if (!error && code === 200 && resData) {
+            setHTableForm(resData,excelId,tableFormData.value)
+        } else {
+            isTableForm.value = false
+            statusDesc.value = '暂无表单'
+            window?.$message?.warning('暂无表单')
+        }
     } else {
         statusDesc.value = `excelId: ${excelId || '-1 或 空'}`
         isTableForm.value = false
     }
 }
 
+//渲染表单
+const tableFormApp = ref(null)
+const setHTableForm = async (resData, excelId, info) => {
+    //先卸载
+    if (tableFormApp.value) {
+        tableFormApp.value?.unmount()
+    }
+    if (resData) {
+        isTableForm.value = true
+        await nextTick(() => {
+            tableFormApp.value = HTableForm({
+                template: resData,
+                tableForm: info,
+                appId: `#table-form-${excelId}`
+            })
+        })
+    } else {
+        isTableForm.value = false
+        statusDesc.value = '暂无表单'
+        window?.$message?.warning('暂无表单')
+    }
+}
+
 //表单数据
 const formLogDataList = ref([])
 const getTheLogBusinessData = async (excelId, recordDate) => {
@@ -188,7 +230,12 @@ const getTheLogBusinessData = async (excelId, recordDate) => {
         recordTime: recordDate,
         theLogId: ""
     }, false)
-    formLogDataList.value = getArrValue(data)
+    //设置默认数据
+    let formArrData = getArrValue(data)
+    for (let i = 0; i < formArrData.length; i++) {
+        formArrData[i] = setFormDefaultData(formArrData[i])
+    }
+    formLogDataList.value = formArrData
     getBussDataInfo()
 }
 
@@ -215,36 +262,11 @@ const getBussDataInfo = (index = 0) => {
         }
         //有数据,关联数据
         tableFormData.value = info
-        console.log(tableFormApp.value)
-        //tableFormApp.value.formData = info
     } else {
         tableFormData.value = {}
     }
-}
-
-//获取模板标签数据
-const tableFormApp = ref(null)
-const getExcelHtml = async (excelId) => {
-    //获取数据
-    const { error, code, data } = await queryApi.getExcelHtml({
-        pkeyId: excelId
-    }, false)
-    //处理数据
-    const resData = isString(data) ? data || '' : ''
-    if (!error && code === 200 && resData) {
-        isTableForm.value = true
-        //渲染表单
-        await nextTick(() => {
-            tableFormApp.value = HTableForm({
-                template: resData,
-                tableForm: tableFormData.value,
-                appId: `#table-form-${excelId}`
-            })
-        })
-    } else {
-        isTableForm.value = false
-        statusDesc.value = '暂无表单'
-        window?.$message?.warning('暂无表单')
+    if (excelHtmlData.value) {
+        setHTableForm(excelHtmlData.value, excelIdVal.value, tableFormData.value)
     }
 }
 
@@ -343,15 +365,6 @@ const saveExcelBussData = async () => {
         tableFormSaveLoading.value = true
         const { error, code } = await queryApi.saveExcelBussData({
             dataInfo: {orderList: formLogDataList.value}
-            /*...tableFormData.value,
-            projectId: projectId.value,
-            contractId: contractId.value,
-            pkeyId: excelIdVal.value,
-            recordTime: recordTime.value,
-            linkTabIds: linkTabIds,
-            isTheLog: "1",
-            theLogId: "",
-            classify: 1,*/
         },false)
         tableFormSaveLoading.value = false
         if (!error && code === 200) {
@@ -434,16 +447,8 @@ const queryCurrentLogSelectProcessList = async (dateVal) => {
 
 //新增表格
 const addTableFormClick = () => {
-    formLogDataList.value.push({
-        projectId: projectId.value,
-        contractId: contractId.value,
-        recordTime: recordTime.value,
-        pkeyId: excelIdVal.value,
-        linkTabIds: [],
-        isTheLog: "1",
-        theLogId: "",
-        classify: 1
-    })
+    const defaultData = setFormDefaultData({})
+    formLogDataList.value.push(defaultData)
     const index = formLogDataList.value.length - 1
     getBussDataInfo(index)
 }
@@ -452,8 +457,46 @@ const addTableFormClick = () => {
 const copyTableFormClick = () => {
     const formLog = formLogDataList.value
     const logIndex = formLogIndex.value
-    formLogDataList.value.push({
-        ...formLog[logIndex],
+    const defaultData = setFormDefaultData(formLog[logIndex])
+    formLogDataList.value.push(defaultData)
+    const index = formLogDataList.value.length - 1
+    getBussDataInfo(index)
+}
+
+//复制任意时间
+const copyTimeLogModal = () => {
+    copyTimeModal.value = true
+    copyTimeLoading.value = false
+}
+const copyTimeModal = ref(false)
+//选择日期
+const copyTimeChoices = ref('')
+const copyTimeChoice = ({choices}) => {
+    copyTimeChoices.value = choices
+}
+//确认复制
+const copyTimeLoading = ref(false)
+const copyTimeSaveClick = async () => {
+    copyTimeLoading.value = true
+    const {primaryKeyId} = menuItem.value
+    const { error, code, data } = await queryApi.copyTheLogBusinessData({
+        nodePrimaryKeyId: primaryKeyId,
+        currentTime: recordTime.value,
+        targetTime: copyTimeChoices.value
+    }, false)
+    //处理数据
+    copyTimeLoading.value = false
+    if (!error && code === 200) {
+        window?.location?.reload()  //刷新页面
+    } else {
+        window?.$message?.warning('复制失败')
+    }
+}
+
+//设置表单默认数据
+const setFormDefaultData = (formInfo) => {
+    return {
+        ...formInfo,
         projectId: projectId.value,
         contractId: contractId.value,
         recordTime: recordTime.value,
@@ -461,14 +504,7 @@ const copyTableFormClick = () => {
         isTheLog: "1",
         theLogId: "",
         classify: 1
-    })
-    const index = formLogDataList.value.length - 1
-    getBussDataInfo(index)
-}
-
-//复制任意时间
-const copyTheLogBusinessData = () => {
-    //copyTheLogBusinessData
+    }
 }
 </script>