廖井涛
2025-02-18 b95bdc2199e991c4643814663a005c5e0e7d5048
north-glass-erp/northglass-erp/src/views/sd/order/CreateOrder.vue
@@ -1,5 +1,5 @@
<script lang="ts"  setup>
import {onMounted, reactive, ref, watch} from "vue"
import {nextTick, onMounted, reactive, ref, watch} from "vue"
import {useRouter,useRoute} from "vue-router"
import * as XLXS from "xlsx"
import {ElMessage, ElMessageBox} from "element-plus"
@@ -145,7 +145,7 @@
    trigger: 'dblclick',
    mode: 'cell',
    showStatus: true,
    showIcon:false
    showIcon:false,
  },//表头参数
  columns:[
    {type: 'seq',fixed:"left", title: t('basicData.Number'), width: 80 },
@@ -736,7 +736,7 @@
//初始化判断是否有id传入
onMounted(async ()=>{
  gridOptions.loading = true
  await initOrder()
  await initOrder(0)
  //启用表格拖动选中
  addListener(xGrid.value,gridOptions)
@@ -755,6 +755,8 @@
  request.post(`/order/getOrderById/${str}`).then((res) => {
    if(res.code==200){
      titleUploadData.value = res.data.order
      const customer = titleSelectJson.value.customer.filter(item => item.id === titleUploadData.value.customerId)
      projects.value = customer[0].projectList
      newOrderId.value=titleUploadData.value.orderId
      if(history.state.orderId!=null){
        titleUploadData.value.orderId=''
@@ -886,47 +888,48 @@
//页面第一次加载执行
const initOrder = async ()=>{
const initOrder = async (val)=>{
  await request.get(`/basicData/orderBasicData`).then((res) => {
    if(res.code==200){
      titleSelectJson.value=deepClone(res.data)
      //其他金额
      otherMoney.value = titleSelectJson.value.orderOtherMoney[0]
      //let columns = []
      otherMoney.value.forEach(item => {
        let column = {
          field: `otherColumns.${item.column}`,
          width:100,
          title: item.alias,
          editRender: {
            name: 'input',
      if(val===0){
        //其他金额
        otherMoney.value = titleSelectJson.value.orderOtherMoney[0]
        //let columns = []
        otherMoney.value.forEach(item => {
          let column = {
            field: `otherColumns.${item.column}`,
            width:100,
            title: item.alias,
            editRender: {
              name: 'input',
            }
          }
        }
        //判断  其他列是否是数字
        if(item.column.indexOf('M')>-1){
          gridOptions.editRules[`otherColumns.${item.column}`] = [
            {
              validator ({ cellValue }) {
                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.range99999Dec3'))
          //判断  其他列是否是数字
          if(item.column.indexOf('M')>-1){
            gridOptions.editRules[`otherColumns.${item.column}`] = [
              {
                validator ({ cellValue }) {
                  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.range99999Dec3'))
                  }
                }
              }
            }
          ]
        }else{
          gridOptions.editRules[`otherColumns.${item.column}`] = [
            { required: false},
            { min: 0, max: 255, message: t('basicData.msg.max255') }
          ]
        }
            ]
          }else{
            gridOptions.editRules[`otherColumns.${item.column}`] = [
              { required: false},
              { min: 0, max: 255, message: t('basicData.msg.max255') }
            ]
          }
        //columns.push(column)
        gridOptions.columns.push(column)
          //columns.push(column)
          gridOptions.columns.push(column)
      })
        })
      }
      //进入页面下拉框设置默认值
      titleUploadData.value.orderType = titleSelectJson.value.orderType[0].basicName
      titleUploadData.value.orderClassify = titleSelectJson.value.orderClassify[0].basicName
@@ -1001,7 +1004,9 @@
  request.post(`/order/saveOrderTitle`,order).then((res) => {
    if(res.code==200){
      ElMessage.success(t('basicData.msg.saveSuccess'))
      router.push({path:'/main/order/selectOrder'})
      router.push({path:'/main/order/createOrder',query:{
          orderId:titleUploadData.value.orderId,
          random:Math.random()}})
    }else {
      ElMessage.error(res.msg)
    }
@@ -1115,6 +1120,20 @@
  reviewOrder(2)
}
let projects = ref([])
const changeProject = (item) => {
  if(typeof item === 'string'){
    titleUploadData.value.project = item
    return
  }
  titleUploadData.value.project = item.project
  titleUploadData.value.salesmanId = item.salesmanId
  titleUploadData.value.salesman = item.salesman
  titleUploadData.value.contacts = item.contacts
  titleUploadData.value.contactNumber = item.contactNumber
}
const changeCustomer =  () => {
  const changedCustomerId = titleUploadData.value.customerId
  const customer = titleSelectJson.value.customer.filter(item => item.id === changedCustomerId)
@@ -1122,12 +1141,15 @@
  titleUploadData.value.project = customer[0].project
  titleUploadData.value.salesmanId = customer[0].salesmanId
  titleUploadData.value.salesman = customer[0].salesman
  titleUploadData.value.contacts = customer[0].contacts
  titleUploadData.value.contactNumber = customer[0].contactNumber
  projects.value = customer[0].projectList
}
const changeSaleMan = () => {
  const changedSaleManId = titleUploadData.value.salesmanId
  const SaleMan = titleSelectJson.value.saleMan.filter(item => item.id === changedSaleManId)
  titleUploadData.value.salesman = SaleMan[0].basicName
  titleUploadData.value.salesman = SaleMan[0]['basicName']
}
const area = (row) => {
@@ -1253,7 +1275,6 @@
//行单元格修改修改触发此事件
const editClosedEvent = ({ row, column }) => {
  //判断修改相应的数值修改面积与金额
   if (['width', 'height', 'quantity', 'price'].includes(column.property)) {
     if(titleUploadData.value?.orderReview!==2){
@@ -1293,7 +1314,6 @@
   //   }
   // }
  titleUploadData.value.money=countMoney(xGrid.value.getTableData().fullData).toString()
}
@@ -1376,7 +1396,7 @@
}
//表格回车,在表格最后一行添加一行空数据
const handleKeyDown = (evnt) =>{
const handleKeyDown =async (evnt) =>{
  //判断表示是否为筛选状态
  if(xGrid.value.isFilter()){
    return
@@ -1400,7 +1420,12 @@
        break;
      case 'quantity':
        if(nextRowIndex === length){
          xGrid.value.insertAt({}, xGrid.value.getTableData.length || -1)
          await editClosedEvent({row,column})
          xGrid.value.clearEdit()
          let rowNext = row
          delete rowNext._X_ROW_KEY
          xGrid.value.insertAt(rowNext, xGrid.value.getTableData.length || -1)
          //xGrid.value.insertAt({}, xGrid.value.getTableData.length || -1)
        }
        const nextRow = xGrid.value.getTableData().fullData[nextRowIndex]
        xGrid.value.setCurrentRow(nextRow)
@@ -1468,7 +1493,7 @@
//创建客户成功返回方法
const createCustomerSuccess = async () => {
  //await initOrder()
  await initOrder(1)
  createCustomerVisible.value = false
}
@@ -1479,7 +1504,18 @@
    <div class="order-primary" style="background-color: white">
      <el-row>
        <el-col  :span="2"><el-text>*{{$t('order.project')}}:</el-text></el-col>
        <el-col  :span="2"><el-input v-model.trim="titleUploadData.project"/></el-col>
        <el-col  :span="2">
<!--          <el-input v-model.trim="titleUploadData.project"/>-->
          <el-select v-model.trim="titleUploadData.project"
                     @change="changeProject"
                     clearable placeholder=" " allow-create  filterable >
            <el-option v-for="item in projects"
                       :label="item.project"
                       :value="item"/>
          </el-select>
        </el-col>
        <el-col  :span="2"><el-text>*{{$t('order.customers')}}:</el-text></el-col>
        <el-col  :span="2">
          <el-select  v-model="titleUploadData.customerId"
@@ -1646,7 +1682,7 @@
      </vxe-grid>
    </div>
    <el-dialog v-model="dialogTableVisible" :title="$t('order.processingNote')" style="width: 60%;height:75% ">
    <el-dialog v-model="dialogTableVisible" :draggable="true" :title="$t('order.processingNote')" style="width: 60%;height:75% ">
      <el-input
          v-model="titleUploadData.processingNote"
          type="textarea"