|
|
@@ -0,0 +1,339 @@
|
|
|
+<template>
|
|
|
+ <el-dialog title="创建套餐包订单" :visible.sync="dialogVisible" width="1000px" append-to-body :close-on-click-modal="false" @close="handleClose">
|
|
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
|
|
+ <el-form-item label="收货信息" prop="addressId">
|
|
|
+ <el-row>
|
|
|
+ <el-col>
|
|
|
+ <el-button plain type="primary" icon="el-icon-plus" @click="handleAddUserAddress()">添加收货地址</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-radio-group v-model="form.addressId" style="width:100%">
|
|
|
+ <el-table border style="margin-top:5px;" v-loading="addressloading" :data="address">
|
|
|
+ <el-table-column label="ID" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-radio :label="scope.row.addressId"></el-radio>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="收货人姓名" align="center" prop="realName" />
|
|
|
+ <el-table-column label="收货人所在省" align="center" prop="province" />
|
|
|
+ <el-table-column label="收货人所在市" align="center" prop="city" />
|
|
|
+ <el-table-column label="收货人所在区" align="center" prop="district" />
|
|
|
+ <el-table-column label="收货人详细地址" align="center" prop="detail" />
|
|
|
+ </el-table>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="就诊人信息" prop="patientId">
|
|
|
+ <el-row>
|
|
|
+ <el-col>
|
|
|
+ <el-button plain type="primary" icon="el-icon-plus" @click="handleAddUserPatient()">添加就诊人</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-radio-group v-model="form.patientId" style="width:100%">
|
|
|
+ <el-table border style="margin-top:5px;" v-loading="patientLoading" :data="patientList">
|
|
|
+ <el-table-column label="ID" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-radio :label="scope.row.patientId"></el-radio>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="患者姓名" align="center" prop="patientName" />
|
|
|
+ <el-table-column label="身份证号" align="center" prop="idCard" width="170px"/>
|
|
|
+ <el-table-column label="出生年月" align="center" prop="birthday" width="180">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="性别" align="center" prop="sex">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <dict-tag :options="sexOptions" :value="scope.row.sex"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="手机号" align="center" prop="mobile" />
|
|
|
+ </el-table>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="套餐包" prop="packageId">
|
|
|
+ <el-select v-model="form.packageId" remote filterable reserve-keyword placeholder="套餐包" :remote-method="packageMethod" style="width: 300px;" @change="changePackage">
|
|
|
+ <el-option
|
|
|
+ v-for="dict in packageList"
|
|
|
+ :key="dict.packageId"
|
|
|
+ :label="dict.packageName"
|
|
|
+ :value="dict.packageId">
|
|
|
+ <span style="float: left ;margin-right: 20px;">{{ dict.packageName }}</span>
|
|
|
+ <span style="float: left">{{ dict.secondName }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-table border style="margin-top:5px;" :data="package">
|
|
|
+ <el-table-column label="套餐包名称" align="center" prop="packageName" />
|
|
|
+ <el-table-column label="别名" align="center" prop="secondName" />
|
|
|
+ <el-table-column label="类型" align="center" prop="packageType">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <dict-tag :options="packageTypeOptions" :value="scope.row.packageType"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="子类型" align="center" prop="packageSubType">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <dict-tag :options="packageSubTypeOptions" :value="scope.row.packageSubType"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="优惠券" prop="couponId">
|
|
|
+ <el-select v-model="form.couponId" placeholder="请选择优惠券" clearable style="width: 300px;" @change="handleCouponChange">
|
|
|
+ <el-option
|
|
|
+ v-for="item in couponList"
|
|
|
+ :key="item.couponId"
|
|
|
+ :label="item.title + ' - ' + item.price + '元'"
|
|
|
+ :value="item.couponId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="支付方式" prop="payType">
|
|
|
+ <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 && form.payType !== '1' && form.payType !== 1" label="实付金额" prop="payMoney">
|
|
|
+ <el-input-number v-model="form.payMoney" :precision="2" :min="0" placeholder="请输入实付金额" style="width: 300px;" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="form.payType && form.payType !== '1' && form.payType !== 1" label="应付金额" prop="payableAmount">
|
|
|
+ <el-input-number v-model="form.payableAmount" :precision="2" :min="0" placeholder="请输入应付金额" style="width: 300px;" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="form.payType && (form.payType === '1' || form.payType === 1)" label="实付金额" prop="payMoney">
|
|
|
+ <el-input-number v-model="form.payMoney" :precision="2" :min="0" placeholder="请输入实付金额" style="width: 300px;" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="订单备注" prop="orderRemark">
|
|
|
+ <el-input type="textarea" rows="2" v-model="form.orderRemark" placeholder="" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div v-if="shareLink" style="margin-top: 10px; padding: 10px; background: #f5f7fa; border-radius: 4px;">
|
|
|
+ <el-form label-width="120px">
|
|
|
+ <el-form-item label="分享链接">
|
|
|
+ <el-input v-model="shareLink" readonly style="width: 400px;">
|
|
|
+ <el-button slot="append" icon="el-icon-document-copy" @click="copyShareLink">复制</el-button>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitForm" :loading="submitLoading">分 享</el-button>
|
|
|
+ <el-button @click="handleClose">取 消</el-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-dialog :title="userAddress.title" v-if="userAddress.open" :visible.sync="userAddress.open" width="800px" append-to-body>
|
|
|
+ <add-user-address ref="addUserAddress" @addUserAddress="addUserAddress" />
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog :title="userPatient.title" v-if="userPatient.open" :visible.sync="userPatient.open" width="800px" append-to-body>
|
|
|
+ <add-patient ref="addPatient" @addUserPatient="addUserPatient" />
|
|
|
+ </el-dialog>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { listUserAddress } from "@/api/store/userAddress";
|
|
|
+import { listPatient } from "@/api/store/patient";
|
|
|
+import { packageList, sharePackageOrderLink } from "@/api/store/package";
|
|
|
+import { getUserCoupon } from "@/api/store/coupon";
|
|
|
+import addUserAddress from "@/views/store/components/addUserAddress";
|
|
|
+import addPatient from "@/views/store/components/addPatient";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "StorePackageOrderDialog",
|
|
|
+ components: { addUserAddress, addPatient },
|
|
|
+ props: {
|
|
|
+ userInfo: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({})
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ dialogVisible: false,
|
|
|
+ submitLoading: false,
|
|
|
+ shareLink: null,
|
|
|
+ form: {
|
|
|
+ addressId: null,
|
|
|
+ patientId: null,
|
|
|
+ packageId: null,
|
|
|
+ payType: null,
|
|
|
+ payMoney: null,
|
|
|
+ payableAmount: null,
|
|
|
+ orderRemark: null,
|
|
|
+ couponId: null
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ addressId: [{ required: true, message: "请选择收货地址", trigger: "change" }],
|
|
|
+ packageId: [{ required: true, message: "请选择套餐包", trigger: "change" }],
|
|
|
+ payType: [{ required: true, message: "请选择支付方式", trigger: "change" }]
|
|
|
+ },
|
|
|
+ address: [],
|
|
|
+ addressloading: false,
|
|
|
+ patientList: [],
|
|
|
+ patientLoading: false,
|
|
|
+ package: [],
|
|
|
+ packageList: [],
|
|
|
+ couponList: [],
|
|
|
+ payTypeOptions: [],
|
|
|
+ packageTypeOptions: [],
|
|
|
+ packageSubTypeOptions: [],
|
|
|
+ sexOptions: [],
|
|
|
+ userAddress: {
|
|
|
+ open: false,
|
|
|
+ title: "创建收货地址"
|
|
|
+ },
|
|
|
+ userPatient: {
|
|
|
+ open: false,
|
|
|
+ title: "创建就诊人"
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getDicts("sys_package_pay_type").then(response => {
|
|
|
+ this.payTypeOptions = response.data;
|
|
|
+ this.payTypeOptions.push({ dictValue: '4', dictLabel: '线下实付' });
|
|
|
+ });
|
|
|
+ this.getDicts("sys_package_type").then(response => {
|
|
|
+ this.packageTypeOptions = response.data;
|
|
|
+ });
|
|
|
+ this.getDicts("sys_package_sub_type").then(response => {
|
|
|
+ this.packageSubTypeOptions = response.data;
|
|
|
+ });
|
|
|
+ this.getDicts("sys_user_sex").then(response => {
|
|
|
+ this.sexOptions = response.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ init(userInfo) {
|
|
|
+ this.dialogVisible = true;
|
|
|
+ this.shareLink = null;
|
|
|
+ this.resetForm();
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.getAddressList(userInfo.userId);
|
|
|
+ this.getPatientList(userInfo.userId);
|
|
|
+ this.getCouponList(userInfo.userId);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ resetForm() {
|
|
|
+ this.form = {
|
|
|
+ addressId: null,
|
|
|
+ patientId: null,
|
|
|
+ packageId: null,
|
|
|
+ payType: null,
|
|
|
+ payMoney: null,
|
|
|
+ payableAmount: null,
|
|
|
+ orderRemark: null,
|
|
|
+ couponId: null
|
|
|
+ };
|
|
|
+ this.package = [];
|
|
|
+ if (this.$refs.form) {
|
|
|
+ this.$refs.form.resetFields();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handlePayTypeChange() {
|
|
|
+ this.form.payMoney = null;
|
|
|
+ this.form.payableAmount = null;
|
|
|
+ },
|
|
|
+ getAddressList(userId) {
|
|
|
+ var data = { userId: userId };
|
|
|
+ this.addressloading = true;
|
|
|
+ listUserAddress(data).then(response => {
|
|
|
+ this.address = response.rows;
|
|
|
+ this.addressloading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getPatientList(userId) {
|
|
|
+ var data = { userId: userId };
|
|
|
+ this.patientLoading = true;
|
|
|
+ listPatient(data).then(response => {
|
|
|
+ this.patientList = response.rows;
|
|
|
+ this.patientLoading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getCouponList(userId) {
|
|
|
+ getUserCoupon({ userId: userId, couponType: 5 }).then(response => {
|
|
|
+ this.couponList = response.rows || [];
|
|
|
+ });
|
|
|
+ },
|
|
|
+ packageMethod(query) {
|
|
|
+ if (query !== '') {
|
|
|
+ packageList(query).then(response => {
|
|
|
+ this.packageList = response.data || [];
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ changePackage(packageId) {
|
|
|
+ var item = this.packageList.find(p => p.packageId === packageId);
|
|
|
+ if (item) {
|
|
|
+ this.package = [item];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleCouponChange(couponId) {
|
|
|
+ console.log('Selected coupon:', couponId);
|
|
|
+ },
|
|
|
+ handleAddUserAddress() {
|
|
|
+ this.userAddress.open = true;
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$refs.addUserAddress.init(this.userInfo.userId);
|
|
|
+ }, 500);
|
|
|
+ },
|
|
|
+ addUserAddress() {
|
|
|
+ this.userAddress.open = false;
|
|
|
+ this.getAddressList(this.userInfo.userId);
|
|
|
+ },
|
|
|
+ handleAddUserPatient() {
|
|
|
+ this.userPatient.open = true;
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$refs.addPatient.init(this.userInfo.userId);
|
|
|
+ }, 500);
|
|
|
+ },
|
|
|
+ addUserPatient() {
|
|
|
+ this.userPatient.open = false;
|
|
|
+ this.getPatientList(this.userInfo.userId);
|
|
|
+ },
|
|
|
+ copyShareLink() {
|
|
|
+ if (!this.shareLink) return;
|
|
|
+ var input = document.createElement('input');
|
|
|
+ input.value = this.shareLink;
|
|
|
+ document.body.appendChild(input);
|
|
|
+ input.select();
|
|
|
+ document.execCommand('copy');
|
|
|
+ document.body.removeChild(input);
|
|
|
+ this.$message.success('链接已复制');
|
|
|
+ },
|
|
|
+ submitForm() {
|
|
|
+ this.$refs["form"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ var submitData = {
|
|
|
+ userId: this.userInfo.userId,
|
|
|
+ addressId: this.form.addressId,
|
|
|
+ patientId: this.form.patientId,
|
|
|
+ packageId: this.form.packageId,
|
|
|
+ payType: this.form.payType,
|
|
|
+ payMoney: this.form.payMoney,
|
|
|
+ payableAmount: this.form.payableAmount,
|
|
|
+ orderRemark: this.form.orderRemark,
|
|
|
+ couponId: this.form.couponId
|
|
|
+ };
|
|
|
+ this.submitLoading = true;
|
|
|
+ sharePackageOrderLink(submitData).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.shareLink = response.shareLink || (response.data && response.data.shareLink);
|
|
|
+ this.$emit("success");
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.submitLoading = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleClose() {
|
|
|
+ this.dialogVisible = false;
|
|
|
+ this.shareLink = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|