Fixiaobai
2023-10-13 e8308ddac0ba4a1f406e8f63d7e6b6f2541cb770
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<template>
  <el-dialog
    :title="!dataForm.id ? '报检' : '报检'"
    :close-on-click-modal="false"
    :visible.sync="visible"
    class="part-dialog"
  >
    <!--检测汇报关联的检验项-->
    <div class="test-apply-div">
      <div class="test-apply-header">
        <span style="color:#303133;">报检申请</span>
      </div>
      <div class="test-apply-body">
        <el-form
          :model="dataForm"
          :rules="dataRule"
          ref="dataForm"
          label-width="120px"
          class="l-mes"
        >
          <el-row>
            <el-col :span="7">
              <el-form-item label="申请类型" prop="applyType">
                <el-select v-model="dataForm.applyType" placeholder="请选择">
                  <el-option
                    v-for="item in reportTypeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="申请编号" prop="applyNo">
                <el-input v-model="dataForm.applyNo" placeholder=""></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="备注" prop="remark">
                <el-input v-model="dataForm.remark" placeholder=""></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
    </div>
    <div class="test-part-div">
      <div class="test-part-header">
        <span style="color:#303133;">报检零件</span>
      </div>
      <div class="test-part-body">
        <el-table
          stripe
          ref="applyPartList"
          :data="applyPartList"
          height="100%"
          :row-style="{ height: '26px' }"
          :cell-style="{ padding: '0' }"
        >
          <el-table-column
            label="系统编号"
            prop="systemNo"
            align="center"
            min-width="75px"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="零件批号"
            prop="outBatchNo"
            align="center"
            min-width="75px"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="零件编号"
            prop="partNo"
            align="center"
            min-width="75px"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="零件名称"
            prop="partName"
            align="center"
            min-width="75px"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="生产数量"
            prop="productQty"
            align="center"
            min-width="75px"
            :show-overflow-tooltip="true"
          />
        </el-table>
      </div>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button
        type="primary"
        :disabled="saveDisabled"
        @click="dataFormSubmit()"
        >确定</el-button
      >
    </span>
  </el-dialog>
</template>
<style>
.test-apply-div {
  border: 1px solid #cfd5de;
  border-radius: 4px;
  width: 100%;
}
.test-apply-header {
  padding: 18px 20px;
  border-bottom: 1px solid #ebeef5;
}
.test-apply-body {
  height: 90px;
}
.test-part-div {
  border: 1px solid #cfd5de;
  border-radius: 4px;
  width: 100%;
}
.test-part-header {
  padding: 18px 20px;
  border-bottom: 1px solid #ebeef5;
}
.test-part-body {
  height: 200px;
}
</style>
<script>
import { addApply } from '@/api/quality/apply'
import { remote } from '@/api/admin/dict'
 
export default {
  props: {
    applyPartList: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      visible: false,
      dataForm: {
        id: 0,
        applyNo: '',
        applyType: '01output',
        remark: ''
      },
      dataRule: {},
      saveDisabled: false,
      clickSaveArr: [],
      reportTypeOptions: []
    }
  },
  methods: {
    init(id) {
      this.dataForm.id = id || 0
      this.visible = true
      this.$nextTick(() => {
        this.$refs.dataForm.resetFields()
        remote('apply_report_type').then((response) => {
          if (response.data.code === 0) {
            this.reportTypeOptions = response.data.data
          } else {
            this.reportTypeOptions = []
          }
        })
      })
    },
    // 表单提交
    dataFormSubmit() {
      let canClickFlag = true
      this.clickSaveArr.push(new Date().getTime())
      if (this.clickSaveArr.length > 1) {
        if (
          this.clickSaveArr[this.clickSaveArr.length - 1] -
            this.clickSaveArr[this.clickSaveArr.length - 2] <
          2000
        ) {
          // 小于2秒则认为重复提交
          canClickFlag = false
        }
      }
      if (canClickFlag) {
        this.saveDisabled = true
        this.$refs.dataForm.validate((valid) => {
          if (valid) {
            if (this.dataForm.id) {
              this.saveDisabled = false
            } else {
              if (this.applyPartList && this.applyPartList.length > 0) {
                addApply(
                  Object.assign(this.dataForm, {
                    applyPartList: this.applyPartList
                  })
                )
                  .then((data) => {
                    this.$message.success('报检成功')
                    this.visible = false
                    this.saveDisabled = false
                    this.$emit('refreshDataList')
                  })
                  .catch((error) => {
                    this.saveDisabled = false
                  })
              } else {
                this.saveDisabled = false
                this.$message.warning('请选择产出零件')
              }
            }
          } else {
            this.saveDisabled = false
          }
        })
      }
    }
  }
}
</script>