//公告管理
<template>
  <div class="notice">
    <div class="sache">
      <el-input
        placeholder="请输入内容"
        v-model="textInput"
        clearable>
      </el-input>
      <el-button type="primary" class="btn"  @click="onclick">
        <i class="el-icon-search"></i>查询
      </el-button>
      <el-button type="primary" class="btn" @click="toInsert">
        <i class="el-icon-plus"></i>新增
      </el-button>
    </div>



    <div class="table">
      <dilTable v-bind.sync="options">
        <el-table-column fixed="right" label="操作" width="120" header-align="center">
          <template slot-scope="scope">
            <el-button
              type="text"
              size="small"
              @click="noticeDetail(scope)"
            >
              详情
            </el-button>
            <el-button
              type="text"
              size="small"
              @click="updateNotice(scope)"
            >
              修改
            </el-button>
            <el-button
              type="text"
              size="mini"
              @click="deleteNotice(scope)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </dilTable>
    </div>
  </div>
</template>




<script>
export default {
  name:"homeworkPath",
  data(){
    return{
      textInput: "" ,
      restaurants: [],
      options:{
        // first请求数据的地址
        requestUrl: "/api/v1/ams/getMarketingNoticeList?apiId=414",
      },
    }
  },
  methods:{
    onclick(){
      this.options.requestUrl = "/api/v1/ams/getCarrierNoticeList?apiId=414&con="+this.textInput;
    },



    CarrierNotice() {
      this.$router.push("/addNotice");

    },
    /*新增通知*/
    toInsert() {
      this.$router.push("/addNotice");

    },

    /*通知详情*/

    noticeDetail(scope) {
      console.log(scope.row.noticeId)
      this.$router.push("/getNoticeById/"+scope.row.noticeId)

    },

    /*这里要改一改*/
    updateNotice(scope){
      console.log(scope.row.noticeId)
      this.$router.push("/editNotice/"+scope.row.noticeId)
    },
    deleteNotice(scope){
      console.log(scope)
      this.$confirm("是否删除", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true,
      })
        .then(() => {
          console.log("enter")
          this.axios
            .post("/api/v1/ams/deleteNotice/" + scope.row.noticeId)
            .then((res) => {
              console.log("res.data.code",res.data.code);
              if (res.data.code == 200) {
                this.$message({
                  type: "success",
                  message: "删除成功!",
                });
                this.$router.go(0);
              } else {
                this.$message({
                  message: "删除失败",
                  type: "warning",
                });
              }
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "删除操作已取消!",
          });
        });
    },
  },

}

</script>

<style lang="scss" scode>
.notice{
  .sache{
    padding: 1.25rem 0.375rem;
    .el-input {
      width: 20%;
      margin-right: 1.25rem;
    }
  }
}
</style>
