<template>
  <template-page
    v-if="pageShow"
    ref="pageRef"
    :get-list="getList"
    :table-attributes="tableAttributes"
    :table-events="tableEvents"
    :options-evens-group="optionsEvensGroup"
    :moreParameters="moreParameters"
    :column-parsing="columnParsing"
    :exportList="exportList"
    key="pageType"
  >
    <div slot="moreSearch">
      <el-radio-group v-model="pageType" size="mini" @change="changePageType">
        <el-radio-button label="list">列表</el-radio-button>
        <el-radio-button label="goodsder">商品明细</el-radio-button>
        <el-radio-button label="codeder">条码明细</el-radio-button>
      </el-radio-group>
      <br /><br />
    </div>
  </template-page>
</template>

<script>
import TemplatePage from '@/components/template/template-page-1.vue'
import import_mixin from '@/components/template/import_mixin.js'
import {
  goodsPurchaseList,
  goodsPurchaseListExport,
  goodsPurchaseItemList,
  goodsPurchaseItemListExport,
  goodsPurchaseCodeList,
  goodsPurchaseCodeListExport
} from '@/api/goodsPurchasedStored.js'
export default {
  components: { TemplatePage },
  mixins: [import_mixin],
  data() {
    return {
      pageType: 'list',
      pageShow: true,
      // 事件组合
      optionsEvensGroup: [],
      // 表格属性
      tableAttributes: {
        // 启用勾选列
        selectColumn: false
      },
      // 表格事件
      tableEvents: {
        'selection-change': this.selectionChange
      },
      // 勾选选中行
      recordSelected: [],
      /** 表单变量 */
      formDialogType: 0,
      formDialogTitles: ['新增', '编辑', '详情'],
      formDialog: false,
      appraise_status: ''
    }
  },
  computed: {
    // 更多参数
    moreParameters() {
      return []
    },
    formItems() {
      return []
    }
  },
  watch: {
    pageType() {
      this.pageShow = false
      this.$nextTick(() => {
        this.pageShow = true
      })
    }
  },
  methods: {
    // 列表请求函数
    getList(p, cb) {
      if (this.pageType == 'list') {
        return goodsPurchaseList(p)
      } else if (this.pageType == 'goodsder') {
        return goodsPurchaseItemList(p)
      } else if (this.pageType == 'codeder') {
        return goodsPurchaseCodeList(p)
      }
    },
    // 列表导出函数
    exportList(...p) {
      if (this.pageType == 'list') {
        return goodsPurchaseListExport(...p)
      } else if (this.pageType == 'goodsder') {
        return goodsPurchaseItemListExport(...p)
      } else if (this.pageType == 'codeder') {
        return goodsPurchaseCodeListExport(...p)
      }
    },
    // 表格列解析渲染数据更改
    columnParsing(item, defaultData) {
      return defaultData
    },
    // 监听勾选变化
    selectionChange(data) {
      this.recordSelected = data
    },
    changePageType() {}
  }
}
</script>

<style lang="scss" scoped>
.tab {
  padding: 20px 20px 0 20px;
}
</style>
