nodes.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <view class="node" :class="prefix ? 'child' : ''"
  3. :hover-class="!prefix && item.child.length ? '' : 'navigator-hover'" v-for="item in nodes"
  4. :key="item.sa_workorder_nodeid" @click.stop="toWork(item)">
  5. <view class="number">
  6. {{ (prefix ? prefix + '-' : '') + item.rowindex }}.
  7. </view>
  8. <view style="flex: 1;">
  9. <view class="label">
  10. {{ item.workpresetjson.workname }}
  11. </view>
  12. <node v-if="!prefix && item.child.length" :nodes="item.child"
  13. :prefix="(prefix ? prefix + '-' : '') + item.rowindex" />
  14. <block v-else>
  15. <view class="images" v-if="item.attinfos.length">
  16. <view class="image" hover-class="navigator-hover" v-for="(img, index) in item.attinfos"
  17. :key="img.attachmentid" @click.stop="preview(index, item.attinfos)">
  18. <up-image :show-loading="true" :src="$Http.getSpecifiedImage(img)" width="80px" height="80px" />
  19. </view>
  20. </view>
  21. <view class="stuta">
  22. <view class="tag" style="background-color: #E64D55;" v-if="item.status == '0'">未完成</view>
  23. <view class="tag" style="background-color: #06A971;" v-if="item.status == '1'">已完成</view>
  24. <view class="tag" style="background-color: #70B603;" v-if="item.status == '2'">进行中</view>
  25. </view>
  26. </block>
  27. </view>
  28. </view>
  29. </template>
  30. <script setup>
  31. import { getCurrentInstance } from 'vue';
  32. const { $Http } = getCurrentInstance().proxy;
  33. import { defineProps } from 'vue';
  34. import node from "./nodes.vue";
  35. const props = defineProps({
  36. nodes: {
  37. type: Array
  38. },
  39. prefix: {
  40. type: [String, Number],
  41. }
  42. });
  43. function toWork(item) {
  44. try {
  45. if (item.child.length) return;
  46. } catch (error) {
  47. item.child = [];
  48. }
  49. if (item.child.length) return;
  50. item.title = (props.prefix ? props.prefix + '-' : '') + item.rowindex + '. ' + item.workpresetjson.workname;
  51. $Http.data = item;
  52. uni.navigateTo({
  53. url: '/pages/workOrder/work',
  54. })
  55. }
  56. function preview(index, imgs) {
  57. wx.previewImage({
  58. urls: imgs.filter(v => isImage(v.postfix)).map(item => item.url),
  59. current: imgs[index].url,
  60. })
  61. }
  62. function isImage(postfix) {
  63. const imageTypes = ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp'];
  64. return imageTypes.includes(postfix.toLowerCase());
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .node {
  69. display: flex;
  70. padding: 10rpx;
  71. margin-top: 10rpx;
  72. font-family: Microsoft YaHei, Microsoft YaHei;
  73. border-radius: 8rpx;
  74. .label,
  75. .number {
  76. font-size: 32rpx;
  77. }
  78. .number {
  79. margin-right: 10rpx;
  80. }
  81. .stuta {
  82. margin-top: 20rpx;
  83. display: flex;
  84. .tag {
  85. border-radius: 8rpx;
  86. padding: 8rpx 12rpx;
  87. font-size: 24rpx;
  88. color: #fff;
  89. }
  90. }
  91. .images {
  92. display: flex;
  93. flex-wrap: wrap;
  94. .image {
  95. margin-top: 20rpx;
  96. margin-right: 20rpx;
  97. }
  98. }
  99. }
  100. .child {
  101. margin-left: -55rpx;
  102. width: calc(100% + 65rpx);
  103. transform: scale(0.9);
  104. .label,
  105. .number {
  106. color: #333;
  107. }
  108. }
  109. </style>