Browse Source

Merge remote-tracking branch 'origin/master'

xgb 2 days ago
parent
commit
c890c745b6

+ 30 - 0
src/api/his/integralOrder.js

@@ -102,4 +102,34 @@ export function finishOrder(orderCode) {
     url: '/his/integralOrder/finishOrder/' + orderCode,
     method: 'get'
   })
+}
+//数据分捡
+export function batchSetErpOrder(params) {
+  return request({
+    url: '/his/integralOrder/batchSetErpOrder',
+    method: 'post',
+    data: params
+  })
+}
+//数据分捡
+export function batchCreateErpOrder(params) {
+  return request({
+    url: '/his/integralOrder/batchCreateErpOrder',
+    method: 'post',
+    data: params
+  })
+}
+//获取城市
+export function getCitys(){
+  return request({
+    url: '/his/city/getCitys',
+    method: 'get'
+  })
+}
+//获取模版
+export function getIntegralTemplate(){
+  return request({
+    url: '/his/integralOrder/importUpdateOrderTemplate',
+    method: 'get'
+  })
 }

+ 201 - 18
src/views/components/his/integralOrderDetails.vue

@@ -64,6 +64,12 @@
               }}</span></el-descriptions-item>
           <el-descriptions-item label="快递单号"><span v-if="item != null">{{ item.deliverySn
               }}</span></el-descriptions-item>
+          <!-- <el-descriptions-item label="物流状态"><span v-if="item != null">{{ item.deliveryType
+              }}</span></el-descriptions-item> -->
+          <el-descriptions-item label="物流状态" ><dict-tag :options="deliveryStatusOptions" :value="item.deliveryStatus"/></el-descriptions-item>
+
+          <el-descriptions-item label="物流跟踪状态" ><span v-if="item!=null"><dict-tag :options="deliveryTypeOptions" :value="item.deliveryType"/> </span></el-descriptions-item>
+
           <el-descriptions-item label="发货时间"><span v-if="item != null">{{ item.deliveryTime
               }}</span></el-descriptions-item>
           <el-descriptions-item label="提交时间"><span v-if="item != null">{{ item.createTime
@@ -100,7 +106,7 @@
 
       </el-table>
     </div>
-    <el-dialog width="50%" title="发货" :visible.sync="sendVisible" append-to-body @close="sendCancel">
+    <el-dialog width="35%" title="发货" :visible.sync="sendVisible" append-to-body @close="sendCancel">
       <el-form ref="form" :model="form" label-width="120px">
         <el-form-item label="快递名称" prop="deliveryName">
           <el-select v-model="selectedExpress" placeholder="请选择快递名称" value-key="name">
@@ -118,11 +124,10 @@
         </el-form-item>
 
         <!-- 代服账号选择表格 -->
-        <el-form-item label="代服账号选择" prop="selectedAccount" required>
+        <!-- <el-form-item label="代服账号选择" prop="selectedAccount" required>
           <div style="border: 1px solid #e6ebf5; border-radius: 4px; padding: 10px;">
             <el-table ref="accountTable" :data="tableData" highlight-current-row
               @current-change="handleAccountSelectionChange" style="width: 100%" size="small" max-height="400">
-              <!-- 固定高度,超出滚动 -->
 
               <el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
               <el-table-column prop="loginAccount" label="登录账号" align="center" width="120"
@@ -147,7 +152,7 @@
 
             </el-table>
 
-            <!-- 分页 -->
+            
             <el-pagination small layout="prev, pager, next" :total="total" :page-size="queryParams.pageSize"
               :current-page="queryParams.pageNum" @current-change="handlePageChange"
               style="margin-top: 10px; text-align: center;">
@@ -157,13 +162,13 @@
               提示:点击表格行选择代服账号
             </div>
 
-            <!-- 显示选中信息 -->
+            
             <div v-if="selectedRow" style="margin-top: 10px; padding: 8px; background: #f5f7fa; border-radius: 4px;">
               <span style="color: #67C23A;">已选择:</span>
               <span>{{ selectedRow.loginAccount }} ({{ selectedRow.senderName }})</span>
             </div>
           </div>
-        </el-form-item>
+        </el-form-item> -->
 
       </el-form>
       <div slot="footer" class="dialog-footer">
@@ -198,11 +203,74 @@
         <el-form-item label="订单状态" prop="status">
           <el-select v-model="editForm.status" placeholder="请选择状态" clearable size="small" filterable>
             <el-option v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictLabel"
-              :value="dict.dictValue" />
+              :value="dict.dictValue" :disabled="dict.dictValue==4||dict.dictValue==6||dict.dictValue==-1"/>
           </el-select>
         </el-form-item>
-        <el-form-item label="详情地址" prop="userAddress">
-          <el-input v-model="editForm.userAddress" placeholder="请输入" />
+        <el-form-item label="收货地址" required v-if="item.status == 1">
+          <div style="margin-bottom: 10px;">
+            <el-select 
+              v-model="selectedProvince" 
+              placeholder="请选择省" 
+              style="width: 32%; margin-right: 1%"
+              @change="onProvinceChange"
+              clearable
+            >
+              <el-option
+                v-for="item in provinceOptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item"
+              />
+            </el-select>
+            
+            <el-select 
+              v-model="selectedCity" 
+              placeholder="请选择市" 
+              style="width: 32%; margin-right: 1%"
+              @change="onCityChange"
+              :disabled="!selectedProvince"
+              clearable
+            >
+              <el-option
+                v-for="item in cityOptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item"
+              />
+            </el-select>
+            
+            <el-select 
+              v-model="selectedDistrict" 
+              placeholder="请选择区" 
+              style="width: 32%;"
+              @change="onDistrictChange"
+              :disabled="!selectedCity"
+              clearable
+            >
+              <el-option
+                v-for="item in districtOptions"
+                :key="item.value"
+                :label="item.label"
+                :value="item"
+              />
+            </el-select>
+          </div>
+          
+          <el-input 
+            v-model="detailAddress" 
+            placeholder="请输入详细地址(街道、门牌号等)" 
+            style="width: 100%"
+            clearable
+          />
+        </el-form-item>
+
+        <!-- 其他状态显示只读的地址信息 -->
+        <el-form-item label="收货地址" v-else>
+          <el-input 
+            v-model="editForm.userAddress" 
+            placeholder="请输入" 
+            disabled
+          />
         </el-form-item>
 
         <!-- 修改:快递信息改为下拉选择 -->
@@ -220,12 +288,11 @@
         </el-form-item>
 
         <!-- 代服账号选择表格 - 使用同一个数据源 -->
-        <el-form-item label="代服账号" prop="loginAccount">
+        <!-- <el-form-item label="代服账号" prop="loginAccount">
           <div style="border: 1px solid #e6ebf5; border-radius: 4px; padding: 10px;">
             <el-table ref="editAccountTable" :data="tableData" highlight-current-row
               @current-change="handleEditAccountSelectionChange" style="width: 100%" size="small" max-height="300">
 
-              <!-- 列定义与发货弹窗相同 -->
               <el-table-column type="index" width="60" label="序号" align="center"></el-table-column>
               <el-table-column prop="loginAccount" label="登录账号" align="center" width="120"
                 show-overflow-tooltip></el-table-column>
@@ -249,7 +316,6 @@
 
             </el-table>
 
-            <!-- 分页 - 使用同一个分页数据 -->
             <el-pagination small layout="prev, pager, next" :total="total" :page-size="queryParams.pageSize"
               :current-page="queryParams.pageNum" @current-change="handlePageChange"
               style="margin-top: 10px; text-align: center;">
@@ -259,14 +325,13 @@
               提示:点击表格行选择代服账号
             </div>
 
-            <!-- 显示选中信息 -->
             <div v-if="editSelectedRow"
               style="margin-top: 10px; padding: 8px; background: #f5f7fa; border-radius: 4px;">
               <span style="color: #67C23A;">已选择:</span>
               <span>{{ editSelectedRow.loginAccount }} ({{ editSelectedRow.senderName }})</span>
             </div>
           </div>
-        </el-form-item>
+        </el-form-item> -->
 
         <el-form-item label="备注" prop="remark">
           <el-input v-model="editForm.remark" placeholder="请输入备注" />
@@ -280,13 +345,14 @@
 </template>
 
 <script>
-import { getExpress,mandatoryRefunds,finishOrder, listIntegralOrder, sendgoods, getIntegralOrder, delIntegralOrder, addIntegralOrder, updateIntegralOrder, exportIntegralOrder, getOrderUserPhone } from "@/api/his/integralOrder";
+import { getExpress,mandatoryRefunds,getCitys,finishOrder, listIntegralOrder, sendgoods, getIntegralOrder, delIntegralOrder, addIntegralOrder, updateIntegralOrder, exportIntegralOrder, getOrderUserPhone } from "@/api/his/integralOrder";
 import { getExpressList } from "@/api/his/express";
 import { listAccount } from "@/api/his/dfAccount";
 export default {
   name: "integralOrder",
   data() {
     return {
+      deliveryStatusOptions:[],
       selectedExpress: null,
       expressOption: [],
       expressDialog: {
@@ -300,7 +366,7 @@ export default {
       editForm: {
         orderId: null,
         status: null,
-        userAddress: null,
+        userAddress: null, // 这个字段将存储拼接后的完整地址
         remark: "",
         loginAccount: null,
         // 新增快递相关字段
@@ -354,6 +420,15 @@ export default {
       total: 0, // 总条数,
       expressOptions: [], // 物流产品字典
       editSelectedExpress: null,
+      // 地址选择相关数据
+      provinceOptions: [], // 省列表
+      cityOptions: [], // 市列表
+      districtOptions: [], // 区列表
+      selectedProvince: null, // 选中的省
+      selectedCity: null, // 选中的市
+      selectedDistrict: null, // 选中的区
+      detailAddress: '', // 详细地址
+      deliveryTypeOptions:[],
     }
   },
   created() {
@@ -363,6 +438,12 @@ export default {
     this.getDicts("df_account_express").then(response => {
       this.expressOptions = response.data;
     });
+    this.getDicts("sys_store_order_delivery_status").then(response => {
+          this.deliveryStatusOptions = response.data;
+    });
+    this.getDicts("sys_delivery_type").then(response => {
+              this.deliveryTypeOptions = response.data;
+            });
   },
   watch: {
     selectedExpress(newVal) {
@@ -454,10 +535,15 @@ export default {
           }
         }
 
-        // 3. 等待代服账号数据加载完成
+        // 3. 初始化地址选择器(只在待发货状态时执行)
+        if (this.item.status == 1) {
+          await this.initAddressSelector();
+        }
+
+        // 4. 等待代服账号数据加载完成
         await this.getAccountList();
 
-        // 4. 在数据都加载完成后尝试选中对应的行
+        // 5. 在数据都加载完成后尝试选中对应的行
         if (this.item.loginAccount) {
           this.$nextTick(() => {
             this.selectCurrentAccount();
@@ -467,6 +553,88 @@ export default {
         console.error('加载数据失败:', error);
       }
     },
+    // 初始化地址选择器
+    async initAddressSelector() {
+      // 重置地址选择器
+      this.provinceOptions = [];
+      this.cityOptions = [];
+      this.districtOptions = [];
+      this.selectedProvince = null;
+      this.selectedCity = null;
+      this.selectedDistrict = null;
+      this.detailAddress = '';
+
+      // 只有在待发货状态时才初始化地址选择器
+      if (this.item.status == 1) {
+        // 获取省份数据
+        try {
+          const response = await getCitys(); // 假设getCitys是您导入的方法
+          this.provinceOptions = response.data || [];
+          
+          // 如果现有地址不为空,尝试解析并设置初始值
+          if (this.item.userAddress) {
+            this.parseExistingAddress(this.item.userAddress);
+          }
+        } catch (error) {
+          console.error('获取地址数据失败:', error);
+        }
+      }
+    },
+
+    // 解析现有地址
+    parseExistingAddress(address) {
+      if (!address || this.item.status != 1) return;
+      
+      // 假设地址格式为 "省 市 区 详细地址"
+      const parts = address.split(' ');
+      if (parts.length >= 4) {
+        const provinceName = parts[0];
+        const cityName = parts[1];
+        const districtName = parts[2];
+        this.detailAddress = parts.slice(3).join(' '); // 剩余部分作为详细地址
+        
+        // 设置省份
+        const province = this.provinceOptions.find(p => p.label === provinceName);
+        if (province) {
+          this.selectedProvince = province;
+          this.onProvinceChange(province);
+          
+          // 设置城市
+          const city = province.children?.find(c => c.label === cityName);
+          if (city) {
+            this.selectedCity = city;
+            this.onCityChange(city);
+            
+            // 设置区域
+            const district = city.children?.find(d => d.label === districtName);
+            if (district) {
+              this.selectedDistrict = district;
+            }
+          }
+        }
+      } else {
+        // 如果格式不匹配,将整个地址作为详细地址
+        this.detailAddress = address;
+      }
+    },
+    // 省份选择变化
+    onProvinceChange(province) {
+      this.selectedCity = null;
+      this.selectedDistrict = null;
+      this.cityOptions = province?.children || [];
+      this.districtOptions = [];
+    },
+
+    // 城市选择变化
+    onCityChange(city) {
+      this.selectedDistrict = null;
+      this.districtOptions = city?.children || [];
+    },
+
+    // 区域选择变化
+    onDistrictChange(district) {
+      // 可以在这里处理区域选择后的逻辑
+    },
     // 选中当前账号(修改订单弹窗使用)
     selectCurrentAccount() {
       if (!this.item.loginAccount || !this.tableData || this.tableData.length === 0) {
@@ -492,6 +660,21 @@ export default {
     },
     //修改订单状态
     submitEditForm() {
+      // 只有在待发货状态(status=1)时才更新地址
+      if (this.item.status == 1) {
+        // 拼接完整地址
+        const province = this.selectedProvince ? this.selectedProvince.label : '';
+        const city = this.selectedCity ? this.selectedCity.label : '';
+        const district = this.selectedDistrict ? this.selectedDistrict.label : '';
+        const detail = this.detailAddress || '';
+        
+        // 使用空格拼接四个字段
+        this.editForm.userAddress = `${province} ${city} ${district} ${detail}`.trim();
+      } else {
+        // 其他状态保持原地址不变
+        this.editForm.userAddress = this.item.userAddress;
+      }
+      
       this.$refs["editForm"].validate(valid => {
         if (valid) {
           updateIntegralOrder(this.editForm).then(response => {

+ 532 - 5
src/views/his/integralOrder/index.vue

@@ -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>