zhangback
2025-11-18 f7490c5b05906399fe754fecdb1f32172a01170d
ui/admin-ui3/src/views/tms/tmsDispatchOrder/index.vue
@@ -46,15 +46,37 @@
        </el-button>
        <el-button
            type="success"
            icon="Delete"
            icon="Promotion"
            :disabled="pageF.multiple"
            @click="handleGenerate"
            v-hasPermi="['tms:tmsDispatchOrder:generate']"
        >生成应收应付费用
        </el-button>
        <el-button
            type="warning"
            icon="Female"
            :disabled="pageF.single"
            @click="handleDropHook"
            v-hasPermi="['tms:tmsDispatchOrder:dropHook']"
        >甩挂
        </el-button>
        <el-button
            type="primary"
            icon="Male"
            :disabled="pageF.single"
            @click="handleConnectHang"
            v-hasPermi="['tms:tmsDispatchOrder:connectHang']"
        >接挂
        </el-button>
      </template>
      <template #menu-before="{row}">
        <el-link size="small" type="primary"  @click="handleAddGoods(row)" class="link-btn"
                 :underline="false" icon="el-icon-document-add">运输货品登记
        </el-link>
        <el-link size="small" type="primary"  @click="handleActual(row)" class="link-btn"
                 :underline="false" icon="el-icon-set-up">实际运输记录
        </el-link>
        <el-link size="small" type="primary" v-if="row.status == 0" @click="handleConfirm(row)" class="link-btn"
                 :underline="false" icon="el-icon-pointer">确定
        </el-link>
@@ -103,6 +125,82 @@
      </template>
    </el-dialog>
    <el-dialog :title="title" v-model="open" class="avue-dialog avue-dialog--top" width="40%">
      <div v-if="optionType === 'dropHook'">
        <el-descriptions
            :column="2"
            border
        >
          <el-descriptions-item label="调度单号">{{ form.dispatchNo }}</el-descriptions-item>
          <el-descriptions-item label="客户" >{{ form.customerName }}</el-descriptions-item>
          <el-descriptions-item label="实际运输工具类型" >{{ form.$actualVehicleType}}</el-descriptions-item>
          <el-descriptions-item label="运输工具号码" >{{ form.licensePlate }}</el-descriptions-item>
          <el-descriptions-item label="托架号" >{{ form.shelfCode }}</el-descriptions-item>
          <el-descriptions-item label="主驾驶员" >{{ form.mainDriverName }}</el-descriptions-item>
          <el-descriptions-item label="副驾驶员" >{{ form.assistantDriverName }}</el-descriptions-item>
        </el-descriptions>
      </div>
      <div  v-if="optionType == 'connectHang'">
        <el-descriptions style="margin-bottom: 20px"
            :column="2"
            border
        >
          <el-descriptions-item label="调度单号">{{ form.dispatchNo }}</el-descriptions-item>
          <el-descriptions-item label="客户" >{{ form.customerName }}</el-descriptions-item>
          <el-descriptions-item label="实际运输工具类型" >{{ form.$actualVehicleType}}</el-descriptions-item>
          <el-descriptions-item label="托架号" >{{ form.shelfCode }}</el-descriptions-item>
        </el-descriptions>
        <avue-form v-model="form" ref="boxFormRef" :option="boxFormOption">
        </avue-form>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary"  :loading="pageF.isUploading" @click="submitForm2">
            {{ pageF.isUploading ? '提交中' : '确 定' }}
          </el-button>
          <el-button @click="cancelBox2">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <el-dialog title="货品信息登记" v-model="open2" class="avue-dialog avue-dialog--top" width="80%">
      <avue-crud
          :option="goodsTableOption"
          v-model="goodsForm"
          @row-update="rowGoodsUpdate"
          @row-save="rowGoodsSave"
          @row-del="rowGoodsDel"
          :data="goodsTableData" ref="goodsCrudRef"
      >
      </avue-crud>
<!--      <template #footer>-->
<!--        <div class="dialog-footer">-->
<!--          <el-button type="primary"  :loading="pageF.isUploading" @click="submitForm2">-->
<!--            {{ pageF.isUploading ? '提交中' : '确 定' }}-->
<!--          </el-button>-->
<!--          <el-button @click="open2 = false">取 消</el-button>-->
<!--        </div>-->
<!--      </template>-->
    </el-dialog>
    <el-dialog title="实际运输信息" v-model="open3" class="avue-dialog avue-dialog--top" width="80%">
      <avue-form  v-model="actualForm"
                  ref="actualFormRef"
                  :option="actualFormOption">
      </avue-form>
            <template #footer>
              <div class="dialog-footer">
                <el-button type="primary"  :loading="pageF.isUploading" @click="submitForm3">
                  {{ pageF.isUploading ? '提交中' : '确 定' }}
                </el-button>
                <el-button @click="open3 = false">取 消</el-button>
              </div>
            </template>
    </el-dialog>
  </basicContainer>
@@ -117,7 +215,7 @@
  getTmsDispatchOrder,
  listTmsDispatchOrder,
  updateTmsDispatchOrder,
  confirmOrder, copyOrder, okOrder
  confirmOrder, copyOrder, okOrder, initGenerate, generateTmsDispatchOrder, dropHook, connectHang
} from "@/api/tms/tmsDispatchOrder";
import useCurrentInstance from "@/utils/useCurrentInstance";
import {computed, onMounted, reactive, ref, toRefs, watch} from "vue";
@@ -135,11 +233,15 @@
import {getTmsConsignor, listTmsConsignor} from "@/api/tms/tmsConsignor";
import {ElMessage, ElMessageBox} from "element-plus";
import {addTmsTrip, listTmsTrip} from "@/api/tms/tmsTrip";
import {addTmsFinanceDetail, listTmsFinanceDetail} from "@/api/tms/tmsFinanceDetail";
import {addTmsFinanceDetail, listTmsFinanceDetail, updateTmsFinanceDetail} from "@/api/tms/tmsFinanceDetail";
import {getTmsProductInfo, listTmsProductInfo} from "@/api/tms/tmsProductInfo";
import {addTmsGoodsDetail, delTmsGoodsDetail, listTmsGoodsDetail, updateTmsGoodsDetail} from "@/api/tms/tmsGoodsDetail";
const {proxy} = useCurrentInstance();
const crudRef = ref();
const boxFormRef = ref();
const goodsCrudRef = ref();
const actualFormRef = ref();
const permissionList = (key: any, row: any, index: any) => {
@@ -168,11 +270,19 @@
  boxTableData: <any>[],
  boxForm: <any>{},
  boxFormOption: <any>{},
  boxTableOption: <any>{}
  boxTableOption: <any>{},
  title: '',
  open: false,
  open2:false,
  goodsTableData: <any>[],
  goodsForm:<any>{},
  open3: false,
  actualForm:<any>{},
})
const {queryParams, form, page, selectionList,
const {queryParams, form, page, selectionList,open3,
  boxTableData, optionType,
  boxFormOption,boxForm,boxTableOption
  boxFormOption,boxForm,boxTableOption,title,open,open2,
  goodsTableData,goodsForm,actualForm
} = toRefs(data);
const option = ref({
  pageKey: 'TmsDispatchOrder',
@@ -180,6 +290,7 @@
  labelWidth: 130,
  searchSpan: 6,
  searchLabelWidth: 150,
  menuWidth: 300,
  group: [
    {
      label: '基本信息',
@@ -205,6 +316,7 @@
                projectName: active.projectName,
                customerId: active.relatedCustomerId,
                customerName: active.relatedCustomerName,
                customerCode: active.relatedCustomerCode,
                contractId: active.relatedContractId,
                contractName: active.relatedContractName,
              });
@@ -692,7 +804,7 @@
        },
        requiredVehicleTypes: {
          label: '要求车型',
          display: true, type: 'select', dicUrl: '/system/dict/data/type/license_type', dataType: 'string',
          display: true, type: 'select', dicUrl: '/system/dict/data/type/vehicle_type', dataType: 'string',
          rules: [
            {
              required: true,
@@ -702,7 +814,7 @@
        },
        actualVehicleType: {
          label: '实际运输工具类型',
          display: true, type: 'select', dicUrl: '/system/dict/data/type/license_type', dataType: 'string',
          display: true, type: 'select', dicUrl: '/system/dict/data/type/vehicle_type', dataType: 'string',
        },
        vehicleId: {
          label: '车牌号',dataType: 'string',
@@ -1173,22 +1285,30 @@
      column: {
        earliestDeparture: {
          label: '要求最早出发时间',
          type: 'date', valueFormat: 'YYYY-MM-DD',
          type: 'datetime',  // 改为 datetime 类型
          format: 'YYYY-MM-DD HH:mm:ss',
          valueFormat: 'YYYY-MM-DD HH:mm:ss',
          display: true,
        },
        latestDeparture: {
          label: '要求最晚出发时间',
          type: 'date', valueFormat: 'YYYY-MM-DD',
          type: 'datetime',  // 改为 datetime 类型
          format: 'YYYY-MM-DD HH:mm:ss',
          valueFormat: 'YYYY-MM-DD HH:mm:ss',
          display: true,
        },
        earliestArrival: {
          label: '要求最早到达时间',
          type: 'date', valueFormat: 'YYYY-MM-DD',
          type: 'datetime',  // 改为 datetime 类型
          format: 'YYYY-MM-DD HH:mm:ss',
          valueFormat: 'YYYY-MM-DD HH:mm:ss',
          display: true,
        },
        latestArrival: {
          label: '要求最晚到达时间',
          type: 'date', valueFormat: 'YYYY-MM-DD',
          type: 'datetime',  // 改为 datetime 类型
          format: 'YYYY-MM-DD HH:mm:ss',
          valueFormat: 'YYYY-MM-DD HH:mm:ss',
          display: true,
        },
      }
@@ -1318,7 +1438,7 @@
      label: '实际运输工具类型', minWidth: 130,
      display: false,
      search: true,
      type: 'select', dicUrl: '/system/dict/data/type/license_type', dataType: 'string',
      type: 'select', dicUrl: '/system/dict/data/type/vehicle_type', dataType: 'string',
    },
@@ -1449,13 +1569,14 @@
    voucherUrl: {
      label: '行程凭证',
      display: true,
      type: 'upload',
      multiple: true,
      span: 24,
      propsHttp: {
      accept:'string',dataType: 'string',
      type: 'upload',
      action: '/common/upload2',
      propsHttp:{
        url: 'url',
        name: 'name',
        res: 'data'
        res: 'data',
      },
    },
    dataSource: {
@@ -1509,6 +1630,14 @@
    voucherUrl: {
      label: '行程凭证',
      display: true,
      span: 24,dataType: 'string',
      type: 'upload',
      action: '/common/upload2',
      propsHttp:{
        url: 'url',
        name: 'name',
        res: 'data',
      },
    },
  }
@@ -1543,13 +1672,14 @@
    voucherUrl: {
      label: '行程凭证',
      display: true,
      type: 'upload',
      multiple: true,
      span: 24,
      propsHttp: {
      accept:'string',dataType: 'string',
      type: 'upload',
      action: '/common/upload2',
      propsHttp:{
        url: 'url',
        name: 'name',
        res: 'data'
        res: 'data',
      },
    },
    dataSource: {
@@ -1594,6 +1724,15 @@
    feeVoucherUrl: {
      label: '费用凭证',
      display: true,
      span: 24,
      accept:'string',dataType: 'object',
      type: 'upload',
      action: '/common/upload2',
      propsHttp:{
        url: 'url',
        name: 'name',
        res: 'data',
      },
    },
  }
@@ -1604,14 +1743,14 @@
  addBtn: false,
  header: false, selection: false,
  column: {
    accountsReceivableName: {
    collectionPlanName: {
      label: '匹配应收方案名称', minWidth: 160,
    },
    accountsReceivableStatus: {
      label: '应收费用生成状态', minWidth: 160,
      type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/accounts_status',
    },
    accountsPayableName: {
    paymentPlanName: {
      label: '匹配应付方案名称', minWidth: 160,
    },
@@ -1646,7 +1785,7 @@
    actualVehicleType: {
      label: '车型', minWidth: 130,
      display: false,
      type: 'select', dicUrl: '/system/dict/data/type/license_type', dataType: 'string',
      type: 'select', dicUrl: '/system/dict/data/type/vehicle_type', dataType: 'string',
    },
    licensePlate: {
@@ -1654,6 +1793,345 @@
      display: false,
    },
  }
})
const connectHangOption = ref({
  menuBtn: false,
  labelWidth: 120,
  column: {
    vehicleId: {
      label: '接挂车辆号码',
      display: true,
      rules: [
        {
          required: true,
          message: "接挂车辆号码不能为空", trigger: "change"
        }
      ],
      type: 'table', suffixIcon: 'search',dataType: 'string',
      children: {
        border: true,
        searchLabelWidth: 100,
        searchMenuSpan: 5,
        column: {
          serviceProviderName: {
            label: '车辆服务商', minWidth: 130,
            search: true,
          },
          vehicleType: {
            label: '车辆类型', minWidth: 120,
            search: true,
          },
          internalCode: {
            label: '车辆内部编码', minWidth: 120,
            search: true,
          },
          licensePlate: {
            label: '车牌号', minWidth: 120,
            search: true,
          },
          licenseHk: {
            label: '香港牌照', minWidth: 120,
            search: true,
          },
          licenseMo: {
            label: '澳门牌照', minWidth: 120,
            search: true,
          },
        },
      },
      props: {
        label: 'licensePlate',
        value: 'id'
      },
      onLoad: ({page, value, data}: { page: any, value: any, data: any }, callback: any) => {
        if (value) {
          let id = value;
          if (Array.isArray(value)) {
            id = value[0]
          }
          getTmsVehicle(id).then(res => {
            return callback(res.data || {})
          })
        } else {
          listTmsVehicle({pageSize: page.pageSize, pageNum: page.currentPage, ...data}).then(res => {
            return callback({
              total: res.total,
              data: res.rows || [],
            })
          })
        }
      }
    },
    driverId: {
      label: '接挂司机',
      display: true,
      rules: [
        {
          required: true,
          message: "接挂司机不能为空", trigger: "change"
        }
      ],
      type: 'table', suffixIcon: 'search',dataType: 'string',
      children: {
        border: true,
        searchMenuSpan: 5,
        column: {
          vehicleProviderName: {
            label: '车辆服务商', minWidth: 130,
            search: true,
          },
          driverName: {
            label: '驾驶员姓名', minWidth: 120,
            search: true,
          },
          licenseType: {
            label: '准驾车型', minWidth: 120,
            type: 'select', dataType: 'string', dicUrl: '/system/dict/data/type/license_type',
            search: true,multiple:true,
          },
        },
      },
      props: {
        label: 'driverName',
        value: 'id'
      },
      onLoad: ({page, value, data}: { page: any, value: any, data: any }, callback: any) => {
        if (value) {
          let id = value;
          if (Array.isArray(value)) {
            id = value[0]
          }
          getTmsDriver(id).then(res => {
            return callback(res.data || {})
          })
        } else {
          listTmsDriver({pageSize: page.pageSize, pageNum: page.currentPage, ...data}).then(res => {
            return callback({
              total: res.total,
              data: res.rows || [],
            })
          })
        }
      }
    },
  }
})
const goodsTableOption = ref({
  pageKey: 'TmsGoodsDetail',
  rowKey: 'id',
  selection: false,
  viewBtn: false,
  column: {
    productId: {
      label: '货品名称',hide:true,
      display: true,minWidth: 120, type: 'table', suffixIcon: 'search',dataType: 'string',
      children: {
        border: true,
        searchLabelWidth: 100,
        searchMenuSpan: 5,
        column: {
          productCode: {
            label: '货品编码', minWidth: 130,
            search: true,
          },
          productName: {
            label: '货品名称', minWidth: 120,
            search: true,
          },
          grossWeight: {
            label: '货品重量', minWidth: 120,
            search: true,
          },
          netWeight: {
            label: '货品净重', minWidth: 120,
            search: true,
          },
          volume: {
            label: '货品体积', minWidth: 120,
            search: true,
          },
          productType: {
            label: '货品类型', minWidth: 120,
            search: true,
          },
        },
      },
      props: {
        label: 'productName',
        value: 'id'
      },
      onLoad: ({page, value, data}: { page: any, value: any, data: any }, callback: any) => {
        if (value) {
          let id = value;
          if (Array.isArray(value)) {
            id = value[0]
          }
          getTmsProductInfo(id).then(res => {
            return callback(res.data || {})
          })
        } else {
          listTmsProductInfo({pageSize: page.pageSize,
            pageNum: page.currentPage,
            ...data,
            customerId:form.value.customerId
          }).then(res => {
            return callback({
              total: res.total,
              data: res.rows || [],
            })
          })
        }
      },
      change: (val: any) => {
        const table = goodsCrudRef.value?.getPropRef?.('productId')?.$refs?.temp;
        if (!table) return;
        let active = table.active;
        if (Array.isArray(active)) active = active[0];
        if (active) {
          Object.assign(goodsForm.value, {
            productId: active.id,
            productName: active.productName,
            productType: active.productType,
            grossWeight: active.grossWeight,
            netWeight: active.netWeight,
            volume: active.volume,
            packUnit: active.packUnit,
          });
          goodsForm.value.sumWeight = active.grossWeight|| 0 * goodsForm.value.quantity;
          goodsForm.value.sumNetWeight = active.netWeight || 0* goodsForm.value.quantity;
          goodsForm.value.sumVolume = active.volume|| 0 * goodsForm.value.quantity;
        }
      },
    },
    productName: {
      label: '货品名称',minWidth: 120,
      display :false,
      hide: false,
    },
    quantity: {
      label: '数量',
      addDisplay :true,minWidth: 100,
      editDisplay :true,
      viewDisplay :true,
      value: 1,
      change:()=>{
        goodsForm.value.sumWeight = goodsForm.value.grossWeight || 0 * goodsForm.value.quantity;
        goodsForm.value.sumNetWeight = goodsForm.value.netWeight || 0* goodsForm.value.quantity;
        goodsForm.value.sumVolume = goodsForm.value.volume || 0 * goodsForm.value.quantity;
      }
    },
    sumWeight: {
      label: '重量(kg)',
      addDisplay :true,minWidth: 100,append: 'Kg',
      editDisplay :true,
      viewDisplay :true,
    },
    sumNetWeight: {
      label: '净重(kg)',
      addDisplay :true,
      editDisplay :true,minWidth: 100,append: 'Kg',
      viewDisplay :true,
    },
    sumVolume: {
      label: '体积(m³)',
      addDisplay :true,
      editDisplay :true,minWidth: 100,append: 'm³',
      viewDisplay :true,
    },
    loosePieces: {
      label: '散件数',
      addDisplay :true,
      editDisplay :true,minWidth: 100,
      viewDisplay :true,
    },
    fullContainers: {
      label: '整箱数',
      addDisplay :true,
      editDisplay :true,minWidth: 100,
      viewDisplay :true,
    },
    containerNo: {
      label: '集装箱号',
      addDisplay :true,
      editDisplay :true,minWidth: 100,
      viewDisplay :true,
    },
    palletCount: {
      label: '托数',
      addDisplay :true,minWidth: 100,
      editDisplay :true,
      viewDisplay :true,
    }
  }})
const actualFormOption = ref({
   menuBtn: false, labelWidth: 140,
  column:{
    departureAddress:{
      label: '实际出发地地址',
      span:24,
    },
    destinationAddress:{
      label: '实际目的地地址',
      span:24,
    },
    actualLoadStart: {
      label: '实际装车开始时间',
      type: 'datetime',  // 改为 datetime 类型
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      display: true,
    },
    actualUnloadEnd: {
      label: '实际卸车完成时间',
      type: 'datetime',  // 改为 datetime 类型
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      display: true,
    },
    actualDeparture: {
      label: '实际出发时间',
      type: 'datetime',  // 改为 datetime 类型
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      display: true,
    },
    actualArrival: {
      label: '实际到达时间',
      type: 'datetime',  // 改为 datetime 类型
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      display: true,
    },
    actualQuantity: {
      label: '实发数量',type: 'number',
    },
    actualWeight: {
      label: '实发重量',type: 'number',
    },
    actualVolume: {
      label: '实发体积',type: 'number',
    },
    reweighWeight: {
      label: '复磅重量',type: 'number',
    },
    electronicLock:{
      label: '电子锁',
    }
  }
})
@@ -1834,20 +2312,151 @@
}
const handleGenerate = () => {
  optionType.value = 'generate';
  pageF.open = true;
  pageF.title = '生成应收应付费用数据';
  boxTableOption.value = generateTableOption.value;
  let ids = selectionList.value.map((item:any) => item.id);
  initGenerate(ids).then(res => {
    boxTableData.value = res.data|| [];
    optionType.value = 'generate';
    pageF.open = true;
    pageF.title = '生成应收应付费用数据';
    boxTableOption.value = generateTableOption.value;
  })
}
const submitGenerate = () => {
  pageF.isUploading = true;
  let ids = selectionList.value.map((item:any) => item.id);
  generateTmsDispatchOrder(ids).then(res => {
    pageF.isUploading = false;
    ElMessage({
      message: "操作成功!",
      type: 'success'
    })
    cancelBox();
    onLoad(page.value);
  }).finally(()=>{
    pageF.isUploading = false;
  })
}
/**
 * 甩挂
 */
const handleDropHook = () => {
    title.value = '调度单甩挂';
  open.value = true;
  form.value = selectionList.value[0];
  optionType.value = 'dropHook';
}
/**
 * 接挂
 */
const handleConnectHang = () => {
  title.value = '调度单接挂';
  open.value = true;
  form.value = selectionList.value[0];
  optionType.value = 'connectHang';
  boxFormOption.value = connectHangOption.value;
}
const submitForm2 = () => {
  pageF.isUploading = true;
  if (optionType.value === 'dropHook') {
    dropHook(form.value.id).then(res => {
      ElMessage({
        message: "提交成功!",
        type: 'success'
      })
      cancelBox2();
      onLoad(page.value);
    }).finally(()=>{
      pageF.isUploading = false;
    })
  }else{
    connectHang({
      dispatchId:form.value.id,
      vehicleId:form.value.vehicleId,
      driverId:form.value.driverId
    }).then(res => {
      ElMessage({
        message: "提交成功!",
        type: 'success'
      })
      cancelBox2();
      onLoad(page.value);
    }).finally(()=>{
      pageF.isUploading = false
    })
  }
}
const cancelBox2 = () => {
  open.value = false;
}
onMounted(() => {
const handleAddGoods = (row: any) => {
  listTmsGoodsDetail({dispatchId: row.id,pageSize:999,pageNum:1}).then(res=>{
    goodsTableData.value =  res.rows || [];
    form.value = row;
    open2.value = true;
  })
}
const rowGoodsUpdate = (row:any,index:any,done:any, loading:any) => {
  updateTmsGoodsDetail(row).then(res => {
    ElMessage({
      message: "修改成功!",
      type: 'success'
    })
    handleAddGoods(form.value);
    onLoad(page.value);
    done();
  }).catch(()=>{
    loading()
  })
}
const rowGoodsSave = (row:any, done:any, loading:any) => {
  row.dispatchId = form.value.id;
  row.dispatchNo = form.value.dispatchNo;
  addTmsGoodsDetail(row).then(res=>{
    ElMessage({
      message: "新增成功!",
      type: 'success'
    })
    handleAddGoods(form.value);
    onLoad(page.value);
    done();
  }).catch(()=>{
    loading()
  })
}
const rowGoodsDel = (row:any) => {
  ElMessageBox.confirm("确定将选择数据删除?", '系统提示', {confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning'}).then(() => {
    return delTmsGoodsDetail(row.id);
  }).then(() => {
    handleAddGoods(form.value);
    ElMessage({
      message: "删除成功!",
      type: 'success'
    })
  });
}
const handleActual = (row:any) => {
    actualForm.value = row;
    open3.value = true;
}
const submitForm3 = ()=>{
  updateTmsDispatchOrder(actualForm.value).then(res=>{
    ElMessage({
      message: "操作成功!",
      type: 'success'
    })
    open3.value = false;
    onLoad(page.value)
  })
}
});
</script>