<template>
  <div>
    <el-form-item label="格式化"> </el-form-item>
    <el-form-item label-width="0">
      <el-select v-model="optionModel.formatType" clearable style="width: 100%">
        <el-option-group v-for="t in op" :key="t.label" :label="t.label">
          <el-option
            v-for="e in t.options"
            :key="e.value"
            :value="e.value"
            :label="e.label"
          ></el-option>
        </el-option-group>
      </el-select>
    </el-form-item>

    <el-form-item
      :label="i18nt('自定义渲染处理')"
      v-if="optionModel.formatType === 'render'"
    >
      <a
        href="javascript:void(0);"
        class="a-link link-oneLind"
        @click="editEventHandler('renderHandle', funConfigParams)"
      >
        <span>{{ optionModel.renderHandle }}</span>
        <i class="el-icon-edit"></i>
      </a>
    </el-form-item>
    <el-form-item :label="i18nt('格式化小数位')" v-if="optionModel.formatType === 'n0'">
      <el-input-number v-model="optionModel.formatDecimal" />
    </el-form-item>
  </div>
</template>

<script>
import i18n from "../../../../../components/xform/utils/i18n";
import eventMixin from "./event-handler/eventMixin";
export default {
  name: "formatType-editor",
  mixins: [i18n, eventMixin],
  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
  },
  data() {
    return {
      funConfigParams: ["dataId", "formCode"],
      op: [
        {
          label: "自定义",
          options: [
            {
              value: "render",
              label: "自定义渲染",
            },
          ],
        },
        {
          label: "业务",
          options: [
            {
              value: "money",
              label: "金额",
            },
          ],
        },
        {
          label: "日期",
          options: [
            {
              value: "d1",
              label: "yyyy-MM-dd",
            },
            {
              value: "d2",
              label: "yyyy/MM/dd",
            },
            {
              value: "d3",
              label: "yyyy年MM月dd日",
            },
            {
              value: "d4",
              label: "yyyy-MM-dd HH:mm:ss",
            },
            {
              value: "d5",
              label: "yyyy-MM-dd hh:mm:ss",
            },
          ],
        },
        {
          label: "数值",
          options: [
            {
              value: "n0",
              label: "自定义小数位",
            },
            {
              value: "n1",
              label: "###,###,###,##0.######",
            },
            {
              value: "n2",
              label: "###,###,###,##0.00####",
            },
            {
              value: "n3",
              label: "###,###,###,##0.000000",
            },
            {
              value: "n4",
              label: "###,###,###,##0.000",
            },
            {
              value: "n5",
              label: "###,###,###,##0.00",
            },
            {
              value: "n6",
              label: "###,###,###,##0",
            },
            {
              value: "n7",
              label: "###,##0.00##%",
            },
          ],
        },
      ],
    };
  },
};
</script>

<style scoped></style>
