ZaiZai 1 an în urmă
părinte
comite
9eac1b2a33

+ 3 - 27
src/api/modules/tentative/detect/commission.js

@@ -9,38 +9,14 @@ export default {
             params: form,
         }, msg)
     },
-    //新增
-    async save(form, msg = true) {
+    //委托单信息表
+    async htmlSave(form, msg = true) {
         return HcApi({
-            url: '/api/blade-business/uentrustinfo/save',
+            url: '/api/blade-business/entrustinfo/save_buss_data',
             method: 'post',
             data: form,
         }, msg)
     },
-    //修改
-    async update(form, msg = true) {
-        return HcApi({
-            url: '/api/blade-business/uentrustinfo/update',
-            method: 'post',
-            data: form,
-        }, msg)
-    },
-    //新增或修改
-    async submit(form, msg = true) {
-        return HcApi({
-            url: '/api/blade-business/uentrustinfo/submit',
-            method: 'post',
-            data: form,
-        }, msg)
-    },
-    //删除
-    async remove(ids, msg = true) {
-        return HcApi({
-            url: '/api/blade-business/uentrustinfo/remove',
-            method: 'post',
-            params: { ids },
-        }, msg)
-    },
     //详情
     async detail(id, msg = true) {
         return HcApi({

+ 34 - 26
src/views/tentative/detect/commission.vue

@@ -77,19 +77,13 @@
             </div>
             <template #footer>
                 <el-button @click="delegateModalClose">取消</el-button>
-                <el-button hc-btn type="warning" @click="linkSamplingShow">关联取样材料</el-button>
+                <el-button hc-btn type="warning" @click="linkSamplingModal = true">关联取样材料</el-button>
                 <el-button hc-btn type="primary" @click="creatingDelegate">创建</el-button>
             </template>
         </hc-new-dialog>
 
         <!-- 关联取样材料 -->
-        <hc-new-dialog v-model="linkSamplingModal" is-footer-center is-table title="关联取样材料" widths="80%" @close="linkSamplingClose">
-            <SamplingPage />
-            <template #footer>
-                <el-button @click="linkSamplingClose">取消</el-button>
-                <el-button hc-btn type="primary" @click="linkSamplingClick">确定</el-button>
-            </template>
-        </hc-new-dialog>
+        <SamplingPage v-model="linkSamplingModal" v-model:id="delegateHtmlForm.sampleId" />
 
         <!-- 创建报告 -->
         <hc-new-dialog v-model="rowActionModal" is-footer-center title="创建报告" widths="40rem" @close="rowActionModalClose">
@@ -230,7 +224,7 @@ const tableColumn = ref([
     { key: 'entrustName', name: '委托单名称' },
     { key: 'materialName', name: '关联材料名称' },
     { key: 'status', name: '委托单状态', width: 120, align: 'center' },
-    { key: 'action', name: '操作', width: 120, align: 'center' },
+    { key: 'action', name: '操作', width: 120, align: 'center', fixed: 'right' },
 ])
 
 //获取数据
@@ -308,34 +302,48 @@ const delegateHtmlRender = (form) => {
 //修改
 const rowEdit = (row) => {
     delegateModal.value = true
+    const { contractId } = deepClone(searchForm.value)
+    delegateContractId.value = contractId
+    if (!isNullES(contractId)) {
+        delegateContractChange()
+    }
 }
 
+//关联取样材料
+const linkSamplingModal = ref(false)
+
 //创建委托
 const creatingDelegate = async () => {
-    console.log(delegateHtmlForm.value)
-    //delegateModalClose()
+    const form = delegateHtmlForm.value
+    if (isNullES(delegateContractId.value)) {
+        window.$message.warning('请先选择合同段')
+        return
+    }
+    form.contractId = delegateContractId.value
+    form.nodeErTreeId = nodeErTreeId.value
+    if (isNullES(form.sampleId)) {
+        window.$message.warning('请先关联取样材料')
+        return
+    }
+    console.log(form)
+    const { error, code, msg } = await mainApi.htmlSave(form)
+    if (!error && code === 200) {
+        window.$message.success('创建成功')
+        delegateModalClose()
+    } else {
+        window.$message.error(msg || '创建失败')
+    }
 }
 
 //关闭委托
 const delegateModalClose = () => {
     delegateModal.value = false
+    delegateHtmlForm.value = {}
+    delegateHtml.value = ''
+    delegateContractId.value = null
+    delegateHtmlLoading.value = false
 }
 
-//关联取样材料
-const linkSamplingModal = ref(false)
-const linkSamplingShow = () => {
-    linkSamplingModal.value = true
-}
-
-//确认关联取样材料
-const linkSamplingClick = () => {
-    linkSamplingClose()
-}
-
-//取消关联取样材料
-const linkSamplingClose = () => {
-    linkSamplingModal.value = false
-}
 
 //查看
 const rowView = (row) => {

+ 104 - 33
src/views/tentative/detect/commission/sampling.vue

@@ -1,35 +1,55 @@
 <template>
-    <hc-body split :project-nmae="projectInfo?.projectName">
-        <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 #action="{ row }">
-                    <el-link v-if="row.id === 1" type="primary" @click="rowSelect(row)">选择</el-link>
-                    <el-link v-else type="success" @click="rowCancel(row)">取消选择</el-link>
-                </template>
-            </hc-table>
-            <template #action>
-                <hc-pages :pages="searchForm" @change="pageChange" />
+    <!-- 关联取样材料 -->
+    <hc-new-dialog v-model="isShow" is-footer-center is-table title="关联取样材料" widths="80%" @close="linkSamplingClose">
+        <hc-body v-if="isShow" split>
+            <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>
-    </hc-body>
+            <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>
+                <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoading" :index-style="{ width: 60 }">
+                    <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-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 { ref } from 'vue'
+import { ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
 import TestTree from '~src/views/tentative/material/components/TestTree.vue'
 import { getStoreValue, setStoreValue } from '~src/utils/storage'
 import samplingApi from '~api/tentative/material/sampling'
 import { getArrValue } from 'js-fast-way'
 
-//事件
-const emit = defineEmits(['change'])
 //变量
 const useAppState = useAppStore()
 const userInfo = ref(useAppState.getUserInfo)
@@ -37,12 +57,46 @@ const projectId = ref(useAppState.getProjectId)
 const contractId = ref(useAppState.getContractId)
 const projectInfo = ref(useAppState.getProjectInfo)
 
+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 treeAutoExpandKeys = ref(getStoreValue('testTreeExpandKeys') || [])
 
 //搜索表单
 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 nodeDataInfo = ref({})
 const wbsElTreeClick = ({ data, keys }) => {
@@ -56,6 +110,12 @@ const wbsElTreeClick = ({ data, keys }) => {
     getTableData()
 }
 
+//搜索
+const searchClick = () => {
+    searchForm.value.current = 1
+    getTableData()
+}
+
 //分页被点击
 const pageChange = ({ current, size }) => {
     searchForm.value.current = current
@@ -66,15 +126,15 @@ const pageChange = ({ current, size }) => {
 //表格数据
 const tableColumn = ref([
     { key: 'materialName', name: '取样名称' },
-    { key: 'samplingDate', name: '取样日期' },
+    { key: 'samplingDate', name: '取样日期', width: 100, align: 'center' },
     { key: 'specificationNumber', name: '样品编号' },
-    { key: 'specificationModel', name: '规格型号' },
-    { key: 'materialCount', name: '试样数量' },
-    { key: 'calculationUnit', name: '计算单位' },
-    { key: 'proposedPosition', name: '拟用部位' },
-    { key: 'representativeCount', name: '代表数量' },
-    { key: 'userName', name: '取样人' },
-    { key: 'action', name: '操作', width: 100, align: 'center' },
+    { key: 'specificationModel', name: '规格型号', width: 80, align: 'center' },
+    { key: 'materialCount', name: '试样数量', width: 80, align: 'center' },
+    { key: 'calculationUnit', name: '计算单位', width: 80, align: 'center' },
+    { key: 'proposedPosition', name: '拟用部位', width: 80, align: 'center' },
+    { key: 'representativeCount', name: '代表数量', width: 80, align: 'center' },
+    { key: 'userName', name: '取样人', width: 80, align: 'center' },
+    { key: 'action', name: '操作', width: 80, align: 'center', fixed: 'right' },
 ])
 
 //获取数据
@@ -84,7 +144,6 @@ const getTableData = async () => {
     tableLoading.value = true
     const { error, code, data } = await samplingApi.queryPage({
         projectId: projectId.value,
-        contractId: contractId.value,
         ...searchForm.value,
     })
     //处理数据
@@ -99,12 +158,24 @@ const getTableData = async () => {
 }
 
 //选择
+const currentId = ref(null)
 const rowSelect = (row) => {
-    emit('change', { type: 1, data: row })
+    currentId.value = row.id
 }
 
 //取消选择
-const rowCancel = (row) => {
-    emit('change', { type: 0, data: row })
+const rowCancel = () => {
+    currentId.value = null
+}
+
+//确认关联取样材料
+const linkSamplingClick = () => {
+    curId.value = currentId.value
+    linkSamplingClose()
+}
+
+//取消关联取样材料
+const linkSamplingClose = () => {
+    isShow.value = false
 }
 </script>