<template>
  <div>
    <basicLayout 
      ref="basicLayout" 
      formPath="productMoneyOdd" 
      tableName="productMoneyOdddTable" 
      idName="sa_itempriceadjustid" 
      :apiId="{query:20221024163504,del:20221025092904}" 
      :options="options"
      :detailPath="{path:'/productMoneyOddDetail'}">
      <div slot="custom"></div>
      <div slot="titleRight">
        <importFile v-if="tool.checkAuth($route.name,'import')" ref="import" accept=".xlsx" :folderid="folderid" :bindData="{ownertable:'sat_orderclueuploadbill',ownerid:'',usetype:'default'}" @onSuccess="uploadOrderclueuploadbillByExcel">
          <a class="error-link" v-if="errorurl" :href="errorurl" slot="errorFile">下载错误数据</a>
        </importFile>
      </div>
      <template v-slot:tbList="scope">
        <div v-if="scope.data.column.columnname == 'status'">
          <span v-if="scope.data.column.data[[scope.data.column.columnname]] == '审核'" style="color:#52C41A">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
          <span v-else-if="scope.data.column.data[[scope.data.column.columnname]] == '新建'" style="color:#000000">{{scope.data.column.data[[scope.data.column.columnname]]}}</span>
        </div>
        <div v-else>
          {{scope.data.column.data[[scope.data.column.columnname]]}}
        </div>
      </template>
      <template v-slot:tbOpreation="scope">
        <!-- <productOddDetail class="inline-16" :rowData="scope.data.data"/> -->
        <!-- <Check v-if="scope.data.data.status == '新建' && tool.checkAuth($route.name,'check')" :rowData="scope.data.data" @checkSuccess="$refs.basicLayout.listData()"/> -->
        <!-- <delete-btn v-if="tool.checkAuth($route.name,'delete')" :id="scope.data.data.sa_itempriceadjustid" @deleteSuccess="$refs.basicLayout.listData()" nameId="20221025092904" nameKey="sa_itempriceadjustids"/> -->
      </template>
    </basicLayout>
  </div>
</template>

<script>
import productOddDetail from './modules/productOddDetail'
import Check from './components/check'
import importFile from './modules/importFile'
export default {
  components:{productOddDetail,Check,importFile},
  name: "index",
  data() {
    return {
      options:[],
      priceGrade:'',
      productList:'',
      folderid:JSON.parse(sessionStorage.getItem('folderid')).appfolderid,
      errorurl:''
    }
  },
  provide () {
    return {
      priceGrade: () => this.priceGrade,
      productList: () => this.productList
    }
  },
  async created () {
    /* 获取价格等级 */
    let res = await this.$store.dispatch('optiontypeselect','pricegrade')
    this.priceGrade = res.data

    this.getProductList()
  },
  methods: {
    /* 获取可添加的商品 */
    async getProductList () {
      let res = await this.$api.requested({
          "accesstoken": "0930ace78dc873659508aaa361ebada7",
          "id": 20221028154004,
          "content": {
              "pageNumber": 1,
              "pageSize": 20,
              "where": {
                  "condition": ""
              }
          }
      })
      this.productList = res.data
      console.log(this.productList);
    },
    async uploadOrderclueuploadbillByExcel (data) {
      let res = await this.$api.requested({
        "id": "20221026142804",
        "content": {
          "attachmentid": data.data.attachmentids[0],
          "remarks": ""
        }
      })     
      this.tool.showMessage(res,() => {
        this.$refs.basicLayout.listData()
        this.$refs.import.dialogUploadVisible = false
      })
    }
  }
}
</script>

<style scoped>

</style>