wujianwei
2025-12-25 ccfedfe40d734687f1a8b72ea47abe160f2fa9a7
ui/admin-ui3/src/views/tms/tmsConsignor/index.vue
@@ -60,12 +60,13 @@
  updateTmsConsignor
} from "@/api/tms/tmsConsignor";
import useCurrentInstance from "@/utils/useCurrentInstance";
import {computed, reactive, ref, toRefs,watch,onMounted} from "vue";
import {computed, reactive, ref, toRefs,watch,nextTick} from "vue";
import {PagesInterface, PageQueryInterface} from "@/utils/globalInterface";
import {usePagePlus} from "@/hooks/usePagePlus";
import {hasPermission} from "@/utils/permissionUtils";
import {getTmsCustomerInfo, listTmsCustomerInfo} from "@/api/tms/tmsCustomerInfo";
import {getArea, getCity, getProvince, getStreet} from "@/api/tms/tmsRegion";
import {getArea, getCity, getProvince, getStreet,getAddressCode} from "@/api/tms/tmsRegion";
import {mapRegeo} from "@/api/common";
const {proxy} = useCurrentInstance();
const crudRef = ref();
@@ -101,8 +102,8 @@
      prop: 'jcxx',
      column:{
        consignorCode: {
          label: '收发货人编码',minWidth: 150,
          addDisplay: true,
          label: '装卸货点编码',minWidth: 150,
          addDisplay: false, disabled: true,
          editDisplay: true,
          viewDisplay: true,
          hide: false,
@@ -110,12 +111,12 @@
          rules: [
            {
              required: true,
              message: "收发货人编码不能为空", trigger: "blur"
              message: "装卸货点编码不能为空", trigger: "blur"
            }
          ],
        },
        consignorName: {
          label: '收发货人名称',minWidth: 150,
          label: '装卸货点名称',minWidth: 150,
          addDisplay: true,
          editDisplay: true,
          viewDisplay: true,
@@ -124,7 +125,7 @@
          rules: [
            {
              required: true,
              message: "收发货人名称不能为空", trigger: "blur"
              message: "装卸货点名称不能为空", trigger: "blur"
            }
          ],
        },
@@ -147,7 +148,7 @@
              message: "所属客户不能为空", trigger: "change"
            }
          ],
          type: 'table',
          type: 'table',dataType: 'string',
          children:{
            border: true,
            searchMenuSpan: 5,
@@ -168,7 +169,7 @@
              contactName: {
                label: '联系人姓名',minWidth: 120,
              },
              signCompany: {
              signCompanyName: {
                label: '签约公司', minWidth: 150,
              },
            },
@@ -196,7 +197,21 @@
              })
            }
          }
          },
          change: (val: any) => {
            const table = crudRef.value?.getPropRef?.('customerId')?.$refs?.temp;
            if (!table) return;
            let active = table.active;
            if (Array.isArray(active)) active = active[0];
            if (active) {
              Object.assign(form.value, {
                customerId: active.id,
                customerSysCode: active.customerCode,
                customerName: active.customerShortName,
              });
            }
          },
        },
        customerSysCode: {
          label: '客户编码',minWidth: 150,
@@ -214,7 +229,7 @@
          ],
        },
        consignorType: {
          label: '收发货人类型',minWidth: 150,
          label: '装卸货点类型',minWidth: 150,
          type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/consignor_type',
          addDisplay: true,
          editDisplay: true,
@@ -224,7 +239,7 @@
          rules: [
            {
              required: true,
              message: "收发货人类型不能为空", trigger: "change"
              message: "装卸货点类型不能为空", trigger: "change"
            }
          ],
        },
@@ -270,70 +285,7 @@
      label: '地址信息',
      prop: 'dzxx',
      column:{
        region: {
          label: '行政区域',minWidth: 150,type:'cascader',
          addDisplay: true,
          editDisplay: true,
          viewDisplay: true,span: 24,
          hide: true,
          search: false,
          lazy: true,
          props: {
            label: 'name',
            value: 'code'
          },
          rules: [
            {
              required: true,
              message: "省份不能为空", trigger: "blur"
            }
          ],
          change:({value=[]}:{value:any})=>{
            if (value && value.length>0){
              form.value.provinceId = value[0];
              form.value.cityId = value[1];
              form.value.districtId = value[2];
              form.value.streetId = value[3];
            }
          },
          lazyLoad (node:any, resolve:any) {
            const stopLevel = 3;
            const level = node.level;
            const data = node.data || {};
            const code = data.code;
            let list:any = [];
            const callback = () => {
              resolve((list || []).map((ele:any) => ({
                ...ele,
                leaf: level >= stopLevel
              })));
            };
            if (level === 0) {
              getProvince().then(res => {
                list = res.data || [];
                callback();
              });
            } else if (level === 1) {
              getCity(code).then(res => {
                list = res.data ||[];
                callback();
              });
            } else if (level === 2) {
              getArea(code).then(res => {
                list = res.data ||  [];
                callback();
              });
            }else if (level === 3) {
              getStreet(code).then(res => {
                list = res.data || [];
                callback();
              });
            } else {
              callback();
            }
          }
        },
        mapLocationDetail: {
          label: '地图位置',minWidth: 150,
          addDisplay: true,
@@ -342,6 +294,44 @@
          hide: true,
          search: false,
          type: 'map',
          // mapChange: async (params:any)=>{
          //   if (params.info === "OK") {
          //     console.log( params)
          //     let { province, city, district, township } = params.regeocode.addressComponent || {};
          //
          //     const res = await getAddressCode({province, city, district, township});
          //     const {provinceCode, cityCode, districtCode, townshipCode} = res.data || {};
          //
          //     form.value.regionLabel = province + " / " + city + " / " + district + " / " + township;
          //
          //     form.value.region = [provinceCode, cityCode, districtCode, townshipCode];
          //     form.value.provinceId = provinceCode;
          //     form.value.cityId = cityCode;
          //     form.value.districtId = districtCode;
          //     form.value.streetId = townshipCode;
          //
          //     form.value.dispatchTransportArea = params.regeocode.formattedAddress;
          //
          //   }
          // }
          change: async ({value}:any)=>{
            if (Array.isArray(value) && value.length === 3){
              mapRegeo(value[1], value[0]).then(async res => {
                let params = res.data || {};
                if (params.info === "OK") {
                  let {province, city, district, township} = params.regeocode.addressComponent || {};
                  const res = await getAddressCode({province, city, district, township});
                  const {provinceCode, cityCode, districtCode, townshipCode} = res.data || {};
                  form.value.regionLabel = province + " / " + city + " / " + district + " / " + township;
                  form.value.provinceId = provinceCode;
                  form.value.cityId = cityCode;
                  form.value.districtId = districtCode;
                  form.value.streetId = townshipCode;
                  form.value.dispatchTransportArea = params.regeocode.formatted_address || params.regeocode.formattedAddress;
                }
              });
            }
          },
        },
        dispatchTransportArea: {
          label: '调度单运输地',
@@ -357,6 +347,94 @@
            }
          ],
        },
        electronicFenceRange: {
          label: '电子围栏范围',
          addDisplay: true,minWidth: 150,
          editDisplay: true,
          viewDisplay: true,append:'米',
          hide: false,
          search: true,
          rules: [
            {
              required: true,
              message: "电子围栏范围不能为空", trigger: "blur"
            }
          ],
        },
        // region: {
        //   label: '行政区域',minWidth: 150,type:'cascader',
        //   addDisplay: true,
        //   editDisplay: true,checkStrictly:true,
        //   viewDisplay: true,span: 24,checkOnClickNode:true,
        //   hide: true,
        //   search: false,
        //   lazy: true,
        //   props: {
        //     label: 'name',
        //     value: 'code'
        //   },
        //   rules: [
        //     {
        //       required: true,
        //       message: "行政区域不能为空", trigger: "blur"
        //     }
        //   ],
        //   change:({value=[]}:{value:any})=>{
        //     if (value && value.length>0){
        //       console.log( value)
        //       form.value.provinceId = value[0];
        //       form.value.cityId = value[1];
        //       form.value.districtId = value[2];
        //       form.value.streetId = value[3];
        //       const cascader = crudRef.value?.getPropRef?.('region')?.$refs?.temp;
        //       console.log('cascader.getCheckedNodes()',cascader)
        //       nextTick(()=>{
        //         crudRef.value.getPropRef('region').$refs.temp.$forceUpdate()
        //       })
        //       if (cascader.getCheckedNodes() && cascader.getCheckedNodes().length >0){
        //         form.value.regionLabel= cascader.getCheckedNodes()[0].text!;
        //       }
        //     }
        //   },
        //   lazyLoad (node:any, resolve:any) {
        //     const stopLevel = 3;
        //     const level = node.level;
        //     const data = node.data || {};
        //     const code = data.code;
        //     let list:any = [];
        //     const callback = () => {
        //
        //       resolve((list || []).map((ele:any) => ({
        //         ...ele,
        //         leaf: level >= stopLevel
        //       })));
        //     };
        //     console.log( level)
        //     if (level === 0) {
        //       getProvince().then(res => {
        //         list = res.data || [];
        //         callback();
        //       });
        //     } else if (level === 1) {
        //       getCity(code).then(res => {
        //         list = res.data ||[];
        //         callback();
        //       });
        //     } else if (level === 2) {
        //       getArea(code).then(res => {
        //         list = res.data ||  [];
        //         callback();
        //       });
        //     }else if (level === 3) {
        //       getStreet(code).then(res => {
        //         list = res.data || [];
        //         callback();
        //       });
        //     } else {
        //       callback();
        //     }
        //   }
        // },
      }
    },
    {
@@ -437,13 +515,13 @@
  column: {
    consignorCode: {
      label: '收发货人编码',minWidth: 150,
      label: '装卸货点编码',minWidth: 150,
      display: false,
      hide: false,
      search: true,
    },
    consignorName: {
      label: '收发货人名称',minWidth: 150,
      label: '装卸货点名称',minWidth: 150,
      display: false,
      hide: false,
      search: true,
@@ -462,7 +540,7 @@
      disabled: true,
    },
    consignorType: {
      label: '收发货人类型',minWidth: 150,
      label: '装卸货点类型',minWidth: 150,
      type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/consignor_type',
      display: false,
      hide: false,
@@ -537,22 +615,29 @@
  },
  rowSaveBegin:(row:any)=>{
    if (row.mapLocationDetail){
      row.mapLocation = row.mapLocationDetail[1]+','+row.mapLocationDetail[0];
      row.mapLocation = row.mapLocationDetail[0]+','+row.mapLocationDetail[1];
      row.addressDetail = row.mapLocationDetail[2]
    }
  },
  rowUpdateBegin:(row:any)=>{
    if (row.mapLocationDetail){
      row.mapLocation = row.mapLocationDetail[1]+','+row.mapLocationDetail[0];
      row.mapLocation = row.mapLocationDetail[0]+','+row.mapLocationDetail[1];
      row.addressDetail = row.mapLocationDetail[2]
    }
  },
  handleEndOpenFunc:()=>{
    form.value.region = [form.value.provinceId, form.value.cityId,
      form.value.districtId, form.value.streetId];
    if (form.value.mapLocation && form.value.addressDetail){
      form.value.mapLocationDetail = [...form.value.mapLocation.split(','), form.value.addressDetail];
  handleEndOpenFunc:  ()=>{
    if (form.value.mapLocation && form.value.addressDetail) {
      form.value.mapLocationDetail = [...form.value.mapLocation.split(',').map(item=> Number(item)), form.value.addressDetail];
      crudRef.value.getPropRef('mapLocationDetail').$refs.temp.text = form.value.mapLocationDetail;
    }
    // nextTick(()=>{
    //   crudRef.value.getPropRef('region').$refs.temp.$forceUpdate()
    // })
    console.log( )
     // crudRef.value.getPropRef('region').$refs.temp.setCheckedKeys(form.value.region);
  },
  handleBeforeOpenFunc:(type:string)=>{
    if (type=='add'){
@@ -560,27 +645,6 @@
    }
  }
})
onMounted(() => {
  watch(() => form.value.customerId, () => {
      if (!form.value.customerId){
        return;
      }
      const table = crudRef.value?.getPropRef?.('customerId')?.$refs?.temp;
      if (!table) return;
      let active = table.active;
      if (Array.isArray(active)) active = active[0];
      if (active) {
        Object.assign(form.value, {
          customerId: active.id,
          customerSysCode: active.customerCode,
          customerName: active.customerShortName,
        });
      }
  });
});
</script>