timeLine.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <div>
  3. <div style="display: flex;flex-direction: row;margin-top:10px;margin-bottom: 3px;">
  4. <div v-for="(obj, index1) in list" style="width: 13vw;">
  5. <div style="display: flex;flex-direction: row;width: 13vw">
  6. <div style="height: 40px;">
  7. <!-- {{ index1 }} -->
  8. <img v-if="index1 == carIndex" style="width: 30px;margin-left: 2vw;" src="@/assets/images/icon/小货车.png" />
  9. </div>
  10. <div style="height: 40px;">
  11. <img v-if="index1 + 0.5 == Number(carIndex)" style="width: 30px;margin-left: 7vw;"
  12. src="@/assets/images/icon/小货车.png" />
  13. </div>
  14. </div>
  15. <!-- <div
  16. style="width:13vw;display: flex;flex-direction: row; font-family: 思源黑体;font-size: 12px;font-weight: bold;color:#C0C4CC">
  17. <div v-show="index1 != 0">{{ formatDate(obj.planInTime) }}</div>
  18. <div style="padding-left: 20px;">{{ formatDate(obj.planOutTime) }}</div>
  19. </div> -->
  20. </div>
  21. </div>
  22. <div style="display: flex;flex-direction: row;padding-left: 3%;">
  23. <div v-for="(item, index) in list" style="width: 13vw;">
  24. <div style="width: 13vw;">
  25. <div style="display: flex;flex-direction: row;">
  26. <div class="activitieyContent" v-if="index == 0" style="background: #06D903;">
  27. 起
  28. <div style="position: absolute;top:-26px;color:#C0C4CC;font-weight: bold;width:100px;text-align: left;left:-10px">{{ gettoptxt(item) }}</div>
  29. </div>
  30. <div class="activitieyContent" v-if="index > 0 && index < list.length - 1" style="">
  31. {{ index }}
  32. <div
  33. style="position: absolute;top:-26px;left:-35px;color:#C0C4CC;font-weight:bold;width:100px;display:flex;justify-content: space-evenly;">
  34. <div>{{ gettoptxt(item) }}</div>
  35. <!-- <div>{{ formatDate(item.planOutTime) }}</div> -->
  36. </div>
  37. </div>
  38. <div class="activitieyContent" v-if="index == list.length - 1" style="background: #ad012f;">
  39. 终
  40. <div style="position: absolute;top:-26px;color:#C0C4CC;width:100px;text-align: left;left:-10px;font-weight: bold;">{{ gettoptxt(item) }}</div>
  41. </div>
  42. <div class="line" style="margin: 2px 4px;margin-top:13px;" v-if="index != list.length - 1"></div>
  43. </div>
  44. <div
  45. style="writing-mode:vertical-rl;width: 35px;line-height: 40px;font-family: 思源黑体;text-align: left;font-size: 13px;font-weight: bold;letter-spacing: 4px;margin-top: 5px;">
  46. {{ item.stationName }}
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script lang="ts" setup>
  54. import {getCurrentInstance} from 'vue'
  55. const props = defineProps({
  56. list: {
  57. type: [Object],
  58. default: ""
  59. },
  60. stationInfo: {
  61. type: Object,
  62. default: ""
  63. },
  64. parentdata: {
  65. type: Object,
  66. default: {}
  67. }
  68. });
  69. const internalInstance = getCurrentInstance();
  70. const gettoptxt = (item) => {
  71. var counttext = "";
  72. if (props.parentdata.peoplecount != undefined) {
  73. counttext= (Object.keys(props.parentdata.peoplecount).indexOf(item.stationName) != -1 ? `上:${props.parentdata.peoplecount[item.stationName].totalin} 下:${props.parentdata.peoplecount[item.stationName].totalout}` : ``)
  74. // console.log(item.stationName)
  75. // console.log(props.parentdata.peoplecount)
  76. }
  77. return (item.planInTime != undefined && item.planInTime != null && item.planInTime.indexOf(":")!= -1 ? (formatDate(item.planInTime)+" ") : '') +counttext;
  78. // return counttext;
  79. }
  80. const carIndex = ref(-1)
  81. // setTimeout(() => {
  82. // internalInstance.ctx.$forceUpdate();
  83. // }, 2000);
  84. // watch(() => props.peoplecount, (val) => {
  85. // console.log('发生变化咯',props,val)
  86. // })
  87. const activities = [
  88. {
  89. content: '白下',
  90. endTime: '7:00',
  91. people: '五六七',
  92. done: true,
  93. color: '#06D903',
  94. index: '起点',
  95. rank: 1,
  96. isNow: true
  97. },
  98. {
  99. content: '白下',
  100. people: '吉吉国王',
  101. done: false,
  102. startTime: '8:00',
  103. endTime: '9:00',
  104. index: '站点1',
  105. color: '#409EFF',
  106. rank: 2
  107. },
  108. {
  109. content: '白下',
  110. people: '吉吉国王',
  111. done: false,
  112. startTime: '8:00',
  113. endTime: '9:00',
  114. index: '站点2',
  115. color: '#409EFF',
  116. rank: 3
  117. },
  118. {
  119. content: '白下',
  120. people: '吉吉国王',
  121. done: false,
  122. startTime: '8:00',
  123. endTime: '9:00',
  124. index: '站点2',
  125. color: '#409EFF',
  126. rank: 4
  127. },
  128. {
  129. content: '白下',
  130. people: '吉吉国王',
  131. done: false,
  132. startTime: '8:00',
  133. endTime: '9:00',
  134. index: '站点2',
  135. color: '#409EFF',
  136. rank: 999
  137. },
  138. ]
  139. const formatDate = (value) => {
  140. var detaAtty = value.split(":")
  141. if (detaAtty.length > 1) {
  142. return detaAtty[0] + ":" + detaAtty[1]
  143. } else {
  144. return value
  145. }
  146. }
  147. const getCurrentStation = () => {
  148. console.log(props.stationInfo)
  149. var stationObj = props.stationInfo;
  150. // var stationObj = {
  151. // currentStation: ",大洋里,化蛟,高坂",
  152. // passStations: ",葛藤坪,溪柄,扆山,田坂,后岐,黄兰,大洋里"
  153. // }
  154. var list = props.list
  155. if (stationObj.passStations == 'null') {
  156. carIndex.value = 0
  157. // return index == 0
  158. } else {
  159. var passStationsArry = stationObj.passStations.split(",");
  160. if (stationObj.currentStation == "null" || stationObj.currentStation == "") {
  161. for (var index in list) {
  162. if (passStationsArry[passStationsArry.length - 1] == list[index].stationName) {
  163. if (index == list.length - 1) {
  164. carIndex.value = index
  165. } else {
  166. carIndex.value = Number(index) + 0.5
  167. }
  168. console.log(carIndex.value)
  169. }
  170. }
  171. } else {
  172. if (stationObj.currentStation.split(",").length == 1) {
  173. for (var index in list) {
  174. if (stationObj.currentStation == list[index].stationName) {
  175. carIndex.value = index
  176. }
  177. }
  178. } else {
  179. var currentStations = stationObj.currentStation.split(",");
  180. const arry = currentStations.filter((item) => !passStationsArry.some((obj) => item === obj))
  181. if (arry.length == 1) {
  182. for (var index in list) {
  183. if (arry[0] == list[index].stationName) {
  184. carIndex.value = index
  185. }
  186. }
  187. } else {
  188. lineList:
  189. for (var i in props.list) {
  190. for (var j in arry) {
  191. if (props.list[i].stationName == arry[j]) {
  192. carIndex.value = i
  193. break lineList;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. }
  201. }
  202. onMounted(() => {
  203. getCurrentStation();
  204. });
  205. </script>
  206. <style lang="scss" scoped>
  207. .activitieyContent {
  208. width: 30px;
  209. height: 30px;
  210. opacity: 1;
  211. background-color: #6495ED;
  212. border-radius: 50%;
  213. text-align: center;
  214. line-height: 30px;
  215. font-family: 思源黑体;
  216. font-size: 12px;
  217. color: #ffffff;
  218. margin-left: 2px;
  219. position: relative;
  220. }
  221. .line {
  222. width: 10vw;
  223. height: 3px;
  224. border-radius: 10px;
  225. opacity: 1;
  226. background: #D8D8D8;
  227. }
  228. </style>