|
@@ -0,0 +1,756 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <el-dialog
|
|
|
|
|
+ title="创建订单"
|
|
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
|
|
+ width="1000px"
|
|
|
|
|
+ append-to-body
|
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
|
+ @close="handleClose"
|
|
|
|
|
+ >
|
|
|
|
|
+ <!-- 处方图片展示区域(与原制单完全一致) -->
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-if="scrmPrescribeInfo"
|
|
|
|
|
+ style="
|
|
|
|
|
+ margin-bottom: 20px;
|
|
|
|
|
+ border-bottom: 1px solid #ebeef5;
|
|
|
|
|
+ padding-bottom: 15px;
|
|
|
|
|
+ "
|
|
|
|
|
+ >
|
|
|
|
|
+ <div style="font-weight: bold; margin-bottom: 10px">处方图片</div>
|
|
|
|
|
+ <div
|
|
|
|
|
+ :style="getImageLayoutStyle(scrmPrescribeInfo.prescribeType)"
|
|
|
|
|
+ style="
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ gap: 20px;
|
|
|
|
|
+ justify-content: flex-start;
|
|
|
|
|
+ flex-wrap: wrap;
|
|
|
|
|
+ "
|
|
|
|
|
+ >
|
|
|
|
|
+ <!-- 西药图片 -->
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-if="shouldShowWesternImage(scrmPrescribeInfo.prescribeType)"
|
|
|
|
|
+ style="text-align: center; flex: 1"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div style="margin-bottom: 5px">西药处方</div>
|
|
|
|
|
+ <el-image
|
|
|
|
|
+ v-if="scrmPrescribeInfo.prescribeImgStoreUrl"
|
|
|
|
|
+ :src="scrmPrescribeInfo.prescribeImgStoreUrl"
|
|
|
|
|
+ :preview-src-list="[scrmPrescribeInfo.prescribeImgStoreUrl]"
|
|
|
|
|
+ style="
|
|
|
|
|
+ width: 200px;
|
|
|
|
|
+ height: auto;
|
|
|
|
|
+ max-height: 200px;
|
|
|
|
|
+ object-fit: contain;
|
|
|
|
|
+ border: 1px solid #ddd;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ "
|
|
|
|
|
+ fit="contain"
|
|
|
|
|
+ />
|
|
|
|
|
+ <div v-else style="color: #909399">暂无西药处方图</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <!-- 中药图片 -->
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-if="shouldShowChineseImage(scrmPrescribeInfo.prescribeType)"
|
|
|
|
|
+ style="text-align: center; flex: 1"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div style="margin-bottom: 5px">中药处方</div>
|
|
|
|
|
+ <el-image
|
|
|
|
|
+ v-if="scrmPrescribeInfo.prescribeImgUrl"
|
|
|
|
|
+ :src="scrmPrescribeInfo.prescribeImgUrl"
|
|
|
|
|
+ :preview-src-list="[scrmPrescribeInfo.prescribeImgUrl]"
|
|
|
|
|
+ style="
|
|
|
|
|
+ width: 200px;
|
|
|
|
|
+ height: auto;
|
|
|
|
|
+ max-height: 200px;
|
|
|
|
|
+ object-fit: contain;
|
|
|
|
|
+ border: 1px solid #ddd;
|
|
|
|
|
+ border-radius: 4px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ "
|
|
|
|
|
+ fit="contain"
|
|
|
|
|
+ />
|
|
|
|
|
+ <div v-else style="color: #909399">暂无中药处方图</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form
|
|
|
|
|
+ ref="form"
|
|
|
|
|
+ :model="form"
|
|
|
|
|
+ :rules="rules"
|
|
|
|
|
+ label-width="120px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-form-item label="收货人姓名" prop="realName" required>
|
|
|
|
|
+ <el-input v-model="form.realName" placeholder="请输入收货人姓名" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="收货人电话" prop="phone" required>
|
|
|
|
|
+ <el-input v-model="form.phone" placeholder="请输入收货人电话" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="收货地址">
|
|
|
|
|
+ <el-cascader
|
|
|
|
|
+ ref="citySelect"
|
|
|
|
|
+ v-model="kdnCityIds"
|
|
|
|
|
+ :options="kdnCitys"
|
|
|
|
|
+ @change="handleKdnCityChange"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="详细地址" prop="detail" required>
|
|
|
|
|
+ <el-input v-model="form.detail" placeholder="请输入收货人详细地址" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item label="商品列表" prop="products">
|
|
|
|
|
+ <!-- 产品来源下拉 —— 与原制单完全一致 -->
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="form.erpType"
|
|
|
|
|
+ placeholder="请选择ERP类型"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ filterable
|
|
|
|
|
+ @change="changeErp"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="dict in erpList"
|
|
|
|
|
+ :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
|
|
|
|
|
+ :key="tablekey"
|
|
|
|
|
+ width="100%"
|
|
|
|
|
+ style="margin-top: 5px"
|
|
|
|
|
+ :data="products"
|
|
|
|
|
+ >
|
|
|
|
|
+ <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="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="sku" />
|
|
|
|
|
+ <el-table-column label="库存" align="center" prop="stock" />
|
|
|
|
|
+ <el-table-column label="单价" align="center" prop="price" />
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ label="数量"
|
|
|
|
|
+ align="center"
|
|
|
|
|
+ prop="count"
|
|
|
|
|
+ width="200px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
|
+ <el-input-number
|
|
|
|
|
+ v-model="scope.row.count"
|
|
|
|
|
+ @change="handleProductCountChange(scope.row)"
|
|
|
|
|
+ size="mini"
|
|
|
|
|
+ :min="1"
|
|
|
|
|
+ :max="scope.row.stock"
|
|
|
|
|
+ />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="小计" align="center" prop="money" />
|
|
|
|
|
+ <el-table-column label="操作" align="center" width="100px">
|
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ size="mini"
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ icon="el-icon-delete"
|
|
|
|
|
+ @click="removeProduct(scope.row)"
|
|
|
|
|
+ >删除</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ </el-table>
|
|
|
|
|
+ <el-row>
|
|
|
|
|
+ <el-col>
|
|
|
|
|
+ <span>商品合计:{{ products.length }}</span>
|
|
|
|
|
+ <span style="margin-left: 10px">商品总价:{{ totalMoney.toFixed(2) }}</span>
|
|
|
|
|
+ </el-col>
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="赠品列表">
|
|
|
|
|
+ <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="giftProducts"
|
|
|
|
|
+ >
|
|
|
|
|
+ <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="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="sku" />
|
|
|
|
|
+ <el-table-column label="库存" align="center" prop="stock" />
|
|
|
|
|
+ <el-table-column label="单价" align="center" prop="price" />
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ label="数量"
|
|
|
|
|
+ align="center"
|
|
|
|
|
+ prop="count"
|
|
|
|
|
+ width="200px"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
|
+ <el-input-number
|
|
|
|
|
+ v-model="scope.row.count"
|
|
|
|
|
+ @change="handleGiftProductCountChange(scope.row)"
|
|
|
|
|
+ size="mini"
|
|
|
|
|
+ :min="1"
|
|
|
|
|
+ :max="scope.row.stock"
|
|
|
|
|
+ />
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ <el-table-column label="小计" align="center" prop="money" />
|
|
|
|
|
+ <el-table-column label="操作" align="center" width="100px">
|
|
|
|
|
+ <template slot-scope="scope">
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ size="mini"
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ icon="el-icon-delete"
|
|
|
|
|
+ @click="removeGiftProduct(scope.row)"
|
|
|
|
|
+ >删除</el-button>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
|
|
+ </el-table>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+
|
|
|
|
|
+ <el-form-item label="支付方式" prop="payType" required>
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="form.payType"
|
|
|
|
|
+ placeholder="请选择支付方式"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ size="small"
|
|
|
|
|
+ @change="handlePayTypeChange"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="item in payTypeOptions"
|
|
|
|
|
+ :key="item.dictValue"
|
|
|
|
|
+ :label="item.dictLabel"
|
|
|
|
|
+ :value="item.dictValue"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item
|
|
|
|
|
+ v-if="form.payType != 5"
|
|
|
|
|
+ label="收款记录"
|
|
|
|
|
+ prop="receiveMoneyId"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-select
|
|
|
|
|
+ v-model="form.receiveMoneyId"
|
|
|
|
|
+ placeholder="请选择收款记录"
|
|
|
|
|
+ @change="handleReceiptChange"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-option
|
|
|
|
|
+ v-for="item in receiptList"
|
|
|
|
|
+ :key="item.id"
|
|
|
|
|
+ :label="getReceiptLabel(item)"
|
|
|
|
|
+ :value="item.id"
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-select>
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item
|
|
|
|
|
+ v-if="form.payType != 5"
|
|
|
|
|
+ label="抵扣金额"
|
|
|
|
|
+ prop="reduceAmount"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-input v-model="form.reduceAmount" disabled />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ <el-form-item
|
|
|
|
|
+ v-if="form.payType == 5"
|
|
|
|
|
+ label="预付金额"
|
|
|
|
|
+ prop="prepaidAmount"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-input v-model="form.prepaidAmount" />
|
|
|
|
|
+ </el-form-item>
|
|
|
|
|
+ </el-form>
|
|
|
|
|
+
|
|
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
|
+ <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>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 赠品选择弹窗 -->
|
|
|
|
|
+ <el-dialog
|
|
|
|
|
+ :title="giftProduct.title"
|
|
|
|
|
+ :visible.sync="giftProduct.open"
|
|
|
|
|
+ width="1000px"
|
|
|
|
|
+ append-to-body
|
|
|
|
|
+ >
|
|
|
|
|
+ <product-select ref="GiftDetails" @selectProduct="selectGiftProduct" />
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+ </el-dialog>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+import { getCustomer, getCanUsePayReceiptList, getScrmPrescribeInfo, updateScrmPrescriptionDocumentSuccess, addBuyTimes } from "@/api/qw/companyCustomer";
|
|
|
|
|
+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 { getAddress } from "@/api/qw/companyCustomer";
|
|
|
|
|
+
|
|
|
|
|
+export default {
|
|
|
|
|
+ name: "CreateOrderDialog",
|
|
|
|
|
+ components: { productSelect },
|
|
|
|
|
+ props: {
|
|
|
|
|
+ visible: {
|
|
|
|
|
+ type: Boolean,
|
|
|
|
|
+ default: false,
|
|
|
|
|
+ },
|
|
|
|
|
+ customerRow: {
|
|
|
|
|
+ type: Object,
|
|
|
|
|
+ default: null,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ data() {
|
|
|
|
|
+ const validatePhone = (rule, value, callback) => {
|
|
|
|
|
+ if (!value) {
|
|
|
|
|
+ callback(new Error("电话号码不能为空"));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const phone = String(value).trim();
|
|
|
|
|
+ if (phone.length !== 11) {
|
|
|
|
|
+ callback(new Error("电话号码必须为11个字符"));
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ callback();
|
|
|
|
|
+ };
|
|
|
|
|
+ const validateAddress = (rule, value, callback) => {
|
|
|
|
|
+ if (!this.form.province || !this.form.city || !this.form.district) {
|
|
|
|
|
+ callback(new Error("请完整选择省/市/区"));
|
|
|
|
|
+ } else if (!this.form.detail) {
|
|
|
|
|
+ callback(new Error("请填写详细地址"));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ callback();
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+ return {
|
|
|
|
|
+ dialogVisible: false,
|
|
|
|
|
+ // 表单数据
|
|
|
|
|
+ form: {
|
|
|
|
|
+ realName: "",
|
|
|
|
|
+ phone: "",
|
|
|
|
|
+ provinceId: null,
|
|
|
|
|
+ cityId: null,
|
|
|
|
|
+ districtId: null,
|
|
|
|
|
+ province: "",
|
|
|
|
|
+ city: "",
|
|
|
|
|
+ district: "",
|
|
|
|
|
+ detail: "",
|
|
|
|
|
+ erpType: "", // ERP类型,与原制单一致
|
|
|
|
|
+ payType: "",
|
|
|
|
|
+ reduceAmount: 0,
|
|
|
|
|
+ receiveMoneyId: null,
|
|
|
|
|
+ prepaidAmount: null,
|
|
|
|
|
+ companyCustomerId: null,
|
|
|
|
|
+ },
|
|
|
|
|
+ rules: {
|
|
|
|
|
+ realName: [
|
|
|
|
|
+ { required: true, message: "收货人姓名不能为空", trigger: "blur" },
|
|
|
|
|
+ ],
|
|
|
|
|
+ phone: [
|
|
|
|
|
+ { required: true, message: "收货人电话不能为空", trigger: "blur" },
|
|
|
|
|
+ { validator: validatePhone, trigger: "blur" },
|
|
|
|
|
+ ],
|
|
|
|
|
+ detail: [
|
|
|
|
|
+ { required: true, message: "详细地址不能为空", trigger: "blur" },
|
|
|
|
|
+ ],
|
|
|
|
|
+ payType: [
|
|
|
|
|
+ { required: true, message: "请选择支付方式", trigger: "change" },
|
|
|
|
|
+ ],
|
|
|
|
|
+ address: [{ validator: validateAddress, trigger: "change" }],
|
|
|
|
|
+ },
|
|
|
|
|
+ // 与原制单完全相同的ERP列表
|
|
|
|
|
+ erpList: [
|
|
|
|
|
+ { dictLabel: "聚水潭", dictValue: "1" },
|
|
|
|
|
+ { dictLabel: "兔灵", dictValue: "2" },
|
|
|
|
|
+ { dictLabel: "京东云仓", dictValue: "3" },
|
|
|
|
|
+ ],
|
|
|
|
|
+ payTypeOptions: [],
|
|
|
|
|
+ receiptList: [],
|
|
|
|
|
+ kdnCitys: [],
|
|
|
|
|
+ kdnCityIds: null,
|
|
|
|
|
+ products: [],
|
|
|
|
|
+ giftProducts: [],
|
|
|
|
|
+ totalMoney: 0,
|
|
|
|
|
+ tablekey: false,
|
|
|
|
|
+ product: { open: false, title: "商品选择" },
|
|
|
|
|
+ giftProduct: { open: false, title: "赠品选择" },
|
|
|
|
|
+ scrmPrescribeInfo: null,
|
|
|
|
|
+ currentCustomerId: null,
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ visible(val) {
|
|
|
|
|
+ this.dialogVisible = val;
|
|
|
|
|
+ if (val && this.customerRow) {
|
|
|
|
|
+ this.initDialog();
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ dialogVisible(val) {
|
|
|
|
|
+ if (!val) {
|
|
|
|
|
+ this.$emit('update:visible', false);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ created() {
|
|
|
|
|
+ getDicts("sys_store_pay_type").then((response) => {
|
|
|
|
|
+ this.payTypeOptions = response.data || [];
|
|
|
|
|
+ });
|
|
|
|
|
+ getKdnCitys().then((res) => {
|
|
|
|
|
+ this.kdnCitys = res.data || [];
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ initDialog() {
|
|
|
|
|
+ const row = this.customerRow;
|
|
|
|
|
+ if (!row) return;
|
|
|
|
|
+ this.currentCustomerId = row.id;
|
|
|
|
|
+ this.form.realName = row.customerName || '';
|
|
|
|
|
+ this.form.phone = row.phone || '';
|
|
|
|
|
+ this.form.companyCustomerId = row.id;
|
|
|
|
|
+ // 若row无电话,可调用接口获取(但一般已有)
|
|
|
|
|
+ if (!this.form.phone) {
|
|
|
|
|
+ getCustomer(row.id).then(res => {
|
|
|
|
|
+ if (res.data && res.data.phone) {
|
|
|
|
|
+ this.form.phone = res.data.phone;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ if (row.address) {
|
|
|
|
|
+ this.sAddress(row);
|
|
|
|
|
+ }
|
|
|
|
|
+ this.fetchReceiptList();
|
|
|
|
|
+ getScrmPrescribeInfo(row.id).then((response) => {
|
|
|
|
|
+ if (response.code === 200 && response.data) {
|
|
|
|
|
+ this.scrmPrescribeInfo = response.data;
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(() => {});
|
|
|
|
|
+ this.products = [];
|
|
|
|
|
+ this.giftProducts = [];
|
|
|
|
|
+ this.totalMoney = 0;
|
|
|
|
|
+ this.form.erpType = '';
|
|
|
|
|
+ this.form.payType = '';
|
|
|
|
|
+ this.form.reduceAmount = 0;
|
|
|
|
|
+ this.form.receiveMoneyId = null;
|
|
|
|
|
+ this.form.prepaidAmount = null;
|
|
|
|
|
+ this.kdnCityIds = null;
|
|
|
|
|
+ this.form.detail = '';
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ sAddress(row) {
|
|
|
|
|
+ getAddress(row.address).then((response) => {
|
|
|
|
|
+ const addressJson = response.data;
|
|
|
|
|
+ if (!addressJson || !addressJson.data || !addressJson.data.provinceName) {
|
|
|
|
|
+ this.$message.error("地址解析失败:未找到有效的省市区信息");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.form.province = addressJson.data.provinceName;
|
|
|
|
|
+ this.form.city = addressJson.data.cityName;
|
|
|
|
|
+ this.form.district = addressJson.data.expAreaName;
|
|
|
|
|
+ this.form.detail = (addressJson.data.streetName || '') + (addressJson.data.address || '');
|
|
|
|
|
+
|
|
|
|
|
+ const province = this.kdnCitys.find(o => o.label === addressJson.data.provinceName);
|
|
|
|
|
+ if (!province) {
|
|
|
|
|
+ this.$message.error(`未找到省份:${addressJson.data.provinceName}`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const city = province.children.find(o => o.label === addressJson.data.cityName);
|
|
|
|
|
+ if (!city) {
|
|
|
|
|
+ this.$message.error(`未找到城市:${addressJson.data.cityName}`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const district = city.children.find(o => o.label === addressJson.data.expAreaName);
|
|
|
|
|
+ if (!district) {
|
|
|
|
|
+ this.$message.error(`未找到区县:${addressJson.data.expAreaName}`);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ this.form.provinceId = province.value;
|
|
|
|
|
+ this.form.cityId = city.value;
|
|
|
|
|
+ this.form.districtId = district.value;
|
|
|
|
|
+ this.kdnCityIds = [province.value, city.value, district.value];
|
|
|
|
|
+ }).catch((error) => {
|
|
|
|
|
+ console.error("地址解析接口错误:", error);
|
|
|
|
|
+ this.$message.error(error?.msg || error?.message || "地址智能识别失败,请手动选择");
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handleKdnCityChange(value) {
|
|
|
|
|
+ const nodes = this.$refs.citySelect.getCheckedNodes();
|
|
|
|
|
+ this.kdnCityIds = value.toString();
|
|
|
|
|
+ if (nodes && nodes.length > 0) {
|
|
|
|
|
+ const selectedNode = nodes[0];
|
|
|
|
|
+ if (selectedNode.pathValues && selectedNode.pathValues.length >= 3) {
|
|
|
|
|
+ this.form.provinceId = selectedNode.pathValues[0];
|
|
|
|
|
+ this.form.cityId = selectedNode.pathValues[1];
|
|
|
|
|
+ this.form.districtId = selectedNode.pathValues[2];
|
|
|
|
|
+ }
|
|
|
|
|
+ if (selectedNode.pathLabels && selectedNode.pathLabels.length >= 3) {
|
|
|
|
|
+ this.form.province = selectedNode.pathLabels[0];
|
|
|
|
|
+ this.form.city = selectedNode.pathLabels[1];
|
|
|
|
|
+ this.form.district = selectedNode.pathLabels[2];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ fetchReceiptList() {
|
|
|
|
|
+ getCanUsePayReceiptList().then((res) => {
|
|
|
|
|
+ if (res.code === 200) {
|
|
|
|
|
+ this.receiptList = res.data || [];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.receiptList = [];
|
|
|
|
|
+ this.$message.error(res.msg || "获取收款记录失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ this.receiptList = [];
|
|
|
|
|
+ this.$message.error("获取收款记录失败,请稍后重试");
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ getReceiptLabel(item) {
|
|
|
|
|
+ if (!item.saleTime) return `无时间 - ${item.totalFee}元`;
|
|
|
|
|
+ const date = new Date(item.saleTime);
|
|
|
|
|
+ if (isNaN(date.getTime())) return `无效时间 - ${item.totalFee}元`;
|
|
|
|
|
+ const year = date.getFullYear();
|
|
|
|
|
+ const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
|
|
|
+ const day = String(date.getDate()).padStart(2, "0");
|
|
|
|
|
+ const hours = String(date.getHours()).padStart(2, "0");
|
|
|
|
|
+ const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
|
|
|
+ const seconds = String(date.getSeconds()).padStart(2, "0");
|
|
|
|
|
+ return `${year}-${month}-${day} ${hours}:${minutes}:${seconds} - ${item.totalFee}元`;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handleReceiptChange(selectedId) {
|
|
|
|
|
+ const selected = this.receiptList.find((item) => item.id === selectedId);
|
|
|
|
|
+ if (selected) {
|
|
|
|
|
+ this.form.reduceAmount = selected.totalFee;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.form.reduceAmount = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handlePayTypeChange(val) {
|
|
|
|
|
+ this.form.receiveMoneyId = null;
|
|
|
|
|
+ this.form.reduceAmount = null;
|
|
|
|
|
+ if (val != 5) {
|
|
|
|
|
+ this.form.prepaidAmount = null;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.form.reduceAmount = null;
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ changeErp() {
|
|
|
|
|
+ this.products = [];
|
|
|
|
|
+ this.giftProducts = [];
|
|
|
|
|
+ this.totalMoney = 0;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handleAddProduct() {
|
|
|
|
|
+ if (!this.form.erpType) {
|
|
|
|
|
+ this.$message.warning("请先选择ERP类型");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ if (this.$refs.Details) {
|
|
|
|
|
+ this.$refs.Details.getDetails(this.form.erpType, 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, 1);
|
|
|
|
|
+ this.product.open = true;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handleAddGiftProduct() {
|
|
|
|
|
+ if (!this.form.erpType) {
|
|
|
|
|
+ this.$message.warning("请先选择ERP类型");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ if (this.$refs.GiftDetails) {
|
|
|
|
|
+ this.$refs.GiftDetails.getDetails(this.form.erpType, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, 1);
|
|
|
|
|
+ this.giftProduct.open = true;
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ selectProduct(row) {
|
|
|
|
|
+ for (let i = 0; i < this.products.length; i++) {
|
|
|
|
|
+ if (this.products[i].id === row.id) return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const newRow = { ...row, count: 1, money: row.price };
|
|
|
|
|
+ this.products.push(newRow);
|
|
|
|
|
+ this.$message.success("商品 " + row.productName + " 添加成功");
|
|
|
|
|
+ this.computeTotalMoney();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ selectGiftProduct(row) {
|
|
|
|
|
+ for (let i = 0; i < this.giftProducts.length; i++) {
|
|
|
|
|
+ if (this.giftProducts[i].id === row.id) return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const newRow = { ...row, count: 1, money: row.price };
|
|
|
|
|
+ this.giftProducts.push(newRow);
|
|
|
|
|
+ this.$message.success("赠品 " + row.productName + " 添加成功");
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ removeProduct(row) {
|
|
|
|
|
+ const index = this.products.findIndex((item) => item.id === row.id);
|
|
|
|
|
+ if (index !== -1) this.products.splice(index, 1);
|
|
|
|
|
+ this.computeTotalMoney();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ removeGiftProduct(row) {
|
|
|
|
|
+ const index = this.giftProducts.findIndex((item) => item.id === row.id);
|
|
|
|
|
+ if (index !== -1) this.giftProducts.splice(index, 1);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handleProductCountChange(row) {
|
|
|
|
|
+ this.tablekey = !this.tablekey;
|
|
|
|
|
+ row.money = row.count * row.price;
|
|
|
|
|
+ this.computeTotalMoney();
|
|
|
|
|
+ this.$forceUpdate();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handleGiftProductCountChange(row) {
|
|
|
|
|
+ row.money = row.count * row.price;
|
|
|
|
|
+ this.$forceUpdate();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ computeTotalMoney() {
|
|
|
|
|
+ this.totalMoney = 0;
|
|
|
|
|
+ this.products.forEach((item) => {
|
|
|
|
|
+ this.totalMoney += item.money || 0;
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ submitForm() {
|
|
|
|
|
+ this.$refs.form.validate((valid) => {
|
|
|
|
|
+ if (!this.form.province || !this.form.city || !this.form.district) {
|
|
|
|
|
+ this.$message.error("请完整选择省/市/区");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.products.length === 0) {
|
|
|
|
|
+ this.$message.error("请至少添加一个商品");
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (valid) {
|
|
|
|
|
+ const params = {
|
|
|
|
|
+ ...this.form,
|
|
|
|
|
+ products: this.products,
|
|
|
|
|
+ giftProducts: this.giftProducts,
|
|
|
|
|
+ totalAmount: this.totalMoney,
|
|
|
|
|
+ };
|
|
|
|
|
+ createUserOrder(params)
|
|
|
|
|
+ .then((response) => {
|
|
|
|
|
+ if (response.code === 200) {
|
|
|
|
|
+ const order = response.order;
|
|
|
|
|
+ this.$message.success("订单创建成功");
|
|
|
|
|
+ this.dialogVisible = false;
|
|
|
|
|
+ this.$emit('success');
|
|
|
|
|
+ if (this.currentCustomerId) {
|
|
|
|
|
+ addBuyTimes(this.currentCustomerId).catch(() => {});
|
|
|
|
|
+ updateScrmPrescriptionDocumentSuccess(this.currentCustomerId).catch(() => {});
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
|
+ this.$message.error(err.message || "创建订单失败");
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ handleClose() {
|
|
|
|
|
+ this.dialogVisible = false;
|
|
|
|
|
+ this.resetForm();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ resetForm() {
|
|
|
|
|
+ this.form = {
|
|
|
|
|
+ realName: "",
|
|
|
|
|
+ phone: "",
|
|
|
|
|
+ provinceId: null,
|
|
|
|
|
+ cityId: null,
|
|
|
|
|
+ districtId: null,
|
|
|
|
|
+ province: "",
|
|
|
|
|
+ city: "",
|
|
|
|
|
+ district: "",
|
|
|
|
|
+ detail: "",
|
|
|
|
|
+ erpType: "",
|
|
|
|
|
+ payType: "",
|
|
|
|
|
+ reduceAmount: 0,
|
|
|
|
|
+ receiveMoneyId: null,
|
|
|
|
|
+ prepaidAmount: null,
|
|
|
|
|
+ companyCustomerId: null,
|
|
|
|
|
+ };
|
|
|
|
|
+ this.products = [];
|
|
|
|
|
+ this.giftProducts = [];
|
|
|
|
|
+ this.totalMoney = 0;
|
|
|
|
|
+ this.kdnCityIds = null;
|
|
|
|
|
+ this.scrmPrescribeInfo = null;
|
|
|
|
|
+ this.currentCustomerId = null;
|
|
|
|
|
+ this.$refs.form && this.$refs.form.clearValidate();
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 处方图片显示判断
|
|
|
|
|
+ shouldShowWesternImage(prescribeType) {
|
|
|
|
|
+ return prescribeType === 1 || prescribeType === 3;
|
|
|
|
|
+ },
|
|
|
|
|
+ shouldShowChineseImage(prescribeType) {
|
|
|
|
|
+ return prescribeType === 2 || prescribeType === 3;
|
|
|
|
|
+ },
|
|
|
|
|
+ getImageLayoutStyle(prescribeType) {
|
|
|
|
|
+ const showWestern = this.shouldShowWesternImage(prescribeType);
|
|
|
|
|
+ const showChinese = this.shouldShowChineseImage(prescribeType);
|
|
|
|
|
+ if ((showWestern && !showChinese) || (!showWestern && showChinese)) {
|
|
|
|
|
+ return {justifyContent: "flex-start"};
|
|
|
|
|
+ }
|
|
|
|
|
+ return {justifyContent: "space-between"};
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+};
|
|
|
|
|
+</script>
|
|
|
|
|
+
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+</style>
|