ZaiZai hai 1 ano
pai
achega
812408ad3b

+ 127 - 32
src/views/tentative/detect/components/linkAssociation.vue

@@ -1,32 +1,58 @@
 <template>
-    <hc-body split :project-nmae="projectInfo?.projectName" padding="10px">
-        <template #tree>
-            <TestTree
-                :auto-expand-keys="treeAutoExpandKeys" :project-id="projectId" :tenant-id="userInfo?.tenant_id"
-                :wbs-temp-id="projectInfo?.referenceWbsTemplateIdTrial" :wbs-type="2" @node-tap="wbsElTreeClick"
-            />
-        </template>
-        <hc-new-card>
-            <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }">
-                <template #key4="{ row }">
-                    <el-tag v-if="row.key4 === 1" type="success" effect="dark">已通过</el-tag>
-                    <el-tag v-if="row.key4 === 2" type="danger" effect="dark">已废除</el-tag>
+    <hc-new-dialog v-model="isShow" is-footer-center is-table title="关联委托单" widths="80%" @close="linkSamplingClose">
+        <hc-body split padding="10px">
+            <template #left>
+                <hc-new-card scrollbar>
+                    <TestTree
+                        :auto-expand-keys="treeAutoExpandKeys" :project-id="projectId" :tenant-id="userInfo?.tenant_id"
+                        :wbs-temp-id="projectInfo?.referenceWbsTemplateIdTrial" :wbs-type="2" @node-tap="wbsElTreeClick"
+                    />
+                </hc-new-card>
+            </template>
+            <hc-new-card>
+                <template #header>
+                    <div class="w-50">
+                        <el-select v-model="searchForm.contractId" placeholder="选择合同段" filterable block>
+                            <el-option v-for="item in contractData" :key="item.id" :label="item.contractName" :value="item.id" />
+                        </el-select>
+                    </div>
+                    <div class="ml-2">
+                        <el-button type="primary" @click="searchClick">
+                            <hc-icon name="search-2" />
+                            <span>搜索</span>
+                        </el-button>
+                    </div>
                 </template>
-                <template #action="{ row }">
-                    <el-link type="primary">选择</el-link>
-                    <el-link type="warning">取消选择</el-link>
+                <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }">
+                    <template #status="{ row }">
+                        <el-tag v-if="row.status === 1" type="info" effect="dark">未上报</el-tag>
+                        <el-tag v-if="row.status === 2" type="warning" effect="dark">已上报-待审批</el-tag>
+                        <el-tag v-if="row.status === 3" type="primary" effect="dark">待试验</el-tag>
+                        <el-tag v-if="row.status === 4" type="success" effect="dark">委托完成</el-tag>
+                    </template>
+                    <template #action="{ row }">
+                        <el-link v-if="row.id == currentId" type="success" @click="rowCancel(row)">取消选择</el-link>
+                        <el-link v-else type="primary" @click="rowSelect(row)">选择</el-link>
+                    </template>
+                </hc-table>
+                <template #action>
+                    <hc-pages :pages="searchForm" @change="pageChange" />
                 </template>
-            </hc-table>
-            <template #action>
-                <hc-pages :pages="searchForm" @change="pageChange" />
-            </template>
-        </hc-new-card>
-    </hc-body>
+            </hc-new-card>
+        </hc-body>
+        <template #footer>
+            <el-button @click="linkSamplingClose">取消</el-button>
+            <el-button hc-btn type="primary" @click="linkSamplingClick">确定</el-button>
+        </template>
+    </hc-new-dialog>
 </template>
 
 <script setup>
-import { onActivated, onDeactivated, ref } from 'vue'
+import { ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
+import { getArrValue } from 'js-fast-way'
+import mainApi from '~api/tentative/detect/commission'
+import samplingApi from '~api/tentative/material/sampling'
 import { getStoreValue, setStoreValue } from '~src/utils/storage'
 import TestTree from '~src/views/tentative/material/components/TestTree.vue'
 
@@ -37,24 +63,63 @@ const projectId = ref(useAppState.getProjectId)
 const contractId = ref(useAppState.getContractId)
 const projectInfo = ref(useAppState.getProjectInfo)
 
-//渲染完成
-onActivated(() => {
+const isShow = defineModel('modelValue', {
+    default: false,
+})
 
+//深度监听数据
+const curId = defineModel('id', {
+    type: [String, Number],
+    default: '',
+})
+
+//监听
+watch(() => curId.value, (id) => {
+    currentId.value = id
+})
+
+//监听
+watch(() => isShow.value, (show) => {
+    if (show) getContractData()
 })
 
 //搜索表单
 const searchForm = ref({ current: 1, size: 20, total: 0 })
 
+//获取合同段信息
+const contractData = ref([])
+const getContractData = async () => {
+    const { data } = await samplingApi.getErtractInfo({
+        projectId: projectId.value,
+        contractId: contractId.value,
+    })
+    const res = getArrValue(data)
+    contractData.value = res
+    if (res.length > 0) {
+        searchForm.value.contractId = res[0].id
+    }
+}
+
 //自动展开缓存
 const treeAutoExpandKeys = ref(getStoreValue('testTreeExpandKeys') || [])
 
 //树被点击
 const nodeDataInfo = ref({})
+const nodeErTreeId = ref('')
 const wbsElTreeClick = ({ data, keys }) => {
   nodeDataInfo.value = data
+    nodeErTreeId.value = data['erTreeId'] || ''
   //缓存自动展开
   treeAutoExpandKeys.value = keys
   setStoreValue('testTreeExpandKeys', keys)
+    //获取表格
+    searchClick()
+}
+
+//搜索
+const searchClick = () => {
+    searchForm.value.current = 1
+    getTableData()
 }
 
 //分页被点击
@@ -65,21 +130,51 @@ const pageChange = ({ current, size }) => {
 }
 
 //表格数据
-const tableData = ref([
-  { key4:1 }, { key4:2 },
-])
+const tableData = ref([])
 const tableColumn = ref([
-  { key: 'key1', name: '委托单位' },
-  { key: 'key2', name: '委托单编号' },
-  { key: 'key3', name: '委托单名称' },
-  { key: 'key4', name: '委托单状态', width: 120, align: 'center' },
-  { key: 'action', name: '操作', width: 120, align: 'center' },
+    { key: 'entrustInfo', name: '委托单位' },
+    { key: 'entrustNo', name: '委托单编号' },
+    { key: 'entrustName', name: '委托单名称' },
+    { key: 'status', name: '委托单状态', width: 120, align: 'center' },
+    { key: 'action', name: '操作', width: 120, align: 'center', fixed: 'right' },
 ])
 
 //获取数据
 const tableLoading = ref(false)
 const getTableData = async () => {
+    tableLoading.value = true
+    const { error, code, data } = await mainApi.page(searchForm.value)
+    //处理数据
+    tableLoading.value = false
+    if (!error && code === 200) {
+        tableData.value = getArrValue(data['records'])
+        searchForm.value.total = data.total || 0
+    } else {
+        tableData.value = []
+        searchForm.value.total = 0
+    }
+}
+
+//选择
+const currentId = ref(null)
+const rowSelect = (row) => {
+    currentId.value = row.id
+}
+
+//取消选择
+const rowCancel = () => {
+    currentId.value = null
+}
+
+//确认关联取样材料
+const linkSamplingClick = () => {
+    curId.value = currentId.value
+    linkSamplingClose()
+}
 
+//取消关联取样材料
+const linkSamplingClose = () => {
+    isShow.value = false
 }
 </script>
 

+ 29 - 22
src/views/tentative/detect/test-form.vue

@@ -25,9 +25,7 @@
                 >
                     预览
                 </el-button>
-                <el-button v-if="NodeStatus === '3'" hc-btn color="#FF976A" style="color: white;" @click="abolishOneClick">
-                    撤回上报流程
-                </el-button>
+                <el-button v-if="NodeStatus === '3'" hc-btn color="#FF976A" style="color: white;" @click="abolishOneClick">撤回上报流程</el-button>
                 <el-dropdown @command="dropdownCommand">
                     <el-button type="primary" hc-btn>
                         <span>更多</span>
@@ -47,9 +45,8 @@
             </template>
             <template #search>
                 <div class="mr-5 w-40">
-                    <el-select v-model="listItemBaseData.key1" placeholder="选择标段" filterable clearable block>
-                        <el-option label="测试1" value="1" />
-                        <el-option label="测试2" value="2" />
+                    <el-select v-model="contractId" placeholder="选择标段" filterable block>
+                        <el-option v-for="item in contractData" :key="item.id" :label="item.contractName" :value="item.id" />
                     </el-select>
                 </div>
                 <div class="mr-5 w-32">
@@ -225,18 +222,12 @@
         />
 
         <!-- 关联委托单 -->
-        <hc-new-dialog v-model="isLinksAssociation" is-footer-center is-table title="关联委托单" widths="80%" @close="linksAssociationClose">
-            <LinkAssociation />
-            <template #footer>
-                <el-button @click="linksAssociationClose">取消</el-button>
-                <el-button hc-btn type="primary" @click="linksAssociationClick">确定</el-button>
-            </template>
-        </hc-new-dialog>
+        <LinkAssociation v-model="isLinksAssociation" v-model:id="commissionId" />
     </div>
 </template>
 
 <script setup>
-import { nextTick, onDeactivated, onMounted, ref, watch } from 'vue'
+import { nextTick, onMounted, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
 import { useRoute, useRouter } from 'vue-router'
 import ListItem from './components/ListItem.vue'
@@ -248,11 +239,10 @@ import TestTree from '../material/components/TestTree.vue'
 import TestTreeMaterial from '../material/components/TestTreeMaterial.vue'
 import LinkAssociation from './components/linkAssociation.vue'
 import { arrToId, getArrValue, getObjValue, isNullES, isString } from 'js-fast-way'
-import { getDictionary } from '~api/other'
-import dayjs from 'dayjs'
-import { eVisaTaskCheckApi } from '~api/other'
+import { eVisaTaskCheckApi, getDictionary, getErtractInfo } from '~api/other'
 import wbsApi from '~api/data-fill/wbs'
 import { toPdfPage } from '~uti/btn-auth'
+import dayjs from 'dayjs'
 
 //变量
 const router = useRouter()
@@ -260,7 +250,7 @@ const useRoutes = useRoute()
 const useAppState = useAppStore()
 const userInfo = ref(useAppState.getUserInfo)
 const projectId = ref(useAppState.getProjectId)
-const contractId = ref(useAppState.getContractId)
+const contractIds = ref(useAppState.getContractId)
 const projectInfo = ref(useAppState.getProjectInfo)
 const contractInfo = ref(useAppState.getContractInfo)
 const divisionTree = ref(null)
@@ -281,10 +271,12 @@ const testTreeItem = ref(getStoreValue('testTreeItem'))
 const isMixRatioTestIds = ref(false)
 const tabTypeKey = ref('')
 const isopersampleIds = ref(false)
+const commissionId = ref('')
 
 //渲染完成
 onMounted(() => {
-  tabTypeKey.value = routerQuery?.tabTypeKey || '1'
+    tabTypeKey.value = routerQuery?.tabTypeKey || '1'
+    commissionId.value = routerQuery?.commissionId || ''
   const { title, mixRatioTestIds } = getObjValue(testTreeItem.value)
   const info = getStoreValue('test-form') || {}
   isMixRatioTestIds.value = !(!mixRatioTestIds || mixRatioTestIds <= 0)
@@ -310,11 +302,10 @@ onMounted(() => {
   getSearchNodeTablesall(1)
   getSearchNodeTablesall(2)
   getCategoryData()
+    getContractData()
 })
 //监听路由参数改变
-watch(() => [
-  useRoutes?.query,
-], ([query]) => {
+watch(() => useRoutes?.query, (query) => {
   if (isNullES(query.key)) {
     setTimeout(() => {
       window?.location?.reload() //刷新页面
@@ -332,6 +323,21 @@ watch(() => [
   }
 })
 
+//获取合同段信息
+const contractData = ref([])
+const contractId = ref(contractIds.value)
+const getContractData = async () => {
+    const { data } = await getErtractInfo({
+        projectId: projectId.value,
+        contractId: contractIds.value,
+    })
+    const res = getArrValue(data)
+    contractData.value = res
+    if (res.length > 0) {
+        contractId.value = res[0].id
+    }
+}
+
 //身份按钮切换数据
 const authBtnTabKey = ref(dataType)
 const authBtnTabdata = ref([
@@ -1234,6 +1240,7 @@ const tableFormSaveClick = async () => {
         const { error, code, data, msg } = await dataApi.saveExcelBussData({
           ...listItemBaseData.value,
           isBatchSave: 1,
+            entrustId: commissionId.value,
           dataInfo: { orderList: FormData },
           // deviceUseIds:listDeviceUseIds.value
         })