<template>
  <p-card title="商品资料属性同步">
    <span slot="extra">
      <p-button type="primary" @click="handleRefreshAbc"> ABC属性同步 </p-button>
    </span>
    <p-grid-form :label-col="{ span: 8 }" :span="8" :items="config.items" @submit="hanlderSubmit"/>
    <p-table ref="table" row-key="id" bordered :columns="config.columns" :remoteParams="remoteParams"
      :remoteUrl="config.remoteUrl" :rowSelectType="false" :data-source="data.list">

    </p-table>
  </p-card>
</template>

<script>
  import config from './config.js'
  import { addItem } from './api.js'
  
  
  export default {
    data() {
      return {
        config,
        data: [],
        remoteParams: {
          goodsName: '',
          barCode: '',
          fourABC: '',
          fiveABC:''
        },
      }
    },
    methods: {
      async handleRefreshAbc(){
        console.log(1)
        let res = await addItem()        
        console.log(res)
        if (res.success) {
          this.$message.success(res.message)          
        } else {
          this.$exception(res)
        }
      },
      hanlderSubmit(e, form) {
        e.preventDefault()
        form.validateFields((error, values) => {
          console.log(error, values, 'valuesvaluesvaluesvaluesvalues')
          // this.queryName = values.name
          // this.queryType = values.type
          // this.getlistCompanyByAuthId()
          if (!error) {
            this.remoteParams = {
              ...this.remoteParams,
              ...values
            }
          }
        })
      },
      handleOk(e) {
        this.confirmLoading = true
        setTimeout(() => {
          this.confirmLoading = false
        }, 2000)
      },
      handleCancel(e) {
        console.log('Clicked cancel button')
      }
    }
  }
</script>

<style>
</style>
