zouyu
2023-11-17 d8ac6057eaad648687699e25a575f3b7b8c1b102
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
<template>
  <el-dialog
    title="库位选择"
    :close-on-click-modal="false"
    :visible.sync="visible"
    width="500px"
  >
    <el-form
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      label-width="80px"
      class="l-mes"
    >
      <el-form-item
        v-if="isQualified"
        label="合格库位"
        prop="targetQualifiedLocationId"
      >
        <el-input
          v-model="dataForm.targetQualifiedLocationIdNo"
          placeholder="合格库位"
          readonly
        >
          <el-button
            slot="append"
            icon="el-icon-search"
            @click="openLocationDialog('targetQualifiedLocationId')"
          ></el-button>
        </el-input>
      </el-form-item>
      <el-form-item
        v-if="!isQualified"
        label="不合格库位"
        prop="targetUnqualifiedLocationId"
      >
        <el-input
          v-model="dataForm.targetUnqualifiedLocationIdNo"
          placeholder="不合格库位"
          readonly
        >
          <el-button
            slot="append"
            icon="el-icon-search"
            @click="openLocationDialog('targetUnqualifiedLocationId')"
          ></el-button>
        </el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button
        type="primary"
        :disabled="isSubmit"
        v-thinclick="`dataFormSubmit`"
        >确定</el-button
      >
    </span>
    <locationDialog
      :currshowlist.sync="showLocation"
      @listenToLocationEvent="selectLocation"
    />
  </el-dialog>
</template>
<script>
import locationDialog from '@/views/common/location.vue'
import { batchUpdateApplyPartV2 } from '@/api/quality/newReport'
export default {
  components: { locationDialog },
  data() {
    return {
      reportInfo: {},
      visible: false,
      dataForm: {
        targetQualifiedLocationId: null,
        targetUnqualifiedLocationId: null,
        targetQualifiedLocationIdNo: null,
        targetUnqualifiedLocationIdNo: null
      },
      isQualified: null,
      showLocation: false,
      dataRule: {},
      isSubmit: false,
      locType: null
    }
  },
  created() {},
  methods: {
    init(reportInfo, isQualified) {
      this.initData()
      this.reportInfo = JSON.parse(JSON.stringify(reportInfo))
      this.isQualified = isQualified
      this.visible = true
    },
    // 初始化dataForm数据
    initData() {
      this.dataForm = {
        targetQualifiedLocationId: null,
        targetUnqualifiedLocationId: null,
        targetQualifiedLocationIdNo: null,
        targetUnqualifiedLocationIdNo: null
      }
    },
    openLocationDialog(type) {
      this.locType = type
      this.showLocation = true
    },
    selectLocation(param) {
      if (param) {
        this.dataForm[this.locType] = param.id
        this.dataForm[this.locType + 'No'] = param.locNo
      }
    },
    // 表单提交
    dataFormSubmit() {
      this.isSubmit = true
      batchUpdateApplyPartV2(
        [
          {
            id: this.reportInfo.id,
            isQualified: this.isQualified,
            systemNo: this.reportInfo.systemNo,
            lotBatchNo: this.reportInfo.lotBatchNo,
            ...this.dataForm
          }
        ],
        1
      )
        .then((data) => {
          this.$message.success('标记成功 ' + data.data.msg)
          this.visible = false
          this.isSubmit = false
          this.$emit('submitFinished')
        })
        .finally(() => {
          this.isSubmit = false
        })
    }
  }
}
</script>