|
|
@@ -115,7 +115,7 @@
|
|
|
<dict-tag :options="statusOptions" :value="scope.row.status" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="100px">
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="240px">
|
|
|
<template slot-scope="scope">
|
|
|
<el-button
|
|
|
size="mini"
|
|
|
@@ -123,6 +123,27 @@
|
|
|
v-hasPermi="['store:externalOrder:query']"
|
|
|
@click="handleView(scope.row)"
|
|
|
>查看</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ v-hasPermi="['store:externalOrder:audit']"
|
|
|
+ @click="handleAudit(scope.row)"
|
|
|
+ v-if="scope.row.status == 1"
|
|
|
+ >审核</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ v-hasPermi="['store:externalOrder:approveOrder']"
|
|
|
+ @click="handleApprove(scope.row)"
|
|
|
+ v-if="scope.row.status == 3 && !scope.row.isApplyAudit"
|
|
|
+ >申请审核</el-button>
|
|
|
+ <el-button
|
|
|
+ size="mini"
|
|
|
+ type="text"
|
|
|
+ v-hasPermi="['store:externalOrder:cancel']"
|
|
|
+ @click="handleCancel(scope.row)"
|
|
|
+ v-if="scope.row.status != 4"
|
|
|
+ >取消订单</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -192,9 +213,9 @@
|
|
|
clearable
|
|
|
size="small"
|
|
|
style="width: 300px; margin-bottom: 10px;"
|
|
|
- @keyup.enter.native="getProductList"
|
|
|
+ @keyup.enter.native="handleProductSearch"
|
|
|
/>
|
|
|
- <el-button type="primary" size="small" style="margin-left: 10px;" @click="getProductList">搜索</el-button>
|
|
|
+ <el-button type="primary" size="small" style="margin-left: 10px;" @click="handleProductSearch">搜索</el-button>
|
|
|
<el-table border width="100%" style="margin-top:5px;" :data="productJson" @selection-change="handleProductSelectionChange">
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
<el-table-column label="商品图片" align="center" width="120">
|
|
|
@@ -206,13 +227,38 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="商品名称" show-overflow-tooltip align="center" prop="productName" />
|
|
|
- <el-table-column label="售价" align="center" prop="price" >
|
|
|
+ <el-table-column label="售价" align="center" prop="price" width="160">
|
|
|
<template slot-scope="scope">
|
|
|
- <span v-if="scope.row.price!=null">{{scope.row.price.toFixed(2)}}</span>
|
|
|
+ <el-input-number
|
|
|
+ v-model="productPrices[scope.row.productId]"
|
|
|
+ :min="0"
|
|
|
+ :precision="2"
|
|
|
+ :step="0.01"
|
|
|
+ size="mini"
|
|
|
+ @change="handleQuantityChange"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="数量" align="center" width="160">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input-number
|
|
|
+ v-model="productQuantities[scope.row.productId]"
|
|
|
+ :min="1"
|
|
|
+ :max="getProductMax(scope.row)"
|
|
|
+ size="mini"
|
|
|
+ style="width: 140px;"
|
|
|
+ @change="handleQuantityChange"
|
|
|
+ />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="库存" align="center" prop="stock" />
|
|
|
</el-table>
|
|
|
+ <pagination
|
|
|
+ v-show="productTotal > 0"
|
|
|
+ :total="productTotal"
|
|
|
+ :page.sync="productQueryParams.pageNum"
|
|
|
+ :limit.sync="productQueryParams.pageSize"
|
|
|
+ @pagination="getProductList"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="支付方式" prop="payType">
|
|
|
<el-select v-model="form.payType" placeholder="请选择支付方式" clearable size="small">
|
|
|
@@ -271,11 +317,56 @@
|
|
|
<el-dialog :title="userAddress.title" v-if="userAddress.open" :visible.sync="userAddress.open" width="800px" append-to-body>
|
|
|
<add-external-user-address ref="addExternalUserAddress" @addUserAddress="addUserAddress" />
|
|
|
</el-dialog>
|
|
|
+
|
|
|
+ <el-dialog title="申请审核" :visible.sync="approveOpen" width="600px" append-to-body :close-on-click-modal="false">
|
|
|
+ <el-form ref="approveForm" :model="approveForm" :rules="approveRules" label-width="120px">
|
|
|
+ <el-form-item label="审核类型" prop="auditType">
|
|
|
+ <el-radio-group v-model="approveForm.auditType">
|
|
|
+ <el-radio :label="1">申请改价</el-radio>
|
|
|
+ <el-radio :label="2">订单完成</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <template v-if="approveForm.auditType === 1">
|
|
|
+ <el-form-item label="原价格">
|
|
|
+ <el-input v-model="approveForm.oldTotalPrice" disabled style="width: 200px;" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="更改后总价" prop="newTotalPrice">
|
|
|
+ <el-input-number v-model="approveForm.newTotalPrice" :precision="2" :min="0" style="width: 200px;" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="更改后实收" prop="newPayPrice">
|
|
|
+ <el-input-number v-model="approveForm.newPayPrice" :precision="2" :min="0" style="width: 200px;" />
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ <el-form-item label="申请原因" prop="priceChangeReason">
|
|
|
+ <el-input v-model="approveForm.priceChangeReason" type="textarea" :rows="3" placeholder="请输入申请原因" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="凭证图片">
|
|
|
+ <el-upload
|
|
|
+ class="avatar-uploader"
|
|
|
+ :action="uploadUrl"
|
|
|
+ :headers="headers"
|
|
|
+ :show-file-list="false"
|
|
|
+ :on-success="handleUploadSuccess"
|
|
|
+ accept="image/*"
|
|
|
+ >
|
|
|
+ <img v-if="approveForm.voucherImages" :src="approveForm.voucherImages" style="max-width: 200px; max-height: 200px;">
|
|
|
+ <el-button v-else size="small" type="primary">点击上传</el-button>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="凭证说明">
|
|
|
+ <el-input v-model="approveForm.voucherRemark" type="textarea" :rows="2" placeholder="请输入凭证说明" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="approveOpen = false">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="submitApprove">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { listExternalOrder, createExternalOrder, getExternalOrder, exportExternalOrder } from "@/api/store/externalOrder";
|
|
|
+import { listExternalOrder, createExternalOrder, getExternalOrder, auditExternalOrder, cancelExternalOrder, approveExternalOrder, exportExternalOrder } from "@/api/store/externalOrder";
|
|
|
import { getCompanyList } from "@/api/company/company";
|
|
|
import { listUserAddress } from "@/api/store/userAddress";
|
|
|
import { listStoreProduct } from "@/api/store/storeProduct";
|
|
|
@@ -306,7 +397,13 @@ export default {
|
|
|
address: [],
|
|
|
addressloading: false,
|
|
|
productJson: [],
|
|
|
+ productTotal: 0,
|
|
|
productNameSearch: null,
|
|
|
+ productQueryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ productName: null
|
|
|
+ },
|
|
|
user: {
|
|
|
open: false,
|
|
|
title: "创建外部订单用户"
|
|
|
@@ -333,13 +430,43 @@ export default {
|
|
|
userId: null,
|
|
|
payType: null,
|
|
|
payMoney: null,
|
|
|
- productIds: []
|
|
|
+ products: []
|
|
|
},
|
|
|
+ productQuantities: {},
|
|
|
+ productPrices: {},
|
|
|
+ selectedProducts: [],
|
|
|
rules: {
|
|
|
addressId: [{ required: true, message: "请选择收货地址", trigger: "change" }],
|
|
|
payType: [{ required: true, message: "支付方式不能为空", trigger: "change" }],
|
|
|
payMoney: [{ required: true, message: "支付金额不能为空", trigger: "blur" }]
|
|
|
},
|
|
|
+ approveOpen: false,
|
|
|
+ approveForm: {
|
|
|
+ orderIds: [],
|
|
|
+ auditType: 1,
|
|
|
+ oldTotalPrice: null,
|
|
|
+ newTotalPrice: null,
|
|
|
+ newPayPrice: null,
|
|
|
+ priceChangeReason: null,
|
|
|
+ voucherImages: null,
|
|
|
+ voucherRemark: null
|
|
|
+ },
|
|
|
+ approveRules: {
|
|
|
+ auditType: [
|
|
|
+ { required: true, message: "请选择审核类型", trigger: "change" }
|
|
|
+ ],
|
|
|
+ newTotalPrice: [
|
|
|
+ { required: true, message: "请输入更改后总价", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ newPayPrice: [
|
|
|
+ { required: true, message: "请输入更改后实收", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ priceChangeReason: [
|
|
|
+ { required: true, message: "请输入申请原因", trigger: "blur" }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload",
|
|
|
+ headers: { Authorization: "Bearer " + this.$store.getters.token },
|
|
|
payTypeOptions: [],
|
|
|
statusOptions: [],
|
|
|
userStatusOptions: []
|
|
|
@@ -351,7 +478,7 @@ export default {
|
|
|
this.getDicts("sys_package_pay_type").then(response => {
|
|
|
this.payTypeOptions = response.data;
|
|
|
});
|
|
|
- this.getDicts("sys_order_status").then(response => {
|
|
|
+ this.getDicts("sys_externalOrder_status").then(response => {
|
|
|
this.statusOptions = response.data;
|
|
|
});
|
|
|
this.getDicts("sys_company_status").then(response => {
|
|
|
@@ -408,9 +535,16 @@ export default {
|
|
|
this.users = [];
|
|
|
this.address = [];
|
|
|
this.productJson = [];
|
|
|
+ this.productTotal = 0;
|
|
|
this.productNameSearch = null;
|
|
|
+ this.productQueryParams.pageNum = 1;
|
|
|
+ this.productQueryParams.productName = null;
|
|
|
+ this.productQuantities = {};
|
|
|
+ this.productPrices = {};
|
|
|
+ this.selectedProducts = [];
|
|
|
this.open = true;
|
|
|
this.title = "创建外部订单";
|
|
|
+ this.getProductList();
|
|
|
},
|
|
|
reset() {
|
|
|
this.form = {
|
|
|
@@ -418,8 +552,11 @@ export default {
|
|
|
userId: null,
|
|
|
payType: null,
|
|
|
payMoney: null,
|
|
|
- productIds: []
|
|
|
+ products: []
|
|
|
};
|
|
|
+ this.productQuantities = {};
|
|
|
+ this.productPrices = {};
|
|
|
+ this.selectedProducts = [];
|
|
|
this.resetForm("form");
|
|
|
},
|
|
|
cancel() {
|
|
|
@@ -481,18 +618,69 @@ export default {
|
|
|
this.addressloading = false;
|
|
|
});
|
|
|
},
|
|
|
+ handleProductSearch() {
|
|
|
+ this.productQueryParams.pageNum = 1;
|
|
|
+ this.productQueryParams.productName = this.productNameSearch;
|
|
|
+ this.getProductList();
|
|
|
+ },
|
|
|
getProductList() {
|
|
|
var data = {
|
|
|
- productName: this.productNameSearch,
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 100
|
|
|
+ pageNum: this.productQueryParams.pageNum,
|
|
|
+ pageSize: this.productQueryParams.pageSize,
|
|
|
+ productName: this.productNameSearch
|
|
|
};
|
|
|
listStoreProduct(data).then(response => {
|
|
|
- this.productJson = response.rows;
|
|
|
+ this.productJson = response.rows || [];
|
|
|
+ this.productJson.forEach(item => {
|
|
|
+ if (this.productPrices[item.productId] == null && item.price != null) {
|
|
|
+ this.$set(this.productPrices, item.productId, Number(item.price));
|
|
|
+ }
|
|
|
+ if (this.productQuantities[item.productId] == null) {
|
|
|
+ this.$set(this.productQuantities, item.productId, 1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.productTotal = response.total || 0;
|
|
|
});
|
|
|
},
|
|
|
+ getDisplayProductPrice(product) {
|
|
|
+ const customPrice = this.productPrices[product.productId];
|
|
|
+ if (customPrice !== undefined && customPrice !== null && customPrice !== "") {
|
|
|
+ return Number(customPrice);
|
|
|
+ }
|
|
|
+ return Number(product.price || 0);
|
|
|
+ },
|
|
|
+ getProductMax(product) {
|
|
|
+ const stock = Number(product.stock);
|
|
|
+ if (Number.isFinite(stock) && stock > 0) {
|
|
|
+ return stock;
|
|
|
+ }
|
|
|
+ return 999;
|
|
|
+ },
|
|
|
handleProductSelectionChange(selection) {
|
|
|
- this.form.productIds = selection.map(item => item.productId);
|
|
|
+ this.selectedProducts = selection;
|
|
|
+ // 初始化未设置数量的商品默认值为1
|
|
|
+ selection.forEach(item => {
|
|
|
+ if (this.productQuantities[item.productId] == null) {
|
|
|
+ this.$set(this.productQuantities, item.productId, 1);
|
|
|
+ }
|
|
|
+ if (this.productPrices[item.productId] == null) {
|
|
|
+ this.$set(this.productPrices, item.productId, this.getDisplayProductPrice(item));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.handleQuantityChange();
|
|
|
+ },
|
|
|
+ isProductSelected(productId) {
|
|
|
+ return this.selectedProducts.some(item => item.productId === productId);
|
|
|
+ },
|
|
|
+ handleQuantityChange() {
|
|
|
+ // 数量变化时自动计算总金额
|
|
|
+ let total = 0;
|
|
|
+ this.selectedProducts.forEach(item => {
|
|
|
+ const quantity = this.productQuantities[item.productId] || 1;
|
|
|
+ const price = this.getDisplayProductPrice(item);
|
|
|
+ total += price * quantity;
|
|
|
+ });
|
|
|
+ this.form.payMoney = total.toFixed(2);
|
|
|
},
|
|
|
submitForm() {
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
@@ -501,16 +689,22 @@ export default {
|
|
|
this.msgError("请选择会员");
|
|
|
return;
|
|
|
}
|
|
|
- if (this.form.productIds.length === 0) {
|
|
|
+ if (this.selectedProducts.length === 0) {
|
|
|
this.msgError("请选择至少一个商品");
|
|
|
return;
|
|
|
}
|
|
|
+ // 构建商品列表 [{productId, num}]
|
|
|
+ const products = this.selectedProducts.map(item => ({
|
|
|
+ productId: item.productId,
|
|
|
+ num: this.productQuantities[item.productId] || 1,
|
|
|
+ price: this.getDisplayProductPrice(item)
|
|
|
+ }));
|
|
|
var submitData = {
|
|
|
addressId: this.form.addressId,
|
|
|
userId: this.form.userId,
|
|
|
payType: this.form.payType,
|
|
|
payMoney: parseFloat(this.form.payMoney) || 0,
|
|
|
- productIds: this.form.productIds
|
|
|
+ products: products
|
|
|
};
|
|
|
createExternalOrder(submitData).then(response => {
|
|
|
if (response.code === 200) {
|
|
|
@@ -528,6 +722,75 @@ export default {
|
|
|
this.detailOpen = true;
|
|
|
});
|
|
|
},
|
|
|
+ handleAudit(row) {
|
|
|
+ this.$confirm("确认审核该订单?审核后订单将变为待发货状态", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ auditExternalOrder(row.orderId).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.msgSuccess("审核成功");
|
|
|
+ this.getList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleCancel(row) {
|
|
|
+ this.$confirm("确认取消该订单?取消后订单将变为已取消状态", "警告", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ cancelExternalOrder(row.orderId).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.msgSuccess("取消订单成功");
|
|
|
+ this.getList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleApprove(row) {
|
|
|
+ this.approveForm = {
|
|
|
+ orderIds: [row.orderId],
|
|
|
+ auditType: 1,
|
|
|
+ oldTotalPrice: row.payPrice,
|
|
|
+ newTotalPrice: null,
|
|
|
+ newPayPrice: null,
|
|
|
+ priceChangeReason: null,
|
|
|
+ voucherImages: null,
|
|
|
+ voucherRemark: null
|
|
|
+ };
|
|
|
+ this.approveOpen = true;
|
|
|
+ },
|
|
|
+ handleUploadSuccess(response) {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.approveForm.voucherImages = response.url;
|
|
|
+ this.msgSuccess("上传成功");
|
|
|
+ } else {
|
|
|
+ this.msgError(response.msg);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ submitApprove() {
|
|
|
+ this.$refs["approveForm"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ const data = {
|
|
|
+ orderIds: this.approveForm.orderIds,
|
|
|
+ auditType: this.approveForm.auditType,
|
|
|
+ newTotalPrice: this.approveForm.newTotalPrice,
|
|
|
+ newPayPrice: this.approveForm.newPayPrice,
|
|
|
+ priceChangeReason: this.approveForm.priceChangeReason,
|
|
|
+ voucherImages: this.approveForm.voucherImages,
|
|
|
+ voucherRemark: this.approveForm.voucherRemark
|
|
|
+ };
|
|
|
+ approveExternalOrder(data).then(response => {
|
|
|
+ this.msgSuccess("提交成功");
|
|
|
+ this.approveOpen = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
handleExport() {
|
|
|
const queryParams = this.queryParams;
|
|
|
this.$confirm("是否确认导出外部订单数据项?", "警告", {
|