<template>
  <nm-container>
    <nm-list ref="list" v-bind="list" @row-click="onChannelChange">
      <!--查询条件-->
      <template v-slot:querybar>
        <el-form-item label="关键字：" prop="key"> <el-input v-model="list.model.key" placeholder="编号/名称" /></el-form-item>
      </template>
    </nm-list>
  </nm-container>
</template>

<script>
import { mapState } from 'vuex'
import { mixins } from 'dcms-ui'
import cols from './cols'

// 接口
const api = $api.crm.channel

export default {
  mixins: [mixins.list],
  components: {},
  data() {
    return {
      curr: { code: '' },
      list: {
        title: '经销商',
        cols,
        action: api.query,
        showNo: true,
        operationWidth: '80',
        noOperation: true,
        noFullscreen: true,
        model: {
          key: '',
          actived: true,
          userId: this.userId,
        },
      },
      select: {
        method: this.queryOptions,
      },
      dialog: {
        item: false,
      },
    }
  },
  computed: {
    ...mapState('app/account', { userId: (s) => s.id }),
  },
  mounted() {
    this.list.model.userId = this.userId
  },
  methods: {
    //状态选择
    queryOptions() {
      return new Promise((resolve) => {
        resolve([
          {
            label: '全部',
            value: null,
          },
          {
            label: '已激活',
            value: true,
          },
          {
            label: '未激活',
            value: false,
          },
        ])
      })
    },
    onChannelChange(row) {
      this.$emit('change', row)
    },
  },
}
</script>