<!-- 课件管理页面 -->
<template>
  <div class="courseManage">
    <!-- 搜索框及按钮 -->
    <div class="filter">
      <div class="filterItems">
        <div class="select">
          <a-select
            v-model:value="projectName"
            style="width: 270px"
            placeholder="请输入项目名称"
            :options="projectNameList"
            @change="selectProjectName"
            allowClear
            showSearch
          ></a-select>
        </div>
        <div class="select">
          <a-select
            v-model:value="projectName"
            style="width: 270px"
            placeholder="请输入项目经理"
            :options="projectNameList"
            @change="selectProjectName"
            allowClear
            showSearch
          ></a-select>
        </div>
        <div class="select">
          <a-select
            v-model:value="projectName"
            style="width: 270px"
            placeholder="请选择状态"
            :options="projectNameList"
            @change="selectProjectName"
            allowClear
            showSearch
          ></a-select>
        </div>
        <div class="select">
          <a-date-picker
            v-model="selectTime"
            type="date"
            placeholder="创建时间"
            style="width: 270px"
          />
        </div>
      </div>
      <div class="btns">
        <div class="btn btn1">
          <div class="search"></div>
          <div class="btnText">搜索</div>
        </div>
        <div class="btn btn2">
          <div class="search"></div>
          <div class="btnText">重置</div>
        </div>
        <div class="btn btn3">
          <div class="search"></div>
          <div class="btnText">创建项目</div>
        </div>
      </div>
    </div>
    <!-- 搜索框及按钮 -->
    <!-- 表格 -->
    <div class="tableBox">
      <a-table
        :columns="columns"
        :data-source="tableData"
        :loading="tableDataTotal === -1 ? true : false"
        :scroll="{ x: 700, y: 800 }"
        expandRowByClick="true"
        @expand="expandTable"
        :pagination="{
          showSizeChanger: true,
          showQuickJumper: true,
          hideOnSinglePage: true,
          pageSizeOptions: [],
          pageSize: pageSize,
          current: currentPage,
          total: tableDataTotal,
          onChange: (page, pageSize) => {
            currentPage = page;
            // console.log('page', page)
            // 加翻页查找代码
            // 	this.setState({
            // 		currentPage: page,
            // 	}, () => {
            // 		this.getMilitaryDeployment()
            // 	})
          },
        }"
      />
    </div>
    <!-- 表格 -->
  </div>
</template>
<script>
import { reactive, toRefs, onMounted, ref } from "vue";
const columns = [
  {
    title: "项目名称",
    dataIndex: "projectName",
    key: "projectName",
    width: 280,
    // align: "center",
    ellipsis: true,
    // scopedSlots: { customRender: "action" }, //引入的插槽
    // customRender: (text, record) => {
    //   console.log(text, record);
    //   return <span>{text.text}</span>;
    // },
  },
  {
    title: "项目经理",
    dataIndex: "manager",
    key: "manager",
    width: 100,
    align: "center",
  },
  {
    title: "状态",
    dataIndex: "state",
    // width: "30%",
    key: "state",
    width: 100,
    align: "center",
  },
  {
    title: "创建人",
    dataIndex: "creater",
    // width: "30%",
    key: "creater",
    width: 100,
    align: "center",
  },
  {
    title: "创建时间",
    dataIndex: "time",
    key: "time",
    width: 180,
    align: "center",
  },
  {
    title: "操作",
    dataIndex: "opacation",
    key: "opacation",
    width: 300,
    align: "center",
  },
];
const rowSelection = ref({
  checkStrictly: false,
  onChange: (selectedRowKeys, selectedRows) => {
    console.log(
      `selectedRowKeys: ${selectedRowKeys}`,
      "selectedRows: ",
      selectedRows
    );
  },
  onSelect: (record, selected, selectedRows) => {
    console.log(record, selected, selectedRows);
  },
  onSelectAll: (selected, selectedRows, changeRows) => {
    console.log(selected, selectedRows, changeRows);
  },
});
export default {
  name: "CourseManage",

  setup() {
    const state = reactive({
      projectNameList: [
        {
          id: 1,
          value: "项目一",
          label: "项目一",
        },
        {
          id: 2,
          value: "项目二",
          label: "项目二",
        },
        {
          id: 3,
          value: "项目三",
          label: "项目三",
        },
        {
          id: 4,
          value: "项目四",
          label: "项目四",
        },
      ],
      projectName: null,
      selectTime: null,

      tableData: [
        {
          key: 1,
          projectName:
            "管理者进阶1管理者进阶1管理者进阶1管理者进阶1管理者进阶1管理者进阶1管理者进阶1",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
          children: [
            {
              key: 5,
              projectName: "管理者进阶5",
              manager: "黄华  刘俊",
              state: "草稿",
              creater: "毛继禹",
              time: "2022-07-20 14:00:03",
              children: [
                {
                  key: 7,
                  projectName:
                    "管理者进阶7管理者进阶7管理者进阶7管理者进阶7管理者进阶7管理者进阶7管理者进阶7",
                  manager: "黄华  刘俊",
                  state: "草稿",
                  creater: "毛继禹",
                  time: "2022-07-20 14:00:03",
                },
                {
                  key: 8,
                  projectName: "管理者进阶8",
                  manager: "黄华  刘俊",
                  state: "草稿",
                  creater: "毛继禹",
                  time: "2022-07-20 14:00:03",
                },
              ],
            },
            {
              key: 6,
              projectName: "管理者进阶6",
              manager: "黄华  刘俊",
              state: "草稿",
              creater: "毛继禹",
              time: "2022-07-20 14:00:03",
            },
          ],
        },
        {
          key: 2,
          projectName: "管理者进阶2",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 3,
          projectName: "管理者进阶3",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
          hasChildren: true,
          children: [
            {
              key: 35,
              projectName: "管理者进阶35",
              manager: "黄华  刘俊",
              state: "草稿",
              creater: "毛继禹",
              time: "2022-07-20 14:00:03",
              children: [
                {
                  key: 37,
                  projectName: "管理者进阶37",
                  manager: "黄华  刘俊",
                  state: "草稿",
                  creater: "毛继禹",
                  time: "2022-07-20 14:00:03",
                },
                {
                  key: 38,
                  projectName: "管理者进阶38",
                  manager: "黄华  刘俊",
                  state: "草稿",
                  creater: "毛继禹",
                  time: "2022-07-20 14:00:03",
                },
              ],
            },
            {
              key: 36,
              projectName: "管理者进阶36",
              manager: "黄华  刘俊",
              state: "草稿",
              creater: "毛继禹",
              time: "2022-07-20 14:00:03",
            },
          ],
        },
        {
          key: 4,
          projectName: "管理者进阶4",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶5",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
        {
          key: 4,
          projectName: "管理者进阶",
          manager: "黄华  刘俊",
          state: "草稿",
          creater: "毛继禹",
          time: "2022-07-20 14:00:03",
        },
      ],
      currentPage: 1,
      tableDataTotal: 20,
      pageSize: 10,
    });

    onMounted(() => {
      // console.log("执行");
    });
    const selectProjectName = (value, index) => {
      console.log("value", value, index);
    };
    const expandTable = (e, a) => {
      console.log("惦记了");
      console.log("e", e, a);
    };
    return {
      ...toRefs(state),
      columns,
      rowSelection,
      selectProjectName,
      expandTable,
    };
  },
};
</script>
<style lang="scss">
.courseManage {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  .filter {
    margin-left: 38px;
    margin-right: 38px;
    margin-top: 30px;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .filterItems {
      display: flex;
      flex-wrap: wrap;
      .select {
        margin-right: 20px;
        margin-bottom: 20px;
      }
    }
    .btns {
      display: flex;
      // flex-wrap: wrap;
      .btn {
        padding: 0px 26px 0px 26px;
        height: 38px;
        background: rgba(64, 158, 255, 0);
        border-radius: 8px;
        border: 1px solid rgba(64, 158, 255, 1);
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 14px;
        flex-shrink: 0;
        .search {
          background-size: 100%;
        }
        .btnText {
          font-size: 14px;
          font-weight: 400;
          color: rgba(64, 158, 255, 1);
          line-height: 36px;
          margin-left: 5px;
        }
      }
      .btn1 {
        .search {
          width: 15px;
          height: 17px;
          background-image: url("../../assets/images/courseManage/search1.png");
        }
      }
      .btn2 {
        .search {
          width: 16px;
          height: 18px;
          background-image: url("../../assets/images/courseManage/reset1.png");
        }
      }
      .btn3 {
        margin-right: 0px;
        .search {
          width: 17px;
          height: 18px;
          background-image: url("../../assets/images/courseManage/add1.png");
        }
      }
      .btn1:hover {
        background: rgba(64, 158, 255, 1);
        .search {
          background-image: url("../../assets/images/courseManage/search0.png");
        }
        .btnText {
          color: #ffffff;
        }
      }
      .btn2:hover {
        background: rgba(64, 158, 255, 1);
        .search {
          background-image: url("../../assets/images/courseManage/reset0.png");
        }
        .btnText {
          color: #ffffff;
        }
      }
      .btn3:hover {
        background: rgba(64, 158, 255, 1);
        .search {
          background-image: url("../../assets/images/courseManage/add0.png");
        }
        .btnText {
          color: #ffffff;
        }
      }
    }
  }
  .tableBox {
    margin: 20px 38px 30px;
  }
}
</style>
