|
@@ -319,8 +319,16 @@
|
|
|
<el-form-item label="备注" prop="remark" >
|
|
|
<el-input v-model="editForm.remark" placeholder="请输入备注" />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="详情地址" prop="userAddress" >
|
|
|
- <el-input v-model="editForm.userAddress" placeholder="请输入" />
|
|
|
+ <el-form-item label="详情地址" prop="userAddress">
|
|
|
+ <el-cascader
|
|
|
+ ref="citySelect"
|
|
|
+ v-model="cityIds"
|
|
|
+ :options="citys"
|
|
|
+ :props="{ checkStrictly: true }"
|
|
|
+ @change="handleCityChange"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ <el-input v-model="editForm.userAddress" placeholder="请输入详细地址(不含省/市/区)" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="收货人电话" prop="userPhone" >
|
|
|
<el-input v-model="editForm.userPhone" placeholder="请输入" />
|
|
@@ -409,6 +417,7 @@ import {getCustomerListBySearch } from "@/api/crm/customer";
|
|
|
import { getTcmScheduleList } from "@/api/company/tcmScheduleReport";
|
|
|
import addSms from '../../crm/components/addSms.vue';
|
|
|
import msgDetails from '../../store/components/followMsgDetails.vue';
|
|
|
+import {getCitys} from "@/api/store/city";
|
|
|
export default {
|
|
|
name: "orderDe",
|
|
|
props:["data"],
|
|
@@ -512,6 +521,8 @@ import msgDetails from '../../store/components/followMsgDetails.vue';
|
|
|
qwSubject:null,
|
|
|
remark:"",
|
|
|
isFirst:null,
|
|
|
+ userAddress: "",
|
|
|
+ userPhone: ""
|
|
|
},
|
|
|
editDyRules:{
|
|
|
deliverySn: [
|
|
@@ -538,7 +549,12 @@ import msgDetails from '../../store/components/followMsgDetails.vue';
|
|
|
deliveryName:null,
|
|
|
deliverySn:null,
|
|
|
orderId:null,
|
|
|
- }
|
|
|
+ },
|
|
|
+ cityIds:[],
|
|
|
+ citys:[],
|
|
|
+ userAddress:null,
|
|
|
+ originalAddress: null,
|
|
|
+ originalDetail: "",
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
@@ -619,6 +635,30 @@ import msgDetails from '../../store/components/followMsgDetails.vue';
|
|
|
|
|
|
},
|
|
|
methods: {
|
|
|
+ getCitys() {
|
|
|
+ return getCitys().then(res => {
|
|
|
+ this.citys = res.data || [];
|
|
|
+ return this.citys;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 新增:切换省市区
|
|
|
+ handleCityChange(val) {
|
|
|
+ this.cityIds = Array.isArray(val) ? val : [];
|
|
|
+ },
|
|
|
+
|
|
|
+ getCityLabelsByIds() {
|
|
|
+ if (!this.cityIds || this.cityIds.length === 0) return [];
|
|
|
+ const [pVal, cVal, aVal] = this.cityIds;
|
|
|
+ const p = this.citys.find(p => p.value === pVal);
|
|
|
+ const c = p?.children?.find(c => c.value === cVal);
|
|
|
+ const a = c?.children?.find(a => a.value === aVal);
|
|
|
+ return [p?.label, c?.label, a?.label].filter(Boolean);
|
|
|
+ },
|
|
|
+ buildFullAddress() {
|
|
|
+ const region = this.getCityLabelsByIds().join(' ');
|
|
|
+ const detail = (this.editForm.userAddress || '').trim();
|
|
|
+ return region && detail ? `${region} ${detail}` : (region || detail || '');
|
|
|
+ },
|
|
|
followMsg(row){
|
|
|
const userId = this.item.userId;
|
|
|
const followDoctorId =this.item.followDoctorId;
|
|
@@ -716,35 +756,84 @@ import msgDetails from '../../store/components/followMsgDetails.vue';
|
|
|
});
|
|
|
},
|
|
|
//修改订单状态
|
|
|
- submitEditForm(){
|
|
|
- this.$refs["editForm"].validate(valid => {
|
|
|
- if (valid) {
|
|
|
- updateStoreOrder(this.editForm).then(response => {
|
|
|
- if (response.code === 200) {
|
|
|
- this.msgSuccess("操作成功");
|
|
|
- this.edit.open = false;
|
|
|
- getOrder(this.item.orderId).then(response => {
|
|
|
- this.item=response.data
|
|
|
- that.getlogList(this.item.orderId);
|
|
|
- that.$parent.$parent.getList();
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ submitEditForm() {
|
|
|
+ this.$refs["editForm"].validate(valid => {
|
|
|
+ if (!valid) return;
|
|
|
+
|
|
|
+ // 判断是否修改了地址:选了更深层级 或 详细地址有改动
|
|
|
+ const regionChanged = Array.isArray(this.cityIds) && this.cityIds.length > 1;
|
|
|
+ const detailChanged = (this.editForm.userAddress || '').trim() !== (this.originalDetail || '');
|
|
|
+ const addressModified = regionChanged || detailChanged;
|
|
|
+
|
|
|
+ // 若修改了地址,要求省市区都选到(3级)
|
|
|
+ if (addressModified) {
|
|
|
+ if (!this.cityIds || this.cityIds.length < 3) {
|
|
|
+ this.msgError("请完整选择省/市/区");
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ const payload = {
|
|
|
+ ...this.editForm,
|
|
|
+ userAddress: addressModified ? this.buildFullAddress() : (this.originalAddress || this.item.userAddress || ''),
|
|
|
+ };
|
|
|
+
|
|
|
+ updateStoreOrder(payload).then(response => {
|
|
|
+ if (response.code === 200) {
|
|
|
+ this.msgSuccess("操作成功");
|
|
|
+ this.edit.open = false;
|
|
|
+ getOrder(this.item.orderId).then(response => {
|
|
|
+ this.item = response.data;
|
|
|
+ this.getlogList(this.item.orderId);
|
|
|
+ this.$parent.$parent.getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
- editOrder(){
|
|
|
- this.edit.open=true;
|
|
|
- this.editForm.orderId=this.item.orderId;
|
|
|
- this.editForm.remark=this.item.remark;
|
|
|
- this.editForm.userAddress = this.item.userAddress.toString();
|
|
|
- this.editForm.userPhone = this.item.userPhone.toString();
|
|
|
- if(this.item.orderBuyType!=null){
|
|
|
- this.editForm.orderBuyType=this.item.orderBuyType.toString();
|
|
|
+ editOrder() {
|
|
|
+ this.edit.open = true;
|
|
|
+ this.editForm.orderId = this.item.orderId;
|
|
|
+ this.editForm.remark = this.item.remark;
|
|
|
+ this.editForm.userPhone = this.item.userPhone != null ? this.item.userPhone.toString() : "";
|
|
|
+ if (this.item.orderBuyType != null) {
|
|
|
+ this.editForm.orderBuyType = this.item.orderBuyType.toString();
|
|
|
+ }
|
|
|
+ this.editForm.orderChannel = this.item.orderChannel;
|
|
|
+ this.editForm.qwSubject = this.item.qwSubject;
|
|
|
+ this.editForm.scheduleId = this.item.scheduleId;
|
|
|
+
|
|
|
+ const currentAddress = (this.item.userAddress || "").toString().trim();
|
|
|
+ // 记录原始完整地址
|
|
|
+ this.originalAddress = currentAddress;
|
|
|
+
|
|
|
+ this.getCitys().then(() => {
|
|
|
+ if (!currentAddress) {
|
|
|
+ this.cityIds = [];
|
|
|
+ this.editForm.userAddress = "";
|
|
|
+ this.originalDetail = "";
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 按“省 市 区 详细地址(空格分隔)”进行拆分。若无区或无市也不报错。
|
|
|
+ const parts = currentAddress.split(/\s+/);
|
|
|
+ const detail = parts.pop() || ""; // 末尾作为详细地址
|
|
|
+ const provLabel = parts[0];
|
|
|
+ const cityLabel = parts[1];
|
|
|
+ const areaLabel = parts[2];
|
|
|
+
|
|
|
+ const province = this.citys.find(p => p.label === provLabel);
|
|
|
+ if (province) {
|
|
|
+ // 只回显省,不预选市/区
|
|
|
+ this.cityIds = [province.value];
|
|
|
+ } else {
|
|
|
+ console.warn("未匹配到省:", { provLabel });
|
|
|
+ this.cityIds = [];
|
|
|
}
|
|
|
- this.editForm.orderChannel = this.item.orderChannel;
|
|
|
- this.editForm.qwSubject = this.item.qwSubject;
|
|
|
- this.editForm.scheduleId=this.item.scheduleId;
|
|
|
+ // 输入框只放“详细地址(不含省市区)”
|
|
|
+ this.editForm.userAddress = detail;
|
|
|
+ // 记录原始详细地址(用于判断有无修改)
|
|
|
+ this.originalDetail = detail;
|
|
|
+ });
|
|
|
},
|
|
|
updateExpress(){
|
|
|
var that=this;
|