<template>
  <div class="demo-tabs-style right_con">
    <div v-if="adminRole_type==='list'">
      <p class="title_summny" style="left:180px">说明：为不同权限的账号录入薪资标准，系统在出账日期自动计算工资</p>
      <Tabs type="card" v-model="adminRole_type">
        <TabPane label="薪资设置" name="list">
          <Table :columns="adminSalaryData" :data="adminSalaryList" class="clear" border></Table>
          <div class="page_summary mar_T_20">
            说明：
            <br>1、按照不同角色权限设置对应的薪资标准，默认为0.00
            <br>2、每月出账日期：如设置10号，则每月10号0：00点后自动计算每个账号的上月工资
            <!-- <br>3、元老业绩奖金入职N月后则可享受，不同角色根据设置的月份来分别计算。 -->
          </div>
        </TabPane>
      </Tabs>
    </div>
    <div v-if="adminRole_type==='edit'">
      <editAdminSalary :role_name="role_name" :role_id="role_id" @return_last="return_last"></editAdminSalary>
    </div>
  </div>
</template>
<script>
import editAdminSalary from "@@/user/edit_adminSalary";
import { mapState } from "vuex";
export default {
  name: "admin_salary",
  components: { editAdminSalary },
  data() {
    return {
      adminRole_type: "list",
      role_name: "",
      role_id: null,
      curIndex: null,
      otherindex: null,
      ratioIndex: null,
      bindRatioIndex: null,
      elderBonusIndex: null,
      beforechangeval: "",
      changeval: "",
      change_btn: {
        is_elder_max: false,
        is_elder_bonus: false,
        is_base_wage: false,
        is_ratio: false,
        is_ratio_max: false,
        is_ratio_ratio: false,
        is_bindratio_max: false,
        is_bindratio_ratio: false,
        is_bind_ratio: false,
        is_spread_min: false,
        is_spread_deduct: false,
        is_spread_reward: false,
        is_spread_max_reward: false,
        is_full_reward: false,
        is_room: false,
        is_food: false,
        is_overtime_pay: false,
        is_statement_date: false,
        is_other: false,
        is_grow_wage: false
      },
      adminSalaryData: [
        {
          title: "角色权限",
          width: 75,
          key: "role_name"
        },
        {
          title: "基本工资",
          width: 75,
          render: (h, params) => {
            if (
              this.change_btn.is_base_wage &&
              params.index === this.curIndex
            ) {
              return h("Input", {
                props: {
                  type: "text",
                  value: this.changeval,
                  autofocus: "autofocus"
                },
                style: { width: "50px", margin: "0px 5px" },
                class: "is_show_input",
                on: {
                  input: value => {
                    this.changeval = value;
                  },
                  "on-blur": () => {
                    this.saveAdminSalaryInfo("is_base_wage", params);
                  },
                  "on-keyup": () => {
                    this.clearNoNum();
                  }
                }
              });
            } else {
              return h(
                "span",
                {
                  class:  "a_text",
                  on: {
                    click: () => {
                      this.whichchange_btn("is_base_wage");
                      this.curIndex = params.index;
                      // this.changeval =(params.row.base_wage / 100).toFixed(2);
                      // this.beforechangeval = (params.row.base_wage / 100).toFixed(2);
                       this.changeval =(params.row.base_wage / 100).toFixed(2);
                      this.beforechangeval = (params.row.base_wage / 100).toFixed(2);
                    }
                  }
                },
                //params.row.base_wage / 100
                (params.row.base_wage / 100).toFixed(2)
              );
            }
          }
        },
        {
          title: "成长基金",
          width: 75,
          render: (h, params) => {
            if (
              this.change_btn.is_grow_wage &&
              params.index === this.curIndex
            ) {
              return h("div", [
                h("Input", {
                  props: {
                    type: "text",
                    value: this.changeval,
                    autofocus: "autofocus"
                  },
                  style: { width: "50px", margin: "0px 5px" },
                  class: "is_show_input",
                  on: {
                    input: value => {
                      this.changeval = value;
                    },
                    "on-blur": () => {
                      this.saveAdminSalaryInfo("is_grow_wage", params);
                    },
                    "on-keyup": () => {
                      this.clearNoNum();
                    }
                  }
                })
              ]);
            } else {
              return h("div", [
                h(
                  "span",
                  {
                    class: "a_text",
                    on: {
                      click: () => {
                        this.whichchange_btn("is_grow_wage");
                        this.curIndex = params.index;
                        this.changeval = (Number(params.row.grow_wage) / 100).toFixed(2);
                        this.beforechangeval =
                         ( Number(params.row.grow_wage) / 100).toFixed(2);
                      }
                    }
                  },
                  (Number(params.row.grow_wage) / 100).toFixed(2)
                )
              ]);
            }
          }
        },
        {
          title: "流水提成比例",
          width: 210,
          render: (h, params) => {
            let ratio = params.row.ratio;
            if (!!!ratio.length) {
              return h("span", "");
            } else {
              if (ratio.length === 1 && ratio[0].max == 0) {
                if (
                  this.change_btn.is_ratio &&
                  params.index === this.curIndex
                ) {
                  return h("div", [
                    h("Input", {
                      props: {
                        type: "text",
                        value: this.changeval,
                        autofocus: "autofocus"
                      },
                      style: { width: "50px", margin: "0px 5px" },
                      class: "is_show_input",
                      on: {
                        input: value => {
                          this.changeval = value;
                        },
                        "on-blur": () => {
                          ratio[0].ratio = this.changeval;
                          this.saveAdminSalaryInfo("is_ratio", params, ratio);
                        },
                        "on-keyup": () => {
                          this.clearNoNum();
                        }
                      }
                    }),
                    h("span", " % ")
                  ]);
                } else {
                  return h("div", [
                    h(
                      "span",
                      {
                        class:  "a_text",
                        on: {
                          click: () => {
                            this.whichchange_btn("is_ratio");
                            this.curIndex = params.index;
                            this.changeval = ratio[0].ratio;
                            this.beforechangeval = ratio[0].ratio;
                          }
                        }
                      },
                      ratio[0].ratio || 0
                    ),
                    h("span", " % ")
                  ]);
                }
              } else {
                return h("div", [
                  h(
                    "div",
                    ratio.map((item, index) => {
                      if (
                        this.change_btn.is_ratio_max &&
                        params.index === this.curIndex &&
                        index === this.ratioIndex
                      ) {
                        return h("div", [
                          h("Input", {
                            props: {
                              type: "text",
                              value: this.changeval,
                              autofocus: "autofocus"
                            },
                            style: { width: "50px", margin: "0px 5px" },
                            class: "is_show_input",
                            on: {
                              input: value => {
                                this.changeval = value;
                              },
                              "on-blur": () => {
                                !!ratio.length
                                  ? ratio.forEach((item, index) => {
                                      item.max = item.max / 100;
                                    })
                                  : "";
                                let obj = ratio;
                                obj[this.ratioIndex].max = this.changeval;
                                this.saveAdminSalaryInfo(
                                  "is_ratio_max",
                                  params,
                                  obj
                                );
                              },
                              "on-keyup": () => {
                                this.clearNoNum();
                              }
                            }
                          }),
                          h("span", "元以上，提成"),
                          h(
                            "span",
                            {
                              class:"a_text",
                              style: { width: "50px", margin: "0px 5px" },
                              on: {
                                click: () => {
                                  this.whichchange_btn("is_ratio_ratio");
                                  this.ratioIndex = index;
                                  this.curIndex = params.index;
                                  this.changeval = ratio[index].ratio;
                                  this.beforechangeval = ratio[index].ratio;
                                }
                              }
                            },
                            item.ratio
                          ),
                          h("span", "%")
                        ]);
                      } else if (
                        this.change_btn.is_ratio_ratio &&
                        params.index === this.curIndex &&
                        index === this.ratioIndex
                      ) {
                        return h("div", [
                          h(
                            "span",
                            {
                              class:  "a_text",
                              style: { width: "50px", margin: "0px 5px" },
                              on: {
                                click: () => {
                                  this.whichchange_btn("is_ratio_max");
                                  this.ratioIndex = index;
                                  this.curIndex = params.index;
                                  this.changeval =
                                   this.translateMoneyData(Number(ratio[index].max) / 100) ;
                                  this.beforechangeval =
                                    this.translateMoneyData(Number(ratio[index].max) / 100);
                                }
                              }
                            },
                            this.translateMoneyData(item.max / 100)
                          ),
                          h("span", "元以上，提成"),
                          h("Input", {
                            props: {
                              type: "text",
                              value: this.changeval,
                              autofocus: "autofocus"
                            },
                            style: { width: "50px", margin: "0px 5px" },
                            class: "is_show_input",
                            on: {
                              input: value => {
                                this.changeval = value;
                              },
                              "on-blur": () => {
                                !!ratio.length
                                  ? ratio.forEach((item, index) => {
                                      item.max = item.max / 100;
                                    })
                                  : "";
                                let obj = ratio;
                                obj[this.ratioIndex].ratio = this.changeval;
                                this.saveAdminSalaryInfo(
                                  "is_ratio_ratio",
                                  params,
                                  obj
                                );
                              },
                              "on-keyup": () => {
                                this.clearNoNum();
                              }
                            }
                          }),
                          h("span", "%")
                        ]);
                      } else {
                        return h("div", [
                          h(
                            "span",
                            {
                              class:  "a_text",
                              style: { width: "50px", margin: "0px 5px" },
                              on: {
                                click: () => {
                                  this.whichchange_btn("is_ratio_max");
                                  this.ratioIndex = index;
                                  this.curIndex = params.index;
                                  this.changeval =
                                    this.translateMoneyData(Number(ratio[index].max) / 100);
                                  this.beforechangeval =
                                    this.translateMoneyData(Number(ratio[index].max) / 100);
                                }
                              }
                            },
                            this.translateMoneyData(item.max / 100)
                          ),
                          h("span", "元以上，提成"),
                          h(
                            "span",
                            {
                              class:  "a_text",
                              style: { width: "50px", margin: "0px 5px" },
                              on: {
                                click: () => {
                                  this.whichchange_btn("is_ratio_ratio");
                                  this.ratioIndex = index;
                                  this.curIndex = params.index;
                                  this.changeval = ratio[index].ratio;
                                  this.beforechangeval = ratio[index].ratio;
                                }
                              }
                            },
                            item.ratio
                          ),
                          h("span", "%")
                        ]);
                      }
                    })
                  )
                ]);
              }
            }
          }
        },
        {
          title: "元老业绩奖金",
          width: 160,
          render: (h, params) => {
            let elderBonus = params.row.elder_bonus;
            if (!!!elderBonus.length) {
              return h("span", "");
            }
            return h("div", [
              h(
                "div",
                elderBonus.map((item, index) => {
                  if (
                    this.change_btn.is_elder_max &&
                    params.index === this.curIndex &&
                    index === this.elderBonusIndex
                  ) {
                    return h("div", [
                      h("Input", {
                        props: {
                          type: "text",
                          value: this.changeval,
                          autofocus: "autofocus"
                        },
                        style: { width: "50px", margin: "0px 5px" },
                        class: "is_show_input",
                        on: {
                          input: value => {
                            this.changeval = value;
                          },
                          "on-blur": () => {
                            let obj = elderBonus;
                            !!obj.length
                              ? obj.forEach((it, ix) => {
                                  it.max = it.max / 100;
                                  it.bonus = it.bonus / 100;
                                })
                              : "";
                            obj[this.elderBonusIndex].max = this.changeval;
                            this.saveAdminSalaryInfo(
                              "is_elder_max",
                              params,
                              obj
                            );
                          },
                          "on-keyup": () => {
                            this.clearNoNum();
                          }
                        }
                      }),
                      h("span", "以上，奖励"),
                      h(
                        "span",
                        {
                          class: "a_text",
                          style: { width: "50px", margin: "0px 5px" },
                          on: {
                            click: () => {
                              this.whichchange_btn("is_elder_bonus");
                              this.elderBonusIndex = index;
                              this.curIndex = params.index;
                              this.changeval = this.translateMoneyData(elderBonus[index].bonus / 100);
                              this.beforechangeval =
                                this.translateMoneyData(elderBonus[index].bonus / 100);
                            }
                          }
                        },
                        this.translateMoneyData(item.bonus / 100)
                      ),
                      h("span", "元")
                    ]);
                  } else if (
                    this.change_btn.is_elder_bonus &&
                    params.index === this.curIndex &&
                    index === this.elderBonusIndex
                  ) {
                    return h("div", [
                      h(
                        "span",
                        {
                          class:  "a_text",
                          style: { width: "50px", margin: "0px 5px" },
                          on: {
                            click: () => {
                              this.whichchange_btn("is_elder_max");
                              this.elderBonusIndex = index;
                              this.curIndex = params.index;
                              this.changeval =
                                this.translateMoneyData(Number(elderBonus[index].max) / 100);
                              this.beforechangeval =
                                this.translateMoneyData(Number(elderBonus[index].max) / 100);
                            }
                          }
                        },
                        this.this.translateMoneyData(item.max / 100)
                      ),
                      h("span", "以上，奖励"),
                      h("Input", {
                        props: {
                          type: "text",
                          value: this.changeval,
                          autofocus: "autofocus"
                        },
                        style: { width: "50px", margin: "0px 5px" },
                        class: "is_show_input",
                        on: {
                          input: value => {
                            this.changeval = value;
                          },
                          "on-blur": () => {
                            let obj = elderBonus;
                            !!obj.length
                              ? obj.forEach((it, ix) => {
                                  it.max = it.max / 100;
                                  it.bonus = it.bonus / 100;
                                })
                              : "";
                            obj[this.elderBonusIndex].bonus = this.changeval;
                            this.saveAdminSalaryInfo(
                              "is_elder_bonus",
                              params,
                              obj
                            );
                          },
                          "on-keyup": () => {
                            this.clearNoNum();
                          }
                        }
                      }),
                      h("span", "元")
                    ]);
                  } else {
                    return h("div", [
                      h(
                        "span",
                        {
                          class:  "a_text",
                          style: { width: "50px", margin: "0px 5px" },
                          on: {
                            click: () => {
                              this.whichchange_btn("is_elder_max");
                              this.elderBonusIndex = index;
                              this.curIndex = params.index;
                              this.changeval =
                               this.translateMoneyData(Number(elderBonus[index].max) / 100) ;
                              this.beforechangeval =
                               this.translateMoneyData(Number(elderBonus[index].max) / 100) ;
                            }
                          }
                        },
                        this.translateMoneyData(item.max / 100)
                      ),
                      h("span", "以上，奖励"),
                      h(
                        "span",
                        {
                          class: "a_text",
                          style: { width: "50px", margin: "0px 5px" },
                          on: {
                            click: () => {
                              this.whichchange_btn("is_elder_bonus");
                              this.elderBonusIndex = index;
                              this.curIndex = params.index;
                              this.changeval =
                                this.translateMoneyData(Number(elderBonus[index].bonus) / 100);
                              this.beforechangeval =
                                this.translateMoneyData(Number(elderBonus[index].bonus) / 100);
                            }
                          }
                        },
                        this.translateMoneyData(item.bonus / 100)
                      ),
                      h("span", "元")
                    ]);
                  }
                })
              )
            ]);
          }
        },
        {
          title: "全勤奖/￥",
          width: 85,
          render: (h, params) => {
            if (
              this.change_btn.is_full_reward &&
              params.index === this.curIndex
            ) {
              return h("Input", {
                props: {
                  type: "text",
                  value: this.changeval,
                  autofocus: "autofocus"
                },
                style: { width: "50px", margin: "0px 5px" },
                class: "is_show_input",
                on: {
                  input: value => {
                    this.changeval = value;
                  },
                  "on-blur": () => {
                    this.saveAdminSalaryInfo("is_full_reward", params);
                  },
                  "on-keyup": () => {
                    this.clearNoNum();
                  }
                }
              });
            } else {
              return h("div", [
                h(
                  "span",
                  {
                    class: "a_text",
                    on: {
                      click: () => {
                        this.whichchange_btn("is_full_reward");
                        this.curIndex = params.index;
                        this.changeval = (params.row.full_reward / 100).toFixed(2);
                        this.beforechangeval = (params.row.full_reward / 100).toFixed(2);
                      }
                    }
                  },
                  (params.row.full_reward / 100).toFixed(2)
                )
              ]);
            }
          }
        },
        {
          title: "加班费/￥",
          width: 85,
          render: (h, params) => {
            if (
              this.change_btn.is_overtime_pay &&
              params.index === this.curIndex
            ) {
              return h("Input", {
                props: {
                  type: "text",
                  value: this.changeval,
                  autofocus: "autofocus"
                },
                style: { width: "50px", margin: "0px 5px" },
                class: "is_show_input",
                on: {
                  input: value => {
                    this.changeval = value;
                  },
                  "on-blur": () => {
                    this.saveAdminSalaryInfo("is_overtime_pay", params);
                  },
                  "on-keyup": () => {
                    this.clearNoNum();
                  }
                }
              });
            } else {
              return h("div", [
                h(
                  "span",
                  {
                    class:  "a_text",
                    on: {
                      click: () => {
                        this.whichchange_btn("is_overtime_pay");
                        this.curIndex = params.index;
                        this.changeval = (params.row.overtime_pay / 100).toFixed(2);
                        this.beforechangeval = (params.row.overtime_pay / 100).toFixed(2);
                      }
                    }
                  },
                  (params.row.overtime_pay / 100).toFixed(2)
                )
              ]);
            }
          }
        },
        {
          title: "住宿费/￥",
          width: 85,
          render: (h, params) => {
            if (this.change_btn.is_room && params.index === this.curIndex) {
              return h("Input", {
                props: {
                  type: "text",
                  value: this.changeval,
                  autofocus: "autofocus"
                },
                style: { width: "50px", margin: "0px 5px" },
                class: "is_show_input",
                on: {
                  input: value => {
                    this.changeval = value;
                  },
                  "on-blur": () => {
                    this.saveAdminSalaryInfo("is_room", params);
                  },
                  "on-keyup": () => {
                    this.clearNoNum();
                  }
                }
              });
            } else {
              return h("div", [
                h(
                  "span",
                  {
                    class:  "a_text",
                    on: {
                      click: () => {
                        this.whichchange_btn("is_room");
                        this.curIndex = params.index;
                        this.changeval = this.translateMoneyData(params.row.room / 100);
                        this.beforechangeval = this.translateMoneyData(params.row.room / 100);
                      }
                    }
                  },
                  this.translateMoneyData(params.row.room / 100)
                )
              ]);
            }
          }
        },
        {
          title: "餐费/￥",
          width: 85,
          render: (h, params) => {
            if (this.change_btn.is_food && params.index === this.curIndex) {
              return h("Input", {
                props: {
                  type: "text",
                  value: this.changeval,
                  autofocus: "autofocus"
                },
                style: { width: "50px", margin: "0px 5px" },
                class: "is_show_input",
                on: {
                  input: value => {
                    this.changeval = value;
                  },
                  "on-blur": () => {
                    this.saveAdminSalaryInfo("is_food", params);
                  },
                  "on-keyup": () => {
                    this.clearNoNum();
                  }
                }
              });
            } else {
              return h("div", [
                h(
                  "span",
                  {
                    class: "a_text",
                    on: {
                      click: () => {
                        this.whichchange_btn("is_food");
                        this.curIndex = params.index;
                        this.changeval = this.translateMoneyData(params.row.food / 100);
                        this.beforechangeval = this.translateMoneyData(params.row.food / 100);
                      }
                    }
                  },
                  this.translateMoneyData(params.row.food / 100)
                )
              ]);
            }
          }
        },
        {
          title: "出账日期",
          key: "statement_date",
          width: 95,
          render: (h, params) => {
            if (
              this.change_btn.is_statement_date &&
              params.index === this.curIndex
            ) {
              return h("div", [
                h("Input", {
                  props: {
                    type: "text",
                    value: this.changeval,
                    autofocus: "autofocus",
                    maxlength: "2"
                  },
                  style: { width: "50px", margin: "0px 5px" },
                  class: "is_show_input",
                  on: {
                    input: value => {
                      this.changeval = value;
                    },
                    "on-blur": () => {
                      if (this.changeval < 1 || this.changeval > 31) {
                        this.$Message.info("请输入正确的日期");
                        this.change_btn.is_statement_date = false;
                        return false;
                      }
                      this.saveAdminSalaryInfo("is_statement_date", params);
                    },
                    "on-keyup": () => {
                      this.clearNoNum();
                    }
                  }
                }),
                h("span", "号")
              ]);
            } else {
              return h("div", [
                h(
                  "p",
                  {
                    class: "a_text",
                    style: { width: "30px", float: "left" },
                    on: {
                      click: () => {
                        this.whichchange_btn("is_statement_date");
                        this.curIndex = params.index;
                        this.changeval = params.row.statement_date;
                        this.beforechangeval = params.row.statement_date;
                      }
                    }
                  },
                 params.row.statement_date
                ),
                h("p", "号")
              ]);
            }
          }
        },
        {
          title: "其他",
          width: 130,
          render: (h, params) => {
            if (params.row.other) {
              let otherlist = params.row.other;
              if (otherlist) {
                return h("div", [
                  h(
                    "div",
                    otherlist.map((item, index) => {
                      if (
                        this.change_btn.is_other &&
                        params.index === this.curIndex &&
                        index === this.otherindex
                      ) {
                        return h("div", [
                          h("span", item.title),
                          h("Input", {
                            props: {
                              type: "text",
                              value: this.changeval,
                              autofocus: "autofocus"
                            },
                            style: { width: "50px", margin: "0px 5px" },
                            class: "is_show_input",
                            on: {
                              input: value => {
                                this.changeval = value;
                              },
                              "on-blur": () => {
                                otherlist.forEach((item, index) => {
                                  item.price = item.price / 100;
                                });
                                let obj = {
                                  other: otherlist,
                                  index: this.otherindex
                                };
                                this.saveAdminSalaryInfo(
                                  "is_other",
                                  params,
                                  obj
                                );
                              },
                              "on-keyup": () => {
                                this.clearNoNum();
                              }
                            }
                          }),
                          h("span", "元")
                        ]);
                      } else {
                        return h("div", [
                          h("span", item.title),
                          h(
                            "span",
                            {
                              class:  "a_text",
                              style: { width: "50px", margin: "0px 5px" },
                              on: {
                                click: () => {
                                  this.whichchange_btn("is_other");
                                  this.otherindex = index;
                                  this.curIndex = params.index;
                                  this.changeval = this.translateMoneyData(otherlist[index].price / 100);
                                  this.beforechangeval =
                                    this.translateMoneyData(otherlist[index].price / 100);
                                }
                              }
                            },
                           this.translateMoneyData(item.price / 100) 
                          ),
                          h("span", "元")
                        ]);
                      }
                    })
                  )
                ]);
              }
            } else {
              return h("span", "");
            }
          }
        },
        {
          title: "最后编辑时间",
          width: 170,
          key: "update_time"
        },
        {
          title: "操作",
          minWidth:83,
          render: (h, params) => {
              return h(
                "span",
                {
                  style: {
                    color: "rgb(0, 156, 255)"
                  },
                  class: "operate-btn",
                  on: {
                    click: () => {
                      this.editsalary(params.row, params.index);
                    }
                  }
                },
                "编辑"
              );
          }
        }
      ],
      adminSalaryList: []
    };
  },
  computed: {
    ...mapState({
      role: state => state.adminInfo.role_id
    }),
    ruzhitime(){
      let arr=null
      this.adminSalaryList.forEach((item,index)=>{
        if(item.role_id==this.role){
          arr = item.elder_time
        }
      })
      return arr
    }
  },
  methods: {
    // input验证
    clearNoNum(isint) {
      if(!!!isint){
        this.changeval = this.changeval.replace(/[^\d.]/g, "");
        this.changeval = this.changeval.replace(/^\./g, "");
        this.changeval = this.changeval.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
        this.changeval = this.changeval.replace(/^(\-)*(\d+)\.(\d\d).*$/,"$1$2.$3");
      }else{
        this.changeval = this.changeval.replace(/[^\d]/g, "");
      }
    },
    // 获取列表数据
    getSalarylist() {
      this.$store.commit("changeloading", true);
      this.$api.getCustomSalary().then(data => {
        if (data.data) {
          this.adminSalaryList = data.data;
          this.$store.commit("changeloading", false);
        } else {
          this.$Message.error(data.msg);
          this.$store.commit("changeloading", false);
        }
      });
    },
    // 控制input显示隐藏
    whichchange_btn(btn) {
      for (let i in this.change_btn) {
        if (i.toString() === btn.toString()) {
          this.change_btn[i] = true;
        } else {
          this.change_btn[i] = false;
        }
      }
      setTimeout(() => {
        document
          .getElementsByClassName("is_show_input")[0]
          .getElementsByTagName("input")[0]
          .focus();
      }, 10);
    },
    // 列表单列修改数据
    saveAdminSalaryInfo(btnname, param, obj) {
      if (this.beforechangeval == this.changeval || this.changeval == "") {
        for (let i in this.change_btn) {
          if (i.toString() === btnname.toString()) {
            this.change_btn[i] = false;
          }
        }
        this.getSalarylist();
        return false;
      }

      let info = param.row;
      let otherInfo;
      let spreadInfo;
      let ratioInfo;
      let elderBonus;
      let bindRatioInfo;
      if ( btnname == "is_other" && obj ) {
        otherInfo = obj.other;
        otherInfo[obj.index].price = Number(this.changeval);
      }
      if ( ( btnname == "is_ratio" || btnname == "is_ratio_max" || btnname == "is_ratio_ratio") && obj ) {
        ratioInfo = obj;
      }
      if ((btnname == "is_elder_max" || btnname == "is_elder_bonus") && obj) {
        elderBonus = obj;
      }
      if ( ( btnname == "is_bind_ratio" || btnname == "is_bindratio_max" || btnname == "is_bindratio_ratio") && obj ) {
        bindRatioInfo = obj;
      }
      if ( ( btnname == "is_spread_min" || btnname == "is_spread_deduct" || btnname == "is_spread_reward" || btnname == "is_spread_max_reward") && obj ) {
        spreadInfo = obj;
      }
      let params = {};
      switch (btnname) {
        case "is_base_wage":
          params = {
            role_id: info.role_id,
            base_wage: Number(this.changeval)
          };
          break;
        case "is_full_reward":
          params = {
            role_id: info.role_id,
            full_reward: Number(this.changeval)
          };
          break;
        case "is_room":
          params = {
           role_id: info.role_id,
            room: Number(this.changeval)
          };
          break;
        case "is_grow_wage":
          params = {
            role_id: info.role_id,
            grow_wage: Number(this.changeval)
          };
          break;
        case "is_food":
          params = {
            role_id: info.role_id,
            food: Number(this.changeval)
          };
          break;
        case "is_overtime_pay":
          params = {
            role_id: info.role_id,
            overtime_pay: Number(this.changeval)
          };
          break;
        case "is_statement_date":
          params = {
            role_id: info.role_id,
            statement_date: Number(this.changeval)
          };
          break;
        case "is_other":
          params = {
            role_id: info.role_id,
            other: otherInfo
          };
          break;
        case "is_ratio":
        case "is_ratio_max":
        case "is_ratio_ratio":
          params = {
            role_id: info.role_id,
            ratio: ratioInfo
          };
          break;
        case "is_bind_ratio":
        case "is_bindratio_max":
        case "is_bindratio_ratio":
          params = {
            role_id: info.role_id,
            bind_ratio: bindRatioInfo
          };
          break;
        case "is_spread_min":
        case "is_spread_deduct":
        case "is_spread_reward":
        case "is_spread_max_reward":
          params = {
            role_id: info.role_id,
            spread: spreadInfo
          };
          break;
        case "is_elder_max":
        case "is_elder_bonus":
          params = {
            role_id: info.role_id,
            elder_bonus: elderBonus
          };
          break;
      }
      this.$api.editListCustomSalaryInfo({ ...params }).then(data => {
        if (data.code === 200) {
          for (let i in this.change_btn) {
            if (i.toString() === btnname.toString()) {
              this.change_btn[i] = false;
            }
          }
          this.getSalarylist();
          this.$Message.info(data.msg);
        } else {
          this.$Message.info(data.msg);
          this.getSalarylist();
        }
      });
    },
    // 编辑按钮
    editsalary(data, index) {
      this.role_name = data.role_name;
      this.role_id = data.role_id;
      this.adminRole_type = "edit";
    },
    // 返回列表页
    return_last() {
      this.adminRole_type = "list";
      this.getSalarylist();
    },
    translateMoneyData(e) {
      e = e.toFixed(2)
      return e
    }
  },
  created() {
    this.getSalarylist();
  }
};
</script>
<style>
.salary_text {
  font-size: 12px;
  position: relative;
  top: -48px;
  left: 120px;
}
.people_num .ivu-input-group {
  margin: 0px 7px;
}
.ivu-input-group-append {
  background-color: #fff;
}
.no_right_border .ivu-input {
  border-right: 0px;
}
#edit-adminsalary-form {
  margin-top: 20px;
}
#edit-adminsalary-form .ivu-input:focus,
.ivu-input:hover {
  border-color: #dddee1 !important;
}
</style>



