Fixiaobai
2023-11-13 c1c20fe004cd930a95eb5758f927e6ab178799e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<template>
  <el-dialog width="60%" title="零件" top="5vh"
             :visible.sync="innerVisible" append-to-body @close="$emit('update:currshowlist', false)"
             :show="currshowlist" class="part-dialog">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px" class="l-mes">
      <el-row>
        <el-col :span="10">
          <el-form-item label="零件编号" prop="partFamilyNo">
            <el-input v-model="dataForm.partNo" placeholder="零件族编号"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10">
          <el-form-item label="零件名称" prop="partFamilyName">
            <el-input v-model="dataForm.partName" placeholder="零件族名称"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3" :offset="1">
        <el-button @click="getSelectPart">搜索</el-button>
        </el-col>
      </el-row>
    </el-form>
    <el-table border
              v-loading="listLoading"
              :data="partList"
               height="300px"
              @row-dblclick="doubleClick"
              @row-click = "rowClick"
              highlight-current-row
              @current-change="handleCurrentChange"
               >
      <el-table-column prop="PART_DESC" label="零件名称" ></el-table-column>
      <el-table-column prop="UNIT_MEAS" label="单位" ></el-table-column>
      <el-table-column prop="PART_NO" label="零件号" align="center"></el-table-column>
    </el-table>
    <span slot="footer" class="dialog-footer">
      <el-button @click="innerVisible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
 
<script>
  import {getPart} from "../../../api/basic/part";
 
  export default {
    props: {
      currshowlist: {
        type: Boolean,
        default: false
      },
      multiSelect:{
        type: Boolean,
        default: false
      }
    },
    data () {
      return {
        partList:[],
        listLoading: false,
        currentRow: null,
        multipleSelection: [],
        innerVisible:false,
        visible: false,
        dataForm: {
          partNo: '',
          partName: '',
        },
        dataRule: {
        }
      }
    },
    watch: {
      currshowlist() {
        this.innerVisible = this.currshowlist;
        if(this.currshowlist){
        }
      },
      innerVisible:{
        handler(newValue, oldValue) {
          if(newValue) {
            this.dataForm.partNo=null
            this.dataForm.partName=null
            this.partList =[]
          }
        },
        immediate: true
      }
    },
    methods: {
      //根据搜索条件搜索ERP零件
      getSelectPart(){
        let queryParam = {
          partNo:this.dataForm.partNo,
          partName:this.dataForm.partName
        }
        getPart(queryParam).then(res => {
          this.partList =res.data.data.data.INVENTORY_PART_INFO
        })
 
      },
      handleCurrentChange(val) {
        this.currentRow = val;
      },
      doubleClick(){
        this.dataFormSubmit()
      },
      rowClick(row){
        this.currentRow = row;
      },
      dataFormSubmit(){
        if (this.currentRow == null){
          this.$message.error('请选择零件')
          return
        }
        if(this.multiSelect){
          this.$emit("handleSelectionChange", this.multipleSelection);
        }else{
          this.$emit("listenToPartEvent", this.currentRow);
        }
        this.innerVisible = false;
      },
    }
  }
</script>