use-add.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <div>
  3. <div class="my-title">上机</div>
  4. <!-- 表单 -->
  5. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  6. <el-form-item label="选择设备" prop="equipmentId">
  7. <device-component v-model="dataForm.equipmentId" :device-id="dataForm.equipmentId"/>
  8. </el-form-item>
  9. </el-form>
  10. <span slot="footer" class="dialog-footer">
  11. <el-button @click="onChose">取消</el-button>
  12. <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
  13. </span>
  14. </div>
  15. </template>
  16. <script>
  17. import DeviceComponent from '@/views/modules/common/device-component.vue'
  18. export default {
  19. name: 'use-add',
  20. components: {DeviceComponent},
  21. data () {
  22. return {
  23. visible: false,
  24. id: 0,
  25. optionsModel: [],
  26. dataForm: {},
  27. dataRule: {
  28. equipmentId: [{ required: true, message: '请选择设备', trigger: 'change' }]
  29. }
  30. }
  31. },
  32. methods: {
  33. onChose () {
  34. this.$emit('onChose')
  35. },
  36. async init () { },
  37. validateField (type) {
  38. this.$refs.dataForm.validateField(type)
  39. },
  40. // 表单提交
  41. dataFormSubmit () {
  42. this.$refs['dataForm'].validate((valid) => {
  43. if (valid) {
  44. this.$http({
  45. url: this.$http.adornUrl(`/biz-service/prodEquipmentUsageRecord/insert`),
  46. method: 'post',
  47. data: this.$http.adornData({...this.dataForm})
  48. }).then(({data}) => {
  49. if (data && data.code === '200') {
  50. this.$message({
  51. message: '操作成功',
  52. type: 'success',
  53. duration: 1500,
  54. onClose: () => {
  55. this.onChose()
  56. this.$emit('refreshDataList')
  57. }
  58. })
  59. } else {
  60. this.$message.error(data.msg)
  61. }
  62. })
  63. }
  64. })
  65. }
  66. }
  67. }
  68. </script>
  69. <style scoped>
  70. </style>