田源
2023-06-07 9412cc46c7d135d29dc6bf9b7ae36a3b6b17347c
分类树组件封装,联调真实表格数据
已修改5个文件
已添加2个文件
438 ■■■■■ 文件已修改
Source/UBCS-WEB/src/components/Crud/Crud.vue 101 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/Master/MasterTree.vue 124 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/main.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/store/index.js 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/store/modules/master.js 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/views/MasterData/items.vue 182 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/vue.config.js 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/Crud/Crud.vue
@@ -97,17 +97,22 @@
        return {}
      }
    },
    templateOid:{
      type:String,
      default:""
    },
    codeClassifyOid:{
      type:String,
      default:""
    },
    coderuleoid:{
      type:String,
      default:""
    },
    tableDataArray:{
      type:Array,
      default:[]
    }
  },
  data() {
    return {
      templateOid:"",
      addvisible:false,
      editvisible:false,
      findvisible:false,
@@ -135,26 +140,49 @@
      },
      tableData:[],
      tableHeadData:[],
      items:{}
      items:{},
      aaa:""
    }
  },
  computed:{
  },
  created() {
    this.CrudHeaderRend();
    this.CrudRend()
    this.$emit('tableData',this.tableData)
  },
  mounted() {
  },
  activated() {
    this.doLayout()
  },
  watch:{
    codeClassifyOid:{
      handler(newval,oldval){
        this.codeClassifyOid=newval;
        this.CrudHeaderRend()
      },
      deep:true
    },
    tableDataArray:{
      handler(newval,oldval){
        this.tableData=newval;
        this.CrudRend()
      }
    }
  },
  methods: {
    rend(){
      this.tableData=this.tableHeadData
    },
    handleSizeChange(val){
      this.page.pageSize=val
      this.$emit('pageSize',val)
      this.CrudRend()
    },
    handleCurrentChange(val){
      this.page.currentPage=val
      this.$emit('currentPage',val)
      this.CrudRend()
    },
    // ç›‘听单元格点击事件并存储正在编辑的行
@@ -178,38 +206,41 @@
    },
    //表格头渲染
    CrudHeaderRend() {
      MasterTable({
        codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
        functionId: 5,
        _: 1685067339479
      }).then(res => {
        this.options=res.data.tableDefineVO.seniorQueryColumns
        this.List = res.data.tableDefineVO.cols[0];
        this.List.forEach(item => {
          let columnItem = {
            label: item.title,
            prop: item.field,
            type: this.columnType[item.type],
            sortable: item.sort,
            width: item.minWidth
          };
          this.option.column.push(columnItem);
          this.option.column=this.tableHeadData;
      if(this.codeClassifyOid != ""){
        MasterTable({
          codeClassifyOid:this.codeClassifyOid,
          functionId: 5,
        }).then(res => {
          this.options=res.data.tableDefineVO.seniorQueryColumns
          this.List = res.data.tableDefineVO.cols[0];
          this.List.forEach(item => {
            let columnItem = {
              label: item.title,
              prop: item.field,
              type: this.columnType[item.type],
              sortable: item.sort,
              width: item.minWidth
            };
            this.option.column.push(columnItem);
            this.option.column=this.tableHeadData;
            this.templateOid=res.data.tableDefineVO.oid
            this.$emit('templateOid',this.templateOid)
          })
        })
      })
      }
    },
    //表格数据
    CrudRend() {
      TableData({
        templateOid: this.templateOid,
        codeClassifyOid: this.codeClassifyOid,
        page: this.page.currentPage,
        limit:this.page.pageSize,
      }).then(res => {
        this.page.total = res.data.total;
        this.data = res.data.data;
        this.tableData=res.data.data;
      })
       TableData({
         templateOid: this.templateOid,
         codeClassifyOid: this.codeClassifyOid,
         page: this.page.currentPage,
         limit:this.page.pageSize,
       }).then(res => {
         this.page.total = res.data.total;
         this.data = res.data.data;
         this.tableData=res.data.data;
       })
    },
    // æŽ’序
    sortChange(val) {
Source/UBCS-WEB/src/components/Master/MasterTree.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,124 @@
<template>
  <avue-tree ref="tree" v-model="CloneTreeAvueform" v-loading="loading" :data="Treedata" :defaultExpandAll="false"
             :option="Treeoption"
             style="height: 80.5vh;padding-top: 5px;padding-bottom: 30px"
             @node-click=" nodeClick"
  ></avue-tree>
</template>
<script>
import {getTreeList} from "@/api/MasterData/master";
import {mapMutations, mapState} from "vuex";
import {TableData} from "@/api/GetItem";
export default {
  name: "MasterTree",
  props:{
    pageSize:{
      type:String,
      default:"10"
    },
    currentPage:{
      type:String,
      default:"1"
    },
    templateOid:{
      type:String,
      default:''
    },
  },
  data(){
    return{
      tableDataArray:[],
      codeClassifyOid:"",
      coderuleoid:"",
      CloneTreeAvueform:{},
      loading:false,
      Treedata:[],
      nodeClickList: "",
      Treeoption: {
        addBtn: false,
        editBtn: false,
        delBtn: false,
        defaultExpandAll: false,
        menu: false,
        lazy: true,
        // treeLoad:function (node,resolve){
        //   console.log(node)
        //   console.log(resolve)
        // }
        treeLoad:function (node, resolve){
          if(node.data != false){
            const parentId = (node.level === 0) ? 0 : node.data.oid;
            const parentBtmName = node.data.attributes.btmname
            getTreeList({parentOid:parentId,parentBtmName:parentBtmName}).then(res=>{
              resolve(res.data.map(item=>{
                return {
                  ...item,
                  label:item.text
                }
              }))
            })
          }
        },
      },
    }
  },
  created() {
    this.getTreeList()
  },
  computed:{
   },
  methods:{
    //获取数据
    getTreeList(){
      getTreeList({'conditionMap[id]': 'wupin'}).then(res=>{
        this.Treedata=res.data
        this.ModifyProperties(this.Treedata, 'text', 'label');
        this.codeClassifyOid=res.data[0].oid;
        this.coderuleoid=res.data[0].attributes.coderuleoid;
        this.$emit("codeClassifyOid", this.codeClassifyOid )
        this.$emit("coderuleoid", this.coderuleoid )
      }).catch(res=>{
        console.log(res)
      })
    },
    //定义一个修改数据属性名的方法
    ModifyProperties(obj, oldName, newName) {
      for (let key in obj) {
        if (key === oldName) {
          obj[newName] = obj[key];
          delete obj[key];
        }
        if (typeof obj[key] === 'object') {
          this.ModifyProperties(obj[key], oldName, newName);
        }
      }
    },
    //树点击事件
    nodeClick(data){
      this.nodeClickList = data;
      console.log(this.currentPage,this.pageSize)
      TableData({
        templateOid: this.templateOid,
        codeClassifyOid: this.codeClassifyOid,
        page: this.pageSize,
        limit:this.currentPage,
      }).then(res => {
        console.log(res)
        // this.page.total = res.data.total;
        // this.data = res.data.data;
        this.tableDataArray=res.data.data;
        this.$emit('tableDataArray',this.tableDataArray)
        console.log(this.tableDataArray)
      })
    }
  }
}
</script>
<style scoped>
</style>
Source/UBCS-WEB/src/main.js
@@ -47,6 +47,7 @@
import originalAdd from "@/views/modeling/originalAdd"
import FormTemplateDialog from "@/components/FormTemplate/index"
import linkTypeAdd from "@/views/modeling/LinkTypeAdd"
import MasterTree from "@/components/Master/MasterTree";
// å°†å·¥å…·å‡½æ•°æ·»åŠ åˆ°å…¨å±€
import utilFunc from './util/func'
@@ -95,6 +96,7 @@
Vue.component('referSelectBtmAttrDialog',referSelectBtmAttrDialog)
Vue.component('FormTemplateDialog',FormTemplateDialog)
Vue.component('LinkTypeAdd',linkTypeAdd)
Vue.component('MasterTree',MasterTree)
// åŠ è½½ç›¸å…³url地址
Object.keys(urls).forEach(key => {
Source/UBCS-WEB/src/store/index.js
@@ -6,6 +6,7 @@
import logs from './modules/logs'
import dict from './modules/dict'
import getters from './getters'
import master from "./modules/master"
Vue.use(Vuex)
const store = new Vuex.Store({
@@ -14,7 +15,8 @@
    common,
    logs,
    tags,
    dict
    dict,
    master
  },
  getters,
})
Source/UBCS-WEB/src/store/modules/master.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,16 @@
const master = {
  state:{
    codeClassifyOid:""
  },
  actions:{
  },
  mutations:{
    codeClassifyOid(state,all){
      state.codeClassifyOid=all
      console.log(state.codeClassifyOid)
    }
  }
}
export default master
Source/UBCS-WEB/src/views/MasterData/items.vue
@@ -2,21 +2,32 @@
    <el-container>
      <el-aside>
        <basic-container style="height: 85vh; max-height: 155vh; overflow-y: scroll;">
          <avue-tree ref="tree" v-model="CloneTreeAvueform" v-loading="loading" :data="Treedata" :defaultExpandAll="false"
                     :option="Treeoption"
                     style="height: 80.5vh;padding-top: 5px;padding-bottom: 30px"
                     @node-click=" nodeClick"
          ></avue-tree>
<!--          æ ‘组件-->
          <master-tree @codeClassifyOid="codeClassifyOidList"
                       @coderuleoid="coderuleoidList"
                       :pageSize="this.pageSize"
                       :currentPage="this.currentPage"
                       :templateOid="this.templateOid"
                       @tableDataArray="tableDataArrays"
                        ></master-tree>
        </basic-container>
      </el-aside>
      <el-main>
      <TableCrud :page="this.page" :templateOid="this.templateOid" :codeClassifyOid="this.codeClassifyOid"></TableCrud>
<!--        è¡¨æ ¼ç»„ä»¶-->
      <TableCrud :page="this.page"
                 :codeClassifyOid="this.codeClassifyOid"
                 :coderuleoid="this.coderuleoid"
                 @pageSize="pageSizes"
                 @currentPage="currentPages"
                 @templateOid="templateOids"
                 :tableDataArray="tableDataArray"
      ></TableCrud>
      </el-main>
    </el-container>
</template>
<script>
import {getTreeList} from "@/api/MasterData/master"
export default {
  name: "items.vue",
  data(){
@@ -28,148 +39,35 @@
        pageSize: 10,
        pageSizes: [10, 30, 50, 100, 200],
      },
      templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
      codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
      CloneTreeAvueform:{},
      loading:false,
      Treedata:[],
      Treeoption: {
        addBtn: false,
        editBtn: false,
        delBtn: false,
        defaultExpandAll: false,
        menu: false,
        lazy: true,
        // treeLoad:function (node,resolve){
        //   console.log(node)
        //   console.log(resolve)
        // }
        treeLoad:function (node, resolve){
          if(node.loading){
            const parentId = (node.level === 0) ? 0 : node.data.oid;
            const parentBtmName = node.data.attributes.btmname
            getTreeList({parentOid:parentId,parentBtmName:parentBtmName}).then(res=>{
              console.log(res)
            })
          }
        },
      },
      nodeClickList: "",
      pageSize:"10",
      currentPage:"1",
      codeClassifyOid:"",
      coderuleoid:"",
      templateOid:"",
      tableDataArray:[]
    }
  },
  created() {
    // this.getAttr()
    this.getTreeList()
  },
  methods:{
    getTreeList(){
      getTreeList({'conditionMap[id]': 'wupin'}).then(res=>{
        this.Treedata=res.data
        this.ModifyProperties(this.Treedata, 'text', 'label');
        console.log(this.Treedata)
      }).catch(res=>{
        console.log(res)
      })
    codeClassifyOidList(val){
      this.codeClassifyOid=val;
      console.log(val)
    },
    //定义一个修改数据属性名的方法
    ModifyProperties(obj, oldName, newName) {
      for (let key in obj) {
        if (key === oldName) {
          obj[newName] = obj[key];
          delete obj[key];
        }
        if (typeof obj[key] === 'object') {
          this.ModifyProperties(obj[key], oldName, newName);
        }
      }
    coderuleoidList(val){
      this.coderuleoid=val;
    },
    //树节点添加按钮
    // TreeAdd() {
    //   this.TreeAddFormVisible = true;
    //   // åˆ¤æ–­å½“前是否有点击子项
    //   if (this.nodeClickList !== "") {
    //     this.TreeFlag = true
    //   }
    // },
    // //树节点添加事件
    // TreeAddHandler() {
    //   const data = this.TreeAddform
    //   this.$set(data, "parentCodeClassifyOid", this.nodeClickList.oid)
    //   TreeSave(data).then(() => {
    //     this.$message({
    //       type: 'success',
    //       message: '添加成功!'
    //     });
    //     this.getAttr();
    //     this.TreeAddFormVisible = false
    //     this.TreeAddform = ""
    //   }).catch(res => {
    //     this.$message({
    //       type: 'warning',
    //       message: res
    //     });
    //   })
    // },
    //树节点删除按钮
    // TreeDel() {
    //   this.$confirm('是否删除当前选择的分类,将会把子分类一并删除,如果存在编码数据将不能被删除,是否继续?', '提示', {
    //     confirmButtonText: '确定',
    //     cancelButtonText: '取消',
    //     type: 'warning',
    //     customClass: 'my-messagebox',
    //   }).then(() => {
    //     TreeCheckDel(this.nodeClickList).then(res => {
    //       if (res.data.data) {
    //         TreeDel(this.nodeClickList).then(() => {
    //           this.$message({
    //             type: 'success',
    //             message: '删除成功!'
    //           });
    //           this.getAttr();
    //         }).catch(res => {
    //           this.$message({
    //             type: 'warning',
    //             message: res
    //           });
    //         })
    //       } else {
    //         this.$confirm('当前数据包含有下级数据,要删除的话会和下级数据一起删除,你确认继续?', '提示', {
    //           confirmButtonText: '确定',
    //           cancelButtonText: '取消',
    //           type: 'warning',
    //           customClass: 'my-messageboxs',
    //         }).then(() => {
    //           TreeDel(this.nodeClickList).then(() => {
    //             this.$message({
    //               type: 'success',
    //               message: '删除成功!'
    //             });
    //             this.getAttr();
    //           }).catch(res => {
    //             this.$message({
    //               type: 'warning',
    //               message: res
    //             });
    //           })
    //         }).catch(() => {
    //           this.$message({
    //             type: 'info',
    //             message: '已取消删除'
    //           });
    //         });
    //       }
    //     })
    //   }).catch(() => {
    //     this.$message({
    //       type: 'info',
    //       message: '已取消删除'
    //     });
    //   });
    // },
    nodeClick(data){
      this.nodeClickList = data
      console.log(data)
    pageSizes(val){
      this.pageSize=val
    },
    currentPages(val){
      this.currentPage=val
    },
    templateOids(val){
      this.templateOid=val
    },
    tableDataArrays(val){
      this.tableDataArray=val
    }
  }
}
Source/UBCS-WEB/vue.config.js
@@ -27,11 +27,16 @@
      '/api': {
        //本地服务接口地址
        // target: 'http://localhost:37000',
        //  target: 'http://localhost:37000',
        target: 'http://192.168.1.51:37000',
        //target: 'http://192.168.3.7:37000',
        // target: 'http://dev.vci-tech.com:37000',
        // target: 'http://192.168.1.51:37000/',
        //   target: 'http://localhost:37000',
        // target: 'http://192.168.1.63:37000',
        //target: 'http://192.168.3.7:37000',
        // target: 'http://dev.vci-tech.com:37000',
        target: 'http://dev.vci-tech.com:37000',
        // target: 'http://192.168.1.51:37000/',
        //target: 'http://192.168.1.51:37000/',
        //远程演示服务地址,可用于直接启动项目
        // target: 'https://saber.bladex.vip/api',
        ws: true,