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

  <div>

    <data-table
      ref="pagingTable"
      :options="options"
      :list-query="listQuery"
      @multi-actions="handleMultiAction"
    >
      <template slot="filter-content">
        <el-input v-model="listQuery.params.id" style="width: 200px" placeholder="搜索留言编码" class="filter-item"/>
        <el-input v-model="listQuery.params.itemname" 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 slot="data-columns">
<!--        <el-table-column type="selection" width="55"/>-->
        <el-table-column align="center" label="留言编号" prop="id"/>
        <template slot-scope="scope">
          <a style="color: #1890ff" @click="handleUpdate(scope.row)">{{ scope.row.id }}</a>
        </template>

        <el-table-column  align="center" label="留言人昵称" prop="itemname"/>
        <el-table-column  align="center" label="留言内容" prop="text"/>
        <el-table-column align="center" label="发布时间">
          <template slot-scope="scope">
            {{ scope.row.createTime | xmDateFormat }}
          </template>
        </el-table-column>


<!--        <el-table-column align="center" label="操作">
          <template slot-scope="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 :visible.sync="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.itemname"/>
        </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>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleUpCancel">取 消</el-button>
        <el-button type="primary" @click="handleSave">确 认</el-button>
      </div>
    </el-dialog>

  </div>

</template>

<script>
import DataTable from '@/components/DataTable'
import MeetRole from '@/components/MeetRole'
import DepartTreeSelect from '@/components/DepartTreeSelect'
import {dataFormatter} from '@/utils'
import {saveLyOrUpData} from "@/api/sys/liuyangl/liuyangl";


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: '/liuyan/lygl/paging',
        // 删除
        deleteUrl: '/liuyan/lygl/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() {
      saveLyOrUpData(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>
