廖井涛
2025-11-24 ff1be3b4ed56b84848ad34ea2383788c220bff64
north-glass-erp/northglass-erp/src/views/sd/product/CreateProduct.vue
@@ -7,17 +7,28 @@
import {useRouter,useRoute} from "vue-router"
import GlassType from "@/components/sd/product/GlassType.vue"
import useProductGlassTypeStore from "@/stores/sd/product/productGlassType"
import {useI18n} from "vue-i18n";
import companyInfo from "@/stores/sd/companyInfo";
const company = companyInfo()
const { t } = useI18n()
const router = useRouter()
const route = useRoute()
let  userInfo = useUserInfo()
let props = defineProps({
  productFlag:null
})
let emit = defineEmits([
  'getProductRow'
])
const disposeList = $ref([
  '彩釉',
  '蒙砂',
  '镀膜',
  '贴膜',
  '喷砂',
  '磨边'
  t('product.coloredGlaze'),
  t('product.frostedSand'),
  t('product.coating'),
  t('product.filmApplication'),
  t('product.sandblasting'),
  t('product.edgeGrinding')
])
let BasicData = ref({
  stuffColor:null,
@@ -67,11 +78,12 @@
  thickness:'',
  totalThickness:'',
  typeId:'',
  productAbbreviation:'',
  creator:userInfo.user.userName
})
let productGlassTypeStore = useProductGlassTypeStore()
productGlassTypeStore.GlassType=['','']
productGlassTypeStore.GlassType=[null,null]
//页面加载请求
request.get(`/basicData/BasicDataByType/product`).then((res) => {
@@ -95,6 +107,12 @@
        item.separation = JSON.parse(item.separation)
      })
      productTotal.value = res.data.title
      if(res.data.title.typeId.length===2){
        productGlassTypeStore.GlassType =[res.data.title.typeId.substring(0,2)]
      }else{
        productGlassTypeStore.GlassType =[res.data.title.typeId.substring(0,2),res.data.title.typeId]
      }
      //BasicData.value = res.data
    }else{
      ElMessage.warning(res.msg)
@@ -103,18 +121,23 @@
})
const saveProduct = () => {
const saveProduct = (type) => {
  if(productDetailList.value.length===0){
    ElMessage.warning("请添加产品详情")
    ElMessage.warning(t('product.msg.productLength'))
    return
  }else if(productDetailList.value[productDetailList.value.length-1].detailType!=='glass'){
    ElMessage.warning("产品详情最后一条不是玻璃,请完善")
    ElMessage.warning(t('product.msg.lastGlass'))
    return
  }else if(productGlassTypeStore.GlassType[1]==='' || productGlassTypeStore.GlassType[1]===null){
    ElMessage.warning("请选择产品类别")
  }else if(productGlassTypeStore.GlassType===null || productGlassTypeStore.GlassType[1]==='' || productGlassTypeStore.GlassType[1]===null){
    ElMessage.warning(t('product.msg.glassType'))
    return
  }
  productTotal.value.typeId =  productGlassTypeStore.GlassType[1]
  if(productGlassTypeStore.GlassType[1]!==undefined){
    productTotal.value.typeId =  productGlassTypeStore.GlassType[1]
  }else{
    productTotal.value.typeId =  productGlassTypeStore.GlassType[0]
  }
  let productName = ""
  productDetailList.value.forEach(item =>{
@@ -134,27 +157,69 @@
    }
  })
  productTotal.value.productName=productName
  productTotal.value.productAbbreviation=productTotal.value.productAbbreviation.trim()
  if(type==='copy'){
    productTotal.value.id = null
    productTotal.value.state = 0
  }
  if(productTotal.value.id != null
      &&
          productTotal.value.creator !== userInfo.user.userName
          & company.notChangeProduct
      ){
    ElMessage.warning(t('product.msg.msg1')+productTotal.value.creator+t('product.msg.msg2'))
    return;
  }
  let product = {
    title: productTotal.value,
    detail:productDetailList.value
  }
  request.post(`/product/saveProduct`,product).then((res) =>{
  //查询产品是否重复
  request.post(`/product/selectProduct/${company.productName}`,product).then((res) =>{
    if(res.code==200){
      ElMessage.success("创建成功")
      router.push("/main/product/selectProduct")
      if(res.data.data.length>0){
        ElMessage.warning(t('product.msg.productDuplication'))
      }else{
        saveProducts(product)
      }
    }
  })
}
const  saveProducts=(product)=>{
  if(props.productFlag===false){
    product.title.state = 1
  }
  request.post(`/product/saveProduct/${userInfo.user.userName}`,product).then((res) =>{
    if(res.code==200){
      ElMessage.success(t('product.msg.saveSuccess'))
      if(props.productFlag===false){
        emit('changePage')
      }else{
        router.push("/main/product/selectProduct")
      }
    }
  })
}
//审核产品状态
const updateProductState =  (state) => {
  request.post(`/product/updateProductStateById/${productTotal.value.id}/${state}`).then((res) =>{
  if(productTotal.value.id!==null && productTotal.value.creator!==userInfo.user.userName && company.notChangeProduct){
    ElMessage.warning(t('product.msg.msg1')+productTotal.value.creator+t('product.msg.msg2'))
    return;
  }
  request.post(`/product/updateProductStateById/${productTotal.value.id}/${state}/${userInfo.user.userName}`).then((res) =>{
    if(res.code==200){
      ElMessage.success("操作成功")
      ElMessage.success(t('product.msg.operateSuccess'))
      //router.go(0)
      router.push({path:'/main/product/createProduct',query:{id:productTotal.value.id,random:Math.random()}})
      if(state===1){
        router.push("/main/product/selectProduct")
      }else{
        router.push({path:'/main/product/createProduct',query:{id:productTotal.value.id,random:Math.random()}})
      }
    }else{
      ElMessage.error("操作失败")
      ElMessage.error(t('product.msg.operateFail'))
    }
  })
}
@@ -171,11 +236,14 @@
const glassSure =  () => {
  let childName = ''
  Object.keys(stuff.value).forEach((item,index)=>{
    childName+=stuff.value[item]
    if(stuff.value[item]!==undefined){
      childName+=stuff.value[item]
    }
  })
  let rege = /^\s*$/
  if(rege.test(childName) || processChecked.value.length===0){
    ElMessage.warning('请输入产品材料属性与工艺属性')
    ElMessage.warning(t('product.msg.glassReview'))
    return
  }
  let productDetail = {
@@ -189,7 +257,7 @@
      productDetailList.value.push(productDetail)
    }else{
      if (productDetailList.value[productDetailList.value.length-1].detailType === 'glass') {
        ElMessage.warning('请先选择间隔物')
        ElMessage.warning(t('product.msg.glassRepeat'))
        return
      }
      productDetailList.value.push(productDetail)
@@ -207,10 +275,13 @@
  let childName = ''
  try {
    Object.keys(hollowBasic.value).forEach((item, index) => {
      if (hollowBasic.value[item] === '') {
        throw new Error("请选择全部中空间隔物下拉框")
      if ((hollowBasic.value[item] === ''||hollowBasic.value[item]===undefined) && item !== 'GlueDepth')  {
        throw new Error(t('product.msg.HollowReview'))
      }
      childName += hollowBasic.value[item]
      if(hollowBasic.value[item]!==undefined){
        childName += hollowBasic.value[item] || ''
      }
    })
  }catch (e){
    ElMessage.warning(e.message)
@@ -224,10 +295,10 @@
  }
  if(hollowFlag.value.flag){
    if (productDetailList.value.length ===0) {
      ElMessage.warning('请先选择产品')
      ElMessage.warning(t('product.msg.firstGlass'))
      return
    }else if(productDetailList.value[productDetailList.value.length-1].detailType !== 'glass'){
      ElMessage.warning('请先选择产品')
      ElMessage.warning(t('product.msg.firstGlass'))
      return
    }
    productDetailList.value.push(Object.assign({},hollowDetail))
@@ -244,10 +315,13 @@
  let childName = ''
  try {
    Object.keys(InterlayerBasic.value).forEach((item, index) => {
      if (InterlayerBasic.value[item] === '') {
        throw new Error("请选择全部中空间隔物下拉框")
      if ((InterlayerBasic.value[item] === ''||InterlayerBasic.value[item]===undefined) && item !== 'color') {
        throw new Error(t('product.msg.InterlayerReview'))
      }
      childName += InterlayerBasic.value[item]
      if(InterlayerBasic.value[item]!==undefined){
        childName += InterlayerBasic.value[item]
      }
    })
  }catch (e){
    ElMessage.warning(e.message)
@@ -260,10 +334,10 @@
  }
  if(InterlayerFlag.value.flag){
    if (productDetailList.value.length ===0) {
      ElMessage.warning('请先选择产品')
      ElMessage.warning(t('product.msg.firstGlass'))
      return
    }else if(productDetailList.value[productDetailList.value.length-1].detailType !== 'glass'){
      ElMessage.warning('请先选择产品')
      ElMessage.warning(t('product.msg.firstGlass'))
      return
    }
    productDetailList.value.push(Object.assign({},InterlayerDetail))
@@ -359,6 +433,7 @@
  hollowFlag.value.flag=true
  hollowFlag.value.index=null
}
const productName = computed(() =>{
  let productName = ""
  productDetailList.value.forEach(item =>{
@@ -372,13 +447,14 @@
        break
      }
      case 'hollow' :{
        productName+='*'+item.detail+"*"
        productName+=company.hollow + item.detail + company.hollow
        break
      }
    }
  })
  return productName
})
@@ -419,12 +495,12 @@
      <div class="line"/>
      <div class="glass-type">
        <h5>材料属性</h5>
        <h5>{{ $t('product.msg.glassTypeTitle') }}</h5>
        <el-row :gutter="50">
<!--          <el-col :span="6"></el-col>-->
          <el-col :span="4">
            <div class="grid-content ep-bg-purple" >
              <el-select v-model="stuff.thickness" size="small" clearable placeholder="*厚度:" >
              <el-select v-model="stuff.thickness" size="small" clearable :placeholder="$t('product.msg.thickness')" >
                <el-option v-for="item in BasicData.stuffThickness"
                           :key="item.id"
                           :label="item.basicName"
@@ -435,7 +511,7 @@
          </el-col>
          <el-col :span="5">
            <div class="grid-content ep-bg-purple" >
              <el-select v-model="stuff.color" size="small" clearable placeholder="*颜色:"  filterable>
              <el-select v-model="stuff.color" size="small" clearable :placeholder="$t('product.msg.color')"  filterable>
                <el-option v-for="item in BasicData.stuffColor"
                           :key="item.id"
                           :label="item.basicName"
@@ -446,7 +522,7 @@
          </el-col>
          <el-col :span="4">
            <div class="grid-content ep-bg-purple" >
              <el-select v-model="stuff.craft" size="small" clearable placeholder="*工艺属性:" >
              <el-select v-model="stuff.craft" size="small" clearable :placeholder="$t('product.msg.craft')" >
                <el-option v-for="item in BasicData.stuffCraft"
                           :key="item.id"
                           :label="item.basicName"
@@ -457,7 +533,7 @@
          </el-col>
          <el-col :span="4">
            <div class="grid-content ep-bg-purple" >
              <el-select v-model="stuff.position" size="small"  clearable placeholder="位置:" >
              <el-select v-model="stuff.position" size="small"  clearable :placeholder="$t('product.msg.location')" >
                <el-option v-for="item in BasicData.stuffPosition"
                           :key="item.id"
                           :label="item.basicName"
@@ -468,7 +544,7 @@
          </el-col>
          <el-col :span="6">
            <div class="grid-content ep-bg-purple" >
              <el-select v-model="stuff.lowE" size="small"  clearable placeholder="LOW-E面:" >
              <el-select v-model="stuff.lowE" size="small"  clearable :placeholder="$t('product.msg.lowELocation')" >
                <el-option v-for="item in BasicData.stuffLowE"
                           :key="item.id"
                           :label="item.basicName"
@@ -482,7 +558,7 @@
      <div class="line"/>
      <div class="glass-process">
        <h5>工艺属性</h5>
        <h5>{{ $t('product.msg.processAttribute') }}</h5>
        <el-checkbox
            v-model="processChecked"
            v-for="item in BasicData.process"
@@ -497,7 +573,7 @@
              v-model="hollowBasic.thickness"
              size="small"
              style="width: 100px"
              clearable placeholder="*中空厚度:" >
              clearable :placeholder="$t('product.msg.hollowThickness')" >
            <el-option v-for="item in BasicData.hollowThickness"
                       :key="item.id"
                       :label="item.basicName"
@@ -508,29 +584,29 @@
              v-model="hollowBasic.gasType"
              size="small"
              style="width: 100px"
              clearable placeholder="*充气方式:" >
              clearable :placeholder="$t('product.msg.hollowGasType')" >
            <el-option v-for="item in BasicData.hollowGasType"
                       :key="item.id"
                       :label="item.basicName"
                       :value="item.basicName"
                       :label="item.basicName+'('+item.nickname+')'"
                       :value="item.nickname"
            />
          </el-select>
          <el-select
              v-model="hollowBasic.Type"
              size="small"
              style="width: 100px"
              clearable placeholder="*封胶:" >
              clearable :placeholder="$t('product.msg.hollowType')" >
            <el-option v-for="item in BasicData.hollowType"
                       :key="item.id"
                       :label="item.basicName"
                       :value="item.basicName"
                       :label="item.basicName+'('+item.nickname+')'"
                       :value="'('+item.nickname+')'"
            />
          </el-select>
          <el-select
              v-model="hollowBasic.GlueDepth"
              size="small"
              style="width: 100px"
              clearable placeholder="*默认胶深:" >
              clearable :placeholder="$t('product.msg.hollowGlueDepth')" >
            <el-option v-for="item in BasicData.hollowGlueDepth"
                       :key="item.id"
                       :label="item.basicName"
@@ -542,20 +618,20 @@
              @click="addHollow"
              size="small"
              type="primary"
              round>中空间隔物</el-button>
              round>{{ $t('product.msg.hollow') }}</el-button>
          <el-button
              v-else
              @click="updateHollowSure"
              size="small"
              type="primary"
              round>中空间隔物修改</el-button>
              round>{{ $t('product.msg.hollowUpdate') }}</el-button>
        </div>
        <div class="glass-spacer-zk">
          <el-select
              v-model="InterlayerBasic.thickness"
              size="small"
              style="width: 100px"
              clearable placeholder="*夹层厚度:" >
              clearable :placeholder="$t('product.msg.interlayerThickness')" >
            <el-option v-for="item in BasicData.InterlayerThickness"
                       :key="item.id"
                       :label="item.basicName"
@@ -566,18 +642,18 @@
              v-model="InterlayerBasic.type"
              size="small"
              style="width: 100px"
              clearable placeholder="*类型:" >
              clearable :placeholder="$t('product.msg.interlayerType')" >
            <el-option v-for="item in BasicData.InterlayerType"
                       :key="item.id"
                       :label="item.basicName"
                       :value="item.basicName"
                       :label="item.basicName+'('+item.nickname+')'"
                       :value="'('+item.nickname+')'"
            />
          </el-select>
          <el-select
              v-model="InterlayerBasic.color"
              size="small"
              style="width: 100px"
              clearable placeholder="*颜色:" >
              clearable :placeholder="$t('product.msg.interlayerColor')">
            <el-option v-for="item in BasicData.InterlayerColor"
                       :key="item.id"
                       :label="item.basicName"
@@ -590,14 +666,14 @@
              size="small"
              type="primary"
              style="margin-left: 100px"
              round>夹层间隔物</el-button>
              round>{{ $t('product.msg.interlayer') }}</el-button>
          <el-button
              v-else
              @click="updateInterlayerSure"
              size="small"
              type="primary"
              style="margin-left: 100px"
              round>夹层间隔物修改</el-button>
              round>{{ $t('product.msg.interlayerUpdate') }}</el-button>
        </div>
      </div>
      <div class="line"/>
@@ -606,12 +682,18 @@
          <el-row :gutter="20">
            <el-col :span="5">
              <div class="grid-content ep-bg-purple" >
                <el-text class="mx-1"  style="margin-left: 0.5rem" >单片玻璃属性:</el-text>
                <el-text class="mx-1"  style="margin-left: 0.5rem" >{{ $t('product.msg.glassAttribute') }}:</el-text>
              </div>
            </el-col>
            <el-col :span="13">
              <div class="grid-content ep-bg-purple" >
                <el-input :value="stuff.thickness+stuff.color+stuff.craft+stuff.position+stuff.lowE" size="small" disabled  />
                <el-input :value="Object.values({...stuff,
                  thickness: stuff.thickness,
                  color: stuff.color,
                  craft: stuff.craft,
                  position: stuff.position,
                  lowE: stuff.lowE
                }).filter(val => val !== null && val !== '').join('')" size="small" disabled  />
              </div>
            </el-col>
            <el-col :span="3">
@@ -620,7 +702,7 @@
                    @click="reset"
                    size="small"
                    type="primary"
                    round>重置</el-button>
                    round>{{ $t('product.msg.reset') }}</el-button>
              </div>
            </el-col>
          </el-row>
@@ -629,7 +711,7 @@
          <el-row :gutter="20">
            <el-col :span="5">
              <div class="grid-content ep-bg-purple" >
                <el-text class="mx-1"  style="margin-left: 0.5rem"  >工艺流程属性:</el-text>
                <el-text class="mx-1"  style="margin-left: 0.5rem"  >{{ $t('product.msg.processFlowAttribute') }}:</el-text>
              </div>
            </el-col>
            <el-col :span="13">
@@ -643,12 +725,12 @@
                    @click="glassSure"
                    size="small"
                    type="primary"
                    round>确认</el-button>
                    round>{{ $t('product.msg.sure') }}</el-button>
                <el-button v-else
                           @click="updateGlassSure"
                           size="small"
                           type="primary"
                           round>修改</el-button>
                           round>{{ $t('product.msg.update') }}</el-button>
              </div>
            </el-col>
          </el-row>
@@ -660,7 +742,7 @@
            <div class="grid-content ep-bg-purple" >
              <el-text class="mx-1"
                       style="margin-left: 0.5rem;text-align: center">
                快速查询:
                {{ $t('product.msg.quickSearch') }}:
              </el-text>
              <el-input v-model="productTotal.query" size="small" disabled  />
            </div>
@@ -669,7 +751,7 @@
            <div class="grid-content ep-bg-purple" >
              <el-text class="mx-1"
                       style="margin-left: 0.5rem;text-align: center">
                计重厚度:
                {{ $t('product.msg.weightThickness') }}:
              </el-text>
              <el-input v-model="productTotal.thickness" size="small" disabled  />
            </div>
@@ -678,18 +760,27 @@
            <div class="grid-content ep-bg-purple" >
              <el-text class="mx-1"
                       style="margin-left: 0.5rem;text-align: center">
                厚度:
                {{ $t('product.msg.allThickness') }}:
              </el-text>
              <el-input v-model="productTotal.totalThickness"  size="small" disabled  />
            </div>
          </el-col>
          <el-col :span="5">
          <el-col :span="8">
            <div class="grid-content ep-bg-purple" >
              <el-text class="mx-1"
                       style="margin-left: 0.5rem;text-align: center">
                备注:
                {{ $t('product.msg.remarks') }}:
              </el-text>
              <el-input v-model="productTotal.remarks"  size="small"   />
            </div>
          </el-col>
          <el-col :span="12">
            <div class="grid-content ep-bg-purple" >
              <el-text class="mx-1"
                       style="margin-left: 0.5rem;text-align: center">
                {{ $t('product.msg.productAbbreviation') }}:
              </el-text>
              <el-input v-model="productTotal.productAbbreviation"  size="small"   />
            </div>
          </el-col>
        </el-row>
@@ -700,18 +791,19 @@
    <div class="glass-part inline-flex"
         :style="{
          boxShadow: `var(--el-box-shadow-lighter)`,
          boxShadow: `var(--el-box-shadow-lighter)`
        }">
      <div class="glass-part-all">
        <el-row >
          <el-col :span="4">
            <div class="grid-content ep-bg-purple" >
              <el-text class="mx-1" size="large"  >产品名称:</el-text>
              <el-text class="mx-1" size="large"  >{{ $t('product.msg.product') }}:</el-text>
            </div>
          </el-col>
          <el-col :span="20">
            <div class="grid-content ep-bg-purple" >
              <el-input :value="productName" size="large" disabled  />
              <el-input :value="productName" size="large" readonly  />
            </div>
          </el-col>
        </el-row>
@@ -723,19 +815,19 @@
            <el-button
                @click = "updateGlass(index)"
                size="small"
                type="primary">修改玻璃</el-button>
                type="primary">{{ $t('product.msg.updateGlass') }}</el-button>
          </el-col>
          <el-col :span="4" v-show="item.detailType === 'Interlayer'">
            <el-button
                @click = "updateInterlayer(index)"
                size="small"
                type="primary">修改夹层</el-button>
                type="primary">{{ $t('product.msg.updateInterlayer') }}</el-button>
          </el-col>
          <el-col :span="4" v-show="item.detailType === 'hollow'">
            <el-button
                @click = "updateHollow(index)"
                size="small"
                type="primary">修改中空</el-button>
                type="primary">{{ $t('product.msg.updateHollow') }}</el-button>
          </el-col>
          <el-col :span="16">
            <el-input
@@ -749,19 +841,27 @@
            <el-button
                @click="deleteProductDetail(index)"
                size="small"
                type="primary">删除</el-button>
                type="primary">{{ $t('product.msg.delete') }}</el-button>
          </el-col>
        </el-row>
      </div>
      <el-button
          v-if="productTotal.state===1"
          @click="saveProduct('copy')"
          style="float: left;
          margin-left: 0.5rem;"
          size="large"
          type="primary"
          round>{{$t('basicData.copy')}}</el-button>
      <el-button
          :disabled="productTotal.state===1"
          @click="saveProduct"
          @click="saveProduct(null)"
          style="float: right;
          margin-right: 0.5rem;"
          size="large"
          type="primary"
          round>{{productTotal.id?'修改':'创建'}}</el-button>
          round>{{productTotal.id?$t('product.msg.update'):$t('product.msg.create')}}</el-button>
      <el-button
          v-if="productTotal.state===0"
          @click="updateProductState(1)"
@@ -769,7 +869,7 @@
          margin-right: 0.5rem;"
          size="large"
          type="primary"
          round>审核</el-button>
          round>{{ $t('product.msg.review') }}</el-button>
      <el-button
          v-else-if="productTotal.state===1"
          @click="updateProductState(0)"
@@ -777,7 +877,7 @@
          margin-right: 0.5rem;"
          size="large"
          type="primary"
          round>反审</el-button>
          round>{{ $t('product.msg.cancelReview') }}</el-button>
    </div>
@@ -799,6 +899,7 @@
    height: 100%;
    width: 39.5%;
    float: right;
  }
  .glass-type{
    width: 100%;
@@ -874,6 +975,8 @@
    margin-top: 2%;
    width: 96%;
    height: 75%;
    overflow-y: auto;
  }