Przeglądaj źródła

药食同源功能

cgp 4 dni temu
rodzic
commit
0d8863f80e

+ 9 - 0
src/api/hisStore/storeProduct.js

@@ -15,6 +15,15 @@ export function getStoreProductAttrValueList(query) {
     params: query
   })
 }
+
+//查询药食同源商品列表
+export function getStoreProductFoodAsMedicineList(query) {
+  return request({
+    url: '/store/store/storeProduct/getStoreProductFoodAsMedicineList',
+    method: 'get',
+    params: query
+  })
+}
 export function getStoreProduct(productId) {
   return request({
     url: '/store/store/storeProduct/' + productId,

+ 121 - 0
src/views/hisStore/components/foodMedicineProductSelect.vue

@@ -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>

+ 8 - 12
src/views/qw/companyCustomer/CreateOrderDialog.vue

@@ -7,7 +7,7 @@
     :close-on-click-modal="false"
     @close="handleClose"
   >
-    <!-- 处方图片展示区域(与原制单完全一致) -->
+    <!-- 处方图片展示区域 -->
     <div
       v-if="scrmPrescribeInfo"
       style="
@@ -303,14 +303,9 @@
       <el-button @click="dialogVisible = false">取 消</el-button>
     </div>
 
-    <!-- 商品选择弹窗(完全复用原 product-select 组件) -->
-    <el-dialog
-      :title="product.title"
-      :visible.sync="product.open"
-      width="1000px"
-      append-to-body
-    >
-      <product-select ref="Details" @selectProduct="selectProduct" />
+    <!-- 商品选择弹窗 -->
+    <el-dialog :title="product.title" :visible.sync="product.open" width="1000px" append-to-body>
+      <food-medicine-product-select ref="Details" @selectProduct="selectProduct" />
     </el-dialog>
 
     <!-- 赠品选择弹窗 -->
@@ -330,12 +325,13 @@ import { getCustomer, getCanUsePayReceiptList, getScrmPrescribeInfo, updateScrmP
 import { createUserOrder } from "@/api/hisStore/storeOrder";
 import { getCitys as getKdnCitys } from "@/api/store/city";
 import { getDicts } from "@/api/system/dict/data";
-import productSelect from "../../hisStore/components/erpProductSelect"; // 请根据实际路径调整
+import productSelect from "../../hisStore/components/erpProductSelect";
+import FoodMedicineProductSelect from "../../hisStore/components/foodMedicineProductSelect";
 import { getAddress } from "@/api/qw/companyCustomer";
 
 export default {
   name: "CreateOrderDialog",
-  components: { productSelect },
+  components: { productSelect,FoodMedicineProductSelect },
   props: {
     visible: {
       type: Boolean,
@@ -381,7 +377,7 @@ export default {
         city: "",
         district: "",
         detail: "",
-        erpType: "",      // ERP类型,与原制单一致
+        erpType: "",
         payType: "",
         reduceAmount: 0,
         receiveMoneyId: null,