import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
import ImageUpload from '@/components/file-upload'
export default {
  data() {
    return {

    }
  },
  computed: {
    productInfo() {
      return [
        {
          name: 'el-input',
          md: 6,
          attributes: { disabled: false, placeholder: '请输入' },
          formItemAttributes: {
            label: '内机条码',
            prop: 'insideCode',
            rules: [...required]
          }
        },
        {
          name: 'el-input',
          md: 6,
          attributes: { disabled: false, placeholder: '请输入' },
          formItemAttributes: {
            label: '发票价格',
            prop: 'invoiceAmount',
            rules: [...required]
          }
        },
        {
          name: 'el-date-picker',
          md: 6,
          attributes: {
            disabled: false,
            style: { width: '100%' },
            placeholder: '请选择',
            type: 'date',
            'value-format': 'yyyy-MM-dd HH:mm:ss',
            // 'picker-options': {
            //   disabledDate: time => {
            //     return time.getTime() < (Date.now() - 86400000)
            //   }
            // }
          },
          formItemAttributes: {
            label: '原保到期',
            prop: 'insureTime',
            rules: [...required]
          },
          events: {
            change: (val) => {
              if (val && this.addFormData.limitNum) {
                const initialDate = new Date(val);
                initialDate.setFullYear(initialDate.getFullYear() + (this.addFormData.limitNum || 0));
                this.addFormData.serviceEndTime = initialDate.toISOString().split('T')[0];
              } else {
                this.addFormData.serviceEndTime = ""
              }
            }
          }
        },
        {
          name: 'el-date-picker',
          md: 6,
          attributes: {
            disabled: true,
            style: { width: '100%' },
            placeholder: '请选择',
            type: 'date',
            'value-format': 'yyyy-MM-dd HH:mm:ss',
            // 'picker-options': {
            //   disabledDate: time => {
            //     return time.getTime() < (Date.now() - 86400000)
            //   }
            // }
          },
          formItemAttributes: {
            label: '服务期限',
            prop: 'serviceEndTime',
            rules: [...required]
          }
        },
        {
          name: 'slot-component',
          md: 3,
          formItemAttributes: {
            label: '',
            'label-width': '0px',
            prop: 'insideCodeImg',
            rules: [...required],
            errLabel: '内机条码'
          },
          render: (h, { props }) => {
            return (
              <div style="padding: 0 10px">
                <ImageUpload fileList={this.addFormData.insideCodeImg} limit={1} isEdit={true} />
                <div style="padding-left:20px">*内机条码</div>
              </div>
            )
          }
        },
        {
          name: 'slot-component',
          md: 3,
          formItemAttributes: {
            label: '',
            'label-width': '0px',
            prop: 'machineImg',
            rules: [...required],
            errLabel: '机器铭牌'
          },
          render: (h, { props }) => {
            return (
              <div style="padding: 0 10px">
                <ImageUpload fileList={this.addFormData.machineImg} limit={1} isEdit={true} />
                <div style="padding-left:20px">*机器铭牌</div>
              </div>
            )
          }
        },
        {
          name: 'slot-component',
          md: 3,
          formItemAttributes: {
            label: '',
            'label-width': '0px',
            prop: 'buyCertImg',
            rules: [...required],
            errLabel: '购机凭证'
          },
          render: (h, { props }) => {
            return (
              <div style="padding: 0 10px">
                <ImageUpload fileList={this.addFormData.buyCertImg} limit={1} isEdit={true} />
                <div style="padding-left:20px">*购机凭证</div>
              </div>
            )
          }
        },
      ]
    }
  },
  methods: {

  }
}
