xm-money-input.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div>
  3. <a-form-model-item label="小数位数">
  4. <sdUglyNumber v-model="component.attr.decimalPrecision" :min="0" :max="5" />
  5. </a-form-model-item>
  6. <a-form-model-item label="默认值">
  7. <a-input-number
  8. v-model="component.attr.defaultValue"
  9. :step="Number(component.attr.decimalPrecision) / 10"
  10. @change="valueChange"
  11. />
  12. </a-form-model-item>
  13. </div>
  14. </template>
  15. <script>
  16. import { InputNumber } from 'ant-design-vue'
  17. import sdUglyNumber from '@/form-designer/sd-ugly-number.vue'
  18. import components from './_import-components/xm-money-input-import'
  19. export const metaInfo = {
  20. caption: '金额',
  21. component: {
  22. props: ['designerData'],
  23. render() {
  24. const { defaultValue } = this.designerData.attr
  25. return (
  26. <InputNumber
  27. defaultValue={defaultValue}
  28. formatter={(value) => `¥ ${value}`.replace(/\B(?=(\d{3})+(?!\d))/g, ',')}
  29. parser={(value) => value.replace(/\$\s?|(,*)/g, '')}
  30. key={this.designerData.key}
  31. />
  32. )
  33. },
  34. },
  35. icon: 'dollar',
  36. order: 600,
  37. }
  38. export const fieldProps = {
  39. dataType: 'number',
  40. key: 1,
  41. attr: {
  42. decimalPrecision: 0,
  43. },
  44. }
  45. export default {
  46. name: 'XmMoneyInput',
  47. components: { sdUglyNumber, ...components },
  48. data() {
  49. return {}
  50. },
  51. methods: {
  52. valueChange() {
  53. this.component.key = this.component.key + 1
  54. },
  55. },
  56. }
  57. </script>
  58. <style module lang="scss">
  59. @use '@/common/design' as *;
  60. </style>