From 79dda6eb5451d16a148bd5c51f61567e8847b136 Mon Sep 17 00:00:00 2001
From: lyh <925863403@qq.com>
Date: 星期五, 09 五月 2025 17:42:12 +0800
Subject: [PATCH] 产品结构树引用(借用)部件前端页面 修改原有删除文档接口

---
 src/views/dnc/base/modules/ProductStructure/Component/ComponentInfo.vue         |    1 
 src/api/dnc.js                                                                  |    2 
 src/views/dnc/common/DocumentBatchDeleteModal.vue                               |    2 
 src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue  |    5 
 src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue         |    2 
 src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue            |   45 +++--
 src/views/dnc/base/modules/ProductStructure/ProductStructureTreeContextMenu.vue |    1 
 src/views/dnc/base/modules/ProductStructure/Document/NcComponentBorrowModal.vue |  324 ++++++++++++++++++++++++++++++++++++++++++++++
 8 files changed, 359 insertions(+), 23 deletions(-)

diff --git a/src/api/dnc.js b/src/api/dnc.js
index 582bfcb..a140a97 100644
--- a/src/api/dnc.js
+++ b/src/api/dnc.js
@@ -30,7 +30,7 @@
   // 涓嬭浇鏂囨。
   downloadDocumentApi: ({ docId, docName }) => requestGetDownLoad(`/nc/doc/download/${docId}`, docName),
   // 鍒犻櫎鏂囨。
-  deleteDocumentApi: docId => deleteAction(`/nc/doc/delete?id=${docId}`),
+  deleteDocumentApi: ({ docId,attributionType, attributionId}) => deleteAction(`/nc/doc/delete/${docId}/${attributionType}/${attributionId}`),
   // 鏂囨。鍑哄簱
   documentOutboundApi: ({ docId, docName }) => requestGetDownLoad(`/nc/doc/pull/${docId}`, docName),
   // 鏂囨。鍙栨秷鍑哄簱
diff --git a/src/views/dnc/base/modules/ProductStructure/Component/ComponentInfo.vue b/src/views/dnc/base/modules/ProductStructure/Component/ComponentInfo.vue
index 5cead5e..0e9abe6 100644
--- a/src/views/dnc/base/modules/ProductStructure/Component/ComponentInfo.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Component/ComponentInfo.vue
@@ -11,6 +11,7 @@
     <a-descriptions-item label="澶勭悊绫诲瀷	">{{currentLevelDetails.processType}}</a-descriptions-item>
     <a-descriptions-item label="鏉愯川">{{currentLevelDetails.structureType}}</a-descriptions-item>
     <a-descriptions-item label="閲嶉噺" >{{currentLevelDetails.componentWeight}}</a-descriptions-item>
+    <a-descriptions-item label="寮曠敤閮ㄤ欢" >{{currentLevelDetails.borrowId>0?'鏄�':'鍚�'}}</a-descriptions-item>
     <a-descriptions-item label="鍒涘缓浜�">{{currentLevelDetails.createBy_dictText}}</a-descriptions-item>
     <a-descriptions-item label="鍒涘缓鏃堕棿">{{currentLevelDetails.createTime}}</a-descriptions-item>
     <a-descriptions-item label="淇敼浜�">{{currentLevelDetails.updateBy_dictText}}</a-descriptions-item>
diff --git a/src/views/dnc/base/modules/ProductStructure/Document/NcComponentBorrowModal.vue b/src/views/dnc/base/modules/ProductStructure/Document/NcComponentBorrowModal.vue
new file mode 100644
index 0000000..95d5ab0
--- /dev/null
+++ b/src/views/dnc/base/modules/ProductStructure/Document/NcComponentBorrowModal.vue
@@ -0,0 +1,324 @@
+<!--
+ Description: 寮曠敤閮ㄤ欢List
+ Author: 浣滆�� liuyh
+ Date:   2025-02-27
+-->
+<template>
+  <a-modal width="75%" :title="title" :visible="visible" @cancel="visible=false" :maskClosable="false" centered
+           @ok="confirmBatchDeleteDocument">
+      <div style="width: 100%">
+        <a-tabs>
+          <a-tab-pane tab="鍙紩鐢ㄩ儴浠跺垪琛�">
+            <div class="table-page-search-wrapper">
+              <a-form layout="inline" @keyup.enter.native="searchQuery">
+                <a-row :gutter="24">
+                  <a-col :md="7" :sm="7">
+                    <a-form-item label="閮ㄤ欢鍚嶇О">
+                      <a-input placeholder="璇疯緭鍏ラ儴浠跺悕绉�" v-model="queryParam.componentName" allow-clear></a-input>
+                    </a-form-item>
+                  </a-col>
+
+                  <a-col :md="7" :sm="7">
+                    <a-form-item label="閮ㄤ欢浠e彿">
+                      <a-input placeholder="璇疯緭鍏ラ儴浠朵唬鍙�" v-model="queryParam.componentCode" allow-clear></a-input>
+                    </a-form-item>
+                  </a-col>
+
+                  <a-col :md="7" :sm="7">
+                    <a-form-item label="閮ㄤ欢鍨嬪彿">
+                      <a-input placeholder="璇疯緭鍏ラ儴浠跺瀷鍙�" v-model="queryParam.componentModel" allow-clear></a-input>
+                    </a-form-item>
+                  </a-col>
+
+                  <a-col :md="7" :sm="7">
+                    <a-form-item label="瑙勬牸">
+                      <a-input placeholder="璇疯緭鍏ヨ鏍�" v-model="queryParam.componentScale" allow-clear></a-input>
+                    </a-form-item>
+                  </a-col>
+
+                  <a-col :md="7" :sm="7">
+                    <a-form-item label="鏉愯川">
+                      <a-input placeholder="璇疯緭鍏ユ潗璐�" v-model="queryParam.structureType" allow-clear></a-input>
+                    </a-form-item>
+                  </a-col>
+
+                  <a-col :md="4" :sm="4">
+                    <a-space>
+                      <a-button type="primary" @click="searchQuery" icon="search">鏌ヨ</a-button>
+                      <a-button type="primary" @click="searchReset" icon="reload">閲嶇疆</a-button>
+                    </a-space>
+                  </a-col>
+                </a-row>
+              </a-form>
+            </div>
+
+            <a-table :columns="columns" :data-source="dataSource" bordered :pagination="ipagination" :loading="loading"
+                     :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" @change="handleTableChange"
+                     :scroll="{y:380}" :size="size" rowKey="componentId" style="min-height: 480px">
+              <span slot="docName" slot-scope="text">{{ text }}</span>
+            </a-table>
+
+          </a-tab-pane>
+        </a-tabs>
+      </div>
+  </a-modal>
+</template>
+
+<script>
+import { deleteAction, getAction } from '@/api/manage'
+import dncApi from '@/api/dnc'
+import { JeecgListMixin } from '@/mixins/JeecgListMixin'
+
+export default {
+  name: 'NcComponentBorrowModal',
+  components: {},
+  mixins: [JeecgListMixin],
+  props: {
+    currentBorrowInfo: {
+      type: Object
+    },
+    size: {
+      type: String
+    }
+  },
+  data() {
+    return {
+      disableMixinCreated: true,
+      visible: false,
+      title: '',
+      columns: [
+        {
+          title: '搴忓彿',
+          dataIndex: 'rowIndex',
+          key: 'rowIndex',
+          width: 50,
+          align: 'center',
+          customRender: function(t, r, index) {
+            return parseInt(index) + 1
+          }
+        },
+        {
+          title: '閮ㄤ欢鍚嶇О',
+          dataIndex: 'componentName',
+          align: 'center',
+          width: 100,
+        },
+        {
+          title: '閮ㄤ欢浠e彿',
+          dataIndex: 'componentCode',
+          align: 'center',
+          width: 100,
+        },
+        {
+          title: '閮ㄤ欢鍨嬪彿',
+          dataIndex: 'componentModel',
+          align: 'center',
+          width: 100,
+        },
+        {
+          title: '鐗╂枡缂栫爜',
+          dataIndex: 'materielCode',
+          align: 'center',
+          width: 100,
+        },
+        {
+          title: '瑙勬牸',
+          dataIndex: 'componentScale',
+          align: 'center',
+          width: 60,
+        },
+        {
+          title: '鏉愭枡',
+          dataIndex: 'structureType',
+          align: 'center',
+          width: 60,
+        },
+        {
+          title: '鍒涘缓鏃堕棿',
+          dataIndex: 'createTime',
+          align: 'center',
+          width: 150,
+        },
+        {
+          title: '鍒涘缓浜�',
+          dataIndex: 'createBy_dictText',
+          align: 'center',
+          width: 100,
+        }
+      ],
+      searchValue: '',
+      searchInput: '',
+      spinning: false,
+      allTreeKeys: [],
+      checkedKeys: [],
+      expandedKeys: [],
+      autoExpandParent: true,
+      isExpandAllTreeNode: true,
+      date: [],
+      url: {
+        list: '/nc/component/getByComponentId',
+        borrow: '/nc/component/borrow',
+      }
+    }
+  },
+  watch: {
+    visible: {
+      handler(value) {
+        if (value) {
+          this.resetData()
+          this.loadData()
+        }
+      }
+    },
+    isExpandAllTreeNode: {
+      handler(value) {
+        if (value) this.expandedKeys = this.allTreeKeys
+        else this.expandedKeys = []
+      }
+    }
+  },
+  created() {
+    this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod)
+  },
+  methods: {
+    handleComponentBorrow() {
+      if (this.currentBorrowInfo.entity.borrowId){
+        this.$message.warning('璇ラ儴浠朵负寮曠敤閮ㄤ欢锛屾棤娉曞紩鐢�')
+        this.visible=false
+      }else {
+        this.visible = true
+      }
+    },
+    // 鑾峰彇褰撳墠鍙紩鐢ㄩ儴浠�
+    loadData() {
+      this.dataSource = []
+      if (!this.url.list) {
+        this.$message.error('璇疯缃畊rl.list灞炴��!')
+        return
+      }
+      var params = this.getQueryParams()//鏌ヨ鏉′欢
+      if (!params) return false
+      params.componentId = this.currentBorrowInfo.key
+      this.loading = true
+      getAction(this.url.list, params).then((res) => {
+        if (res.success) {
+          this.dataSource = res.result.records
+          if (res.result.total) {
+            this.ipagination.total = res.result.total
+          } else {
+            this.ipagination.total = 0
+          }
+        } else this.$message.warning(res.message)
+      }).finally(() => {
+        this.loading = false
+      })
+    },
+    /**
+     * 琛ㄦ牸鍒嗛〉銆佹帓搴忔敼鍙樸�佺瓫閫夋椂瑙﹀彂
+     * @param pagination 鍒嗛〉鍣ㄩ�夐」
+     * @param filters 绛涢�夐�夐」
+     * @param sorter 鎺掑簭閫夐」
+     */
+    handleTableChange(pagination, filters, sorter) {
+      if (sorter.order) {
+        this.isorter.column = sorter.field
+        this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc'
+      } else {
+        this.isorter.column = 'createTime'
+        this.isorter.order = 'desc'
+      }
+      for (let key in filters) {
+        this.filters[key] = filters[key].join(',')
+      }
+      this.loadData()
+    },
+
+    resetData() {
+      this.searchInput = ''
+      this.expandedKeys = []
+      this.selectedRowKeys = []
+      this.selectionRows = {}
+      this.checkedKeys = []
+      this.filters = {}
+      this.isorter = Object.assign({}, this.defaultSorter)
+    },
+    triggerCorrespondingMethod({ methodName, modalTitle }) {
+      if (this[methodName]) {
+        this[methodName]()
+        this.title = modalTitle
+      }
+    },
+    // 纭鎵归噺鍒犻櫎鏂囨。
+    confirmBatchDeleteDocument() {
+
+      if (this.selectedRowKeys.length <= 0) {
+        // this.$message.warning('璇烽�夋嫨涓�鏉¤褰曪紒');
+        this.$notification.warning({
+          message:'娑堟伅',
+          description:"璇烽�夋嫨涓�涓儴浠�"
+        });
+        return;
+      } else {
+        var ids = "";
+        for (var a = 0; a < this.selectedRowKeys.length; a++) {
+          ids += this.selectedRowKeys[a] + ",";
+        }
+        var that = this;
+        this.$confirm({
+          title: "纭寮曠敤",
+          content: "鏄惁寮曠敤閫変腑鏁版嵁?",
+          onOk: function () {
+            that.loading = true;
+            var queryParam = {
+              newIds: ids,
+              oldId: that.currentBorrowInfo.key
+            }
+            getAction(that.url.borrow,queryParam).then((res) => {
+              if (res.success) {
+                //閲嶆柊璁$畻鍒嗛〉闂
+                that.reCalculatePage(that.selectedRowKeys.length)
+                // that.$message.success(res.message);
+                that.$notification.success({
+                  message:'娑堟伅',
+                  description:res.message
+                });
+                that.loadData();
+                that.onClearSelected();
+                that.$emit('submitSuccess')
+              } else {
+                // that.$message.warning(res.message);
+                that.$notification.warning({
+                  message:'娑堟伅',
+                  description:res.message
+                });
+              }
+            }).finally(() => {
+              that.loading = false;
+            });
+          }
+        });
+      }
+    },
+  }
+}
+</script>
+
+<style scoped lang="less">
+/deep/ .ant-modal {
+  .tabs-container {
+    display: flex;
+    justify-content: space-between;
+
+    .replaceSearch {
+      color: #40a9ff;
+      font-weight: bold;
+      background-color: rgb(204, 204, 204);
+    }
+  }
+
+}
+
+::-webkit-scrollbar {
+  width: 8px;
+}
+</style>
\ No newline at end of file
diff --git a/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue b/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue
index 254dc97..29b0cb7 100644
--- a/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue
+++ b/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue
@@ -1,3 +1,8 @@
+<!--
+ Description: 妫�绱㈢數瀛愭牱鏉縇ist
+ Author: 浣滆�� liuyh
+ Date:   2025-02-27
+-->
 <template>
   <a-modal width="75%" :title="title" :visible="visible" @cancel="visible=false" :maskClosable="false" centered
            @ok="handleAssignDocumentToDevice">
diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
index 9bb645b..3af9ab7 100644
--- a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
+++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue
@@ -231,7 +231,7 @@
         okText: '纭',
         cancelText: '鍙栨秷',
         onOk: () => {
-          dncApi.deleteDocumentApi(docId)
+          dncApi.deleteDocumentApi({docId,attributionType,attributionId})
             .then((res) => {
               if (res.success) {
                 that.$notification.success({
diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
index a734005..1fed810 100644
--- a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
+++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue
@@ -4,7 +4,7 @@
       <div style="display: flex;flex-direction: column;height: 100%">
         <div style="display: flex;justify-content: space-between">
           <a-input placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�" allowClear v-model="searchInput"
-                   @change="handleSearchInputChange"/>
+                   @change="handleSearchInputChange" />
           <!--          <a-tooltip title="鍒锋柊">-->
           <!--            <a-button icon="reload" @click="handleTreeReload" style="width: 18%;margin-left: 8px"></a-button>-->
           <!--          </a-tooltip>-->
@@ -31,16 +31,16 @@
                   @select="handleTreeSelect" @expand="handleTreeExpand" @rightClick="handleTreeRightClick">
             <template slot="title" slot-scope="{ label, parentId, key:treeKey,type}">
               <ProductStructureTreeContextMenu ref="contextMenuRef"
-                                               :treeParams="{label,treeKey,searchValue,type}"/>
+                                               :treeParams="{label,treeKey,searchValue,type}" />
             </template>
 
-            <a-icon slot="switcherIcon" type="down"/>
-            <a-icon slot="product" type="shopping"/>
-            <a-icon slot="component" type="camera"/>
-            <a-icon slot="part" type="hdd"/>
-            <a-icon slot="processSpecVersion" type="tag"/>
-            <a-icon slot="process" type="apartment"/>
-            <a-icon slot="processStep" type="tool"/>
+            <a-icon slot="switcherIcon" type="down" />
+            <a-icon slot="product" type="shopping" />
+            <a-icon slot="component" type="camera" />
+            <a-icon slot="part" type="hdd" />
+            <a-icon slot="processSpecVersion" type="tag" />
+            <a-icon slot="process" type="apartment" />
+            <a-icon slot="processStep" type="tool" />
           </a-tree>
         </div>
       </div>
@@ -48,23 +48,25 @@
 
     <!--浜у搧寮圭獥-->
     <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected"
-                  @submitSuccess="getTreeDataByApi"/>
+                  @submitSuccess="getTreeDataByApi" />
     <!--閮ㄤ欢寮圭獥-->
-    <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+    <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
     <!--闆朵欢寮圭獥-->
-    <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+    <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
     <!--宸ヨ壓瑙勭▼鐗堟湰寮圭獥-->
-    <ProcessSpecVersionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+    <ProcessSpecVersionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
     <!--宸ュ簭寮圭獥-->
-    <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+    <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
     <!--宸ユ寮圭獥-->
-    <ProcessStepModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+    <ProcessStepModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
     <!--鏉冮檺閰嶇疆寮圭獥-->
-    <AssignPermissionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+    <AssignPermissionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
     <!--妫�绱㈢數瀛愭ā鏉垮脊绐�-->
-    <NcDocumentSearchModal :currentDocumentInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/>
+    <NcDocumentSearchModal :currentDocumentInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
+    <!--寮曠敤閮ㄤ欢-->
+    <NcComponentBorrowModal :currentBorrowInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" />
     <!--浜у搧缁撴瀯鏍戝熀鏈彸閿彍鍗�(绌虹櫧澶勮Е鍙�)-->
-    <ProductStructureBaseContextMenu ref="baseContextmenuRef"/>
+    <ProductStructureBaseContextMenu ref="baseContextmenuRef" />
   </a-card>
 </template>
 
@@ -80,8 +82,10 @@
 import ProcessStepModal from './ProcessStep/ProcessStepModal'
 import AssignPermissionModal from './Permission/AssignPermissionModal'
 import DeviceCustomTypeModal from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModal.vue'
-import ProductStructureBaseContextMenu from '@views/dnc/base/modules/ProductStructure/ProductStructureBaseContextMenu.vue'
+import ProductStructureBaseContextMenu
+  from '@views/dnc/base/modules/ProductStructure/ProductStructureBaseContextMenu.vue'
 import NcDocumentSearchModal from '@views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue'
+import NcComponentBorrowModal from '@views/dnc/base/modules/ProductStructure/Document/NcComponentBorrowModal.vue'
 
 export default {
   name: 'ProductStructureTree',
@@ -96,7 +100,8 @@
     ComponentModal,
     ProductModal,
     ProductStructureTreeContextMenu,
-    NcDocumentSearchModal
+    NcDocumentSearchModal,
+    NcComponentBorrowModal
   },
   data() {
     return {
diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureTreeContextMenu.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureTreeContextMenu.vue
index 36b9b8a..d494690 100644
--- a/src/views/dnc/base/modules/ProductStructure/ProductStructureTreeContextMenu.vue
+++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureTreeContextMenu.vue
@@ -53,6 +53,7 @@
           // {  label: '瀵煎嚭鏂囨。', code: 'component_export', icon: 'export', isCommonMethod: true },
           { label: '瀵煎叆鍏朵粬鏂囨。', code: 'component_import', icon: 'import', isCommonMethod: true },
           { label: '妫�绱㈢數瀛愭牱鏉�', code: 'component_search', icon: 'search', isCommonMethod: true },
+          { label: '寮曠敤閮ㄤ欢',code: 'component_borrow',icon: 'plus',isCommonMethod: false},
           { label: '鍒犻櫎', code: 'component_delete', icon: 'delete', isCommonMethod: true },
           { label: '鏉冮檺閰嶇疆', code: 'public_assign_permission', icon: 'idcard', isCommonMethod: true }
         ],
diff --git a/src/views/dnc/common/DocumentBatchDeleteModal.vue b/src/views/dnc/common/DocumentBatchDeleteModal.vue
index 05dc60f..36494e3 100644
--- a/src/views/dnc/common/DocumentBatchDeleteModal.vue
+++ b/src/views/dnc/common/DocumentBatchDeleteModal.vue
@@ -212,7 +212,7 @@
           selectedRowKeys.forEach(key => {
             if (attributionType !== 4) {
               method = dncApi.deleteDocumentApi
-              queryParam = key
+              queryParam = { docId: key,attrType:attributionType,attrId:attributionId }
             } else {
               method = dncApi.deleteDeviceRelativeDocumentApi
               queryParam = { docId: key, attributionId }

--
Gitblit v1.9.3