Browse Source

委托单

ZaiZai 1 year ago
parent
commit
a4d07fda3e
2 changed files with 106 additions and 15 deletions
  1. 41 5
      src/views/tentative/detect/commission.vue
  2. 65 10
      src/views/tentative/material/sampling.vue

+ 41 - 5
src/views/tentative/detect/commission.vue

@@ -144,7 +144,7 @@ import { onActivated, ref } from 'vue'
 import { useAppStore } from '~src/store'
 import { useRouter } from 'vue-router'
 import { getStoreValue, setStoreValue } from '~src/utils/storage'
-import { deepClone, formValidate, getArrValue, getObjValue, isNullES, isString } from 'js-fast-way'
+import { arrToId, deepClone, formValidate, getArrValue, getObjValue, isNullES, isString } from 'js-fast-way'
 import { getDictionaryData } from '~uti/tools'
 import { getErtractInfo } from '~api/other'
 import mainApi from '~api/tentative/detect/commission'
@@ -254,9 +254,19 @@ const tableSelection = (rows) => {
 
 //删除
 const delModalClick = async (_, resolve) => {
-    //remove
-
+    const rows = tableCheckedKeys.value
+    if (rows.length <= 0) {
+        window.$message.warning('请先勾选需要删除的数据')
+        return
+    }
+    const { error, code, msg } = await mainApi.remove(arrToId(rows))
     resolve()
+    if (!error && code === 200) {
+        window.$message.success('删除成功')
+        getTableData().then()
+    } else {
+        window.$message.error(msg || '删除失败')
+    }
 }
 
 //委托单变量
@@ -270,6 +280,7 @@ const delegateContractId = ref(null)
 const delegateModal = ref(false)
 const addFormData = () => {
     delegateModal.value = true
+    editHtmlId.value = ''
     const { contractId } = deepClone(searchForm.value)
     delegateContractId.value = contractId
     if (!isNullES(contractId)) {
@@ -280,6 +291,9 @@ const addFormData = () => {
 //合同段被选择
 const delegateContractChange = async () => {
     delegateHtmlLoading.value = true
+    if (!isNullES(editHtmlId.value)) {
+        await getDelegateDataInfo(editHtmlId.value)
+    }
     await getDelegateExcelHtml()
     delegateHtmlLoading.value = false
 }
@@ -299,14 +313,32 @@ const getDelegateExcelHtml = async () => {
     }
 }
 
+//获取委托数据
+const getDelegateDataInfo = async (editId) => {
+    const { error, code, msg, data } = await samplingApi.getBussDataInfoTrialEntrust({
+        id: editId,
+        pkeyId: nodeErTreeId.value,
+        projectId: projectId.value,
+        contractId: delegateContractId.value,
+    })
+    if (!error && code === 200) {
+        delegateHtmlForm.value = getObjValue(data)
+    } else {
+        delegateHtmlForm.value = {}
+        window.$message.error(msg || '获取委托信息失败')
+    }
+}
+
 //委托单html渲染完成
 const delegateHtmlRender = (form) => {
     delegateHtmlForm.value = form
 }
 
 //修改
+const editHtmlId = ref('')
 const rowEdit = (row) => {
     delegateModal.value = true
+    editHtmlId.value = row.id
     const { contractId } = deepClone(searchForm.value)
     delegateContractId.value = contractId
     if (!isNullES(contractId)) {
@@ -319,6 +351,10 @@ const linkSamplingModal = ref(false)
 
 //创建委托
 const creatingDelegate = async () => {
+    if (isNullES(delegateHtml.value)) {
+        window.$message.error('暂无委托单信息')
+        return
+    }
     const form = delegateHtmlForm.value
     if (isNullES(delegateContractId.value)) {
         window.$message.warning('请先选择合同段')
@@ -352,7 +388,7 @@ const delegateModalClose = () => {
 
 //查看
 const rowView = (row) => {
-
+    window.$message.warning('暂无接口')
 }
 
 //表单数据
@@ -396,7 +432,7 @@ const rowActionSave = async () => {
                 commissionId: id,
                 isaddType: true,
             },
-        })
+        }).then()
     } else {
         rowActionLoading.value = false
         window.$message.error(msg || '创建失败')

+ 65 - 10
src/views/tentative/material/sampling.vue

@@ -234,7 +234,14 @@
 
         <!-- 创建委托 -->
         <hc-new-dialog v-model="delegateModal" ui="hc-delegate-html-modal" is-footer-center is-table title="创建委托" widths="60rem" @close="delegateModalClose">
-            <hc-table-form ref="htmlRef" :pkey="nodeErTreeId" :form="delegateHtmlForm" :html="delegateHtml" :loading="delegateHtmlLoading" @render="delegateHtmlRender" />
+            <div class="hc-delegate-contract hc-flex h-40px">
+                <el-select v-model="delegateContractId" placeholder="请先选择合同段" filterable class="w-400px" @change="delegateContractChange">
+                    <el-option v-for="item in contractData" :key="item.id" :label="item.contractName" :value="item.id" />
+                </el-select>
+            </div>
+            <div class="hc-delegate-html" :class="delegateContractId ? 'is-show' : ''">
+                <hc-table-form ref="htmlRef" :pkey="nodeErTreeId" :form="delegateHtmlForm" :html="delegateHtml" :loading="delegateHtmlLoading" @render="delegateHtmlRender" />
+            </div>
             <template #footer>
                 <el-button @click="delegateModalClose">取消</el-button>
                 <el-button hc-btn type="primary" :loading="creatingDelegateLoading" @click="creatingDelegate">创建</el-button>
@@ -249,6 +256,7 @@ import { useAppStore } from '~src/store'
 import TestTree from './components/TestTree.vue'
 import HcDragUpload from './components/HcDragUpload.vue'
 import { getStoreValue, setStoreValue } from '~src/utils/storage'
+import commissionApi from '~api/tentative/detect/commission'
 import samplingApi from '~api/tentative/material/sampling'
 import approachApi from '~api/tentative/material/approach'
 import { getContractUserList, getDictionary } from '~api/other'
@@ -774,7 +782,8 @@ const delegateModal = ref(false)
 const delegateHtml = ref('')
 const delegateHtmlForm = ref({})
 const delegateHtmlLoading = ref(false)
-const delegationClick = async () => {
+const delegateContractId = ref(null)
+const delegationClick = () => {
     const rows = tableCheckedKeys.value
     if (rows.length <= 0) {
         window.$message.warning('请先勾选一条需要委托的数据')
@@ -784,22 +793,34 @@ const delegationClick = async () => {
         return
     }
     delegateModal.value = true
+    editHtmlId.value = rows[0].id
+    const { contractId } = deepClone(searchForm.value)
+    delegateContractId.value = contractId
+    if (!isNullES(contractId)) {
+        delegateContractChange()
+    }
+}
+
+//合同段被选择
+const editHtmlId = ref('')
+const delegateContractChange = async () => {
     delegateHtmlLoading.value = true
+    if (!isNullES(editHtmlId.value)) {
+        await getDelegateDataInfo(editHtmlId.value)
+    }
     await getDelegateExcelHtml()
-    //await getDelegateDataInfo(rows[0])
     delegateHtmlLoading.value = false
 }
 
 //获取委托数据
-const getDelegateDataInfo = async (row) => {
+const getDelegateDataInfo = async (editId) => {
     const { error, code, msg, data } = await samplingApi.getBussDataInfoTrialEntrust({
-        id: row.id,
+        id: editId,
         pkeyId: nodeErTreeId.value,
         projectId: projectId.value,
-        contractId: contractId.value,
+        contractId: delegateContractId.value,
     })
     if (!error && code === 200) {
-        console.log(data)
         delegateHtmlForm.value = getObjValue(data)
     } else {
         delegateHtmlForm.value = {}
@@ -812,7 +833,7 @@ const getDelegateExcelHtml = async () => {
     const { error, code, msg, data } = await samplingApi.getExcelHtml({
         primaryKeyId: nodeErTreeId.value,
         projectId: projectId.value,
-        contractId: contractId.value,
+        contractId: delegateContractId.value,
     })
     if (!error && code === 200) {
         delegateHtml.value = isString(data) ? data : ''
@@ -834,8 +855,20 @@ const creatingDelegate = async () => {
         window.$message.error('暂无委托单信息')
         return
     }
-    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
+    const { error, code, msg } = await commissionApi.htmlSave(form)
+    if (!error && code === 200) {
+        window.$message.success('创建成功')
+        delegateModalClose()
+    } else {
+        window.$message.error(msg || '创建失败')
+    }
 }
 
 //关闭委托
@@ -863,4 +896,26 @@ const delegateModalClose = () => {
         }
     }
 }
+.hc-delegate-html-modal {
+    .hc-delegate-html {
+        position: relative;
+        height: calc(100% - 40px);
+        .hc-table-form-data-item {
+            background-color: #efefef;
+        }
+        &::after {
+            content: "";
+            position: absolute;
+            inset: 0;
+            background: rgb(161 161 161 / 40%);
+            z-index: 22;
+        }
+        &.is-show {
+            &::after {
+                display: none;
+                z-index: -1;
+            }
+        }
+    }
+}
 </style>