price-edit.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <!-- 集采交易-我的集采-集采申请-价格编辑 -->
  2. <template>
  3. <app-drawer title="编辑" :width="400" v-model:show="show">
  4. <el-form ref="formRef" class="el-form--vertical" label-width="60px" :model="formItem" :rules="formRules">
  5. <el-form-item label="数量" prop="Qty">
  6. <el-input-number placeholder="请输入" :min="0" :precision="0" v-model="formItem.Qty" />
  7. </el-form-item>
  8. <el-form-item label="价格" prop="Price">
  9. <el-input-number placeholder="请输入" :min="0" v-model="formItem.Price" />
  10. </el-form-item>
  11. </el-form>
  12. <template #footer>
  13. <el-button @click="onCancel" plain>取消</el-button>
  14. <el-button type="primary" @click="onSubmit">保存</el-button>
  15. </template>
  16. </app-drawer>
  17. </template>
  18. <script lang="ts" setup>
  19. import { ref, PropType } from 'vue'
  20. import type { FormInstance, FormRules } from 'element-plus'
  21. import { regular } from '@/constants/regex'
  22. import AppDrawer from '@pc/components/base/drawer/index.vue'
  23. const props = defineProps({
  24. selectedRow: {
  25. type: Object as PropType<Proto.GZCenterPurchasePrice>
  26. }
  27. })
  28. const emit = defineEmits(['update'])
  29. const show = ref(true)
  30. const formRef = ref<FormInstance>()
  31. const formItem = ref<Partial<Proto.GZCenterPurchasePrice>>({ StepIndex: 0, ...props.selectedRow })
  32. const formRules: FormRules = {
  33. Qty: [{
  34. required: true,
  35. message: '请输入数量',
  36. pattern: regular.integer.reg
  37. }],
  38. Price: [{
  39. required: true,
  40. message: '请输入价格',
  41. pattern: regular.positive.reg
  42. }],
  43. }
  44. const onCancel = () => {
  45. show.value = false
  46. }
  47. const onSubmit = () => {
  48. formRef.value?.validate((valid) => {
  49. if (valid) {
  50. emit('update', formItem.value)
  51. onCancel()
  52. }
  53. })
  54. }
  55. </script>