procurementMixins.js 2.1 KB

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