index.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. define([
  2. 'text!./index.html',
  3. 'css!./index.css'
  4. ], function(html) {
  5. return {
  6. filters: {
  7. rateCovert: function (value) {
  8. return ['非常差', '差', '一般', '好', '非常好'][value - 1];
  9. }
  10. },
  11. props: {
  12. dialogShow: {
  13. type: Boolean,
  14. default: false
  15. },
  16. rateValue: {
  17. type: Number,
  18. default: 5
  19. },
  20. imageList: {
  21. type: Array,
  22. default: function () {
  23. return [];
  24. }
  25. }
  26. },
  27. data: function () {
  28. return {
  29. textHeight: '',
  30. textValue: ''
  31. };
  32. },
  33. watch: {
  34. textValue: {
  35. handler: function () {
  36. this.$nextTick(this.textResize);
  37. },
  38. immediate: true
  39. }
  40. },
  41. methods: {
  42. textResize: function () {
  43. this.textHeight = 'auto';
  44. this.$nextTick(function () {
  45. this.textHeight = this.$refs.textarea.scrollHeight + 'px';
  46. });
  47. },
  48. rateChange: function (value) {
  49. this.$emit('rate-change', value);
  50. },
  51. imageUpload: function (event) {
  52. var files = event.target.files;
  53. if (!files.length) {
  54. return;
  55. }
  56. this.$emit('image-upload', files[0]);
  57. },
  58. imageDelete: function (index) {
  59. this.$emit('image-delete', index);
  60. },
  61. evaluateSubmit: function () {
  62. this.$emit('evaluate-submit', this.textValue);
  63. }
  64. },
  65. template: html
  66. };
  67. });