|
@@ -0,0 +1,121 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
|
|
|
|
|
+ <el-form-item label="商品名称" prop="productName">
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ style="width:200px"
|
|
|
|
|
+ v-model="queryParams.productName"
|
|
|
|
|
+ placeholder="请输入商品名称"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ @keyup.enter.native="handleQuery"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item>
|
|
|
|
|
+ <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+ <el-table border v-loading="loading" :data="list">
|
|
|
|
|
+ <el-table-column label="商品编号" align="center" prop="barCode" />
|
|
|
|
|
+ <el-table-column label="商品图片" align="center" width="100">
|
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
|
+ <el-popover placement="right" title="" trigger="hover">
|
|
|
|
|
+ <img slot="reference" :src="scope.row.image" width="80">
|
|
|
|
|
+ <img :src="scope.row.image" style="max-width: 80px;">
|
|
|
|
|
+ </el-popover>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="商品名称" show-overflow-tooltip align="center" prop="productName" />
|
|
|
|
|
+ <el-table-column label="商品规格" align="center" prop="sku" />
|
|
|
|
|
+ <el-table-column label="库存" align="center" prop="stock" />
|
|
|
|
|
+ <el-table-column label="售价" align="center" prop="price" />
|
|
|
|
|
+ <el-table-column label="代理价" align="center" prop="agentPrice" />
|
|
|
|
|
+ <el-table-column label="操作" align="center" width="100px">
|
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
|
+ <el-button size="mini" type="text" @click="handleSelect(scope.row)">选择</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ </el-table>
|
|
|
|
|
+ <pagination
|
|
|
|
|
+ style="padding-bottom:10px;"
|
|
|
|
|
+ v-show="total>0"
|
|
|
|
|
+ :total="total"
|
|
|
|
|
+ :page.sync="queryParams.pageNum"
|
|
|
|
|
+ :limit.sync="queryParams.pageSize"
|
|
|
|
|
+ @pagination="getList"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+import { getStoreProductAttrValueList, getStoreProductFoodAsMedicineList } from "@/api/hisStore/storeProduct";
|
|
|
|
|
+import pagination from "@/components/Pagination";
|
|
|
|
|
+
|
|
|
|
|
+export default {
|
|
|
|
|
+ name: "FoodMedicineProductSelect",
|
|
|
|
|
+ components: { pagination },
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ loading: true,
|
|
|
|
|
+ list: [],
|
|
|
|
|
+ total: 0,
|
|
|
|
|
+ queryParams: {
|
|
|
|
|
+ productName: "",
|
|
|
|
|
+ pageNum: 1,
|
|
|
|
|
+ pageSize: 10,
|
|
|
|
|
+ // erpType, isGift 由外部传入
|
|
|
|
|
+ },
|
|
|
|
|
+ // 记录当前调用时传入的 isGift,用于区分接口
|
|
|
|
|
+ currentIsGift: null
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ handleSelect(row) {
|
|
|
|
|
+ this.$emit('selectProduct', row);
|
|
|
|
|
+ },
|
|
|
|
|
+ handleQuery() {
|
|
|
|
|
+ this.queryParams.pageNum = 1;
|
|
|
|
|
+ this.getList();
|
|
|
|
|
+ },
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 外部调用此方法传入 erpType 和 isGift
|
|
|
|
|
+ * @param {number|string} erpType ERP类型
|
|
|
|
|
+ * @param {number} isGift 是否赠品(0-商品,1-赠品)
|
|
|
|
|
+ */
|
|
|
|
|
+ getDetails(erpType, isGift) {
|
|
|
|
|
+ this.queryParams.erpType = erpType;
|
|
|
|
|
+ if (isGift !== undefined && isGift !== null) {
|
|
|
|
|
+ this.queryParams.isGift = isGift;
|
|
|
|
|
+ this.currentIsGift = isGift;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ delete this.queryParams.isGift;
|
|
|
|
|
+ this.currentIsGift = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.getList();
|
|
|
|
|
+ },
|
|
|
|
|
+ getList() {
|
|
|
|
|
+ this.loading = true;
|
|
|
|
|
+ // 根据 isGift 选择接口:赠品走原通用接口,商品走药食同源接口
|
|
|
|
|
+ let apiMethod;
|
|
|
|
|
+ if (this.currentIsGift === 1) {
|
|
|
|
|
+ // 赠品 -> 原通用接口
|
|
|
|
|
+ apiMethod = getStoreProductAttrValueList;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 商品(isGift === 0 或未定义)-> 药食同源接口
|
|
|
|
|
+ apiMethod = getStoreProductFoodAsMedicineList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ apiMethod(this.queryParams).then(response => {
|
|
|
|
|
+ this.list = response.rows;
|
|
|
|
|
+ this.total = response.total;
|
|
|
|
|
+ this.loading = false;
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ this.loading = false;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+</style>
|