<template>
  <div class="">
    <!-- <h2>参数设置</h2> -->
    <div>
      <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="10"
            :rules="[
              {
                required: false,
                pattern: /^[1-9][0-9]*$/,
                message: '请输入正确的天数',
              },
            ]"
          >
            缴费状态提前:
            <el-input v-model="form['10']" placeholder="请输入天数">
              <template slot="append">天</template>
            </el-input>
            刷新
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="18">
            用户默认头像地址:
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['18']"
              placeholder="请输入链接地址"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="19">
            学员报名链接地址:
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['19']"
              placeholder="请输入链接地址"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="19">
            平台客服电话:
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['19']"
              placeholder="请输入电话"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item
            prop="23"
            :rules="[
              {
                required: false,
                pattern: /^[1-9][0-9]*$/,
                message: '请输入正确的分钟数',
              },
            ]"
          >
            乐团课结算参考总时长:
            <el-input v-model="form['23']" placeholder="请输入分钟数">
              <template slot="append">分钟</template>
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item
            prop="24"
            :rules="[
              {
                required: false,
                pattern: /^[1-9][0-9]*$/,
                message: '请输入正确的分钟数',
              },
            ]"
          >
            乐团课结算单课时参考时长:
            <el-input v-model="form['24']" placeholder="请输入分钟数">
              <template slot="append">分钟</template>
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item
            prop="25"
            :rules="[
              {
                required: false,
                pattern: /^[1-9][0-9]*$/,
                message: '请输入正确的天数',
              },
            ]"
          >
            退款周期:
            <el-input v-model="form['25']" placeholder="请输入天数">
              <template slot="append">天</template>
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="32">
            接口URL地址:
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['32']"
              placeholder="请输入地址"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="52">
            教师请假数据:
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['52']"
              placeholder="请输入数据"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="53">
            老师陪练报告提交URL:
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['53']"
              placeholder="请输入URL"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="54">
            报告提交URL:
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['54']"
              placeholder="请输入URL"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="58">
            付费陪练课活动截止时间:
            <el-date-picker
              class="marginLR5"
              v-model="form['58']"
              type="datetime"
              format="yyyy-MM-dd HH:mm:ss"
              value-format="yyyy-MM-dd HH:mm:ss"
              placeholder="选择截止时间"
            >
            </el-date-picker>
          </el-form-item>
        </el-row>

        <el-row>
          <el-form-item prop="63">
            付费网管课促销活动开始时间:
            <el-date-picker
              class="marginLR5"
              v-model="form['63']"
              type="datetime"
              format="yyyy-MM-dd HH:mm:ss"
              value-format="yyyy-MM-dd HH:mm:ss"
              placeholder="选择截止时间"
            >
            </el-date-picker>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="62">
            教师端baseURL:
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['62']"
              placeholder="请输入URL"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="64">
            教务端baseURL:
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['64']"
              placeholder="请输入URL"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="66">
            免费网管课可预约截止时间:
            <el-date-picker
              class="marginLR5"
              v-model="form['66']"
              type="datetime"
              format="yyyy-MM-dd HH:mm:ss"
              value-format="yyyy-MM-dd HH:mm:ss"
              placeholder="选择截止时间"
            >
            </el-date-picker>
          </el-form-item>
        </el-row>
        <!-- <el-row>
          <el-form-item
            prop="203"
            :rules="[
              {
                required: false,
                pattern: /^[1-9][0-9]*$/,
                message: '请输入正确的分钟数',
              },
            ]"
          >
            云教室可提前
            <el-input
              v-model="form['203']"
              placeholder="请输入分钟数"

            >
              <template slot="append">分钟</template> </el-input
            >进入教室
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item
            prop="204"
            :rules="[
              {
                required: false,
                pattern: /^[1-9][0-9]*$/,
                message: '请输入正确的分钟数',
              },
            ]"
          >
            云教室课程结束后
            <el-input
              v-model="form['204']"
              placeholder="请输入分钟数"

            >
              <template slot="append">分钟</template> </el-input
            >关闭教室
          </el-form-item>
        </el-row> -->
        <el-row>
          <el-form-item prop="89">
            学员端
            <el-time-picker
              class="marginLR5"
              v-model="form['89']"
              format="HH:mm"
              value-format="HH:mm"
              :picker-options="{
                selectableRange: '00:00:00 - 23:59:59',
              }"
              placeholder="请选择时间"
            >
            </el-time-picker>
          </el-form-item>
          <el-form-item>
            之后的推送延迟到第二天
            <el-time-picker
              class="marginLR5"
              v-model="form['205']"
              format="HH:mm"
              value-format="HH:mm"
              :picker-options="{
                selectableRange: '00:00:00 - 23:59:59',
              }"
              placeholder="请选择时间"
            >
            </el-time-picker>
            发送
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item prop="103">
            乐团满意度调查问卷编号
            <el-input
              style="width: 180px"
              class="marginLR5"
              v-model="form['103']"
              placeholder="请输入问卷编号"
            >
            </el-input>
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item
            prop="74"
            :rules="[
              {
                required: false,
                pattern: /^[1-9][0-9]*$/,
                message: '请输入正确的天数',
              },
            ]"
          >
            乐团缴费开启后
            <el-input v-model="form['74']" placeholder="请输入天数">
              <template slot="append">天</template>
            </el-input>
            向乐团主管发送缴费明细短信
          </el-form-item>
        </el-row>
        <el-row>
          <el-form-item
            prop="240"
            :rules="[
              {
                required: true,
                message: '请输入正确的金额',
                trigger: 'blur',
                pattern: /^(\+)?\d+(\.\d+)?$/,
              },
            ]"
          >
          机构云教室账户余额小于
            <el-input v-model="form['240']" placeholder="请输入金额">
              <template slot="append">元</template>
            </el-input>
            时发送短信和邮件提醒
          </el-form-item>
        </el-row>
      </el-form>
      <!-- 列表 -->
      <!-- <el-row>
        <el-col
          :span="12"
          v-for="(config, index) in configList"
          :key="config.id"
        >
          {{ config.description[0] }}
          <el-input v-model.trim="input[index]" >
            <template slot="append" v-if="config.description[1]">{{
              config.description[1]
            }}</template>
          </el-input>
          <el-button
            @click="onSave(config, index)"
            v-permission="'sysConfig/update/overallManager'"
            type="primary"

            >保存</el-button
          >
        </el-col>
      </el-row> -->
    </div>
    <el-button
      type="primary"
      @click="save"
      class="saveBtn"
      v-permission="'sysConfig/batchUpdate/overallManager'"
      >保存</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>
