田源
2024-04-11 5a00f7eec311c7b71b40df4beaded505eca5329c
Source/ProjectWeb/src/components/dynamic-components/dynamic-button.vue
@@ -39,12 +39,24 @@
        {{ item.name }}
      </el-button>
    </div>
    <div v-else-if="type === 'tree'" class="tree-buttons">
      <el-button v-for="item in basicButtonList"
                 :key="item.oid"
                 :icon="item.paramVOS.webUiButtonIcon"
                 :type="(item.paramVOS.webUiButtonType !== 'text' ? item.paramVOS.webUiButtonType : 'primary') || 'primary'"
                 plain
                 size="small"
                 @click="buttonClick(item)">
        {{ item.name }}
      </el-button>
    </div>
  </div>
</template>
<script>
import func from "@/util/func";
import {validatenull} from "@/util/validate";
import {doAction} from '@/actions/base/BaseAction';
export default {
  name: "dynamic-button",
@@ -239,12 +251,19 @@
  computed: {
    basicButtonList() {
      const basicColumn = this.butttonList;
      if (!basicColumn || !Array.isArray(basicColumn)) {
        return []; // 如果 basicColumn 未定义或者不是数组,返回空数组
      }
      if (this.type === 'form') {
      if (this.type === 'form' || this.type === 'tree') {
        return basicColumn;
      } else if (this.type === 'table' || this.type === 'TreeTable') {
        const top = basicColumn.filter(item => item.paramVOS.webUiButtonLocation === 'top' || func.isEmpty(item.paramVOS.webUiButtonLocation)); // 过滤出来表格上面区域展示的按钮
        const menu = basicColumn.filter(item => item.paramVOS.webUiButtonLocation === 'menu'); // 过滤出来操作栏展示的按钮
        const top = basicColumn.filter(item => {
          return item.paramVOS && (item.paramVOS.webUiButtonLocation === 'top' || func.isEmpty(item.paramVOS.webUiButtonLocation));
        });
        const menu = basicColumn.filter(item => {
          return item.paramVOS && item.paramVOS.webUiButtonLocation === 'menu';
        });
        return {
          top: top,
          menu: menu,
@@ -260,18 +279,14 @@
      this.$refs.dynamicForm.form = row;
    },
    buttonClick(item) {
      // 根据 type 条件动态引入不同的JS文件,并传递 item this 参数
      if (this.type === 'table') {
        import('@/views/base/buttonTable').then(module => {
          const buttonClickTable = module.default;
          buttonClickTable.buttonClick(item,this);
        })
      } else if (this.type === 'form') {
        import('@/views/base/buttonForm').then(module => {
          const buttonClickForm = module.default;
          buttonClickForm.buttonClick(item,this);
        })
      }
      doAction(item,{
        paramVOS: item.paramVOS,
        dataStore: [],
        sourceData: {},
        callback: function (){
        }
      });
    }
  },
}