|
|
@@ -82,6 +82,17 @@
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+ <!-- 这里就是之前添加的ERP账号下拉框 -->
|
|
|
+ <el-form-item label="ERP" prop="loginAccount">
|
|
|
+ <el-select v-model="queryParams.loginAccount" placeholder="ERP账号" size="small" clearable>
|
|
|
+ <el-option
|
|
|
+ v-for="account in erpAccountList"
|
|
|
+ :key="account"
|
|
|
+ :label="account"
|
|
|
+ :value="account"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
@@ -100,7 +111,28 @@
|
|
|
v-hasPermi="['his:integralOrder:export']"
|
|
|
>导出</el-button>
|
|
|
</el-col>
|
|
|
+
|
|
|
<el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="info"
|
|
|
+ plain
|
|
|
+ icon="el-icon-upload2"
|
|
|
+ size="mini"
|
|
|
+ @click="handleImportStatus"
|
|
|
+ >导入订单状态</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-tooltip content="默认erp推送手机号" placement="top">
|
|
|
+ <el-button
|
|
|
+ type="warning"
|
|
|
+ plain
|
|
|
+ icon="el-icon-phone"
|
|
|
+ size="mini"
|
|
|
+ @click="handleErpPhone"
|
|
|
+ >推送手机号码</el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ </el-col>
|
|
|
+<el-col :span="1.5">
|
|
|
<el-button
|
|
|
type="info"
|
|
|
plain
|
|
|
@@ -108,9 +140,29 @@
|
|
|
size="mini"
|
|
|
@click="handleImport"
|
|
|
v-hasPermi="['his:integralOrder:exportDeliver']"
|
|
|
+ v-show="actName === '6'||actName === '1'"
|
|
|
>导入发货</el-button>
|
|
|
</el-col>
|
|
|
-
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="success"
|
|
|
+ plain
|
|
|
+ icon="el-icon-s-operation"
|
|
|
+ size="mini"
|
|
|
+ @click="handleDataSort"
|
|
|
+ v-show="actName === '6'"
|
|
|
+ >数据分拣</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ plain
|
|
|
+ icon="el-icon-plus"
|
|
|
+ size="mini"
|
|
|
+ @click="handleCreateErp"
|
|
|
+ v-show="actName === '6'"
|
|
|
+ >创建ERP</el-button>
|
|
|
+ </el-col>
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
</el-row>
|
|
|
<el-tabs type="card" v-model="actName" @tab-click="handleClickX">
|
|
|
@@ -119,12 +171,14 @@
|
|
|
</el-tabs>
|
|
|
<el-table v-loading="loading" border :data="integralOrderList" @selection-change="handleSelectionChange">
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
+ <el-table-column label="ERP账号" align="center" prop="loginAccount" />
|
|
|
+ <el-table-column label="ERP电话" align="center" prop="erpPhone" />
|
|
|
<el-table-column label="订单编号" align="center" prop="orderCode" />
|
|
|
<el-table-column label="用户名称" align="center" prop="userName" />
|
|
|
<el-table-column label="用户电话" align="center" prop="userPhone" />
|
|
|
<el-table-column label="用户地址" align="center" prop="userAddress" show-overflow-tooltip />
|
|
|
<el-table-column label="支付积分" align="center" prop="integral" />
|
|
|
- <el-table-column label="支付金额" align="center" prop="cash" />
|
|
|
+ <el-table-column label="支付金额" align="center" prop="payMoney" />
|
|
|
<el-table-column label="状态" align="center" prop="status">
|
|
|
<template slot-scope="scope">
|
|
|
<dict-tag :options="statusOptions" :value="scope.row.status"/>
|
|
|
@@ -259,16 +313,170 @@
|
|
|
<el-button @click="upload.open = false">取 消</el-button>
|
|
|
</div>
|
|
|
</el-dialog>
|
|
|
+ <!-- 数据分拣弹窗 -->
|
|
|
+ <el-dialog :title="erpAccountDialog.title" :visible.sync="erpAccountDialog.open" width="600px" append-to-body>
|
|
|
+ <div v-loading="erpAccountDialog.loading">
|
|
|
+ <el-form :model="erpAccountForm" label-width="100px">
|
|
|
+ <el-form-item label="ERP账户" required>
|
|
|
+ <el-select
|
|
|
+ v-model="erpAccountForm.selectedAccount"
|
|
|
+ placeholder="请选择ERP账户"
|
|
|
+ style="width: 100%"
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="account in erpAccountList"
|
|
|
+ :key="account"
|
|
|
+ :label="account"
|
|
|
+ :value="account"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="推送手机号">
|
|
|
+ <el-select
|
|
|
+ v-model="erpAccountForm.selectedPhones"
|
|
|
+ multiple
|
|
|
+ placeholder="请选择推送手机号,不填默认订单用户电话"
|
|
|
+ style="width: 100%"
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="phone in phoneList"
|
|
|
+ :key="phone.phone"
|
|
|
+ :label="phone.phone"
|
|
|
+ :value="phone.phone"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <!-- 订单统计信息 -->
|
|
|
+ <div class="order-summary" v-if="orderSummary">
|
|
|
+ <el-divider content-position="left">订单统计</el-divider>
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="8">
|
|
|
+ <div class="summary-item">
|
|
|
+ <span class="label">选中订单数:</span>
|
|
|
+ <span class="value">{{ orderSummary.selectedCount }}</span>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <div class="summary-item">
|
|
|
+ <span class="label">总金额:</span>
|
|
|
+ <span class="value">¥{{ orderSummary.totalAmount }}</span>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <div class="summary-item">
|
|
|
+ <span class="label">查询条件订单:</span>
|
|
|
+ <span class="value">{{ orderSummary.queryCount }}</span>
|
|
|
+ </div>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="cancelErpAccountDialog">取 消</el-button>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ @click="confirmCreateErpOrder"
|
|
|
+ :disabled="!erpAccountForm.selectedAccount"
|
|
|
+ :loading="erpAccountDialog.submitting"
|
|
|
+ >确认</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ <!-- 推送手机号码管理弹窗 -->
|
|
|
+ <el-dialog :title="erpPhone.title" :visible.sync="erpPhone.open" width="600px" append-to-body>
|
|
|
+ <div style="margin-bottom: 20px;">
|
|
|
+ <el-button type="primary" size="small" @click="handleAddPhone">新增手机号</el-button>
|
|
|
+ </div>
|
|
|
+ <el-table :data="phoneList" border style="width: 100%">
|
|
|
+ <el-table-column prop="phone" label="手机号" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-input
|
|
|
+ v-if="scope.row.editing"
|
|
|
+ v-model="scope.row.phone"
|
|
|
+ placeholder="请输入手机号"
|
|
|
+ @blur="validatePhone(scope.row)"
|
|
|
+ @keyup.enter.native="handleSavePhone(scope.$index)"
|
|
|
+ />
|
|
|
+ <span v-else>{{ scope.row.phone }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" width="300">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button
|
|
|
+ v-if="scope.row.editing"
|
|
|
+ type="success"
|
|
|
+ size="mini"
|
|
|
+ @click="handleSavePhone(scope.$index)"
|
|
|
+ >保存</el-button>
|
|
|
+ <el-button
|
|
|
+ v-if="scope.row.editing"
|
|
|
+ type="info"
|
|
|
+ size="mini"
|
|
|
+ @click="handleCancelEdit(scope.$index)"
|
|
|
+ >取消</el-button>
|
|
|
+ <el-button
|
|
|
+ v-if="!scope.row.editing"
|
|
|
+ type="primary"
|
|
|
+ size="mini"
|
|
|
+ @click="handleEditPhone(scope.$index)"
|
|
|
+ >修改</el-button>
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ size="mini"
|
|
|
+ @click="handleDeletePhone(scope.$index)"
|
|
|
+ >删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="handleSavePhoneList">确 定</el-button>
|
|
|
+ <el-button @click="handleCancelPhoneDialog">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <el-dialog :title="uploadStatus.title" :visible.sync="uploadStatus.open" width="400px" append-to-body>
|
|
|
+ <el-upload
|
|
|
+ ref="uploadStatus"
|
|
|
+ :limit="1"
|
|
|
+ accept=".xlsx, .xls"
|
|
|
+ :headers="uploadStatus.headers"
|
|
|
+ :action="uploadStatus.url + '?updateSupport=' + upload.updateSupport"
|
|
|
+ :disabled="uploadStatus.isUploading"
|
|
|
+ :on-progress="handleFileUploadProgressOrder"
|
|
|
+ :on-success="handleFileSuccessOrder"
|
|
|
+ :auto-upload="false"
|
|
|
+ drag
|
|
|
+ >
|
|
|
+ <i class="el-icon-upload"></i>
|
|
|
+ <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
+ <div class="el-upload__tip text-center" slot="tip">
|
|
|
+ <div class="el-upload__tip" slot="tip">
|
|
|
+ </div>
|
|
|
+ <span>仅允许导入xls、xlsx格式文件。</span>
|
|
|
+ <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importUpdateOrderTemplate">下载模板</el-link>
|
|
|
+ </div>
|
|
|
+ </el-upload>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitOrderStatusFileForm">确 定</el-button>
|
|
|
+ <el-button @click="uploadStatus.open = false">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import {importTemplate, listIntegralOrder,importExpressTemplate, getIntegralOrder, delIntegralOrder, addIntegralOrder, updateIntegralOrder, exportIntegralOrder,cancelOrder } from "@/api/his/integralOrder";
|
|
|
+import {importTemplate,batchSetErpOrder,batchCreateErpOrder,listIntegralOrder,getIntegralTemplate, getIntegralOrder, delIntegralOrder, addIntegralOrder, updateIntegralOrder, exportIntegralOrder,cancelOrder } from "@/api/his/integralOrder";
|
|
|
import integralOrderDetails from '../../components/his/integralOrderDetails.vue';
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
import {getCompanyList} from "@/api/company/company";
|
|
|
import {getAllUserlist} from "@/api/company/companyUser";
|
|
|
import {getQwUserInfo} from "@/api/qw/qwUser";
|
|
|
+import {getErpAccount } from "@/api/his/storeOrder";
|
|
|
+import {queryErpPhone, saveErpPhone} from "@/api/his/storeOrder";
|
|
|
|
|
|
export default {
|
|
|
name: "IntegralOrder",
|
|
|
@@ -331,6 +539,7 @@ export default {
|
|
|
companyUserId:null,
|
|
|
qwUserId:null,
|
|
|
companyId:null,
|
|
|
+ loginAccount: null // 添加ERP账号筛选字段
|
|
|
},
|
|
|
createTime:null,
|
|
|
qwCompanyList:[],
|
|
|
@@ -346,7 +555,44 @@ export default {
|
|
|
status: [
|
|
|
{ required: true, message: "1:待发货;2:待收货;3:已完成不能为空", trigger: "change" }
|
|
|
],
|
|
|
- }
|
|
|
+ },
|
|
|
+ dataSortOpen: false, // 数据分拣弹窗显示控制
|
|
|
+ erpAccountDialog: {
|
|
|
+ open: false,
|
|
|
+ loading: false,
|
|
|
+ submitting: false,
|
|
|
+ title: "数据分拣"
|
|
|
+ },
|
|
|
+ erpAccountForm: {
|
|
|
+ selectedAccount: null,
|
|
|
+ selectedPhones: [] // 添加推送手机号字段
|
|
|
+ },
|
|
|
+ erpAccountList: [],
|
|
|
+ orderSummary: {
|
|
|
+ selectedCount: 0,
|
|
|
+ totalAmount: 0,
|
|
|
+ queryCount: 0
|
|
|
+ },
|
|
|
+ erpPhone: {
|
|
|
+ open: false,
|
|
|
+ title: "设置推送手机号"
|
|
|
+ },
|
|
|
+ phoneList: [], // 手机号列表
|
|
|
+ originalPhoneList: [], // 原始手机号列表,用于取消时恢复
|
|
|
+ uploadStatus: {
|
|
|
+ // 是否显示弹出层
|
|
|
+ open: false,
|
|
|
+ // 弹出层标题
|
|
|
+ title: "",
|
|
|
+ // 是否禁用上传
|
|
|
+ isUploading: false,
|
|
|
+ // 是否更新已经存在的用户数据
|
|
|
+ updateSupport: 0,
|
|
|
+ // 设置上传的请求头部
|
|
|
+ headers: { Authorization: "Bearer " + getToken() },
|
|
|
+ // 上传的地址
|
|
|
+ url: process.env.VUE_APP_BASE_API + "/his/integralOrder/importOrderStatusData"
|
|
|
+ },
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
@@ -360,8 +606,29 @@ export default {
|
|
|
getCompanyList().then(response => {
|
|
|
this.qwCompanyList = response.data;
|
|
|
});
|
|
|
+ this.loadErpAccountData();
|
|
|
},
|
|
|
methods: {
|
|
|
+ handleImportStatus() {
|
|
|
+ this.uploadStatus.title = "导入";
|
|
|
+ this.uploadStatus.open = true;
|
|
|
+ },
|
|
|
+ handleFileUploadProgressOrder(event, file, fileList) {
|
|
|
+ this.uploadStatus.isUploading = true;
|
|
|
+ },
|
|
|
+ // 文件上传成功处理
|
|
|
+ handleFileSuccessOrder(response, file, fileList) {
|
|
|
+ this.uploadStatus.open = false;
|
|
|
+ this.uploadStatus.isUploading = false;
|
|
|
+ this.$refs.uploadStatus.clearFiles();
|
|
|
+ this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ importUpdateOrderTemplate(){
|
|
|
+ getIntegralTemplate().then(response => {
|
|
|
+ this.download(response.msg);
|
|
|
+ });
|
|
|
+ },
|
|
|
//取消订单
|
|
|
cancelOrder(orderCode){
|
|
|
this.$confirm('确定取消此订单?', '提示', {
|
|
|
@@ -565,7 +832,267 @@ export default {
|
|
|
this.qwUserList=response.data;
|
|
|
})
|
|
|
}
|
|
|
- }
|
|
|
+ },
|
|
|
+ // 数据分拣按钮点击事件
|
|
|
+ handleDataSort() {
|
|
|
+ this.erpAccountDialog.open = true;
|
|
|
+ this.erpAccountDialog.title = "数据分拣";
|
|
|
+ this.getErpPhoneList(); // 加载手机号列表
|
|
|
+ this.updateOrderSummary();
|
|
|
+ },
|
|
|
+
|
|
|
+ // 加载ERP账户数据
|
|
|
+ async loadErpAccountData() {
|
|
|
+ try {
|
|
|
+ const response = await getErpAccount();
|
|
|
+ this.erpAccountList = response.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载ERP账户失败:', error);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 更新订单统计
|
|
|
+ updateOrderSummary() {
|
|
|
+ // 如果没有选择任何数据,则使用查询出来的所有数据
|
|
|
+ if (this.ids.length === 0) {
|
|
|
+ this.orderSummary.selectedCount = this.total;
|
|
|
+ this.orderSummary.queryCount = this.total;
|
|
|
+ } else {
|
|
|
+ // 如果选择了数据,则使用选中的数据
|
|
|
+ this.orderSummary.selectedCount = this.ids.length;
|
|
|
+ this.orderSummary.queryCount = this.total;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算总金额(这里需要根据实际数据结构调整)
|
|
|
+ this.calculateTotalAmount();
|
|
|
+ },
|
|
|
+ // 计算总金额
|
|
|
+ calculateTotalAmount() {
|
|
|
+ let totalAmount = 0;
|
|
|
+
|
|
|
+ if (this.ids.length === 0) {
|
|
|
+ // 使用所有查询数据计算金额
|
|
|
+ this.integralOrderList.forEach(order => {
|
|
|
+ totalAmount += parseFloat(order.payMoney || 0);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 使用选中的数据计算金额
|
|
|
+ const selectedOrders = this.integralOrderList.filter(order =>
|
|
|
+ this.ids.includes(order.orderId)
|
|
|
+ );
|
|
|
+ selectedOrders.forEach(order => {
|
|
|
+ totalAmount += parseFloat(order.payMoney || 0);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ this.orderSummary.totalAmount = totalAmount.toFixed(2);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 取消ERP账户对话框
|
|
|
+ cancelErpAccountDialog() {
|
|
|
+ this.erpAccountDialog.open = false;
|
|
|
+ this.erpAccountForm.selectedAccount = null;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 确认创建ERP订单
|
|
|
+ async confirmCreateErpOrder() {
|
|
|
+ // 收集选中的orderId
|
|
|
+ let selectedOrderIds = [];
|
|
|
+
|
|
|
+ if (this.ids.length === 0) {
|
|
|
+ // 如果没有选择任何数据,使用查询出来的所有数据的orderId
|
|
|
+ selectedOrderIds = this.integralOrderList.map(order => order.orderId);
|
|
|
+ } else {
|
|
|
+ // 如果选择了数据,使用选中的orderId
|
|
|
+ selectedOrderIds = this.ids;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 收集ERP账户和手机号
|
|
|
+ const selectedErpAccount = this.erpAccountForm.selectedAccount;
|
|
|
+ const selectedPhones = this.erpAccountForm.selectedPhones;
|
|
|
+
|
|
|
+ // 准备请求参数
|
|
|
+ const params = {
|
|
|
+ orderIds: selectedOrderIds,
|
|
|
+ loginAccount: selectedErpAccount,
|
|
|
+ erpPhones: selectedPhones // 添加手机号参数
|
|
|
+ };
|
|
|
+ try {
|
|
|
+ this.erpAccountDialog.submitting = true;
|
|
|
+
|
|
|
+ // 根据弹窗标题判断是数据分拣还是创建ERP
|
|
|
+ if (this.erpAccountDialog.title === "数据分拣") {
|
|
|
+ // 调用数据分拣接口
|
|
|
+ const response = await batchSetErpOrder(params);
|
|
|
+ this.$message.success('数据分拣成功');
|
|
|
+ } else if (this.erpAccountDialog.title === "创建ERP") {
|
|
|
+ // 调用创建ERP接口
|
|
|
+ const response = await batchCreateErpOrder(params);
|
|
|
+ // console.log("参数:",params)
|
|
|
+ this.$message.success('创建ERP成功');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 关闭弹窗
|
|
|
+ this.cancelErpAccountDialog();
|
|
|
+
|
|
|
+ // 刷新列表
|
|
|
+ this.getList();
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ console.error('操作失败:', error);
|
|
|
+ this.$message.error('操作失败');
|
|
|
+ } finally {
|
|
|
+ this.erpAccountDialog.submitting = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleCreateErp() {
|
|
|
+ this.erpAccountDialog.open = true;
|
|
|
+ this.erpAccountDialog.title = "创建ERP";
|
|
|
+ this.getErpPhoneList(); // 加载手机号列表
|
|
|
+ this.updateOrderSummary();
|
|
|
+ },
|
|
|
+ // 获取ERP手机号列表
|
|
|
+ getErpPhoneList() {
|
|
|
+ queryErpPhone().then(response => {
|
|
|
+ if (response.data && response.data != null && response.data.length > 0) {
|
|
|
+ const phones = response.data.filter(phone => phone.trim());
|
|
|
+ this.phoneList = phones.map(phone => ({
|
|
|
+ phone: phone.trim(),
|
|
|
+ editing: false,
|
|
|
+ originalPhone: phone.trim()
|
|
|
+ }));
|
|
|
+ } else {
|
|
|
+ this.phoneList = [];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 取消ERP账户对话框
|
|
|
+ cancelErpAccountDialog() {
|
|
|
+ this.erpAccountDialog.open = false;
|
|
|
+ this.erpAccountForm.selectedAccount = null;
|
|
|
+ this.erpAccountForm.selectedPhones = []; // 清空手机号选择
|
|
|
+ },
|
|
|
+ // 推送手机号码管理
|
|
|
+ handleErpPhone() {
|
|
|
+ this.getErpPhoneList();
|
|
|
+ this.erpPhone.open = true;
|
|
|
+ },
|
|
|
+ // 新增手机号
|
|
|
+ handleAddPhone() {
|
|
|
+ this.phoneList.push({
|
|
|
+ phone: '',
|
|
|
+ editing: true,
|
|
|
+ originalPhone: '',
|
|
|
+ isNew: true
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 编辑手机号
|
|
|
+ handleEditPhone(index) {
|
|
|
+ this.$set(this.phoneList[index], 'editing', true);
|
|
|
+ this.$set(this.phoneList[index], 'originalPhone', this.phoneList[index].phone);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 保存手机号
|
|
|
+ handleSavePhone(index) {
|
|
|
+ const phone = this.phoneList[index].phone.trim();
|
|
|
+ if (!phone) {
|
|
|
+ this.$message.error('手机号不能为空');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (!this.validatePhoneFormat(phone)) {
|
|
|
+ this.$message.error('请输入正确的手机号格式');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 检查是否重复
|
|
|
+ const duplicateIndex = this.phoneList.findIndex((item, idx) =>
|
|
|
+ idx !== index && item.phone === phone
|
|
|
+ );
|
|
|
+ if (duplicateIndex !== -1) {
|
|
|
+ this.$message.error('手机号已存在');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$set(this.phoneList[index], 'editing', false);
|
|
|
+ this.$set(this.phoneList[index], 'isNew', false);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 取消编辑
|
|
|
+ handleCancelEdit(index) {
|
|
|
+ if (this.phoneList[index].isNew) {
|
|
|
+ // 如果是新增的,直接删除
|
|
|
+ this.phoneList.splice(index, 1);
|
|
|
+ } else {
|
|
|
+ // 如果是编辑的,恢复原值
|
|
|
+ this.$set(this.phoneList[index], 'phone', this.phoneList[index].originalPhone);
|
|
|
+ this.$set(this.phoneList[index], 'editing', false);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 删除手机号
|
|
|
+ handleDeletePhone(index) {
|
|
|
+ this.$confirm('确认删除该手机号?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ this.phoneList.splice(index, 1);
|
|
|
+ this.$message.success('删除成功');
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 验证手机号格式
|
|
|
+ validatePhoneFormat(phone) {
|
|
|
+ const phoneRegex = /^1[3-9]\d{9}$/;
|
|
|
+ return phoneRegex.test(phone);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 验证手机号
|
|
|
+ validatePhone(row) {
|
|
|
+ if (row.phone && !this.validatePhoneFormat(row.phone)) {
|
|
|
+ this.$message.error('请输入正确的手机号格式');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 保存手机号列表
|
|
|
+ handleSavePhoneList() {
|
|
|
+ // 检查是否有正在编辑的项
|
|
|
+ const editingItem = this.phoneList.find(item => item.editing);
|
|
|
+ if (editingItem) {
|
|
|
+ this.$message.error('请先保存正在编辑的手机号');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查是否有空的手机号
|
|
|
+ const emptyPhone = this.phoneList.find(item => !item.phone.trim());
|
|
|
+ if (emptyPhone) {
|
|
|
+ this.$message.error('存在空的手机号,请删除或填写完整');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 构造手机号列表
|
|
|
+ const phoneList = this.phoneList.map(item => item.phone);
|
|
|
+
|
|
|
+ // 调用保存接口
|
|
|
+ saveErpPhone(phoneList).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.$message.success('保存成功');
|
|
|
+ this.erpPhone.open = false;
|
|
|
+ } else {
|
|
|
+ this.$message.error(response.msg || '保存失败');
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message.error('保存失败');
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ // 取消手机号对话框
|
|
|
+ handleCancelPhoneDialog() {
|
|
|
+ this.erpPhone.open = false;
|
|
|
+ this.getErpPhoneList(); // 重新加载原始数据
|
|
|
+ },
|
|
|
+ submitOrderStatusFileForm(){
|
|
|
+ this.$refs.uploadStatus.submit();
|
|
|
+ },
|
|
|
}
|
|
|
};
|
|
|
</script>
|