<template>
    <div>
        <Modal
                v-model="updatemodal"
                width="700"
                title="用户侧接口">
            <div>
                <template>
                    <Form :model="formItem" :label-width="120">
                        <FormItem label="接口地址：">
                            <Input v-model="formItem.url" disabled ></Input>
                        </FormItem>
                        <FormItem label="过滤类型;">
                            <Select v-model="formItem.type">
                                <Option value="1">需要登录</Option>
                                <Option value="0">无需登录</Option>
                            </Select>
                        </FormItem>
                        <FormItem label="状态">
                            <i-switch v-model="formItem.state" true-value="0" false-value="1" size="large">
                                <span slot="0">On</span>
                                <span slot="1">Off</span>
                            </i-switch>
                        </FormItem>
                        <FormItem label="说明：">
                            <Input v-model="formItem.name"></Input>
                        </FormItem>
                        <FormItem label="备注：">
                            <Input v-model="formItem.remarks" type="textarea" :autosize="{minRows: 2,maxRows: 5}"></Input>
                        </FormItem>
                    </Form>
                </template>
            </div>
            <div slot="footer">
                <Button type="success" @click="save" :loading="loading">保存</Button>
                <Button type="primary" @click="close">取消</Button>
            </div>
        </Modal>
    </div>
</template>

<script>
import { uservisitsave } from '../../../../../api/system/sys-user-port-list'
export default {
  name: 'modal',
  props: {
    row: Object,
    updaterow: Object
  },
  data () {
    return {
      loading: false,
      updatemodal: false,
      formItem: {
        url: '',
        type: '0',
        state: '0',
        name: '',
        remarks: '',
        id: ''
      }
    }
  },
  methods: {
    change () {
      this.updatemodal = true
    },
    close () {
      this.updatemodal = false
    },
    save () {
      this.loading = true
      uservisitsave(this.formItem).then(ret => {
        if (ret.data.errcode === 0) {
          this.$Message.success(ret.data.errmsg)
          this.loading = false
          this.updatemodal = false
          this.$emit('init')
        } else {
          this.$Message.error(ret.data.errmsg)
        }
      })
    }
  },
  watch: {
    row (row) {
      this.formItem.url = row.url
      // this.formItem.state = row.state
      this.formItem.name = row.name
      this.formItem.remarks = row.remarks
      this.formItem.id = row.id
    },
    updaterow (updaterow) {
      this.formItem = updaterow
    }
  }
}
</script>

<style scoped>

</style>
