chenlu
2024-10-11 82a5de6d2ec80b45660149c84be28734032562f6
north-glass-erp/northglass-erp/src/views/sd/order/CreateOrder.vue
@@ -15,7 +15,7 @@
import downLoadFile from "@/hook/downLoadFile"
import footSum from "@/hook/footSum"
import {useI18n} from "vue-i18n"
import {multiply} from '@/utils/decimal'
import {multiply,multiplyAuto,divideAuto} from '@/utils/decimal'
const { t } = useI18n()
let dialogTableVisible = ref(false)
@@ -23,7 +23,8 @@
let errorAreaVisible = ref(false)
let otherMoneyVisible = ref(false)
let sizeCheckVisible = ref(false)
const maxTableLen =ref(200)
let orderIdVisible = ref(false)
const maxTableLen =ref(500)
let errorArea = ref(0.4)
const userStore = useUserInfoStore()
const company = companyInfo()
@@ -34,6 +35,7 @@
const shapeList = ref([
    {label:t('order.universalShape'),value:'1'}, {label:t('order.alien'),value:'2'}
])
const newOrderId = ref([])
// 定义表头上传数据
const titleUploadData = ref({
@@ -112,7 +114,8 @@
          { code: 'incrementalChecked', name: t('basicData.incrementalChecked'), prefixIcon: 'vxe-icon-copy', visible: true, disabled: false },
          { code: 'errorArea', name: t('basicData.errorSettlementArea'), prefixIcon: 'vxe-icon-chart-bar-x', visible: true, disabled: false },
          { code: 'otherMoney', name: t('basicData.otherAmounts'), prefixIcon: 'vxe-icon-chart-bar-x', visible: true, disabled: false },
          { code: 'sizeCheck', name: t('basicData.sizeReview'), prefixIcon: 'vxe-icon-eye-fill', visible: true, disabled: false }
          { code: 'sizeCheck', name: t('basicData.sizeReview'), prefixIcon: 'vxe-icon-eye-fill', visible: true, disabled: false },
          { code: 'updateOrderId', name: '修改订单号', prefixIcon: 'vxe-icon-eye-fill', visible: true, disabled: false }
        ]
      ]
    }
@@ -186,6 +189,16 @@
          const regex = /^(0(\.\d{1,2})?|([1-9]\d{0,4})(\.\d{1,2})?|99999(\.9{1,2})?)$/
          if ( !regex.test(cellValue) ) {
            return new Error(t('basicData.msg.range99999Dec2') )
          }
        }
      }
    ],
    quantity: [
      {
        validator ({ cellValue }) {
          const regex = /^[1-9]\d*$/
          if ( !regex.test(cellValue) ) {
            return new Error(t('basicData.msg.greater0') )
          }
        }
      }
@@ -348,13 +361,14 @@
              otherMoney:otherMoney.value,
              orderIdType:company.orderIdType,
              creator:userStore.user.userName,
              creatorId:userStore.user.userId
              creatorId:userStore.user.userId,
              newOrderId:newOrderId.value
            }
            const grossAreaList = $grid.getTableData().fullData.filter(
                item=>item.grossArea === 0
            )
            const errorAreaList = $grid.getTableData().fullData.filter(
                item=>item.width*item.height/1000000 < errorArea.value*1
                item=>(item.width*item.height/1000000 < errorArea.value*1)
            )
            if(grossAreaList.length>0){
              alert(t('order.msg.grossAreaIsNot0'))
@@ -435,7 +449,8 @@
              ElMessage.error(t('basicData.msg.checkoutLose'))
              return
            }
            titleUploadData.value.creatorId=userStore.user.userId
            titleUploadData.value.creator=userStore.user.userName
            let order ={
              title:titleUploadData.value,
            }
@@ -607,11 +622,15 @@
          sizeCheckVisible.value=true
          break
        }
        case 'updateOrderId' :{
          orderIdVisible.value=true
          break
        }
        case 'incrementalAll' :{
          let result = toolbarButtonClickEvent()
          if(result){
            const dataList = xGrid.value.getTableData().visibleData
            const val = getNestedProperty(dataList[result.start],result.cell)
            const val = getNestedProperty(dataList[result.start],result.cell)+""
            const numbersArr = []
            const regex = /\d+/g
@@ -627,6 +646,9 @@
            dataList.forEach((item,index) =>{
              if(index>=result.start ){
                let newStr = subStr1.replace(reg, number);
                if(parseInt(newStr)>9){
                  newStr=parseInt(newStr)
                }
                setNestedValue(item,result.cell,subStr2+newStr)
                number=number+1
              }
@@ -642,7 +664,7 @@
          let result = toolbarButtonClickEvent()
          if (result) {
            const dataList = xGrid.value.getTableData().visibleData
            const val = getNestedProperty(dataList[result.start], result.cell)
            const val = getNestedProperty(dataList[result.start], result.cell)+""
            const numbersArr = []
            const regex = /\d+/g
            let match
@@ -657,6 +679,9 @@
            dataList.forEach((item,index) =>{
              if(index >= result.start && index <= result.end){
                let newStr = subStr1.replace(reg, number);
                if(parseInt(newStr)>9){
                  newStr=parseInt(newStr)
                }
                setNestedValue(item,result.cell,subStr2+newStr)
                number=number+1
              }
@@ -720,15 +745,15 @@
  addListener(xGrid.value,gridOptions)
  const str = route.query.orderId || history.state.orderId
  if (typeof str === 'undefined' || str === null || str === '' || str === '\n' || str === '\r'){
    gridOptions.menuConfig.body.options[0][11].disabled = true
    gridOptions.loading = false
    return
  }
  request.post(`/order/getOrderById/${str}`).then((res) => {
    if(res.code==200){
      console.log(res.data.order)
      titleUploadData.value = res.data.order
      newOrderId.value=titleUploadData.value.orderId
      if(history.state.orderId!=null){
        titleUploadData.value.orderId=''
        titleUploadData.value.id=null
@@ -747,6 +772,10 @@
        if(history.state.type=='copy'){
          xGrid.value.reloadData(orderDetails)
          gridOptions.menuConfig.body.options[0][11].disabled = true
        }
        if(history.state.type=='copyTitle'){
          gridOptions.menuConfig.body.options[0][11].disabled = true
        }
        gridOptions.loading = false
@@ -761,6 +790,7 @@
      //工艺审核后保存按钮禁用
      if(res.data.order.processReview === 2){
        gridOptions.toolbarConfig.buttons[4].disabled = true
        gridOptions.menuConfig.body.options[0][11].disabled = true
      }
@@ -776,6 +806,7 @@
        gridOptions.toolbarConfig.buttons[2].code='reviews'
        gridOptions.toolbarConfig.buttons[2].name=t('basicData.cancelReview')
        gridOptions.toolbarConfig.buttons[3].disabled = false
        gridOptions.menuConfig.body.options[0][11].disabled = true
        const button = {'code': 'cancelOrder',
          status: 'primary',
@@ -786,8 +817,11 @@
          gridOptions.toolbarConfig.buttons[2].disabled = true
          gridOptions.toolbarConfig.buttons[3].disabled = true
          gridOptions.toolbarConfig.buttons[4].disabled = true
        }
      }
      if(res.data.order.productionOrder !==0 ){
        gridOptions.toolbarConfig.buttons[2].disabled = true
      }
@@ -872,9 +906,9 @@
          gridOptions.editRules[`otherColumns.${item.column}`] = [
            {
              validator ({ cellValue }) {
                const regex = /^(0(\.\d{1,2})?|([1-9]\d{0,4})(\.\d{1,2})?|99999(\.9{1,2})?)$/
                const regex = /^(0(\.\d{1,3})?|([1-9]\d{0,4})(\.\d{1,3})?|99999(\.9{1,3})?)$/
                if (cellValue && !regex.test(cellValue)) {
                  return new Error(t('basicData.msg.range99999Dec2'))
                  return new Error(t('basicData.msg.range99999Dec3'))
                }
              }
            }
@@ -972,8 +1006,40 @@
  })
}
//修改订单号方法
const updateOrderId = () => {
  let orderId ={
    oldOrderId:titleUploadData.value.orderId,
    newOrderId:newOrderId.value,
    orderIdType:company.orderIdType,
    creator:userStore.user.userName,
  }
  request.post(`/order/updateOrderId`,orderId).then((res) => {
    if(res.code==200 && res.data==="true"){
      ElMessage.success(t('basicData.msg.saveSuccess'))
      router.push({path:'/main/order/createOrder',query:{
          orderId:newOrderId.value,
          random:Math.random()}})
    }else if(res.data==="false1"){
      ElMessage.warning("输入订单号不能大于最大订单号")
    }else if(res.data==="false2"){
      ElMessage.warning("输入订单号已存在")
    }else if(res.data==="false3"){
      ElMessage.warning("输入订单号相同")
    }else if(res.data==="false4"){
      ElMessage.warning("输入订单号长度不符")
    }else if(res.data==="false5"){
      ElMessage.warning("请输入数字")
    }else if(res.data==="false6"){
      ElMessage.warning("不能修改第一个单子")
    }
  })
}
//更新金额重置
const updateMoney = () => {
  titleUploadData.value.creatorId=userStore.user.userId
  titleUploadData.value.creator=userStore.user.userName
  const updateData = {
    order: titleUploadData.value,
    detail: xGrid.value.getTableData().fullData,
@@ -1035,20 +1101,20 @@
}
const area = (row) => {
  return parseFloat((row.width * row.height/1000000).toFixed(company.decValue))
  return  parseFloat(divideAuto(row.width * row.height,1000000,company.decValue))
}
const countArea = (row) => {
  const area = parseFloat((row.width * row.height/1000000).toFixed(company.decValue))
  const area =  parseFloat(divideAuto(row.width * row.height,1000000,company.decValue))
  let areaSum = 0
  // 获取保留面积
  // 获取保留面积,
  const decValue = company.decValue
  switch (titleUploadData.value.calculateType){
    case 2:{
      areaSum = parseFloat((row.width * row.height * row.quantity/1000000).toFixed(decValue))
      areaSum = parseFloat(divideAuto(row.width * row.height* row.quantity,1000000,company.decValue))
      break
    }
    default :{
      areaSum = parseFloat((area * row.quantity).toFixed(decValue))
      areaSum = parseFloat(multiplyAuto(area ,row.quantity,company.decValue))
      break
    }
  }
@@ -1100,7 +1166,7 @@
      const decValue = company.decValue
      if(titleUploadData.value.calculateType===1){
        item.computeGrossArea = parseFloat((item.computeArea*item.quantity).toFixed(decValue))
        item.computeGrossArea = parseFloat(multiplyAuto(item.computeArea,item.quantity,decValue))
      }else if(titleUploadData.value.calculateType===2){
        item.computeGrossArea = item.grossArea
      }
@@ -1201,10 +1267,30 @@
}
const cellStyle = ({ row, column }) => {
  if(company.longSide!=null){
    if (column.field === 'width') {
      if (row.width > parseInt(company.longSide)) {
        return {
          backgroundColor: '#ec6969'
        }
      }
    }
    if (column.field === 'height') {
      if (row.height > parseInt(company.longSide)) {
        return {
          backgroundColor: '#ec6969'
        }
      }
    }
  }
};
//误差面积计算方法
const errorAreaComputed = () => {
  const regex = /^(0(\.\d{1,2})?|([1-9]\d{0,4})(\.\d{1,2})?|99999(\.9{1,2})?)$/
  if (!regex.test(errorArea.value)) {
  if (!regex.test(errorArea.value.toString())) {
    ElMessage.warning(t('basicData.msg.range99999Dec2'))
    return
  }
@@ -1217,8 +1303,8 @@
    if( !isNaN(item.computeArea*1) && item.computeArea != null && trueArea < errorArea.value){
      item.computeArea = errorArea.value
      item.computeGrossArea = parseFloat((item.computeArea*item.quantity).toFixed(2))
      item.grossAmount=parseFloat((item.price * item.computeGrossArea).toFixed(2))
      item.computeGrossArea =  parseFloat(multiply(item.computeArea,item.quantity))
      item.grossAmount=parseFloat(multiply(item.price , item.computeGrossArea))
    }
  })
  titleUploadData.value.money=countMoney(xGrid.value.getTableData().fullData).toString()
@@ -1247,11 +1333,11 @@
    if( !isNaN(item.computeArea*1) && item.computeArea != null ){
      if(titleUploadData.value.calculateType===3){
        item.grossAmount=parseFloat((item.price * item.quantity).toFixed(2))
        item.grossAmount=parseFloat(multiply(item.price , item.quantity))
      }else{
        item.grossArea = countArea(item)
        item.computeGrossArea = item.grossArea
        item.grossAmount=parseFloat((item.price * item.computeGrossArea).toFixed(2))
        item.grossAmount=parseFloat(multiply(item.price , item.computeGrossArea))
      }
    }
  })
@@ -1284,8 +1370,6 @@
  if(evnt.$event.keyCode === 38 ){
    const { rowIndex,row,column } = xGrid.value.getSelectedCell() || xGrid.value.getEditRecord()
    let nextRowIndex = xGrid.value.getRowIndex(row) - 1;
    console.log(xGrid.value.getTableData().fullData.length)
    console.log(nextRowIndex)
    if (nextRowIndex < xGrid.value.getTableData().fullData.length && nextRowIndex>=0) {
      xGrid.value.setCurrentRow(xGrid.value.getTableData().fullData[nextRowIndex]);
    }
@@ -1447,6 +1531,7 @@
          v-on="gridEvents"
          @keydown="handleKeyDown"
          @edit-closed="editClosedEvent"
          :cell-style="cellStyle"
      >
        <template #num1_filter="{ column, $panel }">
          <div>
@@ -1496,6 +1581,16 @@
        </el-col>
      </el-row>
    </el-dialog>
    <el-dialog v-model="orderIdVisible"  style="width: 300px;height:150px ">
      <el-row>
        <el-col :span="12">
          <el-input v-model="newOrderId"/>
        </el-col>
        <el-col :span="6">
          <el-button @click="updateOrderId">{{$t('basicData.confirmButtonText')}}</el-button>
        </el-col>
      </el-row>
    </el-dialog>
    <el-dialog v-model="otherMoneyVisible"
               :title="$t('basicData.otherAmounts')"
               :close-on-click-modal="false"