<template>
  <div>
    <el-dialog
        title="新 建"
        :visible.sync="dialogProjectVisible"
        width="35%"
        append-to-body
    >
      <div slot="title" style="font-size: 15px">
        选择项目
      </div>
      <layout_table
          :layout="tablecols"
          :data="list"
          :opwidth="200"
          :custom="false"
          :height="320"
          :checkbox="true"
          @onRow="onRow">
      </layout_table>
      <div style="margin-top:16px;text-align:right">
        <el-pagination
            background
            small
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-size="params.content.pageSize"
            layout="total, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </div>
      <div class="dialog-footer">
        <el-button size="small" @click="onColes" class="normal-btn-width">取 消</el-button>
        <el-button size="small" type="warning" class="normal-btn-width btn-warning"  @click="onSubmit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import layout_table from '../components/table'
export default {
  name: "project",
  props:["visible"],
  data(){
    return {
      dialogProjectVisible:false,
      bill_id:"",
      tablecols:[],
      list:[],
      total:0,
      currentPage:0,
      row:"",
      params:{
        "id": 20221020143502,
        "content": {
          "pageNumber": 1,
          "pageSize": 10,
          "type":0, //  1：我负责的；2：我参与的；3：我下属负责的；4：我下属参与的
          "where": {
            "condition": ""
          }
        },
      }
    }
  },
  components:{layout_table},
  mounted() {
    console.log(this.visible)
    this.dialogProjectVisible = true
    this.listData()
  },
  methods:{
    async listData(){
      const res = await this.$api.requested(this.params)
      this.list = res.data
      this.total = res.total
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.params.content.pageSize = val
      this.listData()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.params.content.pageNumber = val
      this.listData()
    },
    onColes(){
      this.dialogProjectVisible = false
      this.$emit("onProject")
    },
    onRow(row){
      console.log("**********************---------------------")
      console.log(row)
      this.row = row
    },
    onSubmit(){
      console.log("**********************---------------------")
      this.dialogProjectVisible = false
      this.$emit("onProject",this.row)
      console.log(this.row)
    }

  },

  created() {
    this.tablecols = this.tool.tabelCol(this.$route.name).projectsTable.tablecols
  }
}
</script>

<style scoped>

</style>