<template>
  <div>
    <c-col v-if="!noRef" :span="24">
      <c-form-item
        :label="`${argadr.title}参考号`"
        :prop="`${argadr.grp}.${argadr.rol}.pts.ref`"
      >
        <c-input
          v-model="model[argadr.grp][argadr.rol].pts.ref"
          :placeholder="'请输入' + argadr.title + '参考号'"
        ></c-input>
      </c-form-item>
    </c-col>

    <c-col :span="24" v-if="!editExtLabel">
      <el-form-item
        :label="`${argadr.title}ID`"
        :prop="`${argadr.grp}.${argadr.rol}.pts.extkey`"
        style="width: 100%"
      >
        <c-fullbox>
          <c-input
            v-model="model[argadr.grp][argadr.rol].pts.extkey"
            :placeholder="'请输入' + argadr.title + 'Extkey'"
            @keyup.enter.native="
              showGridPromptDialog(`${argadr.grp}.${argadr.rol}.pts.extkey`)
            "
            @change="valueChange"
          ></c-input>
          <template slot="footer">
            <c-button
              style="margin:0 10px 0 10;padding: 0 12px;"
              size="small"
              type="primary"
              icon="el-icon-search"
              @click="onSeainf(`${argadr.grp}.${argadr.rol}.pts.extkey`)"
            >
            </c-button>
            <c-button
              style="margin:0 0"
              size="small"
              type="primary"
              @click="onAplpDet"
            >
              {{ $t('buttons.details') }}
            </c-button>
          </template>
        </c-fullbox>
      </el-form-item>
    </c-col>

    <c-col :span="24" v-else>
      <el-form-item
        :label="`${argadr.title}`"
        :prop="`${argadr.grp}.${argadr.rol}.pts.extkey`"
        style="width: 100%"
      >
        <c-fullbox>
          <c-input
            v-model="model[argadr.grp][argadr.rol].pts.extkey"
            :placeholder="'请输入' + argadr.title + 'Extkey'"
            @keyup.enter.native="
              showGridPromptDialog(`${argadr.grp}.${argadr.rol}.pts.extkey`)
            "
            @change="valueChange"
          ></c-input>
          <template slot="footer">
            <c-button
              style="margin:0 10px 0 10;padding: 0 12px;"
              size="small"
              type="primary"
              icon="el-icon-search"
              @click="onSeainf(`${argadr.grp}.${argadr.rol}.pts.extkey`)"
            >
            </c-button>
            <c-button
              style="margin:0 0"
              size="small"
              type="primary"
              @click="onAplpDet"
            >
              {{ $t('buttons.details') }}
            </c-button>
          </template>
        </c-fullbox>
      </el-form-item>
    </c-col>

    <template v-if="!onlySearch">
      <c-col v-if="isAdrblk" :span="24">
        <el-form-item
          label="名称地址"
          :prop="`${argadr.grp}.${argadr.rol}.pts.adrblk`"
        >
          <c-input
            type="textarea"
            :rows="4"
            v-model="model[argadr.grp][argadr.rol].pts.adrblk"
            maxlength="150"
            show-word-limit
            placeholder="请输入名称地址"
            :disabled="disabled"
          ></c-input>
        </el-form-item>
      </c-col>
      <c-col v-else-if="!haveAdrLabel" :span="24">
        <el-form-item
          label=""
          :prop="`${argadr.grp}.${argadr.rol}.pts.adrblk`"
        >
          <c-input
            type="textarea"
            :rows="4"
            v-model="model[argadr.grp][argadr.rol].pts.adrblk"
            maxlength="150"
            show-word-limit
            placeholder="请输入名称地址"
            :disabled="disabled"
          ></c-input>
        </el-form-item>
      </c-col>
      <template v-else>
        <c-col :span="24">
          <el-form-item
            :label="`${argadr.title}名称`"
            :prop="`${argadr.grp}.${argadr.rol}.namelc`"
          >
            <c-input
              type="textarea"
              v-model="model[argadr.grp][argadr.rol].namelc"
              :placeholder="'请输入' + argadr.title + '名称'"
              :disabled="disabled"
              :rows="2"
              maxlength="35"
              show-word-limit
            ></c-input>
          </el-form-item>
        </c-col>

        <c-col :span="24">
          <el-form-item
            :label="`${argadr.title}地址`"
            :prop="`${argadr.grp}.${argadr.rol}.adrelc`"
          >
            <c-input
              type="textarea"
              :rows="2"
              v-model="model[argadr.grp][argadr.rol].adrelc"
              :placeholder="'请输入' + argadr.title + '地址'"
              :disabled="disabled"
              maxlength="35"
              show-word-limit
            ></c-input>
          </el-form-item>
        </c-col>
      </template>
    </template>
  </div>
</template>
<script>
import Api from "~/service/Api";
import CommonProcess from "~/mixin/CommonProcess";
// 机构信息模块
export default {
  inject: ["root"],
  mixins: [CommonProcess],

  props: {
    model: {
      type: Object,
      default: undefined,
    },
    argadr: {
      type: Object,
      default: function () {
        return {
          title: "", //角色名称
          rol: "", //角色
          grp: "", //所属模块
        };
      },
    },
    disabled: {
      //名称地址是否灰显
      type: Boolean,
      default: false,
    },

    isAdrblk: {
      //名称地址是否为大字段
      type: Boolean,
      default: true,
    },
    onlySearch: {
      //是否只展示extkey
      type: Boolean,
      default: false,
    },
    noRef: {
      //无需参考号
      type: Boolean,
      default: false,
    },
    editExtLabel: {
      //自定义ID label
      type: Boolean,
      default: true,
    },
    haveAdrLabel: {
      //有无名称地址 label
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      data: [],
    };
  },
  watch: {},
  methods: {
    onSeainf(data) {
      this.$emit("onSeainf", data);
    },

    onAplpDet() {
      this.$emit("onAplpDet");
    },

    valueChange() {
      if (this.onlySearch) return;
      // this.showGridPromptDialog(
      //   `${this.argadr.grp}.${this.argadr.rol}.pts.extkey`
      // );
    },
  },

  created: function () {},
};
</script>
<style>
</style>
