zouyu
2023-11-10 65cd94b74a6dd5bae9bc2c3a98bc781d97099cb6
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<template>
  <el-dialog
    width="50%"
    title="节点"
    :visible.sync="innerVisible"
    append-to-body
    @close="$emit('update:currshowlist', false)"
    :show="currshowlist"
  >
    <div class="app-container">
      <el-form
        :model="partInfo"
        :rules="dataRule"
        ref="partInfo"
        label-width="80px"
        class="l-mes"
      >
        <el-row type="flex" justify="space-around">
          <el-col :span="10">
            <div style="margin-bottom:20px">
              <el-form-item label="零件" prop="partName">
                <el-input
                  class="innerClass"
                  v-model="partInfo.partName"
                  placeholder="请选择零件"
                  :readonly="true"
                  style="width: 90%"
                >
                  <el-button
                    slot="append"
                    icon="el-icon-search"
                    @click="openPartDialog()"
                  ></el-button>
                </el-input>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="10">
            <div style="margin-bottom:20px">
              <el-form-item label="数量" prop="qpa">
                <el-input v-model="partInfo.qpa" style="width: 80%"></el-input>
              </el-form-item>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button @click="innerVisible = false">取 消</el-button>
      <el-button type="primary" @click="saveSelectRow">确 定</el-button>
    </div>
    <partDialog :currshowlist.sync="showPart" @listenToPartEvent="selectPart" />
  </el-dialog>
</template>
<script>
import partDialog from '@/views/common/part.vue'
import { validateSixDecimalPositive } from '../../../util/validate'
 
export default {
  props: {
    currshowlist: {
      type: Boolean,
      default: false
    },
    nodeParam: {
      type: Object,
      default: () => {
        return {}
      },
      required: true
    }
  },
  data() {
    return {
      showPart: false,
      innerVisible: false,
      options: [],
      partInfo: {
        bomId: null,
        id: null,
        partId: null,
        partNo: null,
        partName: null,
        qpa: null,
        drawingNumber: null,
        unit: null
      },
      dataRule: {
        partName: [
          { required: true, message: '零件不能为空', trigger: 'blur' }
        ],
        qpa: [
          { required: true, message: '数量不能为空', trigger: 'blur' },
          { validator: validateSixDecimalPositive, trigger: 'blur' }
        ]
      }
    }
  },
  components: {
    partDialog
  },
  methods: {
    saveSelectRow() {
      this.$refs.partInfo.validate((valid) => {
        if (valid) {
          this.$emit('listenToPartInfoEvent', this.partInfo)
          this.innerVisible = false
        }
      })
    },
    openPartDialog() {
      this.showPart = true
    },
    selectPart(param) {
      if (typeof param !== 'undefined') {
        this.partInfo.partId = param.id
        this.partInfo.partNo = param.partNo
        this.partInfo.partName = param.partName
        this.partInfo.drawingNumber = param.drawingNumber
        this.partInfo.unit = param.unit
      }
    }
  },
  watch: {
    currshowlist() {
      this.innerVisible = this.currshowlist
      if (this.currshowlist) {
        this.partInfo.id = this.nodeParam.id
        this.partInfo.bomId = this.nodeParam.bomId
        this.partInfo.partId = this.nodeParam.partId
        this.partInfo.partNo = this.nodeParam.partNo
        this.partInfo.partName = this.nodeParam.partName
        this.partInfo.qpa = this.nodeParam.qpa
        this.partInfo.drawingNumber = this.nodeParam.drawingNumber
        this.partInfo.unit = this.nodeParam.unit
      }
    }
  }
}
</script>