scheduling-purchase.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!-- 采购 -->
  2. <template>
  3. <div>
  4. <div class="my-title">{{subTitle}}</div>
  5. <!-- 表单 -->
  6. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  7. <div class="form-item" v-for="(item, index) in dataForm.list" :key="item.purchaseDetailId">
  8. <el-row>
  9. <el-col :span="6">
  10. <el-form-item label="物品名称">
  11. <span>{{item.materialName}}</span>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :span="6">
  15. <el-form-item label="规格/型号">
  16. <span>{{item.specification}}</span>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :span="6">
  20. <el-form-item label="数量">
  21. <span>{{item.cnt}}</span>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="6">
  25. <el-form-item label="用途">
  26. <span>{{item.batchNumber}}</span>
  27. </el-form-item>
  28. </el-col>
  29. </el-row>
  30. <el-row class="my-row">
  31. <el-col :span="6">
  32. <el-form-item label="采购数量" :prop="'list.' + index + '.cnt'" :rules="dataRule.cnt">
  33. <el-input-number v-model="item.cnt" :step="1" :min="0"></el-input-number>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="6">
  37. <el-form-item label="单位" :prop="'list.' + index + '.unitName'" :rules="dataRule.unitName">
  38. <el-input v-model="item.unitName" placeholder="单位单位"></el-input>
  39. </el-form-item>
  40. </el-col>
  41. <el-col :span="12">
  42. <el-form-item label="备注" :prop="'list.' + index + '.notes'" :rules="dataRule.notes">
  43. <el-input type="textarea" v-model="item.notes"></el-input>
  44. </el-form-item>
  45. </el-col>
  46. </el-row>
  47. </div>
  48. </el-form>
  49. <span slot="footer" class="dialog-footer">
  50. <el-button @click="onChose">取消</el-button>
  51. <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
  52. </span>
  53. </div>
  54. </template>
  55. <script>
  56. import {purchase} from '@/api/production'
  57. import MaterialComponent from '@/views/modules/common/material-component'
  58. export default {
  59. name: 'scheduling-purchase',
  60. components: {
  61. MaterialComponent
  62. },
  63. data () {
  64. return {
  65. id: 0,
  66. dataForm: {
  67. list:[]
  68. },
  69. dataRule: {
  70. cnt: [{ required: true, message: '请输入数量', trigger: 'change' }],
  71. unitName: [{ required: true, message: '请输入单位', trigger: 'blur' }]
  72. },
  73. subTitle:''
  74. }
  75. },
  76. methods: {
  77. onChose () {
  78. this.$emit('onChose')
  79. },
  80. async init (row) {
  81. this.dataForm.id = row.id
  82. if(row instanceof Array){
  83. this.subTitle = '批量采购'
  84. this.dataForm.list = row
  85. } else {
  86. this.subTitle = '采购'
  87. this.dataForm.list = [row]
  88. }
  89. },
  90. validateField (type) {
  91. this.$refs.dataForm.validateField(type)
  92. },
  93. // 表单提交
  94. dataFormSubmit () {
  95. this.$refs['dataForm'].validate((valid) => {
  96. if (valid) {
  97. purchase(this.dataForm).then(({data}) => {
  98. if (data && data.code === '200') {
  99. this.$message({
  100. message: '操作成功',
  101. type: 'success',
  102. duration: 1500,
  103. onClose: () => {
  104. this.onChose()
  105. this.$emit('refreshDataList')
  106. }
  107. })
  108. } else {
  109. this.$message.error(data.msg)
  110. }
  111. })
  112. }
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style scoped>
  119. .form-item {
  120. margin: 5px 0;
  121. padding:25px 0 5px;
  122. background-color: #f1f9f9;
  123. border-radius: 10px;
  124. }
  125. </style>