浏览代码

关联质检资料修改

duy 1 年之前
父节点
当前提交
7e9d8dd609

+ 3 - 1
src/views/debit-pay/admin/components/middlepay/addModal.vue

@@ -146,7 +146,7 @@
 
 <script setup>
 import { nextTick, ref, watch } from 'vue'
-import { getStoreValue } from '~src/utils/storage'
+
 import { isNumberReg } from '~uti/tools'
 import HcBillBaseModal from './addBillBaseModal.vue'
 import qualityRleation from './qualityRleation.vue'
@@ -158,6 +158,7 @@ import unitApi from '~api/project/debit/contract/unit'
 import mainApi from '~api/debit-pay/admin/middlepay'
 
 
+import { getStoreValue, setStoreValue } from '~src/utils/storage'
 const props = defineProps({
     projectId: {
         type: [String, Number],
@@ -644,6 +645,7 @@ const addModalClose = () => {
     baseForm.value = { fileList: [], pictureUrl: '' }
     addTableData.value = []
     selectId.value = ''
+    setStoreValue('checkRows', [])
     emit('close')
 }
 //关联质检资料

+ 26 - 2
src/views/debit-pay/admin/components/middlepay/qualityRleation.vue

@@ -31,10 +31,11 @@
 
 <script setup>
 import { nextTick, ref, watch } from 'vue'
-import { getArrValue, getObjValue, getRandom } from 'js-fast-way'
+import { arrUnion, getArrValue, getObjValue, getRandom } from 'js-fast-way'
 import { useAppStore } from '~src/store'
 import unitApi from '~api/project/debit/contract/unit'
 import { queryWbsTreeData } from '~api/other'
+import { getStoreValue, setStoreValue } from '~src/utils/storage'
 const props = defineProps({
     qualityMoadal: {
         type: Boolean,
@@ -64,6 +65,9 @@ const qualityMoadal = ref(props.qualityMoadal)
 const cid = ref(props.cid)
 const periodId = ref(props.periodId)
 const selectId = ref(props.selectId)
+
+//之前节点选中的数据
+const oriCheckRows = ref([])
 watch(() => [
     props.qualityMoadal,
     props.cid,
@@ -83,6 +87,8 @@ watch(qualityMoadal, (val) => {
         nextTick(() => {
                 setSplitRef()
                 tableData.value = []
+                oriCheckRows.value = getStoreValue('checkRows')
+            
             })
         }
     
@@ -135,6 +141,7 @@ const tableColumn = [
 
 const qulModalClose = ()=>{
     qualityMoadal.value = false
+    setStoreValue('checkRows', [])
     emit('close')
 }
 
@@ -201,12 +208,29 @@ const nodeElTreeClick = ({ node, data, keys })=>{
 const tableKeys = ref([])
 const tableSelection = (rows) => {
     tableKeys.value = rows
+     
 }
+//之前选中的
 const saveQualModal = ()=>{
     if ( tableKeys.value.length > 0) {
         qualityMoadal.value = false
         emit('close')
-        emit('finish', tableKeys.value)
+        let alarr = arrUnion(tableKeys.value, oriCheckRows.value)
+         // 使用reduce方法进行去重
+        const uniqueArray = alarr.reduce((acc, current) => {
+        // 检查当前对象的某个字段是否已存在于累积数组中
+        const x = acc.find(item => item.selectId === current.selectId)
+        
+        // 如果不存在,则将其添加到累积数组中
+        if (!x) {
+            return acc.concat([current])
+        } else {
+            return acc
+        }
+        }, [])
+        alarr = uniqueArray
+        emit('finish', alarr)
+        setStoreValue('checkRows', alarr)
     } else {
         window.$message.warning('请先选择你要关联的质检资料')
         emit('close')