index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <ay-container>
  3. <div class="s-fz">
  4. <div class="section">所属物流车</div>
  5. <div class="chunk center justify-between">
  6. <div>
  7. <div class="font-bold mb-spac">{{ func.convert.nullView(data.truckInfo.carNumber) }}</div>
  8. <div>所属物流:{{ func.convert.nullView(data.truckInfo.orgName) }}</div>
  9. </div>
  10. <div class="p-color" v-if="data.truckInfo.truckId" @click="methods.detail">车辆详情</div>
  11. </div>
  12. <div class="center justify-between">
  13. <div class="section">承运协作车</div>
  14. <div class="p-color" @click="methods.save">添加爱车</div>
  15. </div>
  16. <div>
  17. <div
  18. class="chunk center justify-between items-end"
  19. v-for="(t, i) in data.truckInfo.personTruckList"
  20. :key="i"
  21. >
  22. <div>
  23. <div class="font-bold mb-spac">{{ func.convert.nullView(t.carNumber) }}</div>
  24. <div>协作物流:{{ func.convert.nullView(t.orgName) }}</div>
  25. </div>
  26. <div class="p-color bs-fz">
  27. <uni-icons
  28. type="compose"
  29. color=""
  30. size="none"
  31. class="mr-spacd4"
  32. @click="methods.save(t)"
  33. />
  34. <uni-icons type="trash-filled" color="" size="none" @click="methods.del(t)" />
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. <ayb-carNumber ref="carNumber" />
  40. </ay-container>
  41. </template>
  42. <script lang="ts" setup>
  43. const carNumber = ref()
  44. const data = reactive({
  45. truckInfo: {} as 司机车辆管理信息,
  46. })
  47. const methods = {
  48. getTruckInfo() {
  49. webapi.strategy.get_truck_info().then((res) => {
  50. data.truckInfo = res
  51. })
  52. },
  53. detail() {
  54. ay.goPage(config.pages.truckInfo_detail, { params: { truckId: data.truckInfo.truckId } })
  55. },
  56. del(ti: PersonDriver对象 = {}) {
  57. func.native
  58. .showModal({
  59. title: '确认删除',
  60. content: `确定要删除【${ti.carNumber}】车辆信息吗?`,
  61. showCancel: true,
  62. })
  63. .then((res) => {
  64. if (res.confirm) {
  65. webapi.strategy.unbind_person_truck({ id: ti.id }).then((res) => {
  66. if (res) {
  67. func.native.showToast('删除成功')
  68. methods.getTruckInfo()
  69. }
  70. })
  71. }
  72. })
  73. },
  74. save(ti: PersonDriver对象 = {}) {
  75. if (!ti.id && data.truckInfo.personTruckList.length >= 3) {
  76. func.native.showToast('承运协作车最多添加3辆')
  77. return
  78. }
  79. carNumber.value.open(ti.carNumber).then((cn) => {
  80. webapi.strategy
  81. .bind_person_truck<{ userId: string }>({
  82. userId: store.user.userInfo.user_id,
  83. newCarNumber: cn,
  84. id: ti.id,
  85. })
  86. .then((res) => {
  87. if (res) {
  88. if (ti.id) {
  89. func.native.showToast('修改成功')
  90. } else {
  91. func.native.showToast('添加成功')
  92. }
  93. methods.getTruckInfo()
  94. }
  95. })
  96. })
  97. },
  98. }
  99. ay.entrance((args) => {
  100. methods.getTruckInfo()
  101. })
  102. </script>
  103. <style lang="scss" scoped></style>