<template>
  <div class="page-body">
    <div class="page-search row items-center">
      <div class="col row wrap q-mr-lg q-col-gutter-md">
        <div class="col-3">
          <q-input @change="resetSearch" clearable standout="bg-primary text-white" class="col-6 q-pr-lg q-pr-lg"
            v-model="msg.LinkMan" label="联系人" maxlength="20" @clear="resetSearch" />
        </div>
        <div class="col-3">
          <q-input @change="resetSearch" clearable standout="bg-primary text-white" class="col-6 q-pr-lg q-pr-lg"
            v-model="msg.PositionName" label="职位" maxlength="20" @clear="resetSearch" />
        </div>
      </div>
    </div>
    <div class="page-content">
      <q-table :pagination="msg" :loading="loading" no-data-label="暂无相关数据" flat class="sticky-column-table"
        separator="none" :data="data" :columns="columns" row-key="name">
        <template v-slot:top="props">
          <div class="col-2 q-table__title">招聘申请信息</div>
        </template>
        <template v-slot:body-cell-ApplyStatus="props">
          <q-td>
            <span v-if="props.row.ApplyStatus==0" style="color:#E6A23C;">待处理</span>
            <span v-if="props.row.ApplyStatus==1" style="color:#67C23A;">已联系</span>
            <span v-if="props.row.ApplyStatus==2" style="color:#e95252;">不合适</span>
          </q-td>
        </template>
        <template v-slot:bottom>
          <q-pagination class="full-width justify-end" v-model="msg.pageIndex" color="primary" :max="pageCount"
            :input="true" @input="changePage" />
        </template>
        <template v-slot:body-cell-optioned="props">
          <q-td :props="props">
            <q-btn flat size="xs" icon="edit" color="accent" style="font-weight:400" label="编辑"
              @click="EditJob(props.row)" />
            <q-btn flat size="xs" icon="delete" color="negative" style="font-weight:400" label="删除"
              @click="delJob(props.row)" />
          </q-td>
        </template>
      </q-table>
      <jobapply-form v-if="isShowApplyForm" :save-obj="jobapplyObjOption" @close="closejobapply" @success="refreshPage">
      </jobapply-form>
    </div>
  </div>
</template>
<script>
  import {
    GetWebJobApplyPage,
    RemoveWebJobApplyStatus
  } from '../../api/system/webkit'
  import jobapplyForm from '../../components/system/jobapply-form'
  export default {
    meta: {
      title: "招聘信息管理"
    },
    components: {
      jobapplyForm
    },
    data() {
      return {
        columns: [{
          name: 'PositionName',
          label: '申请职位',
          field: 'PositionName',
          align: 'left'
        },{
          name: 'LinkMan',
          label: '联系人',
          field: 'LinkMan',
          align: 'left'
        }, {
          name: 'LinkTel',
          label: '联系电话',
          field: 'LinkTel',
          align: 'left'
        },{
          name: 'Remark',
          label: '备注',
          field: 'Remark',
          align: 'left'
        },{
          name: 'ApplyStatus',
          label: '处理状态',
          field: 'ApplyStatus',
          align: 'left'
        },{
          name: 'optioned',
          label: '操作',
          field: 'MenuId'
        }],
        data: [],
        loading: true,
        msg: {
          pageIndex: 1,
          pageSize: 12,
          rowsPerPage: 12,
          LinkMan: '',
          PositionName: ''
        },
        pageCount: 0,
        isShowApplyForm: false,
        jobapplyObjOption: null,
      }
    },
    mounted() {
      this.getList()
    },
    methods: {
      //重新查询
      resetSearch() {
        this.msg.pageIndex = 1;
        this.getList();
      },
      //翻页
      changePage(val) {
        this.msg.pageIndex = val;
        this.getList()
      },
      //获取菜单分页列表
      getList() {
        this.loading = true;
        GetWebJobApplyPage(this.msg).then(res => {
          this.loading = false
          this.data = res.Data.PageData;
          this.pageCount = res.Data.PageCount;
        }).catch(() => {
          this.loading = false
        })
      },
      //刷新页面
      refreshPage() {
        if (!this.jobapplyObjOption) {
          this.msg.pageIndex = 1;
          this.msg.TypeName = "";
        }
        this.getList()
      },
      //新增修改菜单
      EditJob(obj) {
        if (obj) {
          this.jobapplyObjOption = obj
        } else {
          this.jobapplyObjOption = null
        }
        this.isShowApplyForm = true
      },
      //关闭弹窗
      closejobapply() {
        this.isShowApplyForm = false
      },
      //删除
      delJob(obj) {
        this.$q.dialog({
          title: '提示信息',
          message: '是否确定删除？',
          cancel: true,
          persistent: true,
          ok: "确定",
          cancel: "取消",
        }).onOk(() => {
          let delMsg = {
            Id: obj.Id,
            Status: 1
          }
          RemoveWebJobApplyStatus(delMsg).then(res => {
            if (res.Code == 1) {
              this.$q.notify({
                icon: 'iconfont icon-chenggong',
                color: 'accent',
                timeout: 2000,
                message: '操作成功',
                position: 'top'
              })
              this.getList();
            }
          })
        })
      }
    }
  }

</script>
<style lang="sass">
  @import url('~assets/css/table.sass')

</style>
