scheduling-check.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <!-- 核料 -->
  2. <template>
  3. <div>
  4. <div class="my-title">核料</div>
  5. <!-- 表单 -->
  6. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  7. <el-row class="my-row">
  8. <el-col :span="8">
  9. <el-form-item prop="materialId">
  10. <label slot="label"><span style="color:red">*</span> 物品(零件)名称</label>
  11. <material-component v-model="material" @materialSelected="materialSelected"/>
  12. </el-form-item>
  13. </el-col>
  14. </el-row>
  15. <el-row class="my-row">
  16. <el-col :span="8">
  17. <el-form-item label="物品(零件)规格" prop="specifications">
  18. <el-input v-model="specifications" placeholder="物品(零件)规格" disabled></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="8">
  22. <el-form-item label="物品(零件)单位" prop="unitName">
  23. <el-input v-model="unitName" placeholder="物品(零件)单位" disabled></el-input>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="8">
  27. <el-form-item label="物品(零件)核定数量" prop="inventoryCnt">
  28. <el-input-number v-model="dataForm.inventoryCnt" :step="1" :min="0" :max="Number(dataForm.cnt)"></el-input-number>
  29. </el-form-item>
  30. </el-col>
  31. </el-row>
  32. </el-form>
  33. <span slot="footer" class="dialog-footer">
  34. <el-button @click="onChose">取消</el-button>
  35. <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
  36. </span>
  37. </div>
  38. </template>
  39. <script>
  40. import { updateCheck } from '@/api/production'
  41. import MaterialComponent from '@/views/modules/common/material-component'
  42. export default {
  43. name: 'scheduling-check',
  44. components: {
  45. MaterialComponent
  46. },
  47. data () {
  48. return {
  49. id: 0,
  50. dataForm: {},
  51. material: {},
  52. specifications: '',
  53. unitName: '',
  54. dataRule: {
  55. inventoryCnt: [{ required: true, message: '请输入核定数量', trigger: 'change' }]
  56. }
  57. }
  58. },
  59. methods: {
  60. onChose () {
  61. this.$emit('onChose')
  62. },
  63. async init (scheduleId, materialId) {
  64. this.dataForm.id = scheduleId || ''
  65. this.dataForm.materialId = materialId || ''
  66. },
  67. validateField (type) {
  68. this.$refs.dataForm.validateField(type)
  69. },
  70. // 表单提交
  71. dataFormSubmit () {
  72. this.$refs['dataForm'].validate((valid) => {
  73. if (valid) {
  74. if (this.dataForm.materialId === '') {
  75. this.$message.error('请选择物品!')
  76. return
  77. }
  78. updateCheck(this.dataForm).then(({data}) => {
  79. if (data && data.code === '200') {
  80. this.$message({
  81. message: '操作成功',
  82. type: 'success',
  83. duration: 1500,
  84. onClose: () => {
  85. this.onChose()
  86. this.$emit('refreshDataList')
  87. }
  88. })
  89. } else {
  90. this.$message.error(data.msg)
  91. }
  92. })
  93. }
  94. })
  95. },
  96. materialSelected (item) {
  97. this.unitName = item.unitName
  98. this.specifications = item.specifications
  99. this.dataForm.cnt = item.cnt
  100. this.dataForm.materialId = item.materialId
  101. }
  102. }
  103. }
  104. </script>
  105. <style scoped>
  106. </style>