From bd8c4d0191879275492ab70798b9be267dc9f5b8 Mon Sep 17 00:00:00 2001
From: lihang <lihang@vci-tech.com>
Date: 星期五, 12 五月 2023 17:00:53 +0800
Subject: [PATCH] 业务类型新增按钮

---
 Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IBtmAttributeClient.java   |   29 ++++
 Source/UBCS-WEB/src/views/modeling/BusinessAdd.vue                                                        |  212 +++++++++++++++++++++++++++---
 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/BtmAttributeClient.java            |   38 +++++
 Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IBtmAttributeFallback.java |   22 +++
 Source/UBCS-WEB/src/views/modeling/Business.vue                                                           |   80 ++++------
 Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java     |    2 
 6 files changed, 315 insertions(+), 68 deletions(-)

diff --git a/Source/UBCS-WEB/src/views/modeling/Business.vue b/Source/UBCS-WEB/src/views/modeling/Business.vue
index 40ccabe..87d1d21 100644
--- a/Source/UBCS-WEB/src/views/modeling/Business.vue
+++ b/Source/UBCS-WEB/src/views/modeling/Business.vue
@@ -26,28 +26,28 @@
             <el-descriptions class="margin-top" :column="3" :size="size" border>
               <el-descriptions-item>
                 <template slot="label">
-                  <i class="el-icon-finished"></i>
+                  <i :class="icons.key"></i>
                   鑻辨枃鍚嶇О
                 </template>
                 {{ obj.id }}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
-                  <i class="el-icon-info"></i>
+                  <i :class="icons.name"></i>
                   涓枃鍚嶇О
                 </template>
                 {{ obj.name }}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
-                  <i class="el-icon-date"></i>
+                  <i :class="icons.tableName"></i>
                   鏁版嵁搴撹〃鍚�
                 </template>
                 {{ obj.tableName }}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
-                  <i class="el-icon-folder-opened"></i>
+                  <i :class="icons.domain"></i>
                   鎵�灞為鍩�
                 </template>
                 {{ obj.domain }}
@@ -68,21 +68,21 @@
           </el-descriptions-item> -->
               <el-descriptions-item>
                 <template slot="label">
-                  <i class="el-icon-s-check"></i>
+                  <i :class="icons.revisionRule"></i>
                   鐗堟湰瑙勫垯
                 </template>
                 {{ obj.versionRule }}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
-                  <i class="el-icon-refresh-right"></i>
+                  <i :class="icons.lifeCycle"></i>
                   鐢熷懡鍛ㄦ湡
                 </template>
                 {{ obj.lifeCycleId }}
               </el-descriptions-item>
               <el-descriptions-item>
                 <template slot="label">
-                  <i class="el-icon-view"></i>
+                  <i :class="icons.view"></i>
                   瑙嗗浘
                 </template>
                 {{ obj.viewFlag }}
@@ -96,7 +96,7 @@
           </el-descriptions-item> -->
               <el-descriptions-item>
                 <template slot="label">
-                  <i class="el-icon-chat-line-square"></i>
+                  <i :class="icons.desc"></i>
                   鎻忚堪
                 </template>
                 {{ obj.description }}
@@ -106,7 +106,7 @@
           <!-- 灞炴�у垪琛�-->
           <basic-container>
             <p style="margin-top: 10px;font-weight: 570;font-size: 19px">灞炴�у垪琛�</p>
-            <avue-crud v-model="obj" :data="obj.attributes" :option="loadOption" @row-save="loadSave"></avue-crud>
+            <avue-crud class="attributeCrud" v-model="obj" :data="obj.attributes" :option="loadOption"></avue-crud>
           </basic-container>
         </el-main>
         <el-dialog :visible="ref.visible" title="浠庢暟鎹簱涓坊鍔�" width="700px" append-to-body @close="dialoghandelfalse">
@@ -117,14 +117,10 @@
           </el-select>
           <avue-crud class="businessCrud" v-model="ref.form" :option="ref.option" :data="ref.data" @selection-change="selectionChange">
           </avue-crud>
-          <span slot="footer" class="dialog-footer">
-            <el-button @click="dialoghandelfalse">鍙� 娑�</el-button>
-            <el-button type="primary" @click="dialoghandeltrue">纭� 瀹�</el-button>
-          </span>
         </el-dialog>
       </el-container>
     </el-container>
-    <business-add ref="btmAdd" :btmType="addOption.btmType" :domainOption="domainOptions">
+    <business-add ref="btmAdd" :btmType="addOption.btmType" :domainOption="domainOptions" :icons="icons" @refreshTable="initTreeOnLoad">
   </business-add>
   </el-container>
 </template>
@@ -164,6 +160,8 @@
         border: true,
         height: 466,
         editBtn: false,
+        index: true,
+        rowKey:'oid',
         addBtn: false,
         menu: false,
         highlightCurrentRow: true,
@@ -198,6 +196,16 @@
       },
       domain: null,
       domainOptions: [],
+      icons:{
+        key: 'el-icon-finished',
+        name: 'el-icon-info',
+        tableName: 'el-icon-date',
+        domain: 'el-icon-folder-opened',
+        revisionRule: 'el-icon-s-check',
+        lifeCycle: 'el-icon-refresh-right',
+        view: 'el-icon-view',
+        desc: 'el-icon-chat-line-square'
+      },
       ref: {
         // 浠庤〃涓�夋嫨dialog鐘舵��
         visible: false,
@@ -208,7 +216,7 @@
           headerAlign: 'center',
           border: true,
           index: true,
-          rowKey: 'id',
+          rowKey: 'oid',
           tabs: true,
           addBtn: false,
           menu: false,
@@ -273,36 +281,13 @@
       }
     },
     nodeClick(data) {
-      getDetail(data.oid).then(res => {
-        this.obj = res.data.data;
-      })
-    },
-    //  鍩烘湰淇℃伅娣诲姞
-    basicSave(row, done, loading) {
-      add(Object.assign({
-        createUser: this.userInfo.name
-      }, row)).then(() => {
-        this.$message.success('鏂板鎴愬姛')
-        done();
-        this.getList();
-      }).catch(() => {
-        loading()
-      })
-    },
-    //灞炴�ф坊鍔�
-    loadSave(row, done, loading) {
-      add(Object.assign({
-        createUser: this.userInfo.name
-      }, row)).then(() => {
-        this.$message.success('鏂板鎴愬姛')
-        done();
-        this.getList();
-      }).catch(() => {
-        loading()
-      })
+      if(data.oid){
+        getDetail(data.oid).then(res => {
+          this.obj = res.data.data;
+        })
+      }
     },
     selectFromTable() {
-      console.log('鑾峰彇');
       this.ref.visible = true;
     },
     refOnLoad(domain) {
@@ -339,6 +324,7 @@
     },
     businessAdd(){
       this.$refs.btmAdd.showSubmitDialog = true;
+      this.$refs.btmAdd.refreshAttrTable();
       console.log('娣诲姞');
     },
     businessEdit(){
@@ -356,8 +342,10 @@
   border-radius: 10px;
 }
 
-.businessCrud > .el-card > .el-card__body > .avue-crud_menu{
-  display: none!important;
+.businessCrud > .el-card:nth-of-type(2) > .el-card__body > .avue-crud__menu{
+        display: none !important;
 }
-
+.attributeCrud > .el-card:nth-of-type(2) > .el-card__body > .avue-crud__menu{
+        display: none !important;
+}
 </style>
diff --git a/Source/UBCS-WEB/src/views/modeling/BusinessAdd.vue b/Source/UBCS-WEB/src/views/modeling/BusinessAdd.vue
index 5a75644..c56390b 100644
--- a/Source/UBCS-WEB/src/views/modeling/BusinessAdd.vue
+++ b/Source/UBCS-WEB/src/views/modeling/BusinessAdd.vue
@@ -4,47 +4,84 @@
     :visible.sync="showSubmitDialog"
     append-to-body
     @close="closeSubmitDialog"
-    width="70%"
+    width="74%"
     >
         <el-form ref="form" :model="btmType" show-message="true" inline>
             <el-form-item label="鑻辨枃鍚嶇О:" label-width="100px">
-                <el-input v-model="btmType.id" prefix-icon="el-icon-finished"></el-input>
+                <el-input v-model="btmType.id" :prefix-icon="icons.key"></el-input>
             </el-form-item>
             <el-form-item label="涓枃鍚嶇О:" label-width="100px">
-                <el-input v-model="btmType.name" prefix-icon="el-icon-info"></el-input>
+                <el-input v-model="btmType.name" :prefix-icon="icons.name"></el-input>
             </el-form-item>
             <el-form-item label="鏁版嵁搴撹〃鍚�:" label-width="100px">
-                <el-input v-model="btmType.tableName" prefix-icon="el-icon-date"></el-input>
+                <el-input v-model="btmType.tableName" :prefix-icon="icons.tableName"></el-input>
             </el-form-item>
             <el-form-item label="鎵�灞為鍩�:" label-width="100px">
-                <el-select v-model="btmType.domain" prefix-icon="el-icon-folder-opened">
+                <el-select v-model="btmType.domain" :prefix-icon="icons.domain">
                     <el-option v-for="item in domainOption"
                     :label="item"></el-option>
                 </el-select>
             </el-form-item>
             <el-form-item label="鐗堟湰瑙勫垯:" label-width="100px">
-                <el-input v-model="btmType.revisionRuleId" prefix-icon="el-icon-s-check"></el-input>
+                <el-input v-model="btmType.revisionRuleId" :prefix-icon="icons.revisionRule">
+                    <i slot="suffix" class="el-input__icon el-icon-search"></i>
+                </el-input>
             </el-form-item>
             <el-form-item label="鐢熷懡鍛ㄦ湡:" label-width="100px">
-                <el-input v-model="btmType.lifeCycleId" prefix-icon="el-icon-refresh-right"></el-input>
+                <el-input v-model="btmType.lifeCycleId" :prefix-icon="icons.lifeCycle">
+                    <i slot="suffix" class="el-input__icon el-icon-search"></i>
+                </el-input>
             </el-form-item>
             <el-form-item label="瑙嗗浘:" label-width="100px">
-                <el-input v-model="btmType.view" prefix-icon="el-icon-view"></el-input>
+                <el-input v-model="btmType.view" :prefix-icon="icons.view"></el-input>
             </el-form-item>
             <el-form-item label="鎻忚堪:" label-width="100px">
                 <el-input v-model="btmType.description" 
-                prefix-icon="el-icon-chat-line-square" 
-                style="width:254%;"></el-input>
+                :prefix-icon="icons.desc" 
+                ></el-input>
             </el-form-item>
         </el-form>
-        <avue-crud :option="option" :data="btmType.attributes"></avue-crud>
+        <avue-crud :option="option" :data="btmType.attributes" :page.sync="page" ref="attrTable">
+            <template slot-scope="scope" slot="menuLeft">
+                <el-button type="danger"
+                icon="el-icon-plus"
+                size="small"
+                @click="rowAdd()">灞炴�ч�夋嫨</el-button>
+            </template>
+            
+        </avue-crud>
+        <el-button @click="submitBtmType">纭畾</el-button>
+            <el-button @click="cancleSubmitBtmType">鍙栨秷</el-button>
+
+
+        <el-dialog title="灞炴�ф睜"
+            :visible="attrRef.visible"
+            append-to-body
+            @close="closeAttrDialog"
+            width="80%"
+        >
+            <avue-crud class="attrRef" 
+            :option="attrRef.option" 
+            :data="attrRef.data" 
+            :page.sync="attrRef.page"
+            ref="attrRef"
+            @on-load="attrRefOnLoad"
+            @selection-change="selectionChange">
+                <template slot="name" slot-scope="scope" >
+                    <el-tag>{{scope}}</el-tag>
+                </template>
+            </avue-crud>
+            <el-button @click="confirmSelectAttr">纭畾</el-button>
+            <el-button @click="cancleSelectAttr">鍙栨秷</el-button>
+        </el-dialog>
     </el-dialog>
 </template>
 
 
 <script>
-import { } from '@/api/omd/btmType';
-import { } from '@/api/omd/OmdAttribute';
+
+import {  } from '@/api/omd/btmType';
+import { getPage } from '@/api/omd/OmdAttribute';
 export default {
     name: 'BusinessAdd',
     props: {
@@ -53,19 +90,28 @@
         },
         domainOption:{
             type: Array
+        },
+        icons: {
+            type: Array
         }
     },
     data() {
         return {
             form: {},
             showSubmitDialog : false,
+            page: {
+                currentPage: 1,
+                pageSize:10
+            },
             option: {
                 height: "330px",
-                selection: true,
                 headerAlign: 'center',
                 border: true,
                 index: true,
-                rowKey: 'id',
+                rowKey: 'oid',
+                addBtn: false,
+                refreshBtn: false,
+                columnBtn:false,
                 tabs: true,
                 menu: false,
                 highlightCurrentRow: true,
@@ -73,7 +119,7 @@
                     {
                         label: '灞炴�ц嫳鏂囧悕绉�',
                         prop: 'id',
-                        align: 'center'
+                        align: 'left'
                     }, {
                         label: '灞炴�т腑鏂囧悕绉�',
                         prop: 'name',
@@ -81,7 +127,53 @@
                     },
                     {
                         label: "灞炴�х被鍨�",
-                        prop: "attrDataType",
+                        prop: "typeValue",
+                        align: 'center',
+                        slot: true
+                    },
+                    {
+                        label: "榛樿鍊�",
+                        prop: "defaultValue",
+                        cell: 'true',
+                        align: 'center'
+                    },
+                    {
+                        label: "璇存槑",
+                        prop: "description",
+                        cell: 'true',
+                        align: 'center'
+                    }
+                ]
+            },
+            attrRef:{
+                visible:false,
+                page: {
+                    currentPage:1,
+                    pageSize:10,
+                    key:''
+                },
+                option:{
+                    height: 360,
+                    addBtn: false,
+                    refreshBtn: false,
+                    columnBtn: false,
+                    selection: true,
+                    menu: false,
+                    border: true,
+                    column: [
+                        {
+                        label: '灞炴�ц嫳鏂囧悕绉�',
+                        prop: 'key',
+                        align: 'left',
+                        width: 230
+                    }, {
+                        label: '灞炴�т腑鏂囧悕绉�',
+                        prop: 'label',
+                        align: 'center'
+                    },
+                    {
+                        label: "灞炴�х被鍨�",
+                        prop: "typeValue",
                         align: 'center'
                     },
                     {
@@ -90,23 +182,101 @@
                         align: 'center'
                     },
                     {
+                        label: '鍏佽涓虹┖',
+                        prop: 'nullable',
+                        type: 'switch',
+                        display: false,
+                        hide: true,
+                        labelWidth: 132,
+                        dicData: [{
+                        label: '鍚�',
+                        value: 1
+                        }, {
+                        label: '鏄�',
+                        value: 0
+                        }]
+                    },
+                    {
                         label: "璇存槑",
                         prop: "description",
                         align: 'center'
                     }
-                ]
-            },
+                    ]
+                },
+                data: [],
+                queryNotIn: []
+            }
         }
     },
     created() {
-        console.log('123');
+
     },
     methods: {
         closeSubmitDialog(){
             this.showSubmitDialog = false;
+            this.btmType = {};
+        },
+        closeAttrDialog(){
+            this.attrRef.visible = false;
+        },
+        rowAdd(){
+            this.attrRef.visible = true;
+            this.$refs.attrRef.refreshTable();
+            this.attrRefOnLoad();
+       
+        },
+        attrRefOnLoad(){
+            var str = '';
+            this.attrRef.queryNotIn.forEach(item => {
+                str = str + item + ','
+            });
+            getPage(this.attrRef.page.currentPage, this.attrRef.page.pageSize,{'condition["key_like"]':this.attrRef.page.key}).then(res => {
+                const data = res.data.data;
+                this.attrRef.page.total = data.total;
+                this.attrRef.data = data.records;
+            })
+        },
+        selectionChange(list){
+            this.attrRef.selectData = list;
+        },
+        confirmSelectAttr(){
+            this.btmType.attributes = [];
+            this.attrRef.selectData.forEach(item => {
+                this.btmType.attributes.push({
+                    id: item.key,
+                    name: item.label,
+                    typeValue: item.typeValue,
+                    defaultValue: item.defaultValue,
+                    description: item.description
+                });
+                this.attrRef.queryNotIn.push(item.key);
+            });
+            this.closeAttrDialog();
+        },
+        cancleSelectAttr(){
+            this.attrRef.selectData = [];
+            this.closeAttrDialog();
+        },
+        submitBtmType(){
+            // 娣诲姞瀹屾垚锛屽洖璋冪埗缁勪欢鐨勫埛鏂�
+            console.log(this.btmType);
+            this.$emit('refreshTable');
+        },
+        cancleSubmitBtmType(){
+            this.btmType = {};
+            this.btmType.attributes = [];
+            console.log(this.btmType);
+        },
+        refreshAttrTable(){
+            this.$refs.attrTable.refreshTable();
         }
     }
 }
 </script>
 
-<style></style>
\ No newline at end of file
+<style>
+/* 灞炴�ф睜鍙傜収鍒楄〃 */
+.attrRef > .el-card:nth-of-type(2) > .el-card__body > .avue-crud__menu{
+        display: none !important;
+}
+</style>
\ No newline at end of file
diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IBtmAttributeClient.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IBtmAttributeClient.java
new file mode 100644
index 0000000..1aebee1
--- /dev/null
+++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IBtmAttributeClient.java
@@ -0,0 +1,29 @@
+package com.vci.ubcs.omd.feign;
+
+import com.vci.ubcs.omd.vo.BtmTypeAttributeVO;
+import org.springblade.core.launch.constant.AppConstant;
+import org.springblade.core.tool.api.R;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+
+/**
+ * Description:涓氬姟绫诲瀷鍏宠仈灞炴�� Feign鎺ュ彛绫�
+ *
+ * @author LiHang
+ * @date 2023/5/10
+ */
+@FeignClient(
+	value = AppConstant.APPLICATION_NAME_OMD,
+	fallback = IBtmAttributeFallback.class
+)
+public interface IBtmAttributeClient {
+
+	String API_PREFIX = "/client";
+	String LIST_BY_BTM_OID = API_PREFIX + "/btm-attribute/list-by-btm-oid";
+
+	@GetMapping(LIST_BY_BTM_OID)
+	R<List<BtmTypeAttributeVO>> listByBtmOid(@RequestParam("oid") String oid);
+}
diff --git a/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IBtmAttributeFallback.java b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IBtmAttributeFallback.java
new file mode 100644
index 0000000..462ec2c
--- /dev/null
+++ b/Source/UBCS/ubcs-service-api/ubcs-omd-api/src/main/java/com/vci/ubcs/omd/feign/IBtmAttributeFallback.java
@@ -0,0 +1,22 @@
+package com.vci.ubcs.omd.feign;
+
+import com.vci.ubcs.omd.vo.BtmTypeAttributeVO;
+import org.springblade.core.tool.api.R;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * Description:涓氬姟绫诲瀷鍏宠仈灞炴�eign澶辫触
+ *
+ * @author LiHang
+ * @date 2023/5/10
+ */
+@Component
+public class IBtmAttributeFallback implements IBtmAttributeClient{
+
+	@Override
+	public R<List<BtmTypeAttributeVO>> listByBtmOid(String oid) {
+		return R.fail("鑾峰彇鏁版嵁澶辫触");
+	}
+}
diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/BtmAttributeClient.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/BtmAttributeClient.java
new file mode 100644
index 0000000..a322f89
--- /dev/null
+++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/feign/BtmAttributeClient.java
@@ -0,0 +1,38 @@
+package com.vci.ubcs.omd.feign;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.vci.ubcs.omd.entity.BtmTypeAttribute;
+import com.vci.ubcs.omd.service.IBtmTypeAttributeService;
+import com.vci.ubcs.omd.vo.BtmTypeAttributeVO;
+import com.vci.ubcs.omd.wrapper.BtmTypeAttributeWrapper;
+import lombok.AllArgsConstructor;
+import org.springblade.core.tenant.annotation.NonDS;
+import org.springblade.core.tool.api.R;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+import springfox.documentation.annotations.ApiIgnore;
+
+import java.util.List;
+
+/**
+ * Description: 涓氬姟绫诲瀷鍏宠仈灞炴�ф湇鍔eign瀹炵幇绫�
+ *
+ * @author LiHang
+ * @date 2023/5/10
+ */
+@NonDS
+@ApiIgnore
+@RestController
+@AllArgsConstructor
+public class BtmAttributeClient implements IBtmAttributeClient{
+
+	private final IBtmTypeAttributeService btmTypeAttributeService;
+
+	@GetMapping(LIST_BY_BTM_OID)
+	@Override
+	public R<List<BtmTypeAttributeVO>> listByBtmOid(String oid) {
+		return R.data(BtmTypeAttributeWrapper.build().listEntityVO(
+		btmTypeAttributeService.list(Wrappers.<BtmTypeAttribute>query().lambda().eq(BtmTypeAttribute::getPkBtmType,oid))
+		));
+	}
+}
diff --git a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java
index 8c7215d..70559e2 100644
--- a/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java
+++ b/Source/UBCS/ubcs-service/ubcs-omd/src/main/java/com/vci/ubcs/omd/service/impl/BtmTypeServiceImpl.java
@@ -649,7 +649,6 @@
 			domainMap.forEach((k,v)-> {
 				if (domain.contains(k)){
 					BtmTypeTreeVO parent = new BtmTypeTreeVO();
-					parent.setOid(k);
 					parent.setName(k);
 					parent.setChildList(v.stream().map(s -> {
 						BtmTypeTreeVO child = new BtmTypeTreeVO();
@@ -749,6 +748,7 @@
 				attribute.setReferToName(attr.getReferBtmTypeName());
 				attribute.setTs(now);
 				attribute.setCreateTime(now);
+				attribute.setIsDeleted(0);
 				attribute.setCreateUser(AuthUtil.getUserId());
 				idAttrMap.put(attribute.getKey(),attribute);
 				// 鍦ㄨ繖閲岀粰涓氬姟绫诲瀷璁剧疆鐗堟湰鎺у埗銆佺敓鍛藉懆鏈熸帶鍒躲�佸瘑绾ф帶鍒剁浉鍏崇殑淇℃伅

--
Gitblit v1.9.3