gaoluyang
2025-04-17 481ce9ffb9396cdd8c48bf9b28dffe228b83bc9e
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
<template>
  <div>
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="dialogVisible"
      title="仪器设备验收单" width="80%" @close="resetForm">
      <el-form ref="modelForm" :model="form" :rules="rules" label-width="180px">
        <el-col :span="12">
          <el-form-item label="到货日期:" prop="arrivalDate">
            <el-date-picker v-model="form.arrivalDate" type="date" placeholder="选择日期" size="small" format="yyyy-MM-dd"
              style="width: 100%" value-format="yyyy-MM-dd" :disabled="operationType === 'view'">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="金额:" prop="goldAmount">
            <el-input v-model="form.goldAmount" :disabled="operationType === 'view'" clearable size="small"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="维修单位:" prop="maintenanceunit">
            <el-input v-model="form.maintenanceunit" :disabled="operationType === 'view'" clearable
              size="small"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="收设备主机和备件情况:" prop="spareParts">
            <el-input v-model="form.spareParts" :disabled="operationType === 'view'" clearable size="small"
              type="textarea"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="安装、调试情况:" prop="installationDebugging">
            <el-input v-model="form.installationDebugging" :disabled="operationType === 'view'" clearable size="small"
              type="textarea"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="验收情况:" prop="checkSituation">
            <el-input v-model="form.checkSituation" :disabled="operationType === 'view'" clearable size="small"
              type="textarea"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="接收签字:" prop="receivingSignature">
            <el-input v-model="form.receivingSignature" :disabled="operationType === 'view'" clearable
              size="small"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="厂家代表:" prop="producer">
            <el-input v-model="form.producer" :disabled="operationType === 'view'" clearable size="small"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="接收人:" prop="recipient">
            <el-input v-model="form.recipient" :disabled="operationType === 'view'" clearable size="small"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="接收日期:" prop="recipientDate">
            <el-date-picker v-model="form.recipientDate" type="date" placeholder="选择日期" size="small" format="yyyy-MM-dd"
              style="width: 100%" value-format="yyyy-MM-dd" :disabled="operationType === 'view'">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="resetForm">取 消</el-button>
        <el-button v-if="operationType !== 'view'" :loading="submitFormLoading" type="primary" @click="submitForm">确
          认</el-button>
      </span>
    </el-dialog>
  </div>
</template>
 
<script>
import {
  getDeviceAcceptance,
  addDeviceAcceptance,
  updateDeviceAcceptance,
} from '@/api/cnas/resourceDemand/device.js'
import { selectUserCondition } from "@/api/business/inspectionTask";
export default {
  name: "acceptance-form",
  // import 引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    // 这里存放数据
    return {
      dialogVisible: false,
      submitFormLoading: false,
      form: {
        arrivalDate: '',
        goldAmount: '',
        maintenanceunit: '',
        spareParts: '',
        installationDebugging: '',
        checkSituation: '',
        receivingSignature: '',
        producer: '',
        recipient: '',
        recipientDate: '',
        deviceId: '',
      },
      operationType: '',
      rules: {
        arrivalDate: [{ required: true, message: '请选择到货日期', trigger: 'change' }],
      },
      userList: [],
    }
  },
  mounted() {
 
  },
  // 方法集合
  methods: {
    // 打开弹框
    openDialog(type, id, deviceId) {
      this.dialogVisible = true
      this.operationType = type
      this.form.acceptanceId = id
      this.form.deviceId = deviceId
      this.getUserList()
      if (this.form.acceptanceId) {
        this.searchInfo()
      }
    },
    // 查询详情
    searchInfo() {
      getDeviceAcceptance({ acceptanceId: this.form.acceptanceId }).then(res => {
        if (res.code === 200) {
          this.form = { ...res.data }
        }
      }).catch(error => {
        console.error(error)
      })
    },
    // 提交表单
    submitForm() {
      this.$refs.modelForm.validate((valid) => {
        if (valid) {
          if (this.operationType === 'add') {
            addDeviceAcceptance(this.form).then(res => {
              if (res.code == 200) {
                this.$message.success('新增成功')
                this.resetForm()
              }
              this.submitFormLoading = false
            }).catch(err => {
              this.submitFormLoading = false
            })
          } else {
            updateDeviceAcceptance(this.form).then(res => {
              if (res.code == 200) {
                this.$message.success('修改成功')
                this.resetForm()
              }
              this.submitFormLoading = false
            }).catch(err => {
              this.submitFormLoading = false
            })
          }
        }
      })
    },
    // 关闭弹框
    resetForm() {
      this.dialogVisible = false
      this.$emit('closeDialog')
    },
    getUserList() {
      selectUserCondition().then(res => {
        let data = [];
        res.data.forEach((a) => {
          data.push({
            label: a.name,
            value: a.id,
          });
        });
        this.userList = data
      })
    },
  },
}
</script>
 
<style scoped>
.form-item {
  display: flex;
  align-items: center;
  margin-right: 20px;
}
</style>