<!-- 毕业生信息管理-->
<template>

  <div>

    <data-table
      ref="pagingTable"
      :options="options"
      :list-query="listQuery"
      @multi-actions="handleMultiAction"
    >
      <template #filter-content>
        <el-input v-model="listQuery.params.id" style="width: 200px" placeholder="搜索公告编码" class="filter-item"/>
        <el-input v-model="listQuery.params.title" style="width: 200px" placeholder="搜索公告标题" class="filter-item"/>
        <el-input v-model="listQuery.params.text" style="width: 200px" placeholder="搜索公告内容" class="filter-item" />
        <label>开始时间</label>
        <el-date-picker style="width: 200px" placeholder="开始时间" class="filter-item"
                        v-model="listQuery.params.createTime"
                        type="datetime"
                        format="YYYY-MM-DD"
                        value-format="YYYY-MM-DD"
        ></el-date-picker>
        <label>截至时间</label>
        <el-date-picker style="width: 200px" placeholder="截至时间" class="filter-item"
                        v-model="listQuery.params.updateTime"
                        type="datetime"
                        format="YYYY-MM-DD"
                        value-format="YYYY-MM-DD"
        ></el-date-picker>
<!--        <el-button class="filter-item" type="primary" icon="el-icon-plus" @click="handleAdd">
          添加
        </el-button>-->


      </template>
      <template #data-columns>
<!--        <el-table-column type="selection" width="55"/>-->
        <el-table-column align="center" label="公告编号" prop="id">
          <template #default="scope">
            <a style="color: #1890ff" @click="handleUpdate(scope.row)">{{ scope.row.id }}</a>
          </template>
        </el-table-column>


        <el-table-column  align="center" label="公告标题" prop="title"/>
        <el-table-column  align="center" label="公告内容" prop="text"/>
        <el-table-column align="center" label="发布时间">
          <template #default="scope">
            {{ $filters.xmDateFormat(scope.row.createTime) }}
          </template>
        </el-table-column>


<!--        <el-table-column align="center" label="操作">
          <template #default="scope">
            <a @click="handleUpdate(scope.row)">
              <el-button link type="primary" size="small"
              >编辑公告内容
              </el-button>
            </a>
          </template>
        </el-table-column>-->

      </template>
    </data-table>

    <!--    编辑按钮按下-->
    <el-dialog v-model="dialogVisible" title="编辑公告信息" width="500px">
      <el-form :model="formData" label-position="left" label-width="100px">
        <el-form-item label="公告编号">
          <el-input v-model="formData.id" disabled="disabled"/>
        </el-form-item>
        <el-form-item label="公告标题">
          <el-input v-model="formData.title"/>
        </el-form-item>
        <el-form-item label="公告内容">
          <el-input v-model="formData.text"/>
        </el-form-item>
        <el-form-item label="发布日期">
          <el-date-picker
            v-model="formData.createTime" disabled="disabled"
            type="datetime"
            placeholder="选择日期时间"
            format="YYYY-MM-DD">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="handleUpCancel">取 消</el-button>
          <el-button type="primary" @click="handleSave">确 认</el-button>
        </div>
      </template>
    </el-dialog>

  </div>

</template>

<script>
import DataTable from '@/components/DataTable/index.vue'
import MeetRole from '@/components/MeetRole/index.vue'
import DepartTreeSelect from '@/components/DepartTreeSelect/index.vue'
import {dataFormatter} from '@/utils'
import {saveOrUpData} from "@/api/sys/gggl/gggl.js";


export default {
  name: 'BysxxglList',
  components: {
    DepartTreeSelect,
    DataTable,
    MeetRole
  },

  data() {
    return {

      defaultProps: {
        value: 'value',
        text: 'text',
        label: 'deptName',
        children: 'children'
      },
      qcglData: {},
      dialogVisible: false,// 编辑是否显示

      listQuery: {
        current: 0,
        size: 10,
        total: 0,
        params: {
          banji: '',
          zhuanye: ''
        }
      },

      formData: {
        avatar: ''
      },


      options: {
        //  列表请求URL
        listUrl: '/gonggao/gggl/paging',
        // 删除
        deleteUrl: '/gonggao/gggl/delete',
        //  批量操作列表
        multiActions: [
          {
            value: 'delete',
            label: '删除'
          }
        ]
      }
    }
  },

  //  页面初始化
  created() {

  },

// 方法
  methods: {
    //  格式化字典
    dataFormatter,
    handleAdd() {
      this.formData = {}
      this.dialogVisible = true
    },

    //编辑按钮按下
    handleUpdate(row) {
      this.dialogVisible = true
      this.formData = row
    },

    //取消按钮按下
    handleUpCancel() {
      this.dialogVisible = false;
    },

    departSelected(data) {
      this.formData.id = data.id
      console.log(data + "----depart")
    },
    // 确认按钮按下
    handleSave() {
      saveOrUpData(this.formData).then((response) => {
        this.$message({
          type: 'success',
          message: '保存成功!'
        }, {
          type: 'error',
          message: response.msg
        })
        this.dialogVisible = false
        this.$refs.pagingTable.getList()
        console.log('handlesave')
      })
    },

    //  批量操作监听
    handleMultiAction(obj) {
      if (obj.opt === 'cancel') {
        this.handleCancelOrder(obj.ids)
      }
    }
  }
}
</script>
