<template>
  <el-dialog
    append-to-body
    :title="__('店铺审核')"
    :visible.sync="dialogTableVisibleCategory"
    width="500px"
  >
    <el-form ref="form" label-width="80px" :model="form">
      <el-form-item>
        <el-select
          v-model.trim="form.store_state_id"
          clearable
          :placeholder="__('审核状态')"
        >
          <el-option
            v-for="item in storeState"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">{{ __('取消') }}</el-button>
      <el-button type="primary" @click="save">
        {{ __('确定') }}
      </el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { translateTitle as __ } from '@/utils/i18n'
  import { storeVerify } from '@/api/store/base'

  export default {
    name: 'SetState',
    components: {},
    data() {
      return {
        storeState: [],
        value: '',
        listLoading: true,
        title: '',
        form: {store_state_id:null},
        dialogTableVisibleCategory: false,
      }
    },
    created() {
      let stateJson = [
        {
          value: 3210,
          label: this.__('待完善资料'),
        },
        {
          value: 3220,
          label: this.__('等待审核'),
        },
        {
          value: 3230,
          label: this.__('资料审核没有通过'),
        },
        {
          value: 3240,
          label: this.__('资料审核通过'),
        },
      ]
      this.storeState = stateJson
    },
    methods: {
      __,

      close() {
        this.form = this.$options.data().form
        this.dialogTableVisibleCategory = false
      },
      showEdit(row) {
        this.form.store_id = row.store_id
        this.form.store_state_id = row.store_state_id
        this.dialogTableVisibleCategory = true
      },
      async save() {
        const { msg, status } = await storeVerify(this.form)
        if (200 == status) {
          this.$baseMessage(msg, 'success')
          this.dialogTableVisibleCategory = false
        } else {
          this.$baseMessage(msg, 'error')
          this.dialogTableVisibleCategory = false
        }
        this.$emit('fetch-data')
        this.close()
      },
    },
  }
</script>
