Browse Source

合同计量单元导入

duy 1 year ago
parent
commit
af675da60f
1 changed files with 91 additions and 1 deletions
  1. 91 1
      src/views/project/debit/contract/unit.vue

+ 91 - 1
src/views/project/debit/contract/unit.vue

@@ -24,7 +24,7 @@
                     <el-button hc-btn type="primary" @click="editModalShow = true">修改</el-button>
                     <el-button hc-btn type="danger">删除</el-button>
                     <el-button hc-btn type="warning" @click="treeModalShow = true">增补单元</el-button>
-                    <el-button hc-btn type="success">导入</el-button>
+                    <el-button hc-btn type="success" @click="leadModal">导入</el-button>
                 </template>
                 <div class="relative">
                     <infoTable :info-data="curTreeData" />
@@ -83,6 +83,43 @@
                 </template>
             </hc-table>
         </hc-new-dialog>
+        <!-- 导入合同计量单元 -->
+        <hc-new-dialog v-model="leadModalShow" scrollbar widths="1100px" title="合同计量单元导入" @save="leadModalSave">
+            <div class="hc-el-upload-drag">
+                <el-upload
+                    ref="leadUploadRef" hc drag :show-file-list="true" :auto-upload="false" :headers="getHeader()"
+                    action="/api/blade-meter/tree/contract/import" :data="{ id: checkTreeId }" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
+                    :on-error="handFileError"
+                    :on-success="handleFileDUcess"
+                >
+                    <div class="hc-ui-upload-btn">
+                        <div class="hc-uploader-drop">
+                            <div class="upload-icon">
+                                <HcIcon name="upload-cloud" />
+                            </div>
+                            <div class="text">将文件拖动到此处,或点击上传</div>
+                        </div>
+                        <div class="hc-uploader-accept">支持的文件格式: Excel(xls、xlsx)</div>
+                    </div>
+                </el-upload>
+            </div>
+            <hc-title>
+                <span>范例模板</span>
+                <template #extra>
+                    <el-link type="primary" @click="downLoadExel">下载范例模板.xls</el-link>
+                </template>
+            </hc-title>
+            <el-table :data="tableLeadData" style="width: 100%;" row-key="id" border>
+                <el-table-column prop="k1" label="工程编号" width="90" />
+                <el-table-column prop="k2" label="节点编号" width="90" />
+                <el-table-column prop="k3" label="清单编号" width="90" />
+                <el-table-column prop="k4" label="工程名称" />
+                <el-table-column prop="k5" label="施工图数量" width="100" />
+                <el-table-column prop="k6" label="合同图号" width="90" />
+                <el-table-column prop="k7" label="备注" />
+            </el-table>
+            <div class="mt-4 text-orange">特别提示:清单类型分为:1、普通清单,2、计日工清单,3、暂定金清单,请填写具体数字对应</div>
+        </hc-new-dialog>
     </div>
 </template>
 
@@ -98,6 +135,7 @@ import { getStoreValue, setStoreValue } from '~src/utils/storage'
 import { delMessageV2 } from '~com/message/index.js'
 import { getDictionary } from '~api/other'
 import BigNumber from 'bignumber.js'
+import { getHeader } from 'hc-vue3-ui'
 
 const useAppState = useAppStore()
 const projectId = ref(useAppState.getProjectId || '')
@@ -184,7 +222,14 @@ const treeLoadNode = async ({ node, item, level }, resolve) => {
 
 //节点点击
 const isInfoView = ref(false)
+const checkTreeId = ref('')
+const checkTreeLevel = ref('')
 const treeNodeTap = ({ node, data, keys }) => {
+
+    const { level } = node
+    checkTreeLevel.value = level
+    checkTreeId.value = data.id
+    
     getNodeType(data.id)
     isInfoView.value = node.isLeaf
     TreeAutoExpandKeys.value = keys || []
@@ -441,4 +486,49 @@ const sortModalSave = async () => {
         window?.location?.reload() //刷新页面
     }
 }
+//合同计量单元导入
+const leadModalShow = ref(false)
+const leadUploadRef = ref(null)
+
+const leadModal = ()=>{
+    if (!checkTreeId.value) {
+        window.$message.warning('请先选择左侧节点')
+        return
+    }
+    if (checkTreeLevel.value > 3) {
+        window.$message.warning('只能从前三层节点开始导入,操作失败')
+        return
+    }
+    leadModalShow.value = true
+}
+const handleFileDUcess = (res)=>{
+    const { data } = res
+    window.$message.success(data)
+}
+const handFileError = (err)=>{
+    const msg = JSON.parse(err.message).msg
+    window.$message.warning(msg)
+
+}
+const tableLeadData = ref([
+    { id: 1, k1: '100', k2: '100-1', k3: '', k4: 'K01+000~K015+000(举例本标段里程号)', k5: '', k6: '', k7: '' },
+    { id: 2, k1: '', k2: '100-1', k3: '101-1a', k4: '按合同条款规定,提供建筑工程一切险', k5: '5', k6: '', k7: '' },
+    { id: 3, k1: '', k2: '100-1', k3: '101-1b', k4: '线外供电干线设施', k5: '3', k6: '', k7: '' },
+    { id: 4, k1: '200', k2: '100-2', k3: '', k4: 'K01+000~K015+000(举例本标段里程桩号)', k5: '', k6: '', k7: '' },
+    { id: 5, k1: '', k2: '100-2', k3: '200-2-a', k4: '按合同条款规定,提供建筑工程一切险', k5: '5', k6: '', k7: '' },
+    { id: 6, k1: '', k2: '100-2', k3: '200-2-b', k4: '线外供电干线设施', k5: '3', k6: '', k7: '' },
+])
+
+const leadModalSave = async () => {
+    await leadUploadRef.value.submit()
+    leadModalShow.value = false
+    ishowTree.value = false
+    setTimeout(() => {
+        ishowTree.value = true
+    }, 1000)
+}
+//下载范例模板
+const downLoadExel = ()=>{
+   window.open('https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20240109/98addbf48d620030504b2cb03b1c24f5.xls', '_blank')
+}
 </script>