<template>
  <basic-container>
    <avue-crud
      :option="option"
      :data="data"
      ref="crud"
      v-model="form"
      :permission="permissionList"
      :before-open="beforeOpen"
      :table-loading="loading"
      @row-del="rowDel"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template slot="menuLeft">
        <el-button
          type="danger"
          size="small"
          plain
          icon="el-icon-delete"
          v-if="permission.order_address_delete"
          @click="handleDelete"
        >
          删除
        </el-button>
      </template>

      <template slot-scope="{row}" slot="isDefault">
        <el-tag :type="row.isDefault === 1 ? 'success' : 'info'">
          {{ row.isDefault === 1 ? '是' : '否' }}
        </el-tag>
      </template>

      <template slot-scope="{row}" slot="isActive">
        <el-tag :type="row.isActive === 1 ? 'success' : 'danger'">
          {{ row.isActive === 1 ? '启用' : '禁用' }}
        </el-tag>
      </template>

      <!-- 地区选择器插槽 -->
      <template slot="regionNameForm" slot-scope="{value, column}">
        <region-cascader
          v-model="form.regionName"
          @change="handleRegionChange"
          :placeholder="column.placeholder || '请选择省/市/区'"
        />
      </template>
    </avue-crud>
  </basic-container>
</template>

<script>

import RegionCascader from '@/components/region-cascader'
import addressMixin from './addressMixin';
/**
 * @typedef {import('./types').OrderAddressComponent} OrderAddressComponent
 */

/**
 * @type {OrderAddressComponent}
 */
export default {
  name: 'OrderAddress',
  components: {
    RegionCascader
  },
  mixins: [addressMixin],
}
</script>
