<template>
  <div class="inwardContractMaterial">
    <div class="top">
      <el-input placeholder="请输入物资名称" clearable></el-input>
      <el-button type="primary" @click="onclick">查询</el-button>
      <el-button type="primary" @click="onInsert">新增</el-button>
    </div>
    <div class="table">
      <dilTable v-bind.sync="option" ref="table"> 
        <el-table-column
           fixed="right"
           label="操作"
           width="200px"
           align="center"
        >
        <template slot-scope="scope">
          <el-button type="primary" @click="updateSomeData(scope.row)">修改</el-button>
          <el-button type="primary" @click="deleteSomeData(scope.row)">删除</el-button>
        </template>
        </el-table-column>
      </dilTable>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      option: {
        requestUrl: "/api/v1/rms/getInwardContractMaterial?apiId=482"
      }
    };
  },
  methods: {
    onInsert() {
      this.$router.push("/addInwardContractMaterial");
    },
    updateSomeData(row){
      this.$router.push({
        name:"editInwardContractMaterial",
        params:{
          materialTypeId:row.materialTypeId,
          materialTypeName:row.materialTypeName
        }
      })
    },
    deleteSomeData(row){
      let mapValue={
        materialTypeId:row.materialTypeId,
        materialTypeName:row.materialTypeName
      }
      this.$confirm("你确定要删除吗","提示",{
        confirmButtonText:"确定",
        cancelButtonText:"取消",
        type:"warning"
      }).then(()=>{
        this.axios.post("/api/v1/rms/deleteMaterialForInward", mapValue)
        .then((res)=>{
          if(res.data.code=='200'){
            this.$message.success("删除成功")
            this.$router.go(0)
          }
        })
      })
      .catch()
    },
  }
};
</script>
<style lang="scss" scoped>
.inwardContractMaterial {
  .top {
    .el-input {
      margin-top: 30px;
      margin-left: 30px;
      width: 250px;
    }
  }
  .table {
    margin-left: 30px;
    margin-top: 30px;
  }
}
</style>
