procurementMixins.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. export default {
  2. filters: {
  3. subText(str, index) {
  4. if(str) {
  5. if (str.length <= index) {
  6. return str
  7. }
  8. return str.substring(0, index) + '...'
  9. }
  10. return str
  11. }
  12. },
  13. methods: {
  14. // 校验 只能输入数字和小数点
  15. fpNumInput(e, str) {
  16. const o = e.target
  17. const inputRule = /[^\d.]/g //修改inputRule 的值
  18. this.$nextTick(() => {
  19. this[str].price = o.value.replace(inputRule, '')
  20. if (o.value[0] == '.') {
  21. this[str].price = ''
  22. } else if (o.value[0] == '0' && o.value[1] == '0') {
  23. this[str].price = '0'
  24. }
  25. this[str].price = this[str].price.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.') // 只能输入一个小数点
  26. })
  27. },
  28. // 校验 只能输入数字
  29. NumberInput(e, str) {
  30. const o = e.target
  31. const inputRule = /[^\d]/g //修改inputRule 的值
  32. this.$nextTick(() => {
  33. this[str].number = o.value.replace(inputRule, '')
  34. if (o.value[0] == '0') {
  35. this[str].number = ''
  36. }
  37. })
  38. },
  39. // 状态
  40. procurementStatus(str, res) {
  41. const form = {
  42. isDelFlag: () => res == 1, // 是否删除
  43. isAchieve: () => res == 1, // 是否实现
  44. isAllTab: () => res === 0, // 是否在全部的tab栏下
  45. isSelfParticipationTab: () => res > 0, // 是否在已参与tab栏 是否在自已发布的tab中
  46. isInvolved: () => res === 2, // 是否我创建的
  47. isAdd: () => res === 1, // 是否参与
  48. }
  49. return form[str]()
  50. },
  51. }
  52. }