|
|
@@ -356,10 +356,10 @@
|
|
|
</el-dialog>
|
|
|
<el-dialog :title="editAddress.title" :visible.sync="editAddress.open" width="600px" append-to-body>
|
|
|
<el-form ref="editAddressForm" :model="editAddressForm" :rules="editAddressRules" label-width="100px">
|
|
|
- <el-form-item label="收件人" prop="realName" required>
|
|
|
+ <el-form-item label="收件人" prop="realName">
|
|
|
<el-input v-model="editAddressForm.realName" placeholder="请输入收件人" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="联系电话" prop="userPhone" required>
|
|
|
+ <el-form-item label="联系电话" prop="source">
|
|
|
<el-input v-model="editAddressForm.userPhone" placeholder="请输入联系电话" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="收货地址" prop="district">
|
|
|
@@ -396,7 +396,7 @@
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="详细地址" prop="detail" required>
|
|
|
+ <el-form-item label="详细地址" prop="detail">
|
|
|
<el-input v-model="editAddressForm.detail" placeholder="请输入收货人详细地址" />
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
@@ -494,20 +494,7 @@ import { getTcmScheduleList } from "@/api/company/tcmScheduleReport";
|
|
|
import {getCustomerListBySearch } from "@/api/crm/customer";
|
|
|
import ImageUpload from '@/components/ImageUpload'
|
|
|
import Material from '@/components/Material'
|
|
|
-import {
|
|
|
- bindCustomer,
|
|
|
- getExpress,
|
|
|
- listStoreOrder,
|
|
|
- getStoreOrder,
|
|
|
- delStoreOrder,
|
|
|
- addStoreOrder,
|
|
|
- updateStoreOrder,
|
|
|
- exportStoreOrder,
|
|
|
- uploadCredentials,
|
|
|
- getStoreOrderAddress,
|
|
|
- getUserPhone,
|
|
|
- updateAddressErpFsStoreOrder
|
|
|
-} from "@/api/hisStore/storeOrder";
|
|
|
+import {bindCustomer,getExpress, listStoreOrder, getStoreOrder, delStoreOrder, addStoreOrder, updateStoreOrder, exportStoreOrder,uploadCredentials, getStoreOrderAddress,getUserPhone} from "@/api/hisStore/storeOrder";
|
|
|
import {getCitys} from "@/api/hisStore/city";
|
|
|
import customerDetails from '../../crm/components/customerDetails.vue';
|
|
|
import addSms from '../../crm/components/addSms.vue';
|
|
|
@@ -770,157 +757,42 @@ export default {
|
|
|
this.province=res.data.filter(item => item.level===0 )
|
|
|
})
|
|
|
},
|
|
|
- flattenCityData(data, level = 0) {
|
|
|
- let result = [];
|
|
|
- data.forEach(item => {
|
|
|
- // 转换字段名
|
|
|
- const cityItem = {
|
|
|
- cityId: item.value,
|
|
|
- name: item.label,
|
|
|
- parentId: item.pid,
|
|
|
- level: level
|
|
|
- };
|
|
|
- result.push(cityItem);
|
|
|
-
|
|
|
- // 递归处理子节点
|
|
|
- if (item.children && item.children.length > 0) {
|
|
|
- result = result.concat(this.flattenCityData(item.children, level + 1));
|
|
|
- }
|
|
|
- });
|
|
|
- return result;
|
|
|
- },
|
|
|
handleEditAddress() {
|
|
|
- let loading = this.$loading({
|
|
|
- lock: true,
|
|
|
- text: "请求中...",
|
|
|
- background: "rgba(0, 0, 0, 0.7)",
|
|
|
- });
|
|
|
- const orderId = this.order.id;
|
|
|
-
|
|
|
- getStoreOrderAddress(orderId).then(addressResponse => {
|
|
|
- // 更新解密后的地址
|
|
|
- this.order.userAddress = addressResponse.address;
|
|
|
-
|
|
|
- }).then(res=>{
|
|
|
- const id = this.order.id;
|
|
|
- return getUserPhone(id).then(response =>{
|
|
|
- this.order.userPhone = response.userPhone;
|
|
|
+ this.getCityList();
|
|
|
+ this.editAddressForm.id=this.order.id;
|
|
|
+ this.editAddressForm.realName=this.order.realName;
|
|
|
+ this.editAddressForm.userPhone=this.order.userPhone;
|
|
|
+ var address=this.order.userAddress.split(' ')
|
|
|
+ var province=this.citys.find((item)=>{
|
|
|
+ return item.name==address[0]&&item.level==0;
|
|
|
+ })
|
|
|
+ if(province!=null){
|
|
|
+ this.editAddressForm.provinceId=province.cityId;
|
|
|
+ this.city=this.citys.filter(item => item.parentId===province.cityId&&item.level==1 )
|
|
|
+ }
|
|
|
+ var city=this.citys.find((item)=>{
|
|
|
+ return item.name==address[1]&&item.level==1;
|
|
|
})
|
|
|
- }).then(res=>{
|
|
|
- return getCitys();
|
|
|
- }).then(res => {
|
|
|
- this.citys = this.flattenCityData(res.data);
|
|
|
- this.province = this.citys.filter(item => item.level === 0);
|
|
|
-
|
|
|
- this.editAddressForm = {
|
|
|
- id: this.order.id,
|
|
|
- realName: this.order.realName,
|
|
|
- userPhone: this.order.userPhone,
|
|
|
- provinceId: null,
|
|
|
- cityId: null,
|
|
|
- districtId: null,
|
|
|
- province: '',
|
|
|
- city: '',
|
|
|
- district: '',
|
|
|
- detail: ''
|
|
|
- };
|
|
|
-
|
|
|
- // 解析地址
|
|
|
- if (this.order.userAddress) {
|
|
|
- var addressParts = this.order.userAddress.split(' ');
|
|
|
-
|
|
|
- // 查找省份
|
|
|
- if (addressParts.length > 0) {
|
|
|
- var province = this.citys.find((item) => {
|
|
|
- return item.name === addressParts[0] && item.level === 0;
|
|
|
- });
|
|
|
- if (province != null) {
|
|
|
- this.editAddressForm.provinceId = province.cityId;
|
|
|
- this.editAddressForm.province = province.name;
|
|
|
-
|
|
|
- // 检查是否为直辖市(北京、上海、天津、重庆)
|
|
|
- const isDirectMunicipality = ['北京市', '上海市', '天津市', '重庆市'].includes(province.name);
|
|
|
-
|
|
|
- if (isDirectMunicipality) {
|
|
|
- // 直辖市处理:先找到市级节点(市辖区)
|
|
|
- if (addressParts.length > 1) {
|
|
|
- // 查找市级节点(第2部分,如"市辖区")
|
|
|
- var cityLevel = this.citys.find((item) => {
|
|
|
- return item.name === addressParts[1] && item.level === 1 && item.parentId === province.cityId;
|
|
|
- });
|
|
|
-
|
|
|
- if (cityLevel != null) {
|
|
|
- this.editAddressForm.cityId = cityLevel.cityId;
|
|
|
- this.editAddressForm.city = cityLevel.name;
|
|
|
- this.city = this.citys.filter(item => item.parentId === province.cityId && item.level === 1);
|
|
|
-
|
|
|
- // 使用市级节点的cityId作为parentId查找区县
|
|
|
- if (addressParts.length > 2) {
|
|
|
- var district = this.citys.find((item) => {
|
|
|
- return item.name === addressParts[2] && item.level === 2 && item.parentId === cityLevel.cityId;
|
|
|
- });
|
|
|
-
|
|
|
- if (district != null) {
|
|
|
- this.editAddressForm.districtId = district.cityId;
|
|
|
- this.editAddressForm.district = district.name;
|
|
|
- this.district = this.citys.filter(item => item.parentId === cityLevel.cityId && item.level === 2);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 提取详细地址(第4部分及之后)
|
|
|
- if (addressParts.length > 3) {
|
|
|
- this.editAddressForm.detail = addressParts.slice(3).join(' ');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 普通省份处理:正常匹配市、区
|
|
|
- this.city = this.citys.filter(item => item.parentId === province.cityId && item.level === 1);
|
|
|
|
|
|
- // 查找城市
|
|
|
- if (addressParts.length > 1) {
|
|
|
- var city = this.citys.find((item) => {
|
|
|
- return item.name === addressParts[1] && item.level === 1;
|
|
|
- });
|
|
|
- if (city != null) {
|
|
|
- this.editAddressForm.cityId = city.cityId;
|
|
|
- this.editAddressForm.city = city.name;
|
|
|
- this.district = this.citys.filter(item => item.parentId === city.cityId && item.level === 2);
|
|
|
- }
|
|
|
- }
|
|
|
- // 查找区县
|
|
|
- if (addressParts.length > 2) {
|
|
|
- var district = this.citys.find((item) => {
|
|
|
- return item.name === addressParts[2] && item.level === 2;
|
|
|
- });
|
|
|
- if (district != null) {
|
|
|
- this.editAddressForm.districtId = district.cityId;
|
|
|
- this.editAddressForm.district = district.name;
|
|
|
- }
|
|
|
- }
|
|
|
- // 提取详细地址(第4部分及之后)
|
|
|
- if (addressParts.length > 3) {
|
|
|
- this.editAddressForm.detail = addressParts.slice(3).join(' ');
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ if(city!=null){
|
|
|
+ this.editAddressForm.cityId=city.cityId;
|
|
|
+ this.district=this.citys.filter(item => item.parentId===city.cityId&&item.level==2 )
|
|
|
+ }
|
|
|
+ var district=this.citys.find((item)=>{
|
|
|
+ return item.name==address[2]&&item.level==2;
|
|
|
+ })
|
|
|
+ if(district!=null){
|
|
|
+ this.editAddressForm.districtId=district.cityId;
|
|
|
}
|
|
|
|
|
|
this.editAddress.open = true;
|
|
|
- }).catch(error => {
|
|
|
- this.msgError("加载数据失败");
|
|
|
- console.error(error);
|
|
|
- }).finally(()=>{
|
|
|
- loading.close();
|
|
|
- })
|
|
|
},
|
|
|
/** 提交按钮 */
|
|
|
submitEditAddressForm() {
|
|
|
this.$refs["editAddressForm"].validate(valid => {
|
|
|
if (valid) {
|
|
|
this.editAddressForm.userAddress=this.editAddressForm.province+" "+this.editAddressForm.city+" "+this.editAddressForm.district+" "+this.editAddressForm.detail;
|
|
|
- updateAddressErpFsStoreOrder(this.editAddressForm).then(response => {
|
|
|
+ updateStoreOrder(this.editAddressForm).then(response => {
|
|
|
if (response.code === 200) {
|
|
|
this.msgSuccess("修改成功");
|
|
|
this.editAddress.open = false;
|