index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <script lang="ts" setup>
  2. import { addServiceReportData, pageServiceReportData } from '@/api/reportService'
  3. import { addReportServiceDataReq, ReportServiceRes } from '@/api/reportService/types'
  4. import { onMounted, ref } from 'vue'
  5. import GridAddress from '@/components/address/gridAddress/index.vue'
  6. import { getQuestionTypeList } from '@/api/questionReqort';
  7. import { QuestionType } from '@/api/questionReqort/types';
  8. const active = ref(0)
  9. const formData = ref<Partial<addReportServiceDataReq>>({})
  10. const rules = ref({
  11. type: [{ required: true, message: '请选择服务类型' }],
  12. title: [{ required: true, message: '请输入服务标题' }],
  13. content: [{ required: true, message: '请输入服务内容' }],
  14. contactPerson: [{ required: true, message: '请输入联系人' }],
  15. contactPhone: [{ required: true, message: '请输入联系电话' }],
  16. area: [{ required: true, message: '请选择服务区域' }],
  17. })
  18. // 服务类型
  19. const range = ref<{text: string, value: string}[]>([])
  20. const submit = async () => {
  21. const { data } = await addServiceReportData({
  22. ...formData.value,
  23. streetCode: addressList.value.selectedOptions[1] ? addressList.value.selectedOptions[1].areaCode : '',
  24. streetName: addressList.value.selectedOptions[1] ? addressList.value.selectedOptions[1].areaName : '',
  25. communityCode: addressList.value.selectedOptions[2] ? addressList.value.selectedOptions[2].areaCode : '',
  26. communityName: addressList.value.selectedOptions[2] ? addressList.value.selectedOptions[2].areaName : '',
  27. grid: addressList.value.selectedOptions[3] ? addressList.value.selectedOptions[3].areaCode : '',
  28. gridName: addressList.value.selectedOptions[3] ? addressList.value.selectedOptions[3].areaName : '',
  29. })
  30. if (data) {
  31. uni.showToast({
  32. title: '上报成功',
  33. icon: 'success',
  34. duration: 1000,
  35. })
  36. formData.value = {}
  37. }
  38. }
  39. /**
  40. * 已上报问题
  41. */
  42. const list = ref<ReportServiceRes[]>([])
  43. const loading = ref(false)
  44. const finished = ref(false)
  45. const pageInfo = ref({
  46. pageNumber: 1,
  47. pageSize: 10,
  48. })
  49. const reportServiceList = async () => {
  50. loading.value = true
  51. const { data } = await pageServiceReportData({
  52. pageNumber: pageInfo.value.pageNumber,
  53. pageSize: pageInfo.value.pageSize,
  54. })
  55. list.value = list.value.concat(data.records)
  56. pageInfo.value.pageNumber++
  57. loading.value = false
  58. finished.value = data.records.length < pageInfo.value.pageSize
  59. if (data.records.length === 0 || !data.records) {
  60. finished.value = true
  61. }
  62. }
  63. /** 跳转服务详情 */
  64. const handleGoDetail = (item: ReportServiceRes) => {
  65. uni.navigateTo({
  66. url: `/subPages/pages/reportServer/detail?id=${item.uuid}`,
  67. })
  68. }
  69. /** 选择地区 */
  70. const addressList = ref([])
  71. const areaShow = ref(false)
  72. const handleAddressFinish = (value) => {
  73. formData.value.area = value.selectedOptions[value.tabIndex].areaName
  74. addressList.value = value
  75. }
  76. const hanleSelectArea = () => {
  77. areaShow.value = true
  78. }
  79. onMounted(async () => {
  80. const {data} = await getQuestionTypeList({
  81. page: 1,
  82. limit: 9999,
  83. category:QuestionType.SERVICE
  84. })
  85. if (data.records) {
  86. range.value = data.records.map(item => {
  87. return {
  88. text: item.typeName,
  89. value: item.typeName
  90. }
  91. })
  92. } else {
  93. range.value = []
  94. }
  95. })
  96. </script>
  97. <template>
  98. <van-tabs v-model:active="active" type="card" class="top-tabs">
  99. <van-tab title="上报服务">
  100. <view class="tab-container">
  101. <uni-forms :modelValue="formData" :rules="rules" label-width="110px" label-align="right">
  102. <uni-forms-item label="服务类型" required name="serviceType">
  103. <uni-data-select v-model="formData.serviceType" :localdata="range"></uni-data-select>
  104. </uni-forms-item>
  105. <!-- 问题标题 -->
  106. <uni-forms-item label="所需服务标题" required name="serviceTitle">
  107. <uni-easyinput v-model="formData.serviceTitle" placeholder="所需服务标题"></uni-easyinput>
  108. </uni-forms-item>
  109. <!-- 问题内容 -->
  110. <uni-forms-item label="所需服务内容" required name="serviceContent">
  111. <uni-easyinput v-model="formData.serviceContent" type="textarea" placeholder="所需服务内容"></uni-easyinput>
  112. </uni-forms-item>
  113. <!-- 问题所在地 -->
  114. <uni-forms-item label="所在区域" required name="area">
  115. <uni-easyinput :value="formData.area" placeholder="所在区域" @focus="hanleSelectArea"></uni-easyinput>
  116. <GridAddress v-model="areaShow" @finish="handleAddressFinish"></GridAddress>
  117. </uni-forms-item>
  118. <!-- 联系人姓名 -->
  119. <uni-forms-item label="联系人姓名" required name="contactPerson">
  120. <uni-easyinput v-model="formData.contactPerson" placeholder="联系人姓名"></uni-easyinput>
  121. </uni-forms-item>
  122. <!-- 联系人电话 -->
  123. <uni-forms-item label="联系人电话" required name="contactPhone">
  124. <uni-easyinput v-model="formData.contactPhone" placeholder="联系人电话"></uni-easyinput>
  125. </uni-forms-item>
  126. </uni-forms>
  127. <van-button type="primary" @click="submit">提交</van-button>
  128. </view>
  129. </van-tab>
  130. <van-tab title="已上报服务">
  131. <view class="tab-container">
  132. <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="reportServiceList">
  133. <view v-for="item in list" :key="item.uuid" class="list-item-style">
  134. <view class="top">
  135. <view class="title">{{ item.serviceTitle }}</view>
  136. <van-button plain hairline size="mini" type="primary" @click="handleGoDetail(item)">查看详情</van-button>
  137. </view>
  138. <view>定位:{{ item.area }}</view>
  139. <view class="flex gap-3">
  140. <view class="type">问题类型</view>
  141. <van-tag color="#CFFECE" text-color="black">{{ item.serviceType }}</van-tag>
  142. </view>
  143. </view>
  144. </van-list>
  145. </view>
  146. </van-tab>
  147. </van-tabs>
  148. </template>
  149. <style lang="scss" scoped>
  150. .top-tabs {
  151. :deep(.van-tabs__nav) {
  152. margin: 0;
  153. }
  154. }
  155. .tab-container {
  156. padding: 20px;
  157. padding-bottom: 30px;
  158. min-height: calc(100vh - var(--van-tabs-card-height));
  159. box-sizing: border-box;
  160. display: flex;
  161. flex-direction: column;
  162. > uni-view:first-child {
  163. flex: 1;
  164. }
  165. }
  166. .list-item-style {
  167. padding: 20px;
  168. margin-bottom: 10px;
  169. background-color: white;
  170. > view {
  171. margin-bottom: 10px;
  172. }
  173. .top {
  174. display: flex;
  175. align-items: center;
  176. .title {
  177. font-size: 20px;
  178. font-weight: bold;
  179. flex: 1;
  180. }
  181. .type {
  182. margin-right: 10px;
  183. }
  184. }
  185. }
  186. </style>