<template>
  <div>
    <div class="d-flex flex-between">
      <div>
      </div>
      <el-form label-width="100px" :inline="true">
        <el-form-item prop="state_value">
          <el-select class="mr10" v-model="state_value" placeholder="请选择类别">
            <el-option  v-for="item in type_list"  :key="item.value"  :label="item.label"  :value="item.value" ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="keyword">
          <el-input placeholder="请输入搜索关键字" v-model="keyword" clearable @clear="getListData"></el-input>
        </el-form-item>
        <el-button type="primary" class="ml5" @click="getListData">搜索</el-button>
      </el-form>
    </div>
    <el-table :data="tableData" tooltip-effect="dark" v-loading="loading" style="width: 100%" @selection-change="handleSelectionChange">
      <el-table-column type="selection" align="center" width="55"></el-table-column>
      <el-table-column label="序号" align="center" type="index" width="50"></el-table-column>
      <el-table-column label="类型" prop="lb_name" show-overflow-tooltip></el-table-column>
      <el-table-column label="标题" prop="gw_title" show-overflow-tooltip></el-table-column>
      <el-table-column label="发文字号" prop="gw_zh" show-overflow-tooltip></el-table-column>
      <el-table-column label="发起人" prop="gw_fqr_name" show-overflow-tooltip></el-table-column>
      <el-table-column label="发起科室" prop="gw_fqks_name" show-overflow-tooltip></el-table-column>
      <el-table-column label="发起时间" prop="create_dateline" show-overflow-tooltip></el-table-column>
      <el-table-column label="当前步骤" >
        <template slot-scope="scope">
          {{scope.row.gw_bz!='' ? scope.row.gw_bz : '--'}}
        </template>
      </el-table-column>
      <el-table-column label="当前审核人">
        <template slot-scope="scope">
          {{scope.row.gw_shr!='' ? scope.row.gw_shr : '--'}}
        </template>
      </el-table-column>
      <el-table-column label="状态" >
        <template slot-scope="scope">
          <div>{{scope.row.gw_status}}</div>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="200">
        <template slot-scope="scope">
          <el-button type="text" v-if="scope.row.is_check=='0'" @click="handleCheck(scope.row)">审核</el-button>
          <el-button type="text" v-else @click="handleCheck(scope.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <footer class="flex-item-none" style="display: flex; justify-content: flex-end; margin-top: 30px">
      <el-pagination background layout="total,prev, pager, next" :page-size="limit" :total="total"
        :current-page.sync="cur_page" @current-change="handleCurrentChange"></el-pagination>
    </footer>

   
  </div>
</template>

<script>
import { dbfw_list, org_users } from "./itemApi";
import { useUserStore } from "@/stores/user";
const { real_name, dept_ids } = useUserStore();
export default {
  name: "bbtj",
  data() {
    return {
      state_value: "",
      keyword: "",
      type_list: [
        {
          label: '全部',
          value:'0'
        },
        {
          label: '待审核',
          value:'1'
        },
        {
          label: '已审核',
          value:'2'
        }
      ],
      tableData: [],
      type_value: "",
      multipleSelection:[],
      limit: 10,
      total: 0,
      cur_page: 1,
      yearData:[{
          value: '2016',
          label: '2016年'
        }, {
          value: '2017',
          label: '2017年'
        }, {
          value: '2018',
          label: '2018年'
        }, {
          value: '2019',
          label: '2019年'
        }, {
          value: '2020',
          label: '2020年'
        },{
          value: '2021',
          label: '2021年'
        }, {
          value: '2022',
          label: '2022年'
        }, {
          value: '2023',
          label: '2023年'
        }, {
          value: '2024',
          label: '2024年'
        }, {
          value: '2025',
          label: '2025年'
        }, {
          value: '2026',
          label: '2026年'
        }, {
          value: '2027',
          label: '2027年'
        }, {
          value: '2028',
          label: '2028年'
        }, {
          value: '2029',
          label: '2029年'
        }, {
          value: '2030',
          label: '2030年'
        }],
      dialogFormVisible: false,
      showType:[],
      dialogForm: {
        bbmc: '',
        year: '',
        valiType:[]
      },
      rules_check: {
        bbmc: [
          { required: true, message: '请输入报表名称', trigger: 'blur'}
        ],
        year: [
          { required: true, message: '请选择年份', trigger: 'change'}
        ],
        valiType: [
          { type: 'array', required: true, message: '请选择类型', trigger: 'change' }
        ]
      },
      title: "",
      isEdit: false,
      id: "",
      loading: false,
      userList: [],
    };
  },
  mounted() {
    // this.getUserList();
    this.getListData();
  },
  methods: {
    getUserList() {
      let data = {
        dept_id: dept_ids[0],
        page: 1,
        limit: 9999,
      };
      org_users(data).then((res) => {
        if (res.code == 1) {
          this.userList = res.data.page_data;
        }
      });
    },
    //初始化列表数据
    getListData() {
      this.loading = true;
      let transObj = {
        page: this.cur_page,
        limit: this.limit,
        keyword: this.keyword,
        my_check:1,
      };
      dbfw_list(transObj).then((res) => {
        this.loading = false;
        this.tableData = res.data.page_data;
        this.cur_page = Number(res.data.page_now);
        this.total = Number(res.data.total_rows);
      });
    },
    //多选
     handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    //多选框选择
    handleCheckAllChange(val) {
      this.showType = val;
      this.dialogForm.valiType = val;
    },
    editData(item) {
      this.title = "编辑设置";
      this.isEdit = true;
      this.id = item.cbs_id;
      this.dialogForm.gzmc = item.cbs_name;
      this.dialogForm.sqr = item.cbs_sqr;
      this.dialogForm.cjsj = item.cbs_cjsj;
      this.dialogForm.yydx = item.cbs_yydx;
      this.dialogForm.btrqlx = item.cbs_btrqlx;
      this.dialogForm.btgzlx = item.cbs_btgzlx;
      this.dialogForm.zxbtsj = item.cbs_zxbtsj;
      this.dialogForm.btsjje = item.cbs_btsjje;
      this.dialogForm.shr = item.cbs_shr;

      this.dialogFormVisible = true;
    },
    
    delData(id) {
      let data = {
        cbs_id: id,
      };
      this.$confirm("确认删除该设置?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          shsz_del(data).then((res) => {
            if (res.code == 1) {
              this.$message({
                message: "删除成功！",
                type: "success",
              });
              this.getListData();
            } else {
              this.$message({
                message: res.msg,
                type: "error",
              });
            }
          });
        })
        .catch(() => { });
    },
    //翻页
    handleCurrentChange(val) {
      this.cur_page = val;
      this.getListData();
    },
    //待办发文-审核
    handleCheck(item) {
      let chooseID=item.gw_id;
      this.$router.push({ name: "gwglxt_dbfw_sh", params: { id: chooseID } });
    },
    handleDetail(item){
      console.log('111')
    }
  },
};
</script>

<style lang="scss" scoped>
.time-type-list {
  width: 100%;
  border-bottom: 1px solid #f3f3f3;
  margin-bottom: 20px;
  display: flex;

  li {
    position: relative;
    top: 2px;
    cursor: pointer;
    width: 50px;
    font-size: 14px;
    line-height: 30px;
    text-align: center;

    &+li {
      margin-left: 20px;
    }

    &.selected {
      color: #265cd4;
      border-bottom: 2px solid #265cd4;
    }
  }
}
</style>
