<template>
  <div class="dialog-box" style="position: relative">
    <el-scrollbar class="custom-scroll content-box">
      <el-form
        ref="formViewCarOrderRef"
        :model="formData"
        :size="layoutStore.defaultFormItemSize"
        :rules="rules"
        label-width="120px"
        label-position="right"
        @submit.prevent
      >
        <el-row :gutter="16">
          <el-col :span="12">
            <el-form-item label="订单状态" prop="TourCarOrder.state">
              <el-select
                class="input-item"
                v-model="formData.TourCarOrder.state"
                placeholder=""
                :clearable="true"
                :filterable="true"
                :disabled="true"
                @visible-change="stateWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in stateWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单号" prop="TourCarOrder.orderNo">
              <el-input
                class="input-item"
                v-model="formData.TourCarOrder.orderNo"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
                :readonly="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开始时间" prop="TourCarOrder.startTime">
              <el-date-picker
                class="input-item"
                v-model="formData.TourCarOrder.startTime"
                type="date"
                placeholder=""
                :clearable="true"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结束时间" prop="TourCarOrder.endTime">
              <el-date-picker
                class="input-item"
                v-model="formData.TourCarOrder.endTime"
                type="date"
                placeholder=""
                :clearable="true"
                format="YYYY-MM-DD"
                value-format="YYYY-MM-DD"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包车天数" prop="TourCarOrder.days">
              <el-input-number
                class="input-item"
                v-model="formData.TourCarOrder.days"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="起点" prop="TourCarOrder.startPlaceId">
              <el-select
                class="input-item"
                v-model="formData.TourCarOrder.startPlaceId"
                placeholder=""
                :clearable="true"
                :filterable="true"
                :disabled="true"
                @visible-change="startPlaceIdWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in startPlaceIdWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="乘客联系电话" prop="TourCarOrder.connectPhone">
              <el-input
                class="input-item"
                v-model="formData.TourCarOrder.connectPhone"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
                :readonly="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="乘客联系姓名" prop="TourCarOrder.connectName">
              <el-input
                class="input-item"
                v-model="formData.TourCarOrder.connectName"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
                :readonly="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="乘车人微信" prop="TourCarOrder.connectWechat">
              <el-input
                class="input-item"
                v-model="formData.TourCarOrder.connectWechat"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
                :readonly="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="乘客联系人性别" prop="TourCarOrder.connectSex">
              <el-select
                class="input-item"
                v-model="formData.TourCarOrder.connectSex"
                placeholder=""
                :clearable="true"
                :filterable="true"
                :disabled="true"
                @visible-change="connectSexWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in connectSexWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="乘客备注" prop="TourCarOrder.remark">
              <el-input
                class="input-item"
                v-model="formData.TourCarOrder.remark"
                type="textarea"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
                :readonly="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="司机名称" prop="TourCarOrder.driverName">
              <el-input
                class="input-item"
                v-model="formData.TourCarOrder.driverName"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
                :readonly="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="司机性别" prop="TourCarOrder.driverSex">
              <el-select
                class="input-item"
                v-model="formData.TourCarOrder.driverSex"
                placeholder=""
                :clearable="true"
                :filterable="true"
                :disabled="true"
                @visible-change="driverSexWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in driverSexWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="司机年龄" prop="TourCarOrder.driverAge">
              <el-input-number
                class="input-item"
                v-model="formData.TourCarOrder.driverAge"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="司机驾龄" prop="TourCarOrder.drivingYears">
              <el-input-number
                class="input-item"
                v-model="formData.TourCarOrder.drivingYears"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="司机联系方式" prop="TourCarOrder.driverMobile">
              <el-input
                class="input-item"
                v-model="formData.TourCarOrder.driverMobile"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
                :readonly="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="司机照片" prop="TourCarOrder.driverImage">
              <img :src="formData.TourCarOrder.driverImage" 
              alt="司机照片" 
              style="width:100px;height:100px;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车型种类" prop="TourCarOrder.carModel">
              <el-select
                class="input-item"
                v-model="formData.TourCarOrder.carModel"
                placeholder=""
                :clearable="true"
                :filterable="true"
                :disabled="true"
                @visible-change="carModelWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in carModelWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车型车名" prop="TourCarOrder.carName">
              <el-input
                class="input-item"
                v-model="formData.TourCarOrder.carName"
                type="text"
                placeholder=""
                :clearable="true"
                :show-word-limit="false"
                maxlength=""
                :readonly="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车型座位数" prop="TourCarOrder.carSeatNumber">
              <el-input-number
                class="input-item"
                v-model="formData.TourCarOrder.carSeatNumber"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车型行李数" prop="TourCarOrder.carLuggageNumber">
              <el-input-number
                class="input-item"
                v-model="formData.TourCarOrder.carLuggageNumber"
                placeholder=""
                :clearable="true"
                :step="1"
                :controls="true"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车型照片" prop="TourCarOrder.carImage">
              <img :src="formData.TourCarOrder.carImage" 
              alt="车型照片" 
              style="width:100px;height:100px;" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车型归属" prop="TourCarOrder.categoryType">
              <el-select
                class="input-item"
                v-model="formData.TourCarOrder.categoryType"
                placeholder=""
                :clearable="true"
                :filterable="true"
                @visible-change="categoryTypeWidget.onVisibleChange"
              >
                <el-option
                  v-for="item in categoryTypeWidgetDropdownList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-scrollbar>
  </div>
</template>

<script lang="ts">
export default {
  name: 'formViewCarOrder',
};
</script>

<script setup lang="ts">
import { DialogProp } from '@/components/Dialog/types';
import { VxeColumn, VxeTable } from 'vxe-table';
import { ANY_OBJECT } from '@/types/generic';
import { DictData, DictionaryBase } from '@/common/staticDict/types';
import { ElMessage, ElMessageBox, UploadFile } from 'element-plus';
import { useRoute, useRouter } from 'vue-router';
import { useCommon } from '@/common/hooks/useCommon';
import { useLayoutStore, useStaticDictStore } from '@/store';
import { useDownload } from '@/common/hooks/useDownload';
import { useDropdown } from '@/common/hooks/useDropdown';
import { DropdownOptions, ListData } from '@/common/types/list';
import { useTable } from '@/common/hooks/useTable';
import { TableOptions } from '@/common/types/pagination';
import { useUpload } from '@/common/hooks/useUpload';
import { useUploadWidget } from '@/common/hooks/useUploadWidget';
import { DictionaryController } from '@/api/system';
import { treeDataTranslate, findItemFromList, findTreeNodePath, findTreeNode, stringCase } from '@/common/utils';
import { TourCarDriverData } from '@/api/generated/tourCarDriverController';
import { TourCarOrderData } from '@/api/generated/tourCarOrderController';
import { TourCarCategoryData } from '@/api/generated/tourCarCategoryController';
import { TourCarDriverController, TourCarOrderController, TourCarCategoryController } from '@/api/generated';

const router = useRouter();
const route = useRoute();
const layoutStore = useLayoutStore();
const { downloadFile } = useDownload();
const { getUploadHeaders, getUploadActionUrl, fileListToJson, parseUploadData, getPictureList } = useUpload();
const { 
  Delete,
  Search,
  Edit,
  Plus,
  Refresh,
  Picture,
  Dialog,
  mainContextHeight,
  clientHeight,
  checkPermCodeExist,
  parseParams,
  parseArrayParams,
  formatDateByStatsType,
  getDateRangeFilter,
} = useCommon();
// 静态字典
const { staticDict: StaticDict } = useStaticDictStore();

const props = withDefaults(
  defineProps<{
    subPage?: number | string | boolean;
    id?: ANY_OBJECT;
    saveOnSubmit?: boolean;
    rowData?: ANY_OBJECT;
    // 当使用Dialog.show弹出组件时，须定义该prop属性，以便对dialog进行回调
    dialog?: DialogProp<ANY_OBJECT[]>;
  }>(),
  {
    subPage: 0,
    id: undefined,
    saveOnSubmit: true,
    rowData: undefined,
    dialog: undefined,
  },
);

const formViewCarOrderRef = ref();
// 表单数据定义
type FormViewCarOrderData = {
  TourCarOrder: TourCarOrderData;
};
// 表单数据
const formData = reactive<FormViewCarOrderData>({
  TourCarOrder: {
    // id
    id: undefined,
    // 订单号
    orderNo: undefined,
    // 包车车型id
    categoryId: undefined,
    // 司机id
    driverId: undefined,
    // 开始时间
    startTime: undefined,
    // 结束时间
    endTime: undefined,
    // 包车天数
    days: undefined,
    // 起点
    startPlaceId: undefined,
    // 联系电话
    connectPhone: undefined,
    // 联系姓名
    connectName: undefined,
    // 联系人性别
    connectSex: undefined,
    // 备注
    remark: undefined,
    // 订单状态(1.已下单;2.已取消;3. 已完成)
    state: undefined,
    // 创建用户
    createUserId: undefined,
    // 创建时间
    createTime: undefined,
    // 更新用户
    updateUserId: undefined,
    // 更新时间
    updateTime: undefined,
    // 删除标记(1: 正常 -1: 已删除)
    dataState: undefined,
    // 车型评分
    categoryMark: undefined,
    // 司机评分
    driveMark: undefined,
    // 乘车人微信
    connectWechat: undefined,
    // 司机名称
    driverName: undefined,
    // 司机性别
    driverSex: undefined,
    // 司机年龄
    driverAge: undefined,
    // 司机驾龄
    drivingYears: undefined,
    // 司机联系方式
    driverMobile: undefined,
    // 司机照片
    driverImage: undefined,
    // 车型种类
    carModel: undefined,
    // 车型车名
    carName: undefined,
    // 车型座位数
    carSeatNumber: undefined,
    // 车型行李数
    carLuggageNumber: undefined,
    // 车型照片
    carImage: undefined,
    // 包车每天的价格
    dayPrice: undefined,
    // 包车每天的单位
    dayPriceUnit: undefined,
    // 订单总价格
    totalPrice: undefined,
    // 订单总价格的单位
    totalPriceUnit: undefined,
    // 车型归属(1.平台自营;2.三方个人)
    categoryType: undefined,
    tourCarCategory: {
      // id
      id: undefined,
      // 车型种类
      model: undefined,
      // 标题
      title: undefined,
      // 车名
      name: undefined,
      // 包车价格
      price: undefined,
      // 单位
      unit: undefined,
      // 座位数
      seatNumber: undefined,
      // 图片
      image: undefined,
      // 车型归属(1.平台自营;2.三方个人)
      type: undefined,
      // 关联司机(若车型归属为2，则必填)
      relationDriverId: undefined,
      // 车型标签(以 ,隔开)
      label: undefined,
      // 创建用户
      createUserId: undefined,
      // 创建时间
      createTime: undefined,
      // 更新用户
      updateUserId: undefined,
      // 更新时间
      updateTime: undefined,
      // 删除标记(1: 正常 -1: 已删除)
      dataState: undefined,
      // 评分
      mark: undefined,
      // 组织id
      deptId: undefined,
      // 是否启用
      enable: undefined,
      // 热度值
      hotValue: undefined,
      // 所属区域
      belongTab: undefined,
      // 行李数
      luggageNumber: undefined,
    },
    tourCarDriver: {
      // id
      id: undefined,
      // 司机名称
      name: undefined,
      // 性别
      sex: undefined,
      // 年龄
      age: undefined,
      // 驾龄
      drivingYears: undefined,
      // 司机照片
      image: undefined,
      // 创建用户
      createUserId: undefined,
      // 创建时间
      createTime: undefined,
      // 更新用户
      updateUserId: undefined,
      // 更新时间
      updateTime: undefined,
      // 删除标记(1: 正常 -1: 已删除)
      dataState: undefined,
      // 评分
      mark: undefined,
      // 热度值
      hotValue: undefined,
      // 组织id
      deptId: undefined,
      // 联系方式
      mobile: undefined,
      // 司机类型(1.自营;2.第三方)
      type: undefined,
      // 所属区域
      belongTab: undefined,
    },
  },
},
);
// 表单验证规则
const rules = reactive({
  'TourCarOrder.driverSex': [
  ],
  'TourCarOrder.carImage': [
  ],
  'TourCarOrder.carName': [
  ],
  'TourCarOrder.driverName': [
  ],
  'TourCarOrder.driverImage': [
  ],
  'TourCarOrder.connectPhone': [
  ],
  'TourCarOrder.connectWechat': [
  ],
  'TourCarOrder.driverAge': [
  ],
  'TourCarOrder.connectName': [
  ],
  'TourCarOrder.driverMobile': [
  ],
  'TourCarOrder.days': [
  ],
  'TourCarOrder.categoryType': [
  ],
  'TourCarOrder.startPlaceId': [
  ],
  'TourCarOrder.state': [
  ],
  'TourCarOrder.orderNo': [
  ],
  'TourCarOrder.connectSex': [
  ],
  'TourCarOrder.remark': [
  ],
  'TourCarOrder.endTime': [
  ],
  'TourCarOrder.carModel': [
  ],
  'TourCarOrder.carLuggageNumber': [
  ],
  'TourCarOrder.drivingYears': [
  ],
  'TourCarOrder.startTime': [
  ],
  'TourCarOrder.carSeatNumber': [
  ],
});

const onCancel = () => {
  if (props.dialog) {
    props.dialog.cancel();
  }
};

const isEdit = computed(() => {
  return props.saveOnSubmit ? props.id != null : props.rowData != null;
});

// 初始化页面数据
const loadTourCarOrderData = () => {
  return new Promise<void>((resolve, reject) => {
    if (!isEdit.value) {
      resolve();
      return;
    }
    if (!props.saveOnSubmit && props.rowData != null) {
      formData.TourCarOrder = JSON.parse(JSON.stringify(props.rowData));
      resolve();
      return;
    }
    let params: ANY_OBJECT = {
      id: props.id
    };
    TourCarOrderController.view(params).then(res => {
      formData.TourCarOrder = { ...res.data };
      if (formData.TourCarOrder.tourCarCategory == null) {
        formData.TourCarOrder.tourCarCategory = {
          id: undefined,
          model: undefined,
          title: undefined,
          name: undefined,
          price: undefined,
          unit: undefined,
          seatNumber: undefined,
          image: undefined,
          type: undefined,
          relationDriverId: undefined,
          label: undefined,
          createUserId: undefined,
          createTime: undefined,
          updateUserId: undefined,
          updateTime: undefined,
          dataState: undefined,
          mark: undefined,
          deptId: undefined,
          enable: undefined,
          hotValue: undefined,
          belongTab: undefined,
          luggageNumber: undefined
        };
      }
      if (formData.TourCarOrder.tourCarDriver == null) {
        formData.TourCarOrder.tourCarDriver = {
          id: undefined,
          name: undefined,
          sex: undefined,
          age: undefined,
          drivingYears: undefined,
          image: undefined,
          createUserId: undefined,
          createTime: undefined,
          updateUserId: undefined,
          updateTime: undefined,
          dataState: undefined,
          mark: undefined,
          hotValue: undefined,
          deptId: undefined,
          mobile: undefined,
          type: undefined,
          belongTab: undefined
        };
      }
      resolve();
    }).catch(e => {
      reject(e);
    });
  });
};
/**
 * 订单状态下拉数据获取函数
 */
const loadStateDropdownList = (): Promise<ListData<DictData>> => {
  return Promise.resolve({
    dataList: StaticDict.TourCarOrderState.getList(),
  });
};
// 订单状态配置参数
const stateOptions: DropdownOptions<DictData> = {
  loadData: loadStateDropdownList,
  isTree: false,
};
// 订单状态下拉组件
const stateWidget = useDropdown(stateOptions);
const { dropdownList: stateWidgetDropdownList } = stateWidget
/**
 * 起点下拉数据获取函数
 */
const loadStartPlaceIdDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    const params = {
    };
    DictionaryController.dictTourCarContractMenuByParentId(params).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 起点配置参数
const startPlaceIdOptions: DropdownOptions<DictData> = {
  loadData: loadStartPlaceIdDropdownList,
  isTree: false,
};
// 起点下拉组件
const startPlaceIdWidget = useDropdown(startPlaceIdOptions);
const { dropdownList: startPlaceIdWidgetDropdownList } = startPlaceIdWidget
/**
 * 乘客联系人性别下拉数据获取函数
 */
const loadConnectSexDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'UserSex', itemIdType: 'Integer' }).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 乘客联系人性别配置参数
const connectSexOptions: DropdownOptions<DictData> = {
  loadData: loadConnectSexDropdownList,
  isTree: false,
};
// 乘客联系人性别下拉组件
const connectSexWidget = useDropdown(connectSexOptions);
const { dropdownList: connectSexWidgetDropdownList } = connectSexWidget
/**
 * 司机性别下拉数据获取函数
 */
const loadDriverSexDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    DictionaryController.dictGlobalDict({ dictCode: 'UserSex', itemIdType: 'Integer' }).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 司机性别配置参数
const driverSexOptions: DropdownOptions<DictData> = {
  loadData: loadDriverSexDropdownList,
  isTree: false,
};
// 司机性别下拉组件
const driverSexWidget = useDropdown(driverSexOptions);
const { dropdownList: driverSexWidgetDropdownList } = driverSexWidget
/**
 * 司机照片上传文件改变
 */
const onDriverImageChange = val => {
  formData.TourCarOrder.driverImage = fileListToJson(val);
};
// 司机照片上传文件组件
const driverImageWidget = useUploadWidget(1);
const { fileList: driverImageWidgetFileList, maxCount: driverImageWidgetMaxCount } = driverImageWidget;
/**
 * 车型种类下拉数据获取函数
 */
const loadCarModelDropdownList = (): Promise<ListData<DictData>> => {
  return new Promise((resolve, reject) => {
    const params = {
    };
    DictionaryController.dictTourCarModel(params).then(res => {
      resolve({
        dataList: res.getList(),
      });
    }).catch(e => {
      reject(e);
    });
  });
};
// 车型种类配置参数
const carModelOptions: DropdownOptions<DictData> = {
  loadData: loadCarModelDropdownList,
  isTree: false,
};
// 车型种类下拉组件
const carModelWidget = useDropdown(carModelOptions);
const { dropdownList: carModelWidgetDropdownList } = carModelWidget
/**
 * 车型照片上传文件改变
 */
const onCarImageChange = val => {
  formData.TourCarOrder.carImage = fileListToJson(val);
};
// 车型照片上传文件组件
const carImageWidget = useUploadWidget(1);
const { fileList: carImageWidgetFileList, maxCount: carImageWidgetMaxCount } = carImageWidget;
/**
 * 车型归属下拉数据获取函数
 */
const loadCategoryTypeDropdownList = (): Promise<ListData<DictData>> => {
  return Promise.resolve({
    dataList: StaticDict.TourCarType.getList(),
  });
};
// 车型归属配置参数
const categoryTypeOptions: DropdownOptions<DictData> = {
  loadData: loadCategoryTypeDropdownList,
  isTree: false,
};
// 车型归属下拉组件
const categoryTypeWidget = useDropdown(categoryTypeOptions);
const { dropdownList: categoryTypeWidgetDropdownList } = categoryTypeWidget
const onUploadError = () => {
  ElMessage.error('文件上传失败');
};
const onUploadLimit = () => {
  ElMessage.error('已经超出最大上传个数限制');
};
const refreshFormViewCarOrder = () => {
  // 刷新段落
};
/**
 * 重置过滤值
 */
const resetFormViewCarOrder = () => {
  refreshFormViewCarOrder();
};
/**
 * 重置所有过滤值
 */
const resetFilter = () => {
  resetFormViewCarOrder();
};
const formInit = () => {
  loadTourCarOrderData().then(res => {
    stateWidget.onVisibleChange(true).catch(e => {console.error(e)});
    startPlaceIdWidget.onVisibleChange(true).catch(e => {console.error(e)});
    connectSexWidget.onVisibleChange(true).catch(e => {console.error(e)});
    driverSexWidget.onVisibleChange(true).catch(e => {console.error(e)});
    let driverImageDownloadParams = {
      id: formData.TourCarOrder.id,
      fieldName: 'driverImage',
      asImage: true
    };
    driverImageWidgetFileList.value = parseUploadData(formData.TourCarOrder.driverImage, driverImageDownloadParams);
    carModelWidget.onVisibleChange(true).catch(e => {console.error(e)});
    let carImageDownloadParams = {
      id: formData.TourCarOrder.id,
      fieldName: 'carImage',
      asImage: true
    };
    carImageWidgetFileList.value = parseUploadData(formData.TourCarOrder.carImage, carImageDownloadParams);
    categoryTypeWidget.onVisibleChange(true).catch(e => {console.error(e)});
    if (isEdit.value) refreshFormViewCarOrder();
  }).catch(e => {
    // TODO: 异常处理
    console.error(e);
  });
};

onMounted(() => {
  formInit();
});
</script>
