yuyu
2023-08-02 192a6c1536d3f9017343634c17dc300c6fd98ff6
src/components/view/standard.vue
@@ -12,6 +12,10 @@
    margin-bottom: 10px;
    padding: 0 20px;
  }
  .standard .title *{
    font-size: 16px;
  }
  .thing {
    width: 100%;
@@ -85,6 +89,10 @@
  .standard .title .el-button * {
    font-size: 14px;
  }
  .standard .title .el-button--default{
    color: #004EA2;
  }
  .standard .thing .left .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
    background: rgba(58, 124, 253, 0.3);
@@ -101,9 +109,9 @@
  <div class="standard">
    <div class="title">
      <el-row>
        <el-col :span="12">标准BOM</el-col>
        <el-col :span="12" style="line-height: 32px;">标准BOM</el-col>
        <el-col :span="12" style="text-align: right;">
          <el-button type="primary" icon="el-icon-plus" style="background: #004EA2;">新增</el-button>
          <el-button type="primary" icon="el-icon-plus" style="background: #004EA2;" @click="bomAddModelVisible= true">新增</el-button>
          <el-button icon="el-icon-edit-outline">修改</el-button>
          <el-button icon="el-icon-delete">删除</el-button>
        </el-col>
@@ -128,18 +136,33 @@
        <div class="choose">
          <span>类型:</span>
          <el-select v-model="tableType" size="small" placeholder="请选择" style="width: 224px;margin-right: 52px;">
            <el-option value="工艺文件"></el-option>
            <el-option value="技术指标"></el-option>
            <el-option :value="0" label="工艺文件"></el-option>
            <el-option :value="1" label="技术指标"></el-option>
          </el-select>
          <span>{{tableType=='技术指标'?'项目:':'工艺名称:'}}</span>
          <span>{{tableType==1?'项目:':'工艺名称:'}}</span>
          <el-input v-model="searchName" size="small" placeholder="请输入" style="width: 224px;margin-right: 24px;" clearable></el-input>
          <el-button size="mini"><span>重 置</span></el-button>
          <el-button size="mini" type="primary" style="background: #004EA2;"><span>查 询</span></el-button>
          <el-button size="mini" @click="()=>{searchName='';selectProductTableData()}"><span>重 置</span></el-button>
          <el-button size="mini" type="primary" style="background: #004EA2;" @click="selectProductTableData"><span>查 询</span></el-button>
        </div>
        <div class="table">
          <technology></technology>
          <technology v-if="tableData.length!==0" :tableType="tableType" :tableData="tableData"></technology>
        </div>
      </div>
    </div>
    <div class="bom-add-model">
      <el-dialog
        title="BOM新增"
        :visible.sync="bomAddModelVisible"
        width="30%"
        :before-close="handleClose">
        <el-form>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button @click="bomAddModelVisible = false">取 消</el-button>
          <el-button type="primary" @click="bomAddModelVisible = false">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </div>
</template>
@@ -150,6 +173,7 @@
    components: {technology},
    data() {
      return {
        // BOM树数据结构
        list: [{
          id: 0,
          name: "原材料",
@@ -167,13 +191,24 @@
          children: []
        }],
        search: null,
        tableType: "技术指标",
        searchName: ""
        // 表格类型 1:技术指标,0:工艺路线
        tableType: 1,
        // 查询条件-名称
        searchName: "",
        // 点击选中树节点
        checkTreeNode: {},
        tableData:[],
        // 控制bom新增模态框是否显示
        bomAddModelVisible: false
      }
    },
    watch: {
      search(val) {
        this.$refs.tree.filter(val);
      },
      tableType(val){
        console.log(val)
        this.selectProductTableData()
      }
    },
    mounted() {
@@ -181,7 +216,10 @@
    },
    methods: {
      handleNodeClick(data) {
        console.log(data);
        // console.log(data);
        this.checkTreeNode = data
        // this.selectMaterialTree()
        this.selectProductTableData()
      },
      filterNode(value, data) {
        if (!value) return true;
@@ -210,7 +248,34 @@
              if (a.type == b.id) b.children = [a]
            })
          })
          this.$nextTick().then(() => {
          const firstNode = document.querySelector('.el-tree-node .el-tree-node__children .el-tree-node .el-tree-node__children .el-tree-node .el-tree-node__children .el-tree-node')
          firstNode.click()
          // console.log(firstNode)
          })
        })
      },
      async selectProductTableData() {
        switch (this.tableType) {
          case 0:
        const {data:technologyList} = await this.$axios.get(this.$api.url.selectTechnologyByMaterial,{params:{specificationId:this.checkTreeNode.id,technologyName:this.searchName}})
        this.tableData = technologyList
            break;
          case 1:
        const {data:productList} = await this.$axios.get(this.$api.url.selectProductByMaterial,{params:{specifications:this.checkTreeNode.id,project:this.searchName}})
        productList.forEach((item,index)=>{
          item.name = item.father
          item.index = index+1
          item.id = item.father
          if(item.children.length===1){
            productList[index] = {...item.children[0],index: index+1,name:item.father}
          }
        })
        this.tableData = productList
            break;
        }
        console.log(this.tableData)
      }
    }
  }