task.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <view v-if="show">
  3. <u-popup :show="show" round="15" mode="center" :closeable="true" :customStyle="{ width: '90%' }" @close="show = false">
  4. <view class="popup">
  5. <u-divider text="上传任务日志" class="mt20 mb0"></u-divider>
  6. <view class="bbg">
  7. <images v-model="item.pic"></images>
  8. </view>
  9. <textarea rows="3" placeholder="请输入说明" v-model="item.contents"></textarea>
  10. <view class="contents"></view>
  11. <button class="btn" @click="add()">立即提交</button>
  12. </view>
  13. </u-popup>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. name: 'task',
  19. data() {
  20. return {
  21. show: false,
  22. item: { pic: [] }
  23. };
  24. },
  25. methods: {
  26. init(taskId) {
  27. this.show = true;
  28. this.item = { pic: [], taskId: taskId };
  29. },
  30. add() {
  31. let rule = [
  32. { name: 'pic', checkType: 'notnull', errorMsg: '请上传照片' },
  33. { name: 'contents', checkType: 'notnull', errorMsg: '请输入说明' }
  34. ];
  35. if (!this.verify.check(this.item, rule)) {
  36. uni.showModal({ content: this.verify.error, showCancel: false });
  37. return false;
  38. }
  39. this.http.request({
  40. url: '/app/task/add',
  41. data: { taskId: this.item.taskId, pic: this.item.pic.toString(), contents: this.item.contents },
  42. method: 'POST',
  43. success: (res) => {
  44. uni.showModal({
  45. title: '提示',
  46. content: '上传成功',
  47. showCancel: false,
  48. success: (res) => {
  49. this.$emit('confirm');
  50. this.show = false;
  51. }
  52. });
  53. }
  54. });
  55. }
  56. }
  57. };
  58. </script>
  59. <style lang="scss">
  60. textarea {
  61. height: 130px;
  62. width: 93%;
  63. padding: 10px;
  64. margin-top: 10px;
  65. background-color: #f1f1f1;
  66. border-radius: 5px;
  67. }
  68. </style>