Fixiaobai
2023-09-25 909ff6e1c3756e6b7e85f35589d690b8919364d8
src/components/view/standard.vue
@@ -16,10 +16,11 @@
        <div class="left_search">
          <el-row :gutter="5">
            <el-col :span="21">
              <el-input v-model="search" suffix-icon="el-icon-search" placeholder="请输入搜索内容" size="small" clearable></el-input>
              <el-input v-model="search" suffix-icon="el-icon-search" placeholder="请输入搜索内容" size="small"
                clearable></el-input>
            </el-col>
            <el-col :span="2">
              <el-button size="mini" icon="el-icon-plus" @click="bomLeftAdd=true"></el-button>
              <el-button size="mini" icon="el-icon-plus" @click="leftAddIsCopy"></el-button>
            </el-col>
          </el-row>
        </div>
@@ -51,7 +52,8 @@
            <el-option :value="3" label="生产工艺"></el-option>
          </el-select>
          <span>版本:</span>
          <el-select v-model="versionVal" @change="verevent" size="small" style="width: 13vw;margin-right: 15px;" placeholder="请选择">
          <el-select v-model="versionVal" @change="verevent" size="small" style="width: 13vw;margin-right: 15px;"
            placeholder="请选择">
            <el-option v-for="(item,index) in versionData" :key="index" :label="item.label" :value="item.value">
            </el-option>
          </el-select>
@@ -67,7 +69,8 @@
        </div>
        <div class="contentTable" v-if="this.typeselect == 0">
          <technology @childData="getChildData" @updateDevice="updateDevice"  :tableType="tableType" :tableData="tableData"></technology>
          <technology @childData="getChildData" @updateDevice="updateDevice" :tableType="tableType"
            :tableData="tableData"></technology>
        </div>
        <div class="contentTable" v-if="this.typeselect == 1">
          <target  @childData="getChildData" :tableType="tableType" :tableData="tableData"></target>
@@ -84,38 +87,38 @@
    <div class="bom-add-model">
      <!-- 工艺路线 -->
      <el-dialog title="BOM新增" :visible.sync="technologyVisible" width="45%">
          <el-form :model="technologyForm" :inline="true" label-position="right"
           ref="technologyForm" :rules="technologyRules" label-width="90px">
        <el-form :model="technologyForm" :inline="true" label-position="right" ref="technologyForm"
          :rules="technologyRules" label-width="90px">
           <el-row>
            <el-col :span="12">
              <el-form-item label="工序:" prop="tefather"  style="display: flex;">
                <el-select size="small"
                filterable allow-create default-first-option style="width: 100%;"
                <el-select size="small" filterable allow-create default-first-option style="width: 100%;"
                v-model="technologyForm.tefather" placeholder="请输入或选择工序">
                  <el-option :value="item.father" :label="item.father" v-for="(item,index) in fatherList" :key="index"></el-option>
                  <el-option :value="item.father" :label="item.father" v-for="(item, index) in fatherList"
                    :key="index"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="工艺名称:" prop="tename" style="display: flex;">
                <el-input  style="width: 100%;" size="small" placeholder="请输入工艺名称"
                clearable v-model="technologyForm.tename"></el-input>
                <el-input style="width: 100%;" size="small" placeholder="请输入工艺名称" clearable
                  v-model="technologyForm.tename"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="设备组:" prop="deviceGroup" style="display: flex;">
                <el-select placeholder="请选择设备组" size="small" style="width: 100%;"
                v-model="technologyForm.deviceGroup">
                <el-option :value="item.father"
                v-for="(item,index) in deviceList" :key="index" :label="item.father"></el-option>
                <el-select placeholder="请选择设备组" size="small" style="width: 100%;" v-model="technologyForm.deviceGroup">
                  <el-option :value="item.father" v-for="(item, index) in deviceList" :key="index"
                    :label="item.father"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="生产定额:" prop="productionQuota" style="display: flex;">
                <el-input style="width: 100%;" size="small" clearable v-model.number="technologyForm.productionQuota" placeholder="请输入生产定额" />
                <el-input style="width: 100%;" size="small" clearable v-model.number="technologyForm.productionQuota"
                  placeholder="请输入生产定额" />
              </el-form-item>
            </el-col>
          </el-row>
@@ -127,22 +130,23 @@
      </el-dialog>
        <!-- 技术指标 -->
      <el-dialog title="BOM新增" :visible.sync="targetVisible" width="45%">
          <el-form :model="targetForm" :inline="true" label-position="right"
          :rules="targetRules" ref="targetForm" label-width="90px">
        <el-form :model="targetForm" :inline="true" label-position="right" :rules="targetRules" ref="targetForm"
          label-width="90px">
          <el-row>
            <el-col :span="12">
              <el-form-item label="工序:" prop="pfather">
                <el-select v-model="targetForm.pfather"
                @change="changeFather" size="small" placeholder="请选择工序">
                  <el-option :value="item.name" :label="item.name" v-for="(item,index) in targetFormList" :key="index"></el-option>
                <el-select v-model="targetForm.pfather" @change="changeFather" size="small" placeholder="请选择工序">
                  <el-option :value="item.name" :label="item.name" v-for="(item, index) in targetFormList"
                    :key="index"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="工艺名称:" prop="technologyId">
                <el-select v-model="targetForm.technologyId"
                @change="changeTechnologyId" size="small" placeholder="请选择工艺名称">
                  <el-option :value="item.id" :label="item.name" v-for="(item,index) in technologyIdList" :key="index"></el-option>
                <el-select v-model="targetForm.technologyId" @change="changeTechnologyId" size="small"
                  placeholder="请选择工艺名称">
                  <el-option :value="item.id" :label="item.name" v-for="(item, index) in technologyIdList"
                    :key="index"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
@@ -150,10 +154,10 @@
          <el-row>
            <el-col :span="12">
              <el-form-item label="项目:" prop="father">
                <el-select v-model="targetForm.father"
                filterable allow-create default-first-option
                size="small" placeholder="请输入或选择项目">
                  <el-option :value="item.father" :label="item.father" v-for="(item,index) in projectList" :key="index"></el-option>
                <el-select v-model="targetForm.father" filterable allow-create default-first-option size="small"
                  placeholder="请输入或选择项目">
                  <el-option :value="item.father" :label="item.father" v-for="(item, index) in projectList"
                    :key="index"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
@@ -191,24 +195,23 @@
      </el-dialog>
        <!-- 物料清单 -->
      <el-dialog title="BOM新增" :visible.sync="materialVisible" width="45%">
          <el-form :model="materialForm" label-position="right"
          :rules="materialRules" ref="materialForm" label-width="90px">
        <el-form :model="materialForm" label-position="right" :rules="materialRules" ref="materialForm"
          label-width="90px">
          <el-row :gutter="100">
            <el-col :span="12">
              <el-form-item label="工序:" prop="mfather">
                <el-select placeholder="请选择工序" @change="changeMName"
                  style="width:100%;" v-model="materialForm.mfather" size="small">
                  <el-option v-for="(item,index) in materialFormList" :key="index"
                  :label="item.name" :value="item.name" ></el-option>
                <el-select placeholder="请选择工序" @change="changeMName" style="width:100%;" v-model="materialForm.mfather"
                  size="small">
                  <el-option v-for="(item, index) in materialFormList" :key="index" :label="item.name"
                    :value="item.name"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
              <el-form-item label="工艺名称:" prop="mtechnologyId">
                <el-select placeholder="请选择工艺名称" style="width:100%;"
                v-model="materialForm.mtechnologyId" size="small">
                <el-option v-for="(item,index) in mIdList" :key="index"
                :value="item.id" :label="item.name"></el-option>
                <el-select placeholder="请选择工艺名称" style="width:100%;" v-model="materialForm.mtechnologyId" size="small">
                  <el-option v-for="(item, index) in mIdList" :key="index" :value="item.id"
                    :label="item.name"></el-option>
                </el-select>
              </el-form-item>
            </el-col>
@@ -224,8 +227,7 @@
          <el-row>
            <el-col :span="24">
              <el-table :data="materialForm.tableList" border max-height="470"
              :cell-style="{height:'20px',textAlign:'left'}"
              :header-cell-style="{height:'20px'}">
                :cell-style="{ height: '20px', textAlign: 'left' }" :header-cell-style="{ height: '20px' }">
                <!-- <el-table-column label="供应商名称">
                  <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.supplier"
@@ -234,32 +236,27 @@
                </el-table-column> -->
                <el-table-column label="质量追溯号">
                  <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.qualityTraceability"
                      placeholder="请输入"></el-input>
                    <el-input size="mini" v-model="scope.row.qualityTraceability" placeholder="请输入"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="原材料名称">
                  <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.name"
                      placeholder="请输入"></el-input>
                    <el-input size="mini" v-model="scope.row.name" placeholder="请输入"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="规格型号">
                  <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.specifications"
                      placeholder="请输入"></el-input>
                    <el-input size="mini" v-model="scope.row.specifications" placeholder="请输入"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="单位">
                  <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.unit"
                      placeholder="请输入"></el-input>
                    <el-input size="mini" v-model="scope.row.unit" placeholder="请输入"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="数量">
                  <template slot-scope="scope">
                      <el-input size="mini" v-model="scope.row.num"
                      placeholder="请输入"></el-input>
                    <el-input size="mini" v-model="scope.row.num" placeholder="请输入"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="操作" width="60">
@@ -278,24 +275,23 @@
      </el-dialog>
        <!-- 生产工艺 -->
      <el-dialog title="BOM新增" :visible.sync="productVisible" width="45%">
          <el-form :model="productForm" :inline="true" label-position="right"
          :rules="productRules" ref="productForm" label-width="90px">
        <el-form :model="productForm" :inline="true" label-position="right" :rules="productRules" ref="productForm"
          label-width="90px">
            <el-row>
              <el-col :span="12">
                <el-form-item label="工序:" prop="profather">
                  <el-select v-model="productForm.profather"
                   @change="changeProduct" placeholder="请选择工序" size="small">
                    <el-option v-for="(item,index) in productFormList" :key="index"
                    :value="item.name" :label="item.name"></el-option>
                <el-select v-model="productForm.profather" @change="changeProduct" placeholder="请选择工序" size="small">
                  <el-option v-for="(item, index) in productFormList" :key="index" :value="item.name"
                    :label="item.name"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="工艺名称:" prop="protechnologyId">
                  <el-select placeholder="请选择工艺名称" @change="getProductDeviceList"
                  v-model="productForm.protechnologyId" size="small">
                  <el-option v-for="(item,index) in proIdList" :key="index"
                    :value="item.id" :label="item.name"></el-option>
                <el-select placeholder="请选择工艺名称" @change="getProductDeviceList" v-model="productForm.protechnologyId"
                  size="small">
                  <el-option v-for="(item, index) in proIdList" :key="index" :value="item.id"
                    :label="item.name"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
@@ -303,10 +299,9 @@
            <el-row>
              <el-col :span="12">
                <el-form-item label="设备:" prop="device">
                  <el-select placeholder="请选择设备" size="small"
                  v-model="productForm.device">
                  <el-option v-for="(item,index) in productDeviceList" :key="index"
                    :value="item.device" :label="item.device"></el-option>
                <el-select placeholder="请选择设备" size="small" v-model="productForm.device">
                  <el-option v-for="(item, index) in productDeviceList" :key="index" :value="item.device"
                    :label="item.device"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
@@ -314,8 +309,8 @@
                <el-form-item label="项目:" prop="productFather">
                  <el-select placeholder="请选择项目" size="small"  @change="changeProductFather"
                  v-model="productForm.productFather">
                  <el-option v-for="(item,index) in productProjectList" :key="index"
                    :value="item.name" :label="item.name"></el-option>
                  <el-option v-for="(item, index) in productProjectList" :key="index" :value="item.name"
                    :label="item.name"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
@@ -323,10 +318,9 @@
            <el-row>
              <el-col :span="12">
                <el-form-item label="指标:" prop="product">
                  <el-select placeholder="请选择指标" size="small" @change="changeProProduct"
                    v-model="productForm.product">
                    <el-option v-for="(item,index) in proProductList" :key="index"
                    :value="item.name" :label="item.name"></el-option>
                <el-select placeholder="请选择指标" size="small" @change="changeProProduct" v-model="productForm.product">
                  <el-option v-for="(item, index) in proProductList" :key="index" :value="item.name"
                    :label="item.name"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
@@ -344,23 +338,46 @@
      </el-dialog>
      <!-- 左侧点击+按钮 -->
      <el-dialog title="BOM新增" :visible.sync="bomLeftAdd" width="29%">
        <el-form ref="leftAdd" :model="leftAdd">
            <el-form-item :rules="[{ required: true, message: '请选择产品类型', trigger: 'blur' }]" label="产品类型" prop="type">
              <el-cascader @change="changeLeftAdd" v-model="leftAdd.type"  style="width: 86%;" :options="formTypeOptions" :props="{ checkStrictly: true }" clearable></el-cascader>
      <el-dialog title="BOM新增" :visible.sync="bomLeftAdd" width="45%">
        <el-form ref="leftAdd" :model="leftAdd" style="width: 100%;">
          <el-col :span="24" style="display: flex;justify-content: space-between;">
            <el-form-item style="display: flex"
              :rules="[{ required: true, message: '请选择产品类型', trigger: 'blur' }]" label="类型" prop="type">
              <el-cascader @change="changeLeftAdd" v-model="leftAdd.type" style="width: 90%;" :options="formTypeOptions"
                :props="{ checkStrictly: true }" clearable></el-cascader>
            </el-form-item>
            <el-form-item v-if="leftAdd.type.length<2" label="产品大类" prop="father">
              <el-autocomplete  class="inline-input" style="width: 88%;" v-model="leftAdd.father" :fetch-suggestions="querySearch" placeholder="请选择产品大类" @select="handleSelect"></el-autocomplete>
            <el-form-item style="display: flex"  v-if="leftAdd.type.length < 2" label="大类"
              prop="father">
              <el-autocomplete class="inline-input" style="width: 100%;" v-model="leftAdd.father"
                :fetch-suggestions="querySearch" placeholder="请选择产品大类" @select="handleSelect"></el-autocomplete>
            </el-form-item>
            <el-form-item v-if="leftAdd.type.length<3"  label="产品名称" prop="name">
              <el-autocomplete class="inline-input" style="width: 88%;" v-model="leftAdd.name" :fetch-suggestions="querySearchName" placeholder="请选择产品名称" @select="handleSelect"></el-autocomplete>
          </el-col>
          <el-col :span="24" style="display: flex;justify-content: space-between;">
            <el-form-item style="display: flex;margin-left: 10px;"  v-if="leftAdd.type.length < 3"
              label="名称" prop="name">
              <el-autocomplete class="inline-input" style="width: 100%;" v-model="leftAdd.name"
                :fetch-suggestions="querySearchName" placeholder="请选择产品名称" @select="handleSelect"></el-autocomplete>
            </el-form-item>
            <el-form-item v-if="leftAdd.type.length<4"  label="产品标准" prop="standard">
              <el-autocomplete class="inline-input" style="width: 88%;" v-model="leftAdd.standard" :fetch-suggestions="querySearchStandar" placeholder="请选择产品标准" @select="handleSelect"></el-autocomplete>
            <el-form-item style="display: flex;margin-left: 13px;"  v-if="leftAdd.type.length < 4"
              label="标准" prop="standard">
              <el-autocomplete class="inline-input" style="width: 100%;" v-model="leftAdd.standard"
                :fetch-suggestions="querySearchStandar" placeholder="请选择产品标准" @select="handleSelect"></el-autocomplete>
            </el-form-item>
            <el-form-item  label="产品型号" prop="specifications">
              <el-input v-model="leftAdd.specifications" style="width: 88%;" placeholder="请输入产品型号"></el-input>
          </el-col>
          <el-col :span="24" style="display: flex;justify-content: space-between;">
            <el-form-item style="display: flex;margin-left: 5px"  label="型号"
              prop="specifications">
              <el-input v-model="leftAdd.specifications" style="width: 100%;" placeholder="请输入产品型号"></el-input>
            </el-form-item>
            <el-col :span="10">
              <el-form-item v-if="isCopy" style="display: flex;" label="是否复制">
              <el-radio-group v-model="copyRadio">
                <el-radio label="1">不复制</el-radio>
                <el-radio label="2">复制</el-radio>
              </el-radio-group>
            </el-form-item>
            </el-col>
          </el-col>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="resetForm('leftAdd')">取 消</el-button>
@@ -407,6 +424,9 @@
    return {
      //子组件传的id列表
      childIds:[],
      copyRadio: "1",
      spId: 0,
      ver: 0,
      isUpdateDevice:false,
      //工序列表
      fatherList:[],
@@ -496,6 +516,7 @@
      bomLeftAdd: false,
      bomRightUp: false,
      bomRightDl: false,
      isCopy: false,
      formTypeOptions: null,
      typeselect: 0,
      returntree: {id:28},
@@ -520,6 +541,10 @@
    this.selectVersion()
  },
  methods: {
    leftAddIsCopy() {
      this.bomLeftAdd = true
      this.copyRadio="1"
    },
    updateDevice(val){
      this.isUpdateDevice = val;
    },
@@ -546,7 +571,7 @@
            let obj=JSON.parse(JSON.stringify(this.leftAdd))
            if(obj.type.length===1){
              obj.type=this.getType(obj.type[0])
                  this.$axios.post(this.$api.url.leftAddOneTwo,obj,{
            this.$axios.post(this.$api.url.leftAddOneTwo+"?"+"spId="+this.spId+"&&"+"ver="+this.ver, obj, {
                     headers: { "Content-Type": "application/json" }
                 }).then(res=>{
                     this.$message({
@@ -570,11 +595,10 @@
              let two=one.children.filter(item=>{
                return item.name===obj.father
              })[0]
              console.log("two",two);
              //执行一二级新增
              if(two===undefined||two===null){
                  obj.type=this.getType(obj.type[0])
                  this.$axios.post(this.$api.url.leftAddOneTwo,obj,{
            this.$axios.post(this.$api.url.leftAddOneTwo+"?"+"spId="+this.spId+"&&"+"ver="+this.ver, obj, {
                     headers: { "Content-Type": "application/json" }
                 }).then(res=>{
                     this.$message({
@@ -594,10 +618,9 @@
                let three=two.children.filter(item=>{
                  return item.name===obj.name
                })[0]
                console.log("three",three);
                if(three===undefined||three===null){
                  obj.type=this.getType(obj.type[0])
                  this.$axios.post(this.$api.url.leftAddOneTwo,obj,{
              this.$axios.post(this.$api.url.leftAddOneTwo+"?"+"spId="+this.spId+"&&"+"ver="+this.ver, obj, {
                     headers: { "Content-Type": "application/json" }
                 }).then(res=>{
                     this.$message({
@@ -624,7 +647,7 @@
                       "specifications": obj.specifications,
                       "standard": obj.standard
                     }
                     this.$axios.post(this.$api.url.leftAddThree,StandardDto,{
                this.$axios.post(this.$api.url.leftAddThree+"?"+"spId="+this.spId+"&&"+"ver="+this.ver, StandardDto, {
                     headers: { "Content-Type": "application/json" }
                 }).then(res=>{
                     this.$message({
@@ -645,7 +668,7 @@
                      "id": four.id,
                       "specifications": obj.specifications
                     }
                     this.$axios.post(this.$api.url.leftAddFour,specificationsDto,{
                this.$axios.post(this.$api.url.leftAddFour+"?"+"spId="+this.spId+"&&"+"ver="+this.ver, specificationsDto, {
                     headers: { "Content-Type": "application/json" }
                 }).then(res=>{
                     this.$message({
@@ -666,7 +689,6 @@
              }
              this.resetForm('leftAdd')
          } else {
            console.log('error submit!!');
            return false;
          }
        });
@@ -981,7 +1003,6 @@
      return typeName==="成品"?1:2
    },
    handleSelect(item) {
        console.log(item);
    },
    querySearch(queryString, cb) {
      var restaurants = this.restaurants;
@@ -1045,8 +1066,11 @@
    },
    handleNodeClick(val) {//树的值
      if(val.code==='[5]'&&val.children===undefined){
        this.isCopy=true
        this.returntree = val
        this.selectVersion()
      }else{
        this.isCopy=false
      }
    },
    async selectVersion() {//版本
@@ -1209,13 +1233,11 @@
    handler(newVal, oldVal) {
    if(this.isLeftAdd){
      let tree=JSON.parse(JSON.stringify(this.list))
      console.log(tree);
      let father=null;
      if(newVal.father!=null&&newVal.father!=''&&newVal.type.length>0){
          let one=tree.filter(item=>{
            return item.name===newVal.type[0]
          })[0]
          console.log(one);
          if(one.children===undefined){
            return
          }
@@ -1279,13 +1301,23 @@
      if(!newVal){
        this.clearBomAddModel();
      }
    },
    copyRadio: {
      handler(newval, oldVal) {
        if (newval==='2') {
          this.spId=JSON.stringify(this.returntree.id)
          this.ver=JSON.stringify(this.versionVal)
        }else{
          this.spId=0
          this.ver=0
        }
    }
    }
  }
}
</script>
<style scoped>
.standard .title .el-button {
  height: 32px;
  border: 1px solid rgba(190, 190, 190, 0.44);