Kaynağa Gözat

1.0.97 查询窗口可渲染自定义表头按钮

liuyanpeng 1 yıl önce
ebeveyn
işleme
fe20d35b29

+ 29 - 48
examples/info/InfoWindowExample.vue

@@ -1,61 +1,42 @@
 <template>
   <div>
-    <InfoWindow
-      :info-window-no="infoWindowNo" :multiple="true" :is-search-widget="false" :is-new-similar-assets="false"
-      @get-select-model-data="getSelectModelData"
-    >
+    <InfoWindow ref="infoWindowRef" :info-window-no="infoWindowNo" :multiple="true" :is-search-widget="true">
+      <template #customButton>
+        <a-button :icon="h(PlusCircleTwoTone)" @click="getSelectModelData">自定义按钮</a-button>
+        <a-button :icon="h(PlusCircleTwoTone)" @click="getSelectModelData">自定义按钮</a-button>
+      </template>
       <template #customContent>
         <div>这是自定义内容</div>
       </template>
     </InfoWindow>
   </div>
 </template>
-<script>
-
+<script setup>
 import InfoWindow from '@/info/index.js';
+import { ref, getCurrentInstance, h, onMounted } from 'vue';
+import { PlusCircleTwoTone } from '@ant-design/icons-vue';
+
+const infoWindowNo = ref(null);
+const infoWindowRef = ref(null);
+const { proxy } = getCurrentInstance(); //访问this
+
+onMounted(() => {
+  getInfoWindowNo();
+});
+
+const getInfoWindowNo = () => {
+  if (proxy.$route.params != undefined) {
+    var routeInfoWindowNo = proxy.$route.params.infoWindowNo;
+    if (infoWindowNo.value != routeInfoWindowNo) {
+      infoWindowNo.value = routeInfoWindowNo;
+      console.log('open info window: ' + routeInfoWindowNo);
+    }
+  }
+};
 
-export default {
-  components: {
-    InfoWindow,
-  },
-
-  props: {
-
-  },
-
-  data: function () {
-    return {
-      'infoWindowNo': null,
-    };
-  },
-
-  watch: {
-    '$route': function (to, from) {
-      this.getInfoWindowNo();
-    },
-  },
-
-  mounted: function () {
-    this.getInfoWindowNo();
-  },
-
-  methods: {
-    /**
-     * 获取查询窗口的编号
-     */
-    getInfoWindowNo: function () {
-      if (this.$route.params != undefined) {
-        var routeInfoWindowNo = this.$route.params.infoWindowNo;
-        if (this.infoWindowNo != routeInfoWindowNo) {
-          this.infoWindowNo = routeInfoWindowNo;
-          console.log('open info window: ' + routeInfoWindowNo);
-        }
-      }
-    },
-    getSelectModelData: function (selected) {
-      console.log(selected, '---');
-    },
-  },
+const getSelectModelData = () => {
+  const selectDatas = infoWindowRef.value.getSelectedModelDatas();
+  console.log(selectDatas, '---');
 };
 
 </script>

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pc-component-v3",
-  "version": "1.0.95",
+  "version": "1.0.97",
   "description": "",
   "main": "dist/pc-component-v3.js",
   "scripts": {

+ 3 - 5
packages/info/src/InfoWindow.vue

@@ -9,7 +9,6 @@
       :info-window="infoWindowDto"
       :where-clause-source="whereClauseSource" 
       :is-search-widget="isSearchWidget" 
-      :is-new-similar-assets="isNewSimilarAssets" 
       :parent-model-data="parentModelData"
       :model-data="modelData" 
       :multiple="multiple" 
@@ -19,6 +18,9 @@
       @data-selected="dataSelected"
       @delete-selected="deleteSelected"
     >
+      <template #customButton>
+        <slot name="customButton" />
+      </template>
       <template #customContent>
         <slot name="customContent" />
       </template>
@@ -58,10 +60,6 @@ export default defineComponent({
       type: Boolean,
       default: false,
     },
-    'isNewSimilarAssets': {
-      type: Boolean,
-      default: false,
-    },
     'parentModelData': {
       type: Object,
       default(){

+ 12 - 20
packages/info/src/QueryPage.vue

@@ -37,16 +37,15 @@
           </a-flex>
         </div>
       </div>
-      <a-button v-if="isNewSimilarAssets" style="margin-top: 6px;" @click="newSimilarAssets">
-        <template #icon>
-          <PlusCircleTwoTone />
-        </template>
-        确认添加
-      </a-button>
+      <!-- 自定义按钮 -->
+      <a-space style="margin-top: 6px;">
+        <slot name="customButton" />
+      </a-space>
       <div v-if="!isSearchWidget" style="display: inline-block">
         <QueryPageButton
-          :info-buttons="infoWindowDto.infoButtons" :info-window-no="infoWindowDto.no" :select-info-data="selectInfoData" :icon-src="iconSrc"
-          @refresh-datas="pageSearch" @execute-export="executeExport" @execute-process="executeProcess"
+          :info-buttons="infoWindowDto.infoButtons" :info-window-no="infoWindowDto.no"
+          :select-info-data="selectInfoData" :icon-src="iconSrc" @refresh-datas="pageSearch"
+          @execute-export="executeExport" @execute-process="executeProcess"
         >
           <template #customContent>
             <slot name="customContent" />
@@ -187,7 +186,7 @@ export default {
     SyncOutlined,
     DownloadOutlined,
     QueryPageButton,
-    ExclamationCircleOutlined,PlusCircleTwoTone,
+    ExclamationCircleOutlined, PlusCircleTwoTone,
   },
 
   props: {
@@ -201,11 +200,6 @@ export default {
       type: Boolean,
       default: false,
     },
-    // 用于新增同类资产,其他可以忽略
-    isNewSimilarAssets: {
-      type: Boolean,
-      default: false,
-    },
     parentModelData: {
       type: Object,
       default() {
@@ -246,7 +240,7 @@ export default {
     },
   },
 
-  emits: ['dataSelected', 'deleteSelected','getSelectModelData'],
+  emits: ['dataSelected', 'deleteSelected', 'getSelectModelData'],
 
   data: function () {
     this.Language = Language;
@@ -1008,11 +1002,6 @@ export default {
     infoSelected: function () {
       this.selectInfoData = this.infoWindowDataInstance.getSelected();
     },
-
-    // 获取需要新增同类资产数据
-    newSimilarAssets: function(){
-      this.$emit('getSelectModelData',this.selectInfoData);
-    },
   },
 };
 </script>
@@ -1092,4 +1081,7 @@ nav>>>ul.pagination {
 .m-segmented>>>.ant-segmented-item {
   margin-bottom: 0px;
 }
+:deep(.ant-btn) {
+  padding: 4px 8px;
+}
 </style>