<template>
  <div class="app-container">
    <!-- <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            @click="handleAllDelete"
            >删除</el-button
          >
        </el-col>
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
        >新增</el-button>
      </el-row> -->
    <el-table ref="tables" v-loading="loading" :data="list">
      <el-table-column
        label="比例名称"
        align="center"
        width="200"
        prop="ratioName"
        :show-overflow-tooltip="true"
      />
        <el-table-column
        label="比例"
        align="center"
        width="200"
        prop="ratio"
        :show-overflow-tooltip="true"
      />
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="shwoEdite(scope.row)"
            >修改比例</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="修改" :visible.sync="editOpen" width="600px" append-to-body>
      <el-form ref="form" :model="editForm" label-width="60px">
    
           <el-row>
          <el-col :span="24">
            <el-form-item label="比例" required>
              <el-input
                v-model="editForm.ratio"
                type="number"
                placeholder="请输入修改比例"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
        <div style="color: red;margin-top: 10px;margin-left: 10px;">请输入0-1之间的数字</div>

      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleEdit">确定修改</el-button>
        <el-button @click="cancelEdit">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { commissionRatio,update } from "@/api/deduct/index";

export default {
  name: "report",
  dicts: ["sys_common_status"],
  data() {
    return {
      open: false,  
      editOpen: false,
      // 遮罩层
      loading: true,
      // 选中数组
      total: 0,
      // 表格数据
      list: [],
      // 日期范围
      // 查询参数
      queryParams: {
        pageNumber: 1,
        pageSize: 10,
        ipaddr: undefined,
        userName: undefined,
        status: undefined,
      },
      editForm:{
        "ratio": "",
         "id": null
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    cancelEdit(){
        this.editOpen = false
        this.editForm.ratio = ''
        this.editForm.id = ''
    },
    handleEdit(){
        update(this.addDateRange(this.editForm)).then((response) => {
          this.$modal.msgSuccess("编辑成功");
          this.getList();
          this.cancelEdit()
        });
    },
    shwoEdite(row){
        this.editOpen = true
        this.editForm.ratio = row.ratio
        this.editForm.id = row.id
    },
  
  
    /** 查询登录日志列表 */
    getList() {
      this.loading = true;
      commissionRatio(this.addDateRange({})).then((response) => {
        this.list = response.data;
        this.loading = false;
      });
    },
  },
};
</script>
