<template>	
            <el-form-item label="产品" prop="productCode">
              <el-select v-model="form.productCode" placeholder="请选择产品" filterable remote :remote-method="queryProduct" clearable @focus="(event)=>queryProduct()" v-loadmore="loadMore"
                style="width: 100%" @change="setProductInfo">
                <el-option v-for="(s,index) in productList" :key="index" :label="s.cdesc" :value="s.itemno">
                  <name-code :name="s.itemno" :code="s.cdesc" />
                </el-option>
              </el-select>
            </el-form-item>
</template>


<script>
import { listProduct } from '@/api/baseData/product'
export default {
 data(){
    return{
      //产品代码下拉列表加载
      loadProduct: false,
      //产品代码列表
      productList: [],
      productQueryParams: {
        status: 'T',
        searchValue: null,
        pageNum: 1,
        pageSize: 20,
      },
      proTotal: 0,	
    }
  }, 
  created() {
    this.getList()
    this.queryCurreny()
    this.querySp()
    this.queryProduct()
    // this.queryQuotation()
    this.tableHeight = this.changeHeight()
    listUnit({ corpId: this.$store.getters.corpid }).then((res) => {
      this.unitList = res.rows
    })
  }, 
methods:{

    /** 查询产品列表 */
    queryProduct(v) {
      this.loadProduct = true
      this.productQueryParams.searchValue = v
      this.productQueryParams.pageNum = 1
      listProduct(this.productQueryParams).then((res) => {
        this.productList = res.rows
        this.loadProduct = false
        this.proTotal = res.total
      })
    },
    
    loadMore() {
      if (this.proTotal == this.productList.length) {
        return
      }
      this.loadProduct = true
      let totalPage =
        parseInt(this.proTotal / 20) + (Number(this.proTotal) % 20 > 0 ? 1 : 0)
      if (this.productQueryParams.pageNum + 1 <= totalPage) {
        this.productQueryParams.pageNum = this.productQueryParams.pageNum + 1
        listProduct(this.productQueryParams).then((res) => {
          this.productList = this.productList.concat(res.rows)
          this.loadProduct = false
        })
      }
    },
} 
}
</script>

Logo

DAMO开发者矩阵,由阿里巴巴达摩院和中国互联网协会联合发起,致力于探讨最前沿的技术趋势与应用成果,搭建高质量的交流与分享平台,推动技术创新与产业应用链接,围绕“人工智能与新型计算”构建开放共享的开发者生态。

更多推荐