guoyujie
2025-05-13 be95a7b7f0dc5ea8df7c38331b42f3c8ec3337b4
north-glass-erp/northglass-erp/src/views/sd/basicData/CreateBasicData.vue
@@ -11,92 +11,93 @@
let basic = ref({
  basicType : ['',''],
  input:''
  input:'',
  nickname:''
})
let options=ref([
  { "label": "订单",
  { "label": t('orderBasicData.order'),
    "value": "order",
    "children": [
      {
        "label": "订单类型",
        "label": t('orderBasicData.orderType'),
        "value": "orderType"
      },
      {
        "label": "订单分类",
        "label": t('orderBasicData.orderClassify'),
        "value": "orderClassify"
      },
      {
        "label": "商标选项",
        "label": t('orderBasicData.icon'),
        "value": "icon"
      },
      {
        "label": "包装方式",
        "label": t('orderBasicData.packType'),
        "value": "packType"
      },
      {
        "label": "铝条方式",
        "label": t('orderBasicData.alType'),
        "value": "alType"
      },
      {
        "label": "业务员",
        "label": t('orderBasicData.saleMan'),
        "value": "saleMan"
      }
    ]
  },
  {
    "label": "产品",
    "label": t('orderBasicData.product'),
    "value": "product",
    "children": [
      {
        "label": "材料厚度",
        "label": t('orderBasicData.stuffThickness'),
        "value": "stuffThickness"
      },
      {
        "label": "材料颜色",
        "label": t('orderBasicData.stuffColor'),
        "value": "stuffColor"
      },
      {
        "label": "工艺属性",
        "label": t('orderBasicData.stuffCraft'),
        "value": "stuffCraft"
      },
      {
        "label": "玻璃位置",
        "label": t('orderBasicData.stuffPosition'),
        "value": "stuffPosition"
      },
      {
        "label": "lowe",
        "label": t('orderBasicData.stuffLowE'),
        "value": "stuffLowE"
      },
      {
        "label": "夹胶厚度",
        "label": t('orderBasicData.InterlayerThickness'),
        "value": "InterlayerThickness"
      },
      {
        "label": "夹胶类型",
        "label": t('orderBasicData.InterlayerType'),
        "value": "InterlayerType"
      },
      {
        "label": "夹胶颜色",
        "label": t('orderBasicData.InterlayerColor'),
        "value": "InterlayerColor"
      },
      {
        "label": "工艺流程",
        "label": t('orderBasicData.process'),
        "value": "process"
      },
      {
        "label": "中空厚度",
        "label": t('orderBasicData.hollowThickness'),
        "value": "hollowThickness"
      },
      {
        "label": "充气方式",
        "label": t('orderBasicData.hollowGasType'),
        "value": "hollowGasType"
      },
      {
        "label": "封胶",
        "label": t('orderBasicData.hollowType'),
        "value": "hollowType"
      },
      {
        "label": "默认胶深",
        "label": t('orderBasicData.hollowGlueDepth'),
        "value": "hollowGlueDepth"
      }
    ]
@@ -104,15 +105,15 @@
  {
    "children": [
      {
        "label": "付款条件",
        "label": t('orderBasicData.paymentTerms'),
        "value": "paymentTerms"
      },
      {
        "label": "收款方式",
        "label": t('orderBasicData.payMethod'),
        "value": "payMethod"
      }
    ],
    "label": "送货",
    "label": t('orderBasicData.delivery'),
    "value": "delivery"
  }
])
@@ -128,26 +129,39 @@
    basic.value.basicType[0] =  props.rowIndex.basicType
    basic.value.basicType[1] =  props.rowIndex.basicCategory
    basic.value.input =  props.rowIndex.basicName
    basic.value.nickname =  props.rowIndex.nickname
  }
})
const emit =  defineEmits(['gaveParent'])
const saveBasicData =  () =>{
  if(basic.value.basicType[1]==="hollowThickness"||basic.value.basicType[1]==="stuffThickness"||basic.value.basicType[1]==="InterlayerThickness"){
    if(!basic.value.input.includes("mm")){
      basic.value.input=basic.value.input+"mm"
    }
  }
  basic.value.input=basic.value.input.trim()
  request.post(`/basicData/addBasicData`, basic.value).then(res => {
    if (res.data) {
      ElMessage.success('保存成功')
      ElMessage.success(t('basicData.msg.saveSuccess'))
      emit('gaveParent', true)
    }
  })
}
const updateBasicData =  () =>{
  if(basic.value.basicType[1]==="hollowThickness"||basic.value.basicType[1]==="stuffThickness"||basic.value.basicType[1]==="InterlayerThickness"){
    if(!basic.value.input.includes("mm")){
      basic.value.input=basic.value.input+"mm"
    }
  }
  let submitArr  = props.rowIndex
  submitArr.basicType = basic.value.basicType[0]
  submitArr.basicCategory = basic.value.basicType[1]
  submitArr.basicName = basic.value.input
  submitArr.basicName = basic.value.input.trim()
  submitArr.nickname = basic.value.nickname
  request.post(`/basicData/updateBasicData`, submitArr).then(res => {
    if (res.data) {
      ElMessage.success('修改成功')
      ElMessage.success(t('basicData.msg.saveSuccess'))
      emit('gaveParent', true)
    }
  })
@@ -159,35 +173,85 @@
  ).map((item) =>item.children.filter((item) =>item.value === value[1]))
}
const changeFile = (file) => {
  const isJPG = file.raw.type === 'image/jpeg' || file.raw.type === 'image/png' ;
  const isLt2M = file.size / 1024 / 1024 < 5;
  if (!isJPG) {
    ElMessage.warning(t('orderBasicData.msg2'))
    return
  }
  if (!isLt2M) {
    ElMessage.warning(t('orderBasicData.msg1'))
    return
  }
  return new Promise((resolve, reject) => {
    let reader = new FileReader();
    reader.readAsDataURL(file.raw);
    reader.onload = (e) => {
      resolve(e.target.result);
      basic.value.nickname=e.target.result;
    };
  });
}
</script>
<template>
  <div>
    <el-row>
      <el-col :span="4">基础类型:</el-col>
      <el-col :span="4">{{ $t('orderBasicData.page.searchOrderBasicData') }}:</el-col>
      <el-col :span="12">
        <el-cascader
            v-model="basic.basicType"
            @change="handleChange"
            :options="options"
            clearable
            placeholder=""
            :placeholder="$t('processCard.pleaseSelect')"
            :disabled="props.rowIndex"
        />
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="4">名称:</el-col>
      <el-col :span="4">{{ $t('orderBasicData.name') }}:</el-col>
      <el-col :span="12">
        <el-input v-model="basic.input"/>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="4">{{ $t('orderBasicData.alias') }}:</el-col>
      <el-col :span="12">
        <el-input v-if="basic.basicType.length>0 && basic.basicType[1]!=='process'" v-model="basic.nickname"/>
        <el-select v-model="basic.nickname" v-else>
          <el-option  :label="$t('orderBasicData.commonProcess')" value="" />
          <el-option  :label="$t('orderBasicData.laminatingProcessA')" value="stepA" />
          <el-option  :label="$t('orderBasicData.laminatingProcessB')" value="stepB" />
        </el-select>
      </el-col>
    </el-row>
    <el-row v-if="basic.basicType.length!==0 && basic.basicType[1]==='icon'" >
      <el-col :span="4"></el-col>
      <el-col :span="12">
        <el-button v-show="!props.rowIndex" @click="saveBasicData" type="primary">新增</el-button>
        <el-button v-show="props.rowIndex" @click="updateBasicData" type="primary">修改</el-button>
        <el-upload
            v-model="basic.nickname"
            :limit="1"
            :on-change="changeFile"
            class="upload-demo"
            ref="upload"
            action="https://jsonplaceholder.typicode.com/posts/"
            :file-list="fileList"
            :auto-upload="false">
          <el-button slot="trigger" size="small" type="primary" >{{ $t('orderBasicData.selectFile') }}</el-button>
          <div slot="tip" class="el-upload__tip">{{ $t('orderBasicData.msg3') }}</div>
        </el-upload>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="4"></el-col>
      <el-col :span="12">
        <el-button v-show="!props.rowIndex" @click="saveBasicData" type="primary">{{ $t('basicData.insert') }}</el-button>
        <el-button v-show="props.rowIndex" @click="updateBasicData" type="primary">{{ $t('basicData.update') }}</el-button>
      </el-col>
    </el-row>