Ver código fonte

试验汇总接口调用

duy 1 ano atrás
pai
commit
b4cf65ef8e

+ 43 - 0
src/api/modules/tentative/collect/test.js

@@ -0,0 +1,43 @@
+import { httpApi } from '../../../request/httpApi'
+
+//合同段下拉框
+export const getContractList = (form, msg = true) => httpApi({
+    url: '/api/blade-business/trial/summary/contract/list',
+    method: 'get',
+    params: form,
+}, msg)
+
+//汇总分类列表
+export const getSummaryList = (form, msg = true) => httpApi({
+    url: '/api//blade-business/trial/summary/list',
+    method: 'get',
+    params: form,
+}, msg)
+
+//分页查询
+export const getPage = (form, msg = true) => httpApi({
+    url: '/api/blade-business/trial/summary/page',
+    method: 'post',
+    data: form,
+}, msg)
+
+//删除
+export const removeByIds = (form, msg = true) => httpApi({
+    url: '/api//blade-business/trial/summary/remove',
+    method: 'post',
+    params: form,
+}, msg)
+
+//新增
+export const save = (form, msg = true) => httpApi({
+    url: '/api/blade-business/trial/summary/save',
+    method: 'post',
+    data: form,
+}, msg)
+//下载
+export const download = (form, msg = true) => httpApi({
+    url: '/api/blade-business/trial/summary/download',
+    method: 'post',
+    data: form,
+}, msg)
+

+ 295 - 129
src/views/tentative/collect/test.vue

@@ -1,17 +1,18 @@
 <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 class="hc-tree-box ">
+                <div class="title_box">
+                    汇总分类
                 </div>
-                <div class="ml-2 project-name-box">
-                    <span class="project-alias">{{ projectInfo.projectName }}</span>
-                </div>
-            </div>
-            <div class="hc-tree-box">
                 <el-scrollbar>
-                    <HcLazyTree :auto-expand-keys="treeAutoExpandKeys" is-type @load="treeLoadNode" @nodeTap="wbsElTreeClick" />
+                    <div v-for="(item, index) in testOpt" :key="item.id" class="mt-4" :class="item.id === curItem?.id ? 'bg-slate-200' : ''" @click="handleItem(item)">
+                        <i v-if="true" class="ri-circle-fill" />
+                        <i v-else class="ri-arrow-right-s-fill" style="font-size: larger;" />
+                        {{ item.className }}
+                        <span v-if="false" class="ml-4 bg-blue-100">222</span>
+                    </div>
+                    <!-- <HcLazyTree :auto-expand-keys="treeAutoExpandKeys" is-type @load="treeLoadNode" @node-tap="wbsElTreeClick" /> -->
                 </el-scrollbar>
             </div>
             <!-- 左右拖动 -->
@@ -19,17 +20,11 @@
         </div>
         <div class="hc-page-content-box">
             <HcNewCard :scrollbar="false" action-size="lg">
-                <template #header>
-                    <HcTooltip keys="tentative_collect_test_del">
-                        <el-button hc-btn color="#e03997" @click="delModalClick">
-                            <HcIcon name="delete-bin-2" />
-                            <span>删除</span>
-                        </el-button>
-                    </HcTooltip>
+                <template #extra>
                     <HcTooltip keys="tentative_collect_test_print">
-                        <el-button hc-btn color="#567722">
-                            <HcIcon name="printer" />
-                            <span>打印</span>
+                        <el-button hc-btn color="#567722" @click="addClick">
+                            <HcIcon name="add" />
+                            <span>新增</span>
                         </el-button>
                     </HcTooltip>
                     <HcTooltip keys="tentative_collect_test_download">
@@ -38,72 +33,149 @@
                             <span>下载</span>
                         </el-button>
                     </HcTooltip>
+                    <HcTooltip keys="tentative_collect_test_del">
+                        <el-button hc-btn color="#e03997" @click="delModalClick">
+                            <HcIcon name="delete-bin-2" />
+                            <span>删除</span>
+                        </el-button>
+                    </HcTooltip>
                 </template>
-                <template #search>
-                    <div class="w-auto">
-                        <el-select v-model="searchForm.contractId" block clearable placeholder="请选择合同段">
+                <template #header>
+                    <div class="w-64">
+                        <el-select
+                            v-model="searchForm.contractId"
+                            placeholder="请选择"
+                            @change="changeContract"
+                        >
                             <el-option
-                                v-for="item in projectInfo?.contractInfoList" :key="item.id"
-                                :label="item.name" :value="item.id"
+                                v-for="item in contractOptions"
+                                :key="item.id"
+                                :label="item.contractName"
+                                :value="item.id"
                             />
                         </el-select>
                     </div>
-                    <div class="w-32 ml-2">
-                        <el-select v-model="searchForm.type" block clearable placeholder="检测类别">
+                    <div class="w-64 ml-2">
+                        <el-select v-model="searchForm.detectionType" block clearable placeholder="检测类别" @change="changeType">
                             <el-option
                                 v-for="item in typeData" :key="item.value" :label="item.label"
                                 :value="item.value"
                             />
                         </el-select>
                     </div>
-                    <div class="w-32 ml-2">
-                        <el-select v-model="searchForm.approval" block clearable placeholder="审批状态">
-                            <el-option
-                                v-for="item in approvalData" :key="item.value" :label="item.label"
-                                :value="item.value"
-                            />
-                        </el-select>
-                    </div>
+               
                     <div class="w-64 ml-2">
                         <HcDatePicker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
                     </div>
-                    <div class="ml-2">
-                        <el-button type="primary" @click="searchClick">
-                            <HcIcon name="search-2" />
-                            <span>搜索</span>
-                        </el-button>
-                    </div>
                 </template>
                 <HcTable
                     ref="tableRef" :column="tableColumn" :datas="tableData" :loading="tableLoading"
                     is-new :index-style="{ width: 60 }" is-check :check-style="{ width: 29 }"
                     @selection-change="tableSelection"
-                />
+                >
+                    <template #action="{ row }">
+                        <el-button
+                            hc-btn
+                            type="primary" 
+                            @click="viewPdf(row)"
+                        >
+                            <HcIcon name="eye" />
+                            <span>查看</span>
+                        </el-button>
+                    </template>
+                </HcTable>
                 <template #action>
                     <HcPages :pages="searchForm" @change="pageChange" />
                 </template>
             </HcNewCard>
         </div>
+        <hc-new-dialog
+            v-model="addFormShow" :loading="addFormLoading" title="新增分类"
+            widths="30rem" @close="addModalClose" @save="addModalSave"
+        >
+            <el-form
+                ref="addFormRef" :model="addFormModal" :rules="addFormRules"
+                label-position="left" label-width="auto" size="large"
+            >
+                <el-form-item class="mb-0" label="合同段:" prop="contractId">
+                    <el-select
+                        v-model="addFormModal.contractId"
+                        placeholder="请选择"
+                    >
+                        <el-option
+                            v-for="item in contractOptions"
+                            :key="item.id"
+                            :label="item.contractName"
+                            :value="item.id"
+                        />
+                    </el-select>
+                </el-form-item>
+                <el-form-item class="mb-0 mt-4" label="汇总类别:" prop="classId">
+                    <el-select
+                        v-model="addFormModal.classId"
+                        placeholder="请选择"
+                    >
+                        <el-option
+                            v-for="item in testOpt"
+                            :key="item.id"
+                            :label="item.className"
+                            :value="item.id"
+                        />
+                    </el-select>
+                </el-form-item>
+                <el-form-item class="mb-0 mt-4" label="报告时间:">
+                    <HcDatePicker :dates="addbetweenTime" clearable @change="addbetweenTimeUpdate" />
+                </el-form-item>
+            </el-form>
+            <el-form-item class="mb-0 mt-4" label="单位类型:" prop="unitType	">
+                <el-select
+                    v-model="addFormModal.unitType	"
+                    placeholder="请选择"
+                >
+                    <el-option
+                        v-for="item in unitOpt"
+                        :key="item.id"
+                        :label="item.name"
+                        :value="item.id"
+                    />
+                </el-select>
+            </el-form-item>
+            <el-form-item class="mb-0 mt-4" label="检测类型:" prop="detectionType">
+                <el-select
+                    v-model="addFormModal.detectionType"
+                    placeholder="请选择"
+                >
+                    <el-option
+                        v-for="item in typeData" :key="item.value" :label="item.label"
+                        :value="item.value"
+                    />
+                </el-select>
+            </el-form-item>
+        </hc-new-dialog>
     </div>
 </template>
 
 <script setup>
 import { onMounted, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
-import queryApi from '~api/data-fill/query'
-import { getArrValue, getObjValue } from 'js-fast-way'
-import { getStoreValue, setStoreValue } from '~src/utils/storage'
+import { download, getContractList, getPage, getSummaryList, removeByIds, save } from '~api/tentative/collect/test'
+import { arrToId, getArrValue, getObjValue } from 'js-fast-way'
+
 import { delMessageV2 } from '~com/message/index.js'
+import { getDictionary } from '~api/other'
+import { toPdfPage } from '~uti/btn-auth'
 
 //变量
 const useAppState = useAppStore()
 const projectId = ref(useAppState.getProjectId)
 const contractId = ref(useAppState.getContractId)
-const projectInfo = ref(useAppState.getProjectInfo)
+
 const isCollapse = ref(useAppState.getCollapse)
-const contractInfo = ref(useAppState.getContractInfo)
-const { contractType } = contractInfo.value
-const classifyType = ref(contractType === 2 ? '2' : '1')
+
+
+
+
+const contractOptions = ref([])
 //监听
 watch(() => [
     useAppState.getCollapse,
@@ -111,89 +183,109 @@ watch(() => [
     isCollapse.value = Collapse
 })
 
-//自动展开缓存
-const treeAutoExpandKeys = ref(getStoreValue('wbsTreeExpandKeys') || [])
 
-//渲染完成
-onMounted(() => {
 
+//渲染完成
+onMounted(async () => {
+   await gettypeData()
+   await getContractOpt()
+   await getTextOpt()
+   getTableData()
 })
 
 //搜索表单
 const searchForm = ref({
-    contractId: null, type: null, approval: null, betweenTime: null,
+    contractId: null, detectionType: null, betweenTime: null,
     current: 1, size: 20, total: 0,
 })
 
-//树相关的变量
-const primaryKeyId = ref('')
-const nodeItemInfo = ref({})
-const nodeDataInfo = ref({})
-
-//懒加载的数据
-const treeLoadNode = async ({ node, item, level }, resolve) => {
-    let contractIdRelation = '', parentId = '', primaryKeyId = ''
-    if (level !== 0) {
-        const nodeData = getObjValue(item)
-        contractIdRelation = nodeData?.contractIdRelation || ''
-        parentId = contractIdRelation ? nodeData?.primaryKeyId : nodeData?.id
-        primaryKeyId = nodeData?.id || ''
-    }
-    //获取数据
-    const { data } = await queryApi.queryWbsTreeData({
-        contractId: contractId.value || '',
-        contractIdRelation,
-        primaryKeyId,
-        parentId,
-        classifyType: classifyType.value,
+//获取合同段列表
+const getContractOpt = async () => {
+    const { error, code, data } = await getContractList({
+        contractId: contractId.value,
+        projectId: projectId.value,
+      
     })
-    resolve(getArrValue(data))
+    //判断状态
+    if (!error && code === 200) {
+        let resdata = getArrValue(data)
+       contractOptions.value = resdata
+       if ( contractOptions.value.length > 0) {
+        searchForm.value.contractId = contractOptions.value[0].id
+       }
+
+    } else {
+        contractOptions.value = []
+    }
 }
 
-//树被点击
-const wbsElTreeClick = ({ node, data, keys }) => {
-    nodeItemInfo.value = node
-    nodeDataInfo.value = data
-    primaryKeyId.value = data['primaryKeyId'] || ''
-    //缓存自动展开
-    treeAutoExpandKeys.value = keys
-    setStoreValue('wbsTreeExpandKeys', keys)
-    //改变搜索表单数据
-    //searchForm.value.wbsId = data['contractIdRelation'] ? data['id'] : data['primaryKeyId']
-    //searchForm.value.contractIdRelation = data['contractIdRelation']
-    searchForm.value.current = 1
+//获取汇总分类列表
+const testOpt = ref([])
+const getTextOpt = async () => {
+    const { error, code, data } = await getSummaryList()
+    //判断状态
+    if (!error && code === 200) {
+        let resdata = getArrValue(data)
+        testOpt.value = resdata
+        if ( testOpt.value.length > 0) {
+        curItem.value = testOpt.value[0]
+       }
+
+    } else {
+        testOpt.value = []
+    }
+}
+const curItem = ref(null)
+const handleItem = (item)=>{
+    curItem.value = item
     getTableData()
 }
-
 //检测类别
-const typeData = ref([
-    { label: '自检', value: '1' },
-    { label: '抽检', value: '2' },
-    { label: '平行试验', value: '3' },
-    { label: '验证试验', value: '4' },
-    { label: '中心试验', value: '5' },
-])
+const typeData = ref([])
+//获取检测类别
+
+const gettypeData = async () => {
+    const { data } = await getDictionary({
+        code: 'trial_detection_category',
+    })
+    //处理数据
+    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']),
+        })
+    }
+    typeData.value = newArr
+}
 
-//审批状态
-const approvalData = ref([
-    { label: '未上报', value: '1' },
-    { label: '待审批', value: '2' },
-    { label: '已审批', value: '3' },
-])
 
 //日期时间被选择
 const betweenTime = ref(null)
 const betweenTimeUpdate = ({ arr, query }) => {
     betweenTime.value = arr
-    searchForm.value.betweenTime = query
+    searchForm.value.startDate = arr[0]
+    searchForm.value.endDate = arr[1]
+    getTableData()
+}
+const addbetweenTime = ref(null)
+const addbetweenTimeUpdate = ({ arr, query }) => {
+    addbetweenTime.value = arr
+    addFormModal.value.startDate = arr[0]
+    addFormModal.value.endDate = arr[1]
+ 
 }
 
-//搜索
-const searchClick = () => {
-    searchForm.value.current = 1
+//选择检测类别
+const changeType = ()=>{
+    getTableData()
+}
+const changeContract = ()=>{
     getTableData()
 }
 
+
 //分页被点击
 const pageChange = ({ current, size }) => {
     searchForm.value.current = current
@@ -204,34 +296,39 @@ const pageChange = ({ current, size }) => {
 //表格数据
 const tableRef = ref(null)
 const tableColumn = ref([
-    { key: 'key1', name: '报告编号' },
-    { key: 'key2', name: '工程部位' },
-    { key: 'key3', name: '试验日期' },
-    { key: 'key4', name: '样品编号' },
-    { key: 'key5', name: '生产厂家' },
-    { key: 'key6', name: '规格型号' },
-    { key: 'key7', name: '代表数量' },
-    { key: 'key8', name: '密度(开kg/m3)' },
-    { key: 'key9', name: '比表面积(m2/kg)' },
-    { key: 'key10', name: '细度(%)' },
-    { key: 'key11', name: '标准稠度用水量(%)' },
-    { key: 'key12', name: '初凝结时间(min)' },
-    { key: 'key13', name: '终凝结时间(min)' },
-    { key: 'key14', name: '安定性霍氏夹法' },
-    { key: 'key15', name: '抗折3D胶砂强度(Mpa)' },
-    { key: 'key16', name: '抗折28D胶砂强度(Mpa)' },
-    { key: 'key17', name: '抗压3D胶砂强度(Mpa)' },
-    { key: 'key18', name: '抗压28D胶砂强度(Mpa)' },
-    { key: 'key19', name: '试验结果' },
-    { key: 'key20', name: '检测类型' },
-    { key: 'key21', name: '检测人' },
+    { key: 'summaryNumber', name: '汇总编号' },
+    { key: 'classIdName', name: '汇总类别' },
+    { key: 'detectionTypeName', name: '检测类型' },
+    { key: 'summaryDateName', name: '汇总日期' },
+    { key: 'action', name: '操作', width:100 },
+   
 ])
 
 //获取数据
 const tableLoading = ref(false)
 const tableData = ref([])
 const getTableData = async () => {
+    if (!searchForm.value.contractId) {
+        window.$message.warning('请选择合同段')
+        return
+    }
+    if (curItem.value) {
+        const { error, code, data } = await getPage({
+            ...searchForm.value,
+            classId:curItem.value?.id,
+        })
+        //判断状态
+        if (!error && code === 200) {
+            let resdata = getArrValue(data['records'])
+        tableData.value = resdata
 
+        } else {
+            tableData.value = []
+        }
+    } else {
+        window.$message.warning('请先选择汇总分类')
+    }
+   
 }
 
 //多选
@@ -244,10 +341,14 @@ const tableSelection = (rows) => {
 
 //删除
 const delModalClick = () => {
+    if (tableCheckedKeys.value.length === 0) {
+        window.$message.warning('请先选择数据')
+        return
+    }
     delMessageV2(async (action, instance, done) => {
             if (action === 'confirm') {
                 instance.confirmButtonLoading = true
-                  //removeContractTreeNode()
+                  removeContractTreeNode()
                 instance.confirmButtonLoading = false
                 done()
             } else {
@@ -255,7 +356,22 @@ const delModalClick = () => {
             }
      })
 }
-
+const removeContractTreeNode = async () => {
+    const loadingInstance = window.$loading.service({
+        fullscreen: true,
+        text: '删除节点中,请耐心等待...',
+        background: 'rgba(0, 0, 0, 0.7)',
+    })
+  
+    const { error, code } = await removeByIds({
+        ids: arrToId( tableCheckedKeys.value),
+    })
+    loadingInstance.close()
+    if (!error && code === 200) {
+        window?.$message?.success('删除成功')
+            getTableData()
+    }
+}
 //左右拖动,改变树形结构宽度
 const leftWidth = ref(382)
 const onmousedown = () => {
@@ -271,8 +387,58 @@ const onmousedown = () => {
         document.onmouseup = null
     }
 }
+//查看pdf
+const viewPdf = (row)=>{
+    const { pdfUrl } = row
+    if (pdfUrl) {
+        toPdfPage(pdfUrl)
+    } else {
+        window.$message.warning('暂无数据')
+    }
+}
+
+//新增试验汇总
+const addFormModal = ref({})
+const addFormShow = ref(false)
+const addFormLoading = ref(false)
+const addClick = ()=>{
+ 
+    addFormShow.value = true
+
+}
+const addModalClose = ()=>{
+    addFormShow.value = false
+    addFormModal.value = {}
+  
+}
+
+const addFormRules = ref(null)
+const addFormRef = ref(null)
+
+const addModalSave = async ()=>{
+    console.log(addFormModal.value)
+    addFormLoading.value = true
+    const { error, code, msg } = await save({
+            ...addFormModal.value,
+            
+     })
+     addFormLoading.value = false
+        //判断状态
+        if (!error && code === 200) {
+         window.$message.success(msg)
+         addFormShow.value = false
+         getTableData()
+
+        } 
+}
+const unitOpt = ref([
+    { name:'施工', id:'1' },
+])
 </script>
 
 <style lang="scss" scoped>
-
+.title_box{
+    font-size: 24px;
+    font-weight: bolder;
+}
 </style>