<template>
  <div class="adjust-custom">
    <xd-base-field
      ref="adjustcCustom"
      v-if="status && list.length > 0"
      v-model="adjust"
      :list="list"
      label-width="100px"
    >
      <template slot="custom" slot-scope="scope">
        <el-form :label-width="scope.width" :model="customForm" :rules="customRules">
          <el-form-item label="选择影院"></el-form-item>
          <el-form-item label="选择影厅">
            <xd-select-list
              class="input30"
              placeholder="请选择影厅"
              multiple
              :list="null"
              :default-value="[]"
            ></xd-select-list>
          </el-form-item>
        </el-form>
      </template>
    </xd-base-field>
    <div class="adjust-btn">
      <el-button @click="handleClick('adjustCard')" type="primary">提交</el-button>
    </div>
  </div>
</template>

<script>
  import XdBaseField from "@/components/XdBaseField";
  import XdSelectList from "@/components/XdSelectList";

  export default {
    name: "AdjustCustom",
    components: {
      XdSelectList,
      XdBaseField
    },
    data() {
      return {
        adjust: {}, //表单绑定变量
        status: false, //是否初始化完成表单
        list: [], //表单列表
        customForm: {

        },
        customRules: {

        }
      }
    },
    created() {
      this.initForm();
    },
    methods: {
      /**
       * @description 初始化表单
       * @param params
       */
      initForm(...params) {
        let form = [
          {
            label: 'ID:', //label
            ele: 'el-input', //package 名称
            type: 'text',
            valueKey: 'id', //form[valueKey]
            value: '15', //v-model
            disabled: true,
            classNmae: 'input40',
          },
          {
            label: '', //label
            ele: 'slot', //package 名称
            slot: 'custom',
          },
          {
            label: '超过:', //label
            ele: 'xd-over-add-price', //package 名称
            valueKey: {min: 'price_min', list: 'price_type', value: 'price'}, //form[valueKey]
            defaultValue: {min: '', list: 'raise', value: ''}, //默认图片对象
            unit: '元',
            list: [
              {label: "加价", value: "raise"},
              {label: "下调", value: "reduce"},
              {label: "固定值", value: "fixed"}
            ],
            rules: [
              {
                required: true,
                validator(rule, value, callback) {
                  let temp = false;
                  Object.keys(value).map(key => {
                    if (!value[key]) temp = true;
                  });
                  if (temp) callback('请设置规则')
                  else callback();
                },
                message: '请选择日期',
                trigger: 'change'
              }
            ]
          },
          {
            label: '选择礼拜:', //label
            ele: 'xd-select-week-time', //package 名称
            valueKey: {list: 'week_day', start: 'week_start', end: 'week_end'}, //form[valueKey]
            defaultValue: {list: [], start: '', end: ''}, //默认图片对象
            collapse: true,
            list: [
              {label: '日', value: 0},
              {label: "一", value: 1},
              {label: "二", value: 2},
              {label: "三", value: 3},
              {label: "四", value: 4},
              {label: "五", value: 5},
              {label: "六", value: 6}
            ]
          },
          {
            label: '权重:', //label
            ele: 'el-input', //package 名称
            type: 'text',
            valueKey: 'weight', //form[valueKey]
            value: '', //v-model
            classNmae: 'input20',
          },
          {
            label: '状态:', //label
            ele: 'xd-select-status', //package 名称
            valueKey: 'status', //form[valueKey]
            value: 'N', //v-model
            isall: false,
            backValueType: '', //返回值类型 1=>返回（Y,N）2=> [true|false] 3=>[1,0] 4=>[1,2]
            placeholder: '请选择',
            list: 'status', //status=>状态  best=>推荐  associate=>关联 yes=>是否 open=> 是否开启  check=>审核
          },
        ];

        this.list = form;
        this.status = true;
      },

      /**
       * @description 提交数据事件
       */
      handleClick() {
        this.$refs['adjustcCustom'].submit()
          .then(res => {
            this.$emit('onSubmit', this.adjust);
          })
          .catch(res => {
            console.log('no')
          })
      }
    }
  }
</script>

<style scoped lang="scss">
  .adjust-btn {
    margin-left: 100px;
  }

</style>
