Переглянути джерело

Merge remote-tracking branch 'origin/master'

ZaiZai 8 місяців тому
батько
коміт
b8126b285f

+ 35 - 0
src/api/modules/tentative/collect/month.js

@@ -0,0 +1,35 @@
+import { httpApi } from '../../../request/httpApi'
+
+
+
+//月报汇总分页查询
+export const getMonthPage = (form, msg = true) => httpApi({
+    url: '/api/blade-business/trial/summary/monthly/page',
+    method: 'post',
+    data: form,
+}, msg)
+//月报汇总编辑备注
+export const editRemark = (form, msg = true) => httpApi({
+    url: '/api/blade-business/trial/summary/monthly/edit',
+    method: 'post',
+    data: form,
+}, msg)
+
+//月报汇总下载
+export const download = (form, msg = true) => httpApi({
+    url: '/api/blade-business/trial/summary/monthly/download',
+    method: 'post',
+    data: form,
+}, msg)
+
+//月报汇总打印
+export const print = (form, msg = true) => httpApi({
+    url: '/api/blade-business/trial/summary/monthly/print',
+    method: 'post',
+    data: form,
+}, msg)
+
+
+
+
+

+ 30 - 0
src/utils/tools.js

@@ -66,3 +66,33 @@ export const setAppName = (name) => {
 export const isPathUrl = (path) => {
     return /^(https?:|mailto:|tel:)/.test(path)
 }
+
+//判断起止时间是否为1个月
+export const isExactlyOneMonthApart = (dateStr1, dateStr2)=> {
+    // 将日期字符串转换为 Date 对象
+    const date1 = new Date(dateStr1)
+    const date2 = new Date(dateStr2)
+    
+    // 获取两个日期的年、月、日
+    const year1 = date1.getFullYear()
+    const month1 = date1.getMonth()
+    const day1 = date1.getDate()
+    
+    const year2 = date2.getFullYear()
+    const month2 = date2.getMonth()
+    const day2 = date2.getDate()
+    
+    // 计算日期差值(以毫秒为单位)
+    const diff = Math.abs(date2 - date1)
+    
+    // 计算日期相差的天数
+    const daysDiff = Math.ceil(diff / (1000 * 60 * 60 * 24))
+    
+    // 判断日期相差的天数是否等于一个月的天数
+    const daysInMonth1 = new Date(year1, month1 + 1, 0).getDate() // 当月的天数
+    const daysInMonth2 = new Date(year2, month2 + 1, 0).getDate() // 下个月的天数
+    
+    return daysDiff === daysInMonth1 || daysDiff === daysInMonth2
+}
+
+

+ 61 - 1
src/views/data-fill/wbs.vue

@@ -507,7 +507,28 @@
         </hc-new-dialog>
         <!-- 上传文件 -->
         <hc-new-dialog v-model="uploadModal" :footer="false" title="上传文件" widths="38rem" @close="uploadModalClose">
-            <HcUpload :datas="uploadData" :file-list="fileListData" :is-canupload="false" action="/api/blade-manager/exceltab/add-bussfile-node" accept="application/pdf" accept-tip="允许格式:pdf" @change="uploadChange" @close="uploadModalClose" />
+            <div class="mb-4">
+                <span style="color: red;">*</span> 选择附件类型:
+                <el-select
+                    v-model="typevalue"
+                    placeholder="请选择"
+                    style="width: 240px"
+                    clearable
+                >
+                    <el-option
+                        v-for="item in typeoptions"
+                        :key="item.value"
+                        :label="item.label"
+                        :value="item.value"
+                    />
+                </el-select>
+            </div>
+            <HcUpload
+                :datas="uploadData" :file-list="fileListData" :is-canupload="false" action="/api/blade-manager/exceltab/add-bussfile-node" accept="application/pdf" accept-tip="允许格式:pdf" :disabled="!typevalue" 
+                @change="uploadChange"
+                @close="uploadModalClose"
+                @upload="beforeUpload"
+            />
         </hc-new-dialog>
     </div>
 </template>
@@ -1974,6 +1995,41 @@ const syncdata = async ()=>{
     }
 }
 //附件添加
+
+const typeoptions = ref([
+{
+    value: '1',
+    label: '模板1',
+  },
+  {
+    value: '2',
+    label: '模板2',
+  },
+])
+const getFileTypeApi = async () => {
+    const { data } = await getDictionary({
+        code: 'wbs_node_type',
+    })
+    //处理数据
+    let newArr = []
+    const newData = getArrValue(data)
+    for (let i = 0; i < newData.length; i++) {
+        newArr.push({
+            label: newData[i]['dictValue'],
+            value: Number(newData[i]['dictKey']),
+        })
+    }
+    typeoptions.value = newArr
+}
+const typevalue = ref('')
+const beforeUpload = ()=>{
+    console.log(1111111)
+    if (!typevalue.value) {
+        window.$message.warning('请先选择模板')
+        return
+    
+    }
+}
 const isCanadd = ref(true)
  const uploadModal = ref(false)
  const fileListData = ref([])
@@ -1981,6 +2037,8 @@ const uploadData = ref({})
 const uploadModalClose = ()=>{
     uploadModal.value = false
  }
+
+
 //获取附件添加列表
 const getBussFileList = async (pkeyId) => {
     const { error, code, data } = await wbsApi.selectTableFileListByTen({
@@ -1995,10 +2053,12 @@ const getBussFileList = async (pkeyId) => {
 const addFilelist = ()=>{
     getBussFileList(primaryKeyId.value)
      uploadModal.value = true
+    //  getFileTypeApi()
        //上传的配置
        uploadData.value = {
                 classify:authBtnTabKey.value,
                 nodeId: primaryKeyId.value,
+                type:typevalue.value,
             }
 
 }

+ 123 - 168
src/views/tentative/collect/monthly.vue

@@ -1,45 +1,9 @@
 <template>
     <div class="hc-page-layout-box">
-        <!-- <div :style="`width:${leftWidth}px;`" class="hc-layout-left-box bg-white">
-            <div class="hc-project-box">
-                <div class="hc-project-icon-box">
-                    <HcIcon name="stack" />
-                </div>
-                <div class="ml-2 project-name-box">
-                    <span class="project-alias">{{ projectInfo.projectName }}</span>
-                </div>
-            </div>
-            <div class="hc-tree-search-box">
-                <div class="hc-search-tree-val">
-                    <el-input v-model="searchTreeVal" block clearable placeholder="请输入名称关键词检索" @keyup="searchTreeKeyUp">
-                        <template #suffix>
-                            <HcIcon name="search-2" ui="text-xl" />
-                        </template>
-                    </el-input>
-                </div>
-                <div v-loading="treeLoading" class="hc-tree-scrollbar" element-loading-text="获取数据中...">
-                    <el-scrollbar>
-                        <KeepAlive>
-                            <template v-if="isSearchTree">
-                                <HcTreeData :datas="searchTreeData" @change="testTreeCheckChange" />
-                            </template>
-                            <template v-else>
-                                <TestTree
-                                    :contract-id="contractId" :project-id="projectId"
-                                    @change="testTreeCheckChange"
-                                />
-                            </template>
-                        </KeepAlive>
-                    </el-scrollbar>
-                </div>
-            </div>
-    
-            <div class="horizontal-drag-line" @mousedown="onmousedown" />
-        </div> -->
         <div class="hc-page-content-box">
             <HcNewCard>
                 <template #header>
-                    <div class="w-40">
+                    <div class="w-60">
                         <el-select v-model="searchForm.type" clearable placeholder="请选择检测类别">
                             <el-option
                                 v-for="item in typeData" :key="item.value" :label="item.label"
@@ -52,15 +16,18 @@
                     </div>
                     <div class="w-64 ml-2">
                         <el-tree-select
+                            ref="selectTree"
                             v-model="testId"
-                            :data="testData"
-                            :render-after-expand="false"
-                            show-checkbox
+                            lazy
+                            multiple
+                            :load="tesrtreeload"
+                            :props="testprops"
                             style="width: 240px"
+                            show-checkbox
                             placeholder="请选择试验检测项目名称"
                         />
                     </div>
-                    <div class="ml-2">
+                    <div class="ml-14">
                         <el-button type="primary" @click="searchClick">
                             <HcIcon name="search-2" />
                             <span>搜索</span>
@@ -75,7 +42,7 @@
                         </el-button>
                     </HcTooltip>
                     <HcTooltip keys="tentative_collect_monthly_print">
-                        <el-button hc-btn color="#567722">
+                        <el-button hc-btn color="#567722" @click="print">
                             <HcIcon name="printer" />
                             <span>打印</span>
                         </el-button>
@@ -132,22 +99,22 @@
 <script setup>
 import { onMounted, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
-import { useRoute, useRouter } from 'vue-router'
-import TestTree from './components/TestTree.vue'
-import HcTreeData from './components/HcTreeData.vue'
+
+
 import queryApi from '~api/data-fill/query'
-import { getArrValue } from 'js-fast-way'
+import { calcDate, getArrValue } from 'js-fast-way'
 import { getDictionary } from '~api/other'
+import samplingApi from '~api/tentative/material/sampling'
+import { editRemark, getMonthPage } from '~api/tentative/collect/month'
+import { isExactlyOneMonthApart } from '~uti/tools'
 
-//初始变量
-const router = useRouter()
-const useRoutes = useRoute()
 const useAppState = useAppStore()
 
 //全局变量
 const projectId = ref(useAppState.getProjectId)
 const contractId = ref(useAppState.getContractId)
 const projectInfo = ref(useAppState.getProjectInfo)
+const userInfo = ref(useAppState.getUserInfo)
 const isCollapse = ref(useAppState.getCollapse)
 
 //监听
@@ -193,79 +160,38 @@ const searchTreeClick = async () => {
 }
 
 const testId = ref()
-const testData = ref([
-{
-    value: '1',
-    label: 'Level one 1',
-    children: [
-      {
-        value: '1-1',
-        label: 'Level two 1-1',
-        children: [
-          {
-            value: '1-1-1',
-            label: 'Level three 1-1-1',
-          },
-        ],
-      },
-    ],
-  },
-  {
-    value: '2',
-    label: 'Level one 2',
-    children: [
-      {
-        value: '2-1',
-        label: 'Level two 2-1',
-        children: [
-          {
-            value: '2-1-1',
-            label: 'Level three 2-1-1',
-          },
-        ],
-      },
-      {
-        value: '2-2',
-        label: 'Level two 2-2',
-        children: [
-          {
-            value: '2-2-1',
-            label: 'Level three 2-2-1',
-          },
-        ],
-      },
-    ],
-  },
-  {
-    value: '3',
-    label: 'Level one 3',
-    children: [
-      {
-        value: '3-1',
-        label: 'Level two 3-1',
-        children: [
-          {
-            value: '3-1-1',
-            label: 'Level three 3-1-1',
-          },
-        ],
-      },
-      {
-        value: '3-2',
-        label: 'Level two 3-2',
-        children: [
-          {
-            value: '3-2-1',
-            label: 'Level three 3-2-1',
-          },
-        ],
-      },
-    ],
-  },
-])
+const selectTree = ref(null)
+const tesrtreeload = async (node, resolve) => {
+    let parentId = '0'
+    if (node.level !== 0) {
+        parentId = node?.data?.id
+    }
+    //获取数据
+    const { error, code, data } = await samplingApi.queryLazyTree({
+        wbsId:projectInfo.value?.referenceWbsTemplateIdTrial,
+        tenantId:  userInfo.value?.tenant_id,
+        projectId: projectId.value,
+        parentId,
+        wbsType: 2,
+    })
+    //处理数据
+    if (!error && code === 200) {
+        resolve(getArrValue(data))
+    } else {
+        resolve([])
+    }
+}
+
+const testprops = ref({
+    label: 'title',
+    children: 'children',
+    isLeaf: function (data) {
+          return !data.hasChildren
+    },
+})
 //搜索表单
 const searchForm = ref({
-    type: null, approval: null, betweenTime: null,
+    type: '', contractId: '', endTime: '', startTime:'', ids:'',
     current: 1, size: 20, total: 0,
 })
 //检测类别
@@ -289,13 +215,26 @@ const gettypeData = async () => {
 //日期时间被选择
 const betweenTime = ref(null)
 const betweenTimeUpdate = ({ arr, query }) => {
+    const date1 = new Date(arr[0])
+    const date2 = new Date(arr[1])
+     // 计算两个日期的月份差
+    //  const monthDiff = isExactlyOneMonthApart(date1, date2)
+    //  console.log(monthDiff, 'monthDiff')
+    //  if (!monthDiff) {
+    //     window.$message.warning('起始时间必须为1个月')
+    //     return
+    //  }
+
     betweenTime.value = arr
-    searchForm.value.betweenTime = query
+    searchForm.value.startTime = arr[0]
+    searchForm.value.endTime = arr[1]
 }
 
 //搜索
 const searchClick = () => {
     searchForm.value.current = 1
+    searchForm.value.ids = testId.value.join(',')
+    console.log(testId.value, '11111111')
     getTableData()
 }
 
@@ -325,52 +264,57 @@ const tableSpanMethod = ({ rowIndex, columnIndex }) => {
 
 //获取数据
 const tableLoading = ref(false)
-const tableData = ref([
-    {
-        title: 'No. 189, Grove St, Los Angeles',
-        month: '本月',
-        name: '100',
-        state: '2',
-        zip: 'CA 90036',
-    },
-    {
-        title: 'No. 189, Grove St, Los Angeles',
-        month: '累计',
-        name: '100',
-        state: '2',
-        zip: 'CA 90036',
-    },
-    {
-        title: 'No. 189, Grove St, Los Angeles',
-        month: '本月',
-        name: '100',
-        state: '2',
-        zip: 'CA 90036',
-    },
-    {
-        title: 'No. 189, Grove St, Los Angeles',
-        month: '累计',
-        name: '100',
-        state: '2',
-        zip: 'CA 90036',
-    },
-    {
-        title: 'No. 189, Grove St, Los Angeles',
-        month: '本月',
-        name: '100',
-        state: '2',
-        zip: 'CA 90036',
-    },
-    {
-        title: 'No. 189, Grove St, Los Angeles',
-        month: '累计',
-        name: '100',
-        state: '2',
-        zip: 'CA 90036',
-    },
-])
-const getTableData = () => {
+const tableData = ref([])
+const getTableData = async () => {
+    if (!searchForm.value.type) {
+        window.$message.warning('请选择检查类别')
+        return
+    } else if (!searchForm.value.startTime || !searchForm.value.endTime) {
+        window.$message.warning('请选择开始时间和结束时间')
+        return
+    } else if (searchForm.value.ids) {
+        window.$message.warning('请选择试验检测项目名称')
+        return
+    }
+    tableLoading.value = true
+    const { error, code, data } = await getMonthPage({
+            ...searchForm.value,
+            ids:'1635200237830144002',
+            contractId:contractId.value,
+        })
+        tableLoading.value = false
+        //判断状态
+        if (!error && code === 200) {
+            let resdata = getArrValue(data['records'])
+        let arr = []
+        resdata.forEach((ele)=>{
+            let obj1 = {
+                title:ele.trialProjectName,
+                month: '本月',
+                name: ele.currentMonth.qualifiedTotal,
+                state: ele.currentMonth.unQualifiedTotal,
+                zip:  ele.currentMonth.remarks,
 
+            }
+            let obj2 = {
+                title:ele.trialProjectName,
+                month: '累计',
+                name: ele.totalMonth.qualifiedTotal,
+                state: ele.totalMonth.unQualifiedTotal,
+                zip:  ele.totalMonth.remarks,
+
+            }
+            arr.push(obj1)
+            arr.push(obj2)
+             tableData.value = arr
+             searchForm.value.total = data['total']
+        })
+  
+   
+
+        } else {
+            tableData.value = []
+        }
 }
 
 
@@ -383,8 +327,19 @@ const editorsNoteModalClick = (row) => {
 
 //保存
 const editorsNoteLoading = ref(false)
-const editorsNoteModalSave = () => {
-    editorsNoteModal.value = true
+const editorsNoteModalSave = async (id) => {
+    // editorsNoteModal.value = true
+    const { error, code, data, msg } = await editRemark({
+        contractId: contractId.value,
+        recordId: id,
+        remarks:editorsNoteVal.value,
+      
+    })
+    //判断状态
+    if (!error && code === 200) {
+     window.$message.success(msg)
+     editorsNoteModal.value = false
+    }
 }
 const editorsNoteModalClose = () => {
     editorsNoteModal.value = false