purchase-operate.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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="12">
  9. <el-form-item ref="supplierCheckbox" label="供应商" prop="supplierId">
  10. <supplier-component v-model="dataForm.supplierId" :supplier-id.sync="dataForm.supplierId"></supplier-component>
  11. </el-form-item>
  12. </el-col>
  13. <el-col :span="12">
  14. <el-form-item ref="supplierInput" label="其他供应商" prop="supplierOther">
  15. <el-input v-model="dataForm.supplierOther" placeholder="请输入其他供应商"></el-input>
  16. </el-form-item>
  17. </el-col>
  18. </el-row>
  19. <el-row class="my-row">
  20. <el-col :span="12">
  21. <el-form-item label="采购依据" prop="procurementBasis">
  22. <el-select
  23. v-model="dataForm.procurementBasis"
  24. placeholder="请选择">
  25. <el-option
  26. v-for="item in optionsPB"
  27. :key="item.code"
  28. :label="item.value"
  29. :value="item.code">
  30. </el-option>
  31. </el-select>
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="12">
  35. <el-form-item label="不含税单价" prop="price">
  36. <el-input-number v-model="dataForm.price" :step="1" :min="0" :precision="1"></el-input-number>
  37. </el-form-item>
  38. </el-col>
  39. </el-row>
  40. <el-row class="my-row">
  41. <el-col :span="12">
  42. <el-form-item label="含税单价" prop="taxPrice">
  43. <el-input-number v-model="dataForm.taxPrice" :step="1" :min="0" :precision="1"></el-input-number>
  44. </el-form-item>
  45. </el-col>
  46. <el-col :span="12">
  47. <el-form-item label="含税总价" prop="procurementCode">
  48. <span>{{ (dataForm.cnt * dataForm.price).toFixed(1) }}</span>
  49. </el-form-item>
  50. </el-col>
  51. </el-row>
  52. <el-row class="my-row">
  53. <el-col :span="12">
  54. <el-form-item label="税率" prop="taxRate">
  55. <el-input-number v-model="dataForm.taxRate" :step="1" :precision="1"/>&nbsp;%
  56. </el-form-item>
  57. </el-col>
  58. </el-row>
  59. </el-form>
  60. <span slot="footer" class="dialog-footer">
  61. <el-button @click="onChose">取消</el-button>
  62. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  63. </span>
  64. </div>
  65. </template>
  66. <script>
  67. import SupplierComponent from '../common/supplier-component'
  68. import { getDictList } from '@/api/dict'
  69. export default {
  70. name: 'purchase-operate',
  71. components: {
  72. SupplierComponent
  73. },
  74. data () {
  75. let validateSupplier = (rule, value, callback) => {
  76. if (!this.dataForm.supplierId && !this.dataForm.supplierOther) {
  77. callback(new Error('请至少填写一项供应商信息'))
  78. } else {
  79. // 任意值被填写,清除验证提示
  80. if (!this.dataForm.supplierId || !this.dataForm.supplierOther) {
  81. this.$refs.supplierCheckbox.clearValidate()
  82. this.$refs.supplierInput.clearValidate()
  83. }
  84. callback()
  85. }
  86. }
  87. return {
  88. id: 0,
  89. dataForm: {
  90. cnt: 1
  91. },
  92. dataRule: {
  93. supplierId: [{required: true, validator: validateSupplier, trigger: 'change'}],
  94. supplierOther: [{required: true, validator: validateSupplier, trigger: 'blur'}],
  95. procurementBasis: [{ required: true, message: '请选择采购依据', trigger: 'change' }],
  96. price: [{ required: true, message: '请输入不含税单价', trigger: 'change' }],
  97. taxPrice: [{ required: true, message: '请输入含税单价', trigger: 'change' }],
  98. taxRate: [{ required: true, message: '请输入税率', trigger: 'change' }]
  99. },
  100. optionsPB: [] // 采购依据(字典)
  101. }
  102. },
  103. methods: {
  104. onChose () {
  105. this.$emit('onChose')
  106. },
  107. // 获取采购依据字典
  108. getPbList () {
  109. getDictList({type: 'procurement_basis'}).then(({data}) => {
  110. if (data) {
  111. this.optionsPB = data
  112. }
  113. })
  114. },
  115. async init (row) {
  116. if (!row) return
  117. this.getPbList()
  118. this.dataForm = row
  119. },
  120. validateField (type) {
  121. this.$refs.dataForm.validateField(type)
  122. },
  123. // 表单提交
  124. dataFormSubmit () {
  125. this.$refs['dataForm'].validate((valid) => {
  126. if (valid) {
  127. // // 检查供应商
  128. // if (!this.dataForm.supplierId && !this.dataForm.supplierOther) {
  129. // this.$message.error('请填写供应商')
  130. // return
  131. // }
  132. this.$http({
  133. url: this.$http.adornUrl(`/biz-service/purchaseDetail/updatePurchaseDetail`),
  134. method: 'post',
  135. data: this.$http.adornData({...this.dataForm})
  136. }).then(({data}) => {
  137. if (data && data.code === '200') {
  138. this.$message({
  139. message: '操作成功',
  140. type: 'success',
  141. duration: 1500,
  142. onClose: () => {
  143. this.onChose()
  144. this.$emit('refreshDataList')
  145. }
  146. })
  147. } else {
  148. this.$message.error(data.msg)
  149. }
  150. })
  151. }
  152. })
  153. }
  154. }
  155. }
  156. </script>
  157. <style scoped>
  158. </style>