Ver código fonte

调整直播类型

yfh 1 dia atrás
pai
commit
bbf36a40ea

+ 104 - 50
src/views/hisStore/components/productOrder.vue

@@ -368,9 +368,9 @@
              <el-select @change="provinceChange" v-model="editAddressForm.provinceId" placeholder="请选择">
                 <el-option
                   v-for="item in province"
-                  :key="item.cityId"
-                  :label="item.name"
-                  :value="item.cityId">
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
                 </el-option>
               </el-select>
           </el-col>
@@ -378,9 +378,9 @@
             <el-select @change="cityChange" v-model="editAddressForm.cityId" placeholder="请选择">
                 <el-option
                   v-for="item in city"
-                  :key="item.cityId"
-                  :label="item.name"
-                  :value="item.cityId">
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
                 </el-option>
               </el-select>
           </el-col>
@@ -388,9 +388,9 @@
              <el-select @change="districtChange" v-model="editAddressForm.districtId" placeholder="请选择">
                 <el-option
                   v-for="item in district"
-                  :key="item.cityId"
-                  :label="item.name"
-                  :value="item.cityId">
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value">
                 </el-option>
               </el-select>
           </el-col>
@@ -725,67 +725,121 @@ export default {
 
     },
     districtChange(val){
-      var item=this.citys.find((item)=>{
-        return item.cityId==val&&item.level==2;
+      var item=this.district.find((item)=>{
+        return item.value==val;
       })
-      this.editAddressForm.district=item.name;
+
+      this.editAddressForm.district=item.label;
 
     },
     cityChange(val){
-      this.district=this.citys.filter(item => item.parentId===val )
+      // this.district=this.citys.filter(item => item.value===val )
       this.editAddressForm.districtId=null;
-      var item=this.citys.find((item)=>{
-        return item.cityId==val&&item.level==1;
+      var item=this.city.find((item)=>{
+        return item.value==val;
       })
-      this.editAddressForm.city=item.name;
+      console.log(item)
+      this.district = item.children;
+      this.editAddressForm.city=item.label;
 
 
     },
     provinceChange(val){
-      this.city=this.citys.filter(item => item.parentId===val )
+      // this.city=this.citys.filter(item => item.value===val )
       this.district=[];
       this.editAddressForm.cityId=null;
       this.editAddressForm.districtId=null;
       var item=this.citys.find((item)=>{
-        return item.cityId==val&&item.level==0;
+        return item.value==val;
       })
-      this.editAddressForm.province=item.name;
+      this.city = item.children;
+      this.editAddressForm.province=item.label;
     },
-    getCityList(){
-      getCitys().then(res => {
-          this.citys=res.data;
-          this.province=res.data.filter(item => item.level===0 )
-        })
+    async getCityList() {
+      try {
+        const res = await getCitys();
+        this.citys = res.data;
+        this.province = res.data.filter(item => item.pid === 0);
+        // 可选:返回数据以便链式调用
+        return res.data;
+      } catch (error) {
+        console.error('获取城市列表失败:', error);
+      }
     },
-    handleEditAddress() {
-        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;
-        })
+    async handleEditAddress() {
+      // 等待城市数据加载完成
+      await this.getCityList();
 
-        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.editAddressForm.id = this.order.id;
+      this.editAddressForm.realName = this.order.realName;
+      this.editAddressForm.userPhone = this.order.userPhone;
+
+      // 初始化表单中的地址字段
+      this.editAddressForm.provinceId = '';
+      this.editAddressForm.cityId = '';
+      this.editAddressForm.districtId = '';
+      this.editAddressForm.detail = '';
+
+      // 初始化级联数据
+      this.city = [];
+      this.district = [];
+
+      // 检查是否有地址数据
+      if (!this.order?.userAddress) {
+        this.editAddress.open = true;
+        return;
+      }
+
+      // 分割地址
+      const addressParts = this.order.userAddress.trim().split(/\s+/);
 
+      // 如果地址格式不正确,将整个地址作为详情
+      if (addressParts.length < 4) {
+        this.editAddressForm.detail = this.order.userAddress;
         this.editAddress.open = true;
+        return;
+      }
+
+      // 解析省份
+      const provinceName = addressParts[0];
+      const province = this.citys?.find(item => item.label === provinceName);
+
+      if (province) {
+        this.editAddressForm.provinceId = province.value;
+
+        // 获取城市列表
+        if (Array.isArray(province.children)) {
+          this.city = province.children.filter(item => item.pid === province.value);
+
+          // 解析城市
+          const cityName = addressParts[1];
+          const city = this.city.find(item => item.label === cityName);
+
+          if (city) {
+            this.editAddressForm.cityId = city.value;
+
+            // 获取区县列表
+            if (Array.isArray(city.children)) {
+              this.district = city.children.filter(item => item.pid === city.value);
+
+              // 解析区县
+              const districtName = addressParts[2];
+              const district = this.district.find(item => item.label === districtName);
+
+              if (district) {
+                this.editAddressForm.districtId = district.value;
+              }
+            }
+          }
+        }
+      }
+
+      // 详细地址是剩余部分
+      this.editAddressForm.detail = addressParts.slice(3).join(' ');
+
+      // 打开编辑对话框
+      this.editAddress.open = true;
     },
     /** 提交按钮 */
     submitEditAddressForm() {

+ 13 - 3
src/views/live/live/index.vue

@@ -304,9 +304,14 @@
           </el-radio-group>
         </el-form-item>
         <el-form-item label="直播类型" prop="liveType">
-          <el-radio-group v-model="form.liveType" :disabled="isViewOnly">
-<!--            <el-radio :label="1">直播</el-radio>-->
-            <el-radio :label="2">录播</el-radio>
+          <el-radio-group v-model="form.liveType">
+            <el-radio
+              v-for="item in liveTypeDictList"
+              :key="item.dictValue"
+              :label="parseInt(item.dictValue)"
+            >
+              {{ item.dictLabel }}
+            </el-radio>
           </el-radio-group>
         </el-form-item>
 <!--        <el-form-item label="直播达人" prop="talentId">-->
@@ -436,6 +441,7 @@ export default {
   components: { Editor,VideoUpload },
   data() {
     return {
+      liveTypeDictList: [],
       // 是否只读
       isViewOnly:false,
       baseUrl: process.env.VUE_APP_BASE_API,
@@ -535,6 +541,10 @@ export default {
   },
   created() {
     this.getList();
+    // 新增:获取直播类型字典
+    this.getDicts("live_type").then((response) => {
+      this.liveTypeDictList = response.data;
+    });
   },
   watch: {
     'form.startTime': {