Bladeren bron

关联样品修改

duy 3 maanden geleden
bovenliggende
commit
c1d1b0b689
1 gewijzigde bestanden met toevoegingen van 123 en 2 verwijderingen
  1. 123 2
      src/views/tentative/detect/components/basicInfo.vue

+ 123 - 2
src/views/tentative/detect/components/basicInfo.vue

@@ -99,7 +99,7 @@
                 
                 <div class="header_title">
                     <div class="text-bold">样品信息</div>
-                    <el-link type="primary">关联样品</el-link>
+                    <el-link type="primary" @click="linkSample">关联样品</el-link>
                 </div>
 
                 <div class="form-box">
@@ -201,11 +201,46 @@
                 </div>
             </hc-card>
         </div>
+        
+        <!-- 关联取样 -->
+        <hc-new-dialog
+            v-model="linksSampleModal" is-table save-text="确认" title="关联取样信息" widths="75rem"
+            @close="linksSampleModalClose" @save="linksSampleModalSave"
+        >
+            <div class="hc-links-sample-modal-box">
+                <div class="hc-links-sample-tree-box">
+                    <el-scrollbar>
+                        <TestTree
+                            :project-id="projectId" :tenant-id="userInfo?.tenant_id"
+                            :wbs-temp-id="projectInfo?.referenceWbsTemplateIdTrial" :wbs-type="2"
+                            :entrust="1" @node-tap="linksSampleTreeClick"
+                        />
+                    </el-scrollbar>
+                </div>
+                <div class="hc-links-sample-table-box">
+                    <HcTable
+                        ref="tableSampleRef" :column="linksSampleTableColumn" :datas="linksSampleTableData"
+                        :is-index="false" :loading="linksSampleTableLoading" is-new is-check
+                        :check-style="{ width: 29 }"
+                        @selection-change="linksSampleTableSelection"
+                    />
+                </div>
+            </div>
+        </hc-new-dialog>
     </hc-drawer>
 </template>
 
 <script setup>
-import { ref } from 'vue'
+import { nextTick, ref } from 'vue'
+import TestTree from '../../material/components/TestTree.vue'
+import { useAppStore } from '~src/store'
+import { getArrValue } from 'js-fast-way'
+import dataApi from '~api/tentative/detect/test'
+const useAppState = useAppStore()
+const userInfo = ref(useAppState.getUserInfo)
+const projectId = ref(useAppState.getProjectId)
+const projectInfo = ref(useAppState.getProjectInfo)
+const contractId = ref(useAppState.getContractId)
 const handleSave = () => {}
 const handleRefresh = () => {}
 const isShow = defineModel('modelValue', {
@@ -235,6 +270,74 @@ const tableData = ref([
     { name: '名称3', text: '文本3', color: '无' },
    
 ])
+//关联取样
+const linksSampleModal = ref(false)
+
+const linkSample = () => {
+    linksSampleModal.value = true
+}
+
+
+const linksSampleTableColumn = [
+     { key: 'materialName', name: '样品名称' },
+    { key: 'samplingDate', name: '取样日期' },
+    { key: 'specificationModel', name: '规格型号' },
+    { key: 'proposedPosition', name: '拟用部位' },
+    { key: 'userName', name: '取样人' },
+]
+const linksSampleTableData = ref([])
+const linksSampleTableLoading = ref(false)
+const tableSampleRef = ref()
+//搜索表单
+const linksSampleSearchForm = ref({
+    nodeId: null, current: 1, size: 20, total: 0,
+})
+//关联取样树点击事件
+const linksSampleTreeClick = ({ data }) => {
+        linksSampleSearchForm.value.nodeId = data.primaryKeyId
+    linksSampleSearchForm.value.current = 1
+    getLinksSampleData()
+}
+//获取关联数据
+
+const getLinksSampleData = async () => {
+    linksSampleTableLoading.value = true
+    const { error, code, data } = await dataApi.sampleListInfo({
+        ...linksSampleSearchForm.value,
+        projectId: projectId.value,
+        contractId: contractId.value,
+        id: '',
+    })
+    //处理数据
+    linksSampleTableLoading.value = false
+    if (!error && code === 200) {
+        linksSampleTableData.value = getArrValue(data)
+        linksSampleTableData.value.forEach((iten) => {
+            if (iten.isRelation === 1) {
+                nextTick(() => {
+                    tableSampleRef.value?.toggleRowSelection(iten, true)
+                })
+
+            }
+        })
+        //searchForm.value.total = data.total || 0
+    } else {
+        linksSampleTableData.value = []
+        //searchForm.value.total = 0
+    }
+}
+//关闭关联取样
+const linksSampleModalClose = () => {
+    linksSampleModal.value = false
+}
+const linksSampleModalSave = () => {
+    linksSampleModal.value = false
+}
+//多选
+const tableSampleCheckedKeys = ref([])
+const linksSampleTableSelection = (rows) => {
+    tableSampleCheckedKeys.value = rows
+}
 </script>
 
 <style scoped lang="scss">
@@ -256,4 +359,22 @@ const tableData = ref([
     padding-left:30px ;
     padding-right:30px ;
 }
+.hc-links-sample-modal-box {
+    position: relative;
+    height: 100%;
+    display: flex;
+    .hc-links-sample-tree-box,
+    .hc-links-sample-table-box {
+        position: relative;
+        width: 300px;
+        height: 100%;
+    }
+    .hc-links-sample-tree-box {
+        margin-right: 24px;
+        border: 1px solid #EEEEEE;
+    }
+    .hc-links-sample-table-box {
+        flex: 1;
+    }
+}
 </style>