fujunling
2023-06-06 29d2aabc6a07be091d7b52ba51e12a6baf16f7ac
Source/UBCS-WEB/src/components/Crud/Crud.vue
@@ -1,30 +1,149 @@
<template>
<basic-container style="height: 750px">
  <avue-crud ref="crud" :data="data" :option="option" style="height: 750px" @sort-change="sortChange"></avue-crud>
</basic-container>
  <basic-container>
<!--    <avue-crud ref="crud"-->
<!--               v-loading="loading"-->
<!--               :data="data"-->
<!--               :option="option"-->
<!--               :page="page"-->
<!--               @sort-change="sortChange"-->
<!--               @selection-change="selectionChange"-->
<!--               @on-load="onLoad">-->
<!--      <template slot="menu">-->
<!--        <el-button type="text">文字按钮</el-button>-->
<!--      </template>-->
<!--      <template slot="menuLeft">-->
<!--      </template>-->
<!--    </avue-crud>-->
    <div class="testbox">
      <div style="margin-top: 10px;display: flex;flex-wrap: wrap;width: 100%;">
        <el-button size="small" type="primary" plain @click="addvisible=true">增加
          <FormTemplateDialog
            :visible.sync="addvisible"
            :type="add"
            :templateOid="this.templateOid"
            :codeClassifyOid="this.codeClassifyOid"
            :codeRuleOid="this.codeRuleOid"
            :disabledProp="disabledProp"
            :rowOid="rowOid"
          >
          </FormTemplateDialog></el-button>
        <el-button size="small" type="primary" plain @click="editvisible=true">编辑
          <FormTemplateDialog
            :visible.sync="editvisible"
            :type="edit"
            :templateOid="this.templateOid"
            :codeClassifyOid="this.codeClassifyOid"
            :codeRuleOid="this.codeRuleOid"
            :disabledProp="disabledProp"
            :rowOid="rowOid"
          ></FormTemplateDialog></el-button>
        <el-button size="small" type="primary" plain>批量导入申请</el-button>
        <el-button size="small" type="primary" plain>历史数据导入</el-button>
        <el-button size="small" type="primary" plain>批量申请编码</el-button>
        <el-button size="small" type="primary" plain>批量发布</el-button>
        <el-button size="small" type="primary" plain>查看流程历史</el-button>
        <el-button size="small" type="primary" plain>删除</el-button>
        <el-button size="small" type="primary" plain>发布</el-button>
        <el-button size="small" type="primary" plain>数据更改</el-button>
        <el-button size="small" type="primary" plain>回收</el-button>
        <el-button size="small" type="primary" plain>导出
          <transfer filter-placeholder="请输入拼音全拼或者拼音缩写" ></transfer>
        </el-button>
        <el-button size="small" type="primary" plain @click="findvisible=true">查询
        <advancedQuery  :visible.sync="findvisible" :options="this.options"></advancedQuery>
        </el-button>
        <el-button size="small" type="primary" plain>相似项查询</el-button>
        <el-button size="small" type="primary" plain style="margin-left: 1px;margin-top:10px">刷新</el-button>
        <el-input placeholder="请输入关键字按回车查询" style="width: 180px;margin-left: 5px;margin-top:10px" size="small"></el-input>
      </div>
      <el-row style="height: 700px;width: 100%">
        <el-table :data="tableData" style="" @cell-click="handleCellClick" max-height="700"  @selection-change="handleSelectionChange"  @sort-change="sortChange">
          <el-table-column
            type="selection"
            fixed
            width="55">
          </el-table-column>
          <el-table-column
            type="index"
            fixed
            label="序号"
            width="55">
          </el-table-column>
          <div v-for="(item,index) in this.tableHeadData" :key="index">
            <el-table-column :label="item.label" :prop="item.prop" :sortable="item.sortable" :width="item.width">
              <!-- 编辑和展示逻辑 -->
              <template slot-scope="{ row }">
                <el-input v-if="editingRow === row && editShow== item.prop" v-model="row[item.prop]" @blur="saveRow"></el-input>
                <span v-else>{{row[item.prop]}}</span>
                <el-switch
                  v-if="editShow === 'true'"
                  v-model="row[item.prop]"
                  active-color="#13ce66"
                  inactive-color="#ff4949">
                </el-switch>
              </template>
            </el-table-column>
          </div>
<!--          <el-table-column fixed="right" label="操作" width="120" >-->
<!--            <template slot-scope="scope" >-->
<!--              <el-button size="small" type="text" @click.native.prevent="enumDeleteRow(scope.$index, tableData)">-->
<!--                移除-->
<!--              </el-button>-->
<!--            </template>-->
<!--          </el-table-column>-->
        </el-table>
      </el-row>
    </div>
    <div class="block" style="display: flex;justify-content: flex-end">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage4"
        :page-sizes="page.pageSizes"
        :page-size="page.pageSizes"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total">
      </el-pagination>
    </div>
  </basic-container>
</template>
<script>
import { MasterTable,TableData } from "@/api/GetItem";
import {MasterTable, TableData} from "@/api/GetItem";
export default {
  name: "Crud.vue",
  data(){
    return{
      data:[
        {
          zhiliangbz:"111",
        },
        {
          xinghaoguige:"1121",
        },
      ],
      option:{
  data() {
    return {
      addvisible:false,
      editvisible:false,
      findvisible:false,
      templateOid: "78B8C7C5-A042-0B96-FE6D-65421451782A",
      codeClassifyOid: "4524E801-6CC6-92E8-1AC3-2AB9604E8F96",
      codeRuleOid: "B95872A6-9CEA-D490-8F1B-9D26548CAF96",
      rowOid: '6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9',
      disabledProp: ["id"],
      editingRow:null,
      editShow: "",
      editAttr:"",
      loading: false,
      data: [],
      options:{},
      option: {
        //默认高度,
        align:'center',
        menuAlign:'center',
        column:[]
        align: 'center',
        menuAlign: 'center',
        addBtn: false,
        editBtn: false,
        selection: true,
        selectionFixed: false,
        index: true,
        column: []
      },
      List:[],
      List: [],
      columnType: {
        text: "input",
        combox: "select",
@@ -32,67 +151,137 @@
        number: "number",
        datetime: "datetime",
      },
      page: {
        total: 0,
        currentPage: 1,
        pageSize: 10,
        pageSizes: [10, 30, 50, 100, 200],
      },
      tableData:[],
      tableHeadData:[],
      items:{}
    }
  },
  computed:{
  },
  created() {
   this.CrudHeaderRend();
   this.CrudRend()
    this.CrudHeaderRend();
    this.CrudRend()
  },
  activated() {
    this.doLayout()
  },
  methods:{
  methods: {
    handleSizeChange(val){
      console.log(val)
    },
    // 监听单元格点击事件并存储正在编辑的行
    handleCellClick(row, column) {
      this.editingRow = row;
      this.editShow = column.property;
    },
    //删除
    enumDeleteRow(row) {
      console.log(row)
      this.tableData.splice(row, 1)
    },
    // 将正在编辑的行的状态变为 null ,即退出编辑状态
    saveRow() {
      this.editingRow = null;
    },
    doLayout() {
      this.$nextTick(() => {
        this.$refs.crud.doLayout();
      });
    },
    CrudHeaderRend(){
      MasterTable({codeClassifyOid:"D9CF223F-317D-71EB-BD11-433A94CAD9F3",functionId: 5,_: 1685067339479}).then(res=>{
        this.List=res.data.tableDefineVO.cols[0];
        this.List.forEach(item=>{
          console.log(item)
          let columnItem={
            label:item.title,
            prop:item.field,
            type:this.columnType[item.type],
            sortable:item.sort,
            width:item.minWidth
    //表格头渲染
    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;
        })
      })
    },
    CrudRend(){
      TableData({templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
    //表格数据
    CrudRend() {
      TableData({
        templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
        codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
        page: 1,
        limit: 9,
        page: this.page.currentPage,
        limit:9,
        _: 1685089123575
      }).then(res=>{
        console.log(res)
        this.data=res.data.data
      }).then(res => {
        this.page.total = res.data.total;
        this.data = res.data.data;
        this.tableData=res.data.data;
      })
    },
    // 排序
    sortChange(val){
      console.log(val)
      // TableData(  {
      //   templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
      //   codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
      //   order:"desc",
      //   sort:val.prop
      // }).then(res=>{
      //   console.log(res.data.data)
      //   this.data=res.data.data
      // })
    sortChange(val) {
      this.loading = true;
      let order = ""
      if (val.order == "ascending") {
        order = "asc";
      } else {
        order = "desc";
      }
      TableData({
        templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
        codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
        order: order,
        sort: val.prop,
        page: this.page.currentPage,
        limit: this.page.pageSize,
      }).then(res => {
        setTimeout(() => {
          this.data = res.data.data;
          this.loading = false;
        }, 100);
      })
    },
    //分页刷新
    async onLoad(val) {
      await TableData({
        templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
        codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
        page: val.currentPage,
        limit: val.pageSize,
        _: 1685089123575
      }).then(res => {
        this.data = res.data.data;
      })
    },
    //多选
    handleSelectionChange(row) {
      console.log(row)
    }
  }
}
</script>
<style scoped>
<style lang="scss" scoped>
.testbox {
  .el-table--scrollable-x .el-table__body-wrapper {
    overflow: auto !important;
  }
  .el-table__fixed-right-patch {
    background-color: #f5f7fa !important;
  }
}
</style>