Procházet zdrojové kódy

个微信息采集绑定套餐包

wjj před 3 týdny
rodič
revize
db40dab643

+ 115 - 0
src/views/components/his/productAttrValueSelect.vue

@@ -0,0 +1,115 @@
+<template>
+  <div class="product-select" >
+    <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="primary" 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="店铺名称" show-overflow-tooltip align="center" prop="storeName" />
+      <el-table-column label="规格" align="center" prop="prescribeSpec" />
+      <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="costPrice" />
+      <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 { listStore, getStoreProductAttrValueList } from "@/api/store/storeProduct";
+export default {
+  name: "selectProduct",
+  data() {
+    return {
+      loading: true,
+      list:[],
+      total: 0,
+      queryParams: {
+        productName:"",
+        pageNum: 1,
+        pageSize: 10,
+        isPackage:0,
+        storeId:null,
+      }
+    };
+  },
+  created() {
+     
+  },
+  methods: {
+    getData(isPackage){
+      this.queryParams.isPackage=isPackage;
+      this.getList();
+
+    },
+    handleSelect(row){
+      this.$emit('selectProduct',row);
+    },
+    /** 搜索按钮操作 */
+    handleQuery() {
+      this.queryParams.pageNum = 1;
+      this.getList();
+    },
+    getDetails(storeId){
+      this.queryParams.storeId=storeId;
+      this.getList();
+    },
+    getList(){
+      this.loading = true;
+      getStoreProductAttrValueList(this.queryParams).then(response => {
+        this.list = response.rows;
+        this.total = response.total;
+        this.loading = false;
+      });
+    }
+  }
+};
+</script>
+<style scoped>
+
+.product-select{
+  padding-bottom: 15px;
+}
+</style>

+ 452 - 60
src/views/qw/collectionFully/BindPackageDialog.vue

@@ -1,63 +1,307 @@
 <template>
 <template>
-  <el-dialog
-    :title="isEdit ? '编辑套餐' : '绑定套餐'"
-    :visible.sync="dialogVisible"
-    width="500px"
-    append-to-body
-    @close="handleClose"
-  >
-    <el-form ref="form" :model="form" :rules="rules" label-width="100px">
-      <el-form-item label="套餐包" prop="packageIds">
-        <el-select
-          v-model="form.packageIds"
-          placeholder="请选择套餐包"
-          clearable
-          filterable
-          multiple
-          :disabled="isEdit"
-        >
-          <el-option
-            v-for="item in packageOptions"
-            :key="item.dictValue"
-            :label="item.dictLabel"
-            :value="parseInt(item.dictValue)"
+  <div>
+    <el-dialog
+      :title="isEdit ? '编辑套餐' : '绑定套餐'"
+      :visible.sync="dialogVisible"
+      width="1000px"
+      append-to-body
+      @close="handleClose"
+    >
+      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+        <el-form-item label="ERP类型" prop="erpType">
+          <el-radio-group v-model="form.erpType">
+            <el-radio :label="1">聚水潭</el-radio>
+            <el-radio :label="2">兔灵</el-radio>
+            <el-radio :label="3">京东云仓</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item label="药品配置" prop="productJson">
+          <el-select
+            v-model="form.storeId"
+            placeholder="请选择店铺"
+            clearable
+            size="small"
+            filterable
+            @change="changeStore"
+          >
+            <el-option
+              v-for="dict in storeList"
+              :key="dict.dictValue"
+              :label="dict.dictLabel"
+              :value="dict.dictValue"
+            />
+          </el-select>
+          <div style="float: right">
+            <el-button
+              plain
+              type="primary"
+              icon="el-icon-plus"
+              @click="handleAddProduct"
+              >添加商品</el-button
+            >
+          </div>
+
+          <!-- 药品表格 -->
+          <el-table
+            border
+            width="100%"
+            style="margin-top: 5px"
+            :data="drugList"
+          >
+            <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="50" />
+                  <img :src="scope.row.image" style="max-width: 50px" />
+                </el-popover>
+              </template>
+            </el-table-column>
+            <el-table-column
+              label="商品名称"
+              show-overflow-tooltip
+              align="center"
+              prop="productName"
+            />
+            <el-table-column
+              label="数量"
+              align="center"
+              prop="count"
+              width="150px"
+            >
+              <template slot-scope="scope">
+                <div>
+                  <el-input-number
+                    v-model="scope.row.count"
+                    @change="handleProductCountChange(scope.row)"
+                    size="small"
+                    :min="1"
+                  ></el-input-number>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="规格" align="center" prop="prescribeSpec" />
+            <el-table-column label="商品编号" align="center" prop="barCode" />
+            <el-table-column label="商品规格" align="center" prop="sku" />
+            <el-table-column label="店铺名称" align="center" prop="storeName" />
+            <el-table-column label="最低价" align="center" prop="minPrice">
+              <template slot-scope="scope">
+                <div v-if="scope.row.minPrice != null">
+                  {{ scope.row.minPrice.toFixed(2) }}
+                </div>
+              </template>
+            </el-table-column>
+
+            <el-table-column label="售价" align="center" prop="price">
+              <template slot-scope="scope">
+                <div v-if="scope.row.price != null">
+                  {{ scope.row.price.toFixed(2) }}
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="小计" align="center" prop="money">
+              <template slot-scope="scope">
+                <div v-if="scope.row.money != null">
+                  {{ scope.row.money.toFixed(2) }}
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column
+              label="操作"
+              align="center"
+              width="100px"
+              fixed="right"
+            >
+              <template slot-scope="scope">
+                <el-button
+                  size="mini"
+                  type="text"
+                  icon="el-icon-delete"
+                  @click="handleProductDelete(scope.row)"
+                  >删除</el-button
+                >
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-form-item>
+        <el-form-item label="总金额" prop="totalPrice">
+          <el-input-number
+            v-model="form.totalPrice"
+            :precision="1"
+            :step="1"
+            :min="0.1"
+          />
+        </el-form-item>
+
+        <!-- 赠品 -->
+        <el-form-item label="赠品配置" prop="giftProductJson">
+          <div style="float: right">
+            <el-button
+              plain
+              type="primary"
+              icon="el-icon-plus"
+              @click="handleAddGiftProduct"
+              >添加赠品</el-button
+            >
+          </div>
+
+          <!-- 药品表格 -->
+          <el-table
+            border
+            width="100%"
+            style="margin-top: 5px"
+            :data="giftDrugList"
+          >
+            <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="50" />
+                  <img :src="scope.row.image" style="max-width: 50px" />
+                </el-popover>
+              </template>
+            </el-table-column>
+            <el-table-column
+              label="商品名称"
+              show-overflow-tooltip
+              align="center"
+              prop="productName"
+            />
+            <el-table-column
+              label="数量"
+              align="center"
+              prop="count"
+              width="150px"
+            >
+              <template slot-scope="scope">
+                <div>
+                  <el-input-number
+                    v-model="scope.row.count"
+                    @change="handleGiftProductCountChange(scope.row)"
+                    size="small"
+                    :min="1"
+                  ></el-input-number>
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="规格" align="center" prop="prescribeSpec" />
+            <el-table-column label="商品编号" align="center" prop="barCode" />
+            <el-table-column label="商品规格" align="center" prop="sku" />
+            <el-table-column label="店铺名称" align="center" prop="storeName" />
+            <el-table-column label="成本价" align="center" prop="costPrice">
+              <template slot-scope="scope">
+                <div v-if="scope.row.costPrice != null">
+                  {{ scope.row.costPrice.toFixed(2) }}
+                </div>
+              </template>
+            </el-table-column>
+
+            <el-table-column label="售价" align="center" prop="price">
+              <template slot-scope="scope">
+                <div v-if="scope.row.price != null">
+                  {{ scope.row.price.toFixed(2) }}
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column label="小计" align="center" prop="money">
+              <template slot-scope="scope">
+                <div v-if="scope.row.money != null">
+                  {{ scope.row.money.toFixed(2) }}
+                </div>
+              </template>
+            </el-table-column>
+            <el-table-column
+              label="操作"
+              align="center"
+              width="100px"
+              fixed="right"
+            >
+              <template slot-scope="scope">
+                <el-button
+                  size="mini"
+                  type="text"
+                  icon="el-icon-delete"
+                  @click="handleGiftProductDelete(scope.row)"
+                  >删除</el-button
+                >
+              </template>
+            </el-table-column>
+          </el-table>
+        </el-form-item>
+        <!-- <el-form-item label="套餐包" prop="packageIds">
+          <el-select
+            v-model="form.packageIds"
+            placeholder="请选择套餐包"
+            clearable
+            filterable
+            multiple
+            :disabled="isEdit"
+          >
+            <el-option
+              v-for="item in packageOptions"
+              :key="item.dictValue"
+              :label="item.dictLabel"
+              :value="parseInt(item.dictValue)"
+            />
+          </el-select>
+        </el-form-item> -->
+
+        <el-form-item label="支付类型" prop="payType">
+          <el-radio-group v-model="form.payType">
+            <el-radio :label="1">全款</el-radio>
+            <el-radio :label="2">物流代收</el-radio>
+          </el-radio-group>
+        </el-form-item>
+
+        <el-form-item v-if="form.payType === 2" label="预付金额" prop="amount">
+          <el-input
+            v-model="form.amount"
+            placeholder="请输入物流代收金额"
+            type="number"
           />
           />
-        </el-select>
-      </el-form-item>
-
-      <el-form-item label="支付类型" prop="payType">
-        <el-radio-group v-model="form.payType">
-          <el-radio :label="1">全款</el-radio>
-          <el-radio :label="2">物流代收</el-radio>
-        </el-radio-group>
-      </el-form-item>
-
-      <el-form-item
-        v-if="form.payType === 2"
-        label="预付金额"
-        prop="amount"
-      >
-        <el-input
-          v-model="form.amount"
-          placeholder="请输入物流代收金额"
-          type="number"
-        />
-      </el-form-item>
-    </el-form>
-
-    <div slot="footer" class="dialog-footer">
-      <el-button @click="dialogVisible = false">取 消</el-button>
-      <el-button type="primary" :loading="submitLoading" @click="submitForm">确 定</el-button>
-    </div>
-  </el-dialog>
+        </el-form-item>
+      </el-form>
+
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="dialogVisible = false">取 消</el-button>
+        <el-button type="primary" :loading="submitLoading" @click="submitForm"
+          >确 定</el-button
+        >
+      </div>
+    </el-dialog>
+
+    <el-dialog
+      :title="product.title"
+      v-if="product.open"
+      :visible.sync="product.open"
+      width="1000px"
+      append-to-body
+    >
+      <product-attr-value-select ref="Details" @selectProduct="selectProduct" />
+    </el-dialog>
+
+    <el-dialog
+      :title="giftProduct.title"
+      v-if="giftProduct.open"
+      :visible.sync="giftProduct.open"
+      width="1000px"
+      append-to-body
+    >
+      <product-attr-value-select
+        ref="Details"
+        @selectProduct="selectGiftProduct"
+      />
+    </el-dialog>
+  </div>
 </template>
 </template>
 
 
 <script>
 <script>
-import {allPrivatePackage} from "@/api/store/package";
-import {bindCollectionPackage} from "@/api/qw/collectionPendingSales";
+import { allPrivatePackage } from "@/api/store/package";
+import { bindCollectionPackage } from "@/api/qw/collectionPendingSales";
+import { listStore } from "@/api/store/storeProduct";
+import productAttrValueSelect from "../../components/his/productAttrValueSelect.vue";
 
 
 export default {
 export default {
   name: "BindPackageDialog",
   name: "BindPackageDialog",
+  components: { productAttrValueSelect },
   props: {
   props: {
     visible: {
     visible: {
       type: Boolean,
       type: Boolean,
@@ -81,22 +325,38 @@ export default {
       packageOptions: [],
       packageOptions: [],
       form: {
       form: {
         id: null,
         id: null,
-        packageIds: [],
+        // packageIds: [],
         payType: 1,
         payType: 1,
         amount: null,
         amount: null,
+        productJson: null,
+        giftProductJson: null,
+        erpType: null,
+        storeId: null,
+        totalPrice: null,
       },
       },
       rules: {
       rules: {
         packageIds: [
         packageIds: [
-          {required: true, message: "请选择套餐包", trigger: "change"},
+          { required: true, message: "请选择套餐包", trigger: "change" },
         ],
         ],
         payType: [
         payType: [
-          {required: true, message: "请选择支付类型", trigger: "change"},
+          { required: true, message: "请选择支付类型", trigger: "change" },
         ],
         ],
         amount: [
         amount: [
-          {required: true, message: "请填写物流代收金额", trigger: "blur"},
+          { required: true, message: "请填写物流代收金额", trigger: "blur" },
         ],
         ],
       },
       },
       originalPackageId: [], // 编辑模式下保留的原套餐包ID
       originalPackageId: [], // 编辑模式下保留的原套餐包ID
+      storeList: [], //店铺列表
+      drugList: [], //药品列表
+      giftDrugList: [], //赠品列表
+      product: {
+        open: false,
+        title: "商品选择",
+      },
+      giftProduct: {
+        open: false,
+        title: "赠品选择",
+      },
     };
     };
   },
   },
   computed: {
   computed: {
@@ -123,8 +383,121 @@ export default {
   },
   },
   created() {
   created() {
     this.fetchPackageList();
     this.fetchPackageList();
+    listStore().then((res) => {
+      this.storeList = res.rows;
+    });
   },
   },
   methods: {
   methods: {
+    handleAddProduct() {
+      if (this.form.storeId == null || this.form.storeId == "") {
+        return this.$message({
+          message: "请先选择店铺",
+          type: "warning",
+        });
+      } else {
+        setTimeout(() => {
+          this.$refs.Details.getDetails(this.form.storeId);
+        }, 1);
+        this.product.open = true;
+      }
+    },
+
+    handleAddGiftProduct() {
+      if (this.form.storeId == null || this.form.storeId == "") {
+        return this.$message({
+          message: "请先选择店铺",
+          type: "warning",
+        });
+      } else {
+        setTimeout(() => {
+          this.$refs.Details.getDetails(this.form.storeId);
+        }, 1);
+        this.giftProduct.open = true;
+      }
+    },
+
+    selectProduct(row) {
+      console.log(row);
+      for (var i = 0; i < this.drugList.length; i++) {
+        if (this.drugList[i].id == row.id) {
+          return;
+        }
+      }
+      row.count = 1;
+      row.money = row.count * row.price;
+      row.usageMethod = "口服";
+      row.usageFrequencyUnit = 1;
+      this.drugList.push(row);
+      this.compute();
+      this.$message({
+        message: "添加成功",
+        type: "success",
+      });
+    },
+
+    selectGiftProduct(row) {
+      console.log(row);
+      for (var i = 0; i < this.giftDrugList.length; i++) {
+        if (this.giftDrugList[i].id == row.id) {
+          return;
+        }
+      }
+      row.count = 1;
+      row.money = row.count * row.price;
+      row.usageMethod = "口服";
+      row.usageFrequencyUnit = 1;
+      this.giftDrugList.push(row);
+      this.giftCompute();
+      this.$message({
+        message: "添加成功",
+        type: "success",
+      });
+    },
+    changeStore() {
+      this.drugList = [];
+      this.giftDrugList = [];
+    },
+
+    handleProductCountChange(row) {
+      row.money = row.count * row.price;
+      this.$forceUpdate();
+      this.compute();
+    },
+    handleGiftProductCountChange(row) {
+      row.money = row.count * row.price;
+      this.$forceUpdate();
+      this.giftCompute();
+    },
+    handleProductDelete(row) {
+      this.drugList.splice(
+        this.drugList.findIndex((item) => item.id === row.id),
+        1
+      );
+      this.compute();
+    },
+    handleGiftProductDelete(row) {
+      this.giftDrugList.splice(
+        this.giftDrugList.findIndex((item) => item.id === row.id),
+        1
+      );
+      this.giftCompute();
+    },
+    compute() {
+      this.totalMoney = 0;
+      var that = this;
+      this.drugList.forEach(function (value) {
+        that.totalMoney += value.money;
+      });
+      that.totalMoney = that.totalMoney.toFixed(2);
+    },
+    giftCompute() {
+      this.totalMoney = 0;
+      var that = this;
+      this.giftDrugList.forEach(function (value) {
+        that.totalMoney += value.money;
+      });
+      that.totalMoney = that.totalMoney.toFixed(2);
+    },
     fetchPackageList() {
     fetchPackageList() {
       allPrivatePackage().then((res) => {
       allPrivatePackage().then((res) => {
         this.packageOptions = res.rows || [];
         this.packageOptions = res.rows || [];
@@ -143,6 +516,10 @@ export default {
         this.form.packageIds = [];
         this.form.packageIds = [];
         this.form.payType = 1;
         this.form.payType = 1;
         this.form.amount = null;
         this.form.amount = null;
+        this.drugList = [];
+        this.giftDrugList = [];
+        this.erpType = null;
+        this.storeId = null;
       }
       }
       this.$nextTick(() => {
       this.$nextTick(() => {
         if (this.$refs.form) {
         if (this.$refs.form) {
@@ -153,13 +530,21 @@ export default {
     submitForm() {
     submitForm() {
       this.$refs.form.validate((valid) => {
       this.$refs.form.validate((valid) => {
         if (!valid) return;
         if (!valid) return;
-
+        if (this.drugList != null) {
+          this.form.productJson = JSON.stringify(this.drugList);
+        }
+        if (this.giftDrugList != null) {
+          this.form.giftProductJson = JSON.stringify(this.giftDrugList);
+        }
         const params = {
         const params = {
           id: this.form.id,
           id: this.form.id,
-          // 编辑模式下使用原套餐包ID,新增模式下使用表单选择的套餐包ID
-          packageIds: this.isEdit ? this.originalPackageId : this.form.packageIds,
           payType: this.form.payType,
           payType: this.form.payType,
           amount: this.form.amount,
           amount: this.form.amount,
+          erpType: this.form.erpType,
+          storeId: this.form.storeId,
+          productJson: this.form.productJson,
+          giftProductJson: this.form.giftProductJson,
+          totalPrice: this.form.totalPrice,
         };
         };
 
 
         this.submitLoading = true;
         this.submitLoading = true;
@@ -169,9 +554,14 @@ export default {
             this.dialogVisible = false;
             this.dialogVisible = false;
             this.$emit("success", res.data);
             this.$emit("success", res.data);
             this.$emit("update:visible", false);
             this.$emit("update:visible", false);
+            this.drugList = [];
+            this.giftDrugList = [];
           })
           })
           .catch((error) => {
           .catch((error) => {
-            this.$message.error(error.msg || (this.isEdit ? "修改失败" : "绑定失败"));
+            // console.log("aaaa",error);
+            // this.$message.error(
+            //   error.Error || (this.isEdit ? "修改失败" : "绑定失败")
+            // );
           })
           })
           .finally(() => {
           .finally(() => {
             this.submitLoading = false;
             this.submitLoading = false;
@@ -182,6 +572,8 @@ export default {
       this.dialogVisible = false;
       this.dialogVisible = false;
       this.$emit("update:visible", false);
       this.$emit("update:visible", false);
       this.$refs.form?.resetFields();
       this.$refs.form?.resetFields();
+      this.drugList = [];
+      this.giftDrugList = [];
     },
     },
   },
   },
 };
 };