<template>
  <div class="">
    <!-- <h2>参数设置</h2> -->
    <div class="m-core">
      <!-- 列表 -->
      <el-form :inline="true" :model="form" ref="form">
        <el-alert
          style="margin: 10px 0"
          title="收费分润设置"
          :closable="false"
          type="info"
        >
        </el-alert>
        <el-row>
          <el-form-item prop="68">
            默认收款渠道(双乾: YQPAY 汇付: ADAPAY):
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['68']"
              placeholder="请输入渠道"
              size="mini"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="69">
            是否用收费配置(1:使用 0:不使用):
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['69']"
              placeholder="请输入渠道"
              size="mini"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="90">
            延迟分账开始执行时间:
            <el-date-picker
              class="marginLR5"
              v-model="form['90']"
              type="datetime"
              format="yyyy-MM-dd HH:mm:ss"
              value-format="yyyy-MM-dd HH:mm:ss"
              placeholder="选择始执行时间"
              size="mini"
            >
            </el-date-picker>
          </el-form-item>
        </el-row>
      </el-form>
    </div>
    <el-button size="mini" type="primary" @click="save" class="saveBtn"
     v-permission="'sysConfig/batchUpdate/overallManagerTwo'"
      >保存</el-button
    >
  </div>
</template>
<script>
import pagination from "@/components/Pagination/index";
import { sysConfigList, sysConfigUpdate } from "@/api/generalSettings";
export default {
  components: { pagination },
  name: "overallManagerTwo",
  data() {
    return {
      configList: [],
      input: [],
      form: {},
    };
  },
  mounted() {
    this.__init();
  },
  methods: {
    __init() {
      sysConfigList({ group: "DEFAULT" }).then((res) => {
        if (res.code == 200 && res.data.length > 0) {
          res.data.forEach((item) => {
            // this.form[item.paramName] = item.paranValue
            this.$set(this.form, item.id, item.paranValue);
          });
          // this.$forceUpdate()
          console.log(this.form);
        }
      });
    },
    // onSave(row, index) {
    //   let params = {
    //     id: row.id,
    //     paranValue: this.input[index],
    //     paramName: row.paramName,
    //     description: row.description.join("{}"),
    //   };
    //   sysConfigUpdate(params).then((res) => {
    //     if (res.code == 200) {
    //       this.$message.success("修改成功");
    //     }
    //   });
    // },
    async save() {
      this.$refs.form.validate(async (valid) => {
        if (valid) {
          let param = [];
          for (let i in this.form) {
            param.push({
              id: i,
              paranValue: this.form[i],
            });
          }
          try {
            const res = await sysConfigUpdate(param);
            this.$message.success("保存成功");
            this.__init();
          } catch (e) {
            console.log(e);
          }
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
@import "~@scss/views/courseRulersManager/index.scss";
</style>
