田源
2023-06-09 f7e33d69713a5145d19fde5792b422826bc14107
Source/UBCS-WEB/src/components/Crud/Crud.vue
@@ -1,20 +1,5 @@
<template>
  <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">增加
@@ -25,21 +10,18 @@
            :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"
            :templateOid="this.templateOids"
            :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>
@@ -49,8 +31,9 @@
        <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 size="small" type="primary" plain @click="openD">导出
          <integration-transfer :visible.sync="dialogPush" :data="transferData"
                                :props="transferProps" @save="handelTransferSave"></integration-transfer>
        </el-button>
        <el-button size="small" type="primary" plain @click="findvisible=true">查询
        <advancedQuery  :visible.sync="findvisible" :options="this.options"></advancedQuery>
@@ -87,22 +70,14 @@
              </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"
        :current-page="page.currentPage"
        :page-sizes="page.pageSizes"
        :page-size="page.pageSizes"
        layout="total, sizes, prev, pager, next, jumper"
@@ -111,19 +86,56 @@
    </div>
  </basic-container>
</template>
<script>
import {MasterTable, TableData} from "@/api/GetItem";
import {listCodeAttributeByClassId} from '@/api/integration/integration.js'
import integrationTransfer from '@/views/integration/integrationTransfer'
import pinyin from "js-pinyin";
export default {
  components: {
    integrationTransfer
  },
  name: "Crud.vue",
  props:{
    page:{
      type: Object,
      default: ()=>{
        return {}
      }
    },
    codeClassifyOid:{
      type:String,
      default:""
    },
    coderuleoid:{
      type:String,
      default:""
    },
    tableDataArray:{
      type:Array,
      default:[]
    },
    total:{
      type:String,
      default:""
    },
    tableHeadDataFateher:{
      type:Array,
      default:[]
    }
  },
  data() {
    return {
      transferData:[],
      transferProps: {
        key: 'oid',
        label: 'name'
      },
      templateOid:"",
      addvisible:false,
      editvisible:false,
      findvisible:false,
      templateOid: "78B8C7C5-A042-0B96-FE6D-65421451782A",
      codeClassifyOid: "4524E801-6CC6-92E8-1AC3-2AB9604E8F96",
      codeRuleOid: "B95872A6-9CEA-D490-8F1B-9D26548CAF96",
      dialogPush:false,
      rowOid: '6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9',
      disabledProp: ["id"],
      editingRow:null,
@@ -133,14 +145,6 @@
      data: [],
      options:{},
      option: {
        //默认高度,
        align: 'center',
        menuAlign: 'center',
        addBtn: false,
        editBtn: false,
        selection: true,
        selectionFixed: false,
        index: true,
        column: []
      },
      List: [],
@@ -151,35 +155,85 @@
        number: "number",
        datetime: "datetime",
      },
      page: {
        total: 0,
        currentPage: 1,
        pageSize: 10,
        pageSizes: [10, 30, 50, 100, 200],
      },
      tableData:[],
      tableHeadData:[],
      items:{}
      tableHeadDataFateher:[],
      items:{},
      seniorQueryColumns:[]
    }
  },
  computed:{
  },
  created() {
    this.CrudHeaderRend();
    this.CrudRend()
    // this.CrudHeaderRend();
    // this.tableHeadHandle()
  },
  mounted() {
  },
  activated() {
    this.doLayout()
  },
  watch:{
    codeClassifyOid:{
      handler(newval,oldval){
        this.codeClassifyOid=newval;
        this.CrudHeaderRend()
      },
      deep:true
    },
    tableDataArray:{
      handler(newval,oldval){
        this.tableData=newval;
      //
      }
    },
    total:{
      handler(newval,oldval){
        this.page.total=newval;
      }
    },
    tableHeadData:{
      handler(newval,oldval){
        this.tableHeadDataFateher=newval
      }
    }
  },
  methods: {
    openD(){
      this.dialogPush=true;
      this.getListCodeByClassId()
    },
    async getListCodeByClassId() {
      this.transferData = []
      const response = await listCodeAttributeByClassId({ codeClassifyId: this.codeClassifyOid })
      if (response.status === 200) {
        const data = response.data.data
        this.transferData = data
      }
    },
    rend(){
      this.tableData=this.tableHeadData
    },
    handleSizeChange(val){
      this.page.pageSize=val
      this.$emit('pageSize',val)
      this.CrudRend()
      console.log(this.tableData)
    },
    handleCurrentChange(val){
      this.page.currentPage=val
      this.$emit('currentPage',val)
      this.CrudRend()
      console.log(val)
      console.log(this.tableData)
    },
    // 监听单元格点击事件并存储正在编辑的行
    handleCellClick(row, column) {
      this.editingRow = row;
      this.editShow = column.property;
      console.log(row)
      this.rowOid=row.oid
    },
    //删除
    enumDeleteRow(row) {
@@ -195,41 +249,59 @@
        this.$refs.crud.doLayout();
      });
    },
    tableHeadHandle(){
      this.options=this.tableHeadDataFateher.tableDefineVO.seniorQueryColumns
      this.List = this.tableHeadDataFateher.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;
      })
    },
    //表格头渲染
    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)
            console.log(this.templateOid)
          })
        })
      })
      }
    },
    //表格数据
    CrudRend() {
      TableData({
        templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
        codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
        page: this.page.currentPage,
        limit:9,
        _: 1685089123575
      }).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) {
@@ -241,8 +313,8 @@
        order = "desc";
      }
      TableData({
        templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
        codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
        templateOid: this.templateOid,
        codeClassifyOid: this.codeClassifyOid,
        order: order,
        sort: val.prop,
        page: this.page.currentPage,
@@ -257,11 +329,10 @@
    //分页刷新
    async onLoad(val) {
      await TableData({
        templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
        codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
        templateOid: this.templateOid,
        codeClassifyOid: this.codeClassifyOid,
        page: val.currentPage,
        limit: val.pageSize,
        _: 1685089123575
      }).then(res => {
        this.data = res.data.data;
      })