You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

224 lines
8.2 KiB

1 month ago
  1. <template>
  2. <view class="">
  3. <view class="personal-pet-health-info">
  4. <view class="personal-pet-info-title border-bottom">
  5. 宠物健康情况
  6. </view>
  7. <u--form labelPosition="left" :model="petHealthInfo" ref="uForm">
  8. <u-form-item required label="疫苗" prop="petHealthInfo.vaccineStatus" labelWidth="80" borderBottom
  9. @click="showVaccine = true">
  10. <u--input v-model="petHealthInfo.vaccineStatus" disabled disabledColor="#ffffff" placeholder="请选择"
  11. placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input>
  12. <u-icon slot="right" name="arrow-right" color="#AAA"></u-icon>
  13. </u-form-item>
  14. <u-form-item required label="驱虫" prop="petHealthInfo.dewormingStatus" labelWidth="80" borderBottom
  15. @click="showExpelling = true">
  16. <u--input v-model="petHealthInfo.dewormingStatus" disabled disabledColor="#ffffff" placeholder="请选择"
  17. placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input>
  18. <u-icon slot="right" name="arrow-right" color="#AAA"></u-icon>
  19. </u-form-item>
  20. <u-form-item label="绝育" prop="petHealthInfo.sterilization" labelWidth="80" borderBottom
  21. @click="showSterilization = true" ref="item1">
  22. <u--input v-model="petHealthInfo.sterilization" disabled disabledColor="#ffffff" placeholder="请选择"
  23. placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input>
  24. <u-icon slot="right" name="arrow-right" color="#AAA"></u-icon>
  25. </u-form-item>
  26. <u-form-item v-if="petType=='dog' || petType=='狗狗' " label="狗证" prop="petHealthInfo.doglicenseStatus" labelWidth="80" borderBottom
  27. @click="showDog = true" ref="item1">
  28. <u--input v-model="petHealthInfo.doglicenseStatus" disabled disabledColor="#ffffff" placeholder="请选择"
  29. placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input>
  30. <u-icon slot="right" name="arrow-right" color="#AAA"></u-icon>
  31. </u-form-item>
  32. <view class="dog-tips" v-if="petType=='dog' || petType=='狗狗'">
  33. <u-icon name="info-circle" color="#A94F20" size="12"></u-icon>
  34. <view style="margin-left: 3px;">
  35. 未办理养犬许可证且需要外出遛狗, 犬只存在被相关单位收缴
  36. 甚至捕杀的可能请您遵守当地养犬规范合法文明养犬具体
  37. 请您查看当地养犬条例
  38. </view>
  39. </view>
  40. <u-form-item required label="健康" prop="petHealthInfo.healths" labelWidth="80"
  41. @click="healthsSelect">
  42. <u--input disabled disabledColor="#ffffff" placeholder="请选择(多选)" :value="petHealthInfo.healthStatus && petHealthInfo.healthStatus.join(',')"
  43. placeholderStyle="text-align:right;color:#AAA" border="none" inputAlign="right"></u--input>
  44. <view slot="right">
  45. <u-icon v-if="showHealths" name="arrow-down" color="#AAA"></u-icon>
  46. <u-icon v-else name="arrow-right" color="#AAA" ></u-icon>
  47. </view>
  48. </u-form-item>
  49. </u--form>
  50. </view>
  51. <view class="health-select" v-show="showHealths">
  52. <view style="padding: 10px;height: 85%;">
  53. <u-checkbox-group v-model="petHealthInfo.healthStatus" @change="checkboxChange" placement="column" activeColor="#ffbf60">
  54. <u-checkbox :customStyle="{marginBottom: '8px'}" v-for="(item, index) in healthData"
  55. :key="index" :label="item" :name="item">
  56. </u-checkbox>
  57. </u-checkbox-group>
  58. <u--input placeholder="请输入其他健康特征"
  59. :disabled="!(petHealthInfo.healthStatus && petHealthInfo.healthStatus.includes('其他'))"
  60. border="surround" maxlength='20'
  61. :customStyle="{backgroundColor: '#fff'}"
  62. @change=updatePetHealthInfo()
  63. v-model="petHealthInfo.remark"></u--input>
  64. </view>
  65. </view>
  66. <u-picker :show="showVaccine" :showToolbar='false' :columns="vaccineActions" @cancel="showVaccine = false" :immediateChange="true"
  67. :defaultIndex="defaultVaccine"
  68. @confirm="vaccineSelect"></u-picker>
  69. <u-picker :show="showExpelling" :showToolbar='false' :columns="expellingActions" @cancel="showExpelling = false" :immediateChange="true"
  70. :defaultIndex="defaultDeworming"
  71. @confirm="expellingSelect"></u-picker>
  72. <u-picker :show="showSterilization" :showToolbar='false' :columns="sterilizationActions" @cancel="showSterilization = false" :immediateChange="true"
  73. :defaultIndex="defaultSterilization"
  74. @confirm="sterilizationSelect"></u-picker>
  75. <u-picker :show="showDog" :showToolbar='false' :columns="dogActions" @cancel="showDog = false" :immediateChange="true"
  76. :defaultIndex="defaultDoglicense"
  77. @confirm="dogSelect"></u-picker>
  78. </view>
  79. </template>
  80. <script>
  81. import { getDictList } from "@/api/system/user"
  82. export default {
  83. data() {
  84. return {
  85. showVaccine: false,
  86. showExpelling: false,
  87. showSterilization: false,
  88. showDog:false,
  89. showHealths: false,
  90. vaccineActions: [[ '每年都免疫','有免疫史','未免疫']],
  91. expellingActions: [['未驱虫', '定期驱虫', '有驱虫史']],
  92. sterilizationActions: [['已绝育','未绝育']],
  93. dogActions: [[ '是','否']],
  94. healthData: [],
  95. tempHealths: []
  96. }
  97. },
  98. props: {
  99. petType: {
  100. type: String,
  101. default: 'dog'
  102. },
  103. petHealthInfo:{
  104. type:Object,
  105. default:()=>({
  106. vaccineStatus: '',
  107. dewormingStatus: '',
  108. sterilization: '',
  109. doglicenseStatus:'',
  110. healthStatus: [],
  111. remark:''
  112. })
  113. },
  114. defaultVaccine:0,
  115. defaultDeworming:0,
  116. defaultSterilization:0,
  117. defaultDoglicense:0
  118. },
  119. mounted() {
  120. this.getHealthDataList()
  121. this.defaultVaccine=[].push(this.vaccineActions[0].indexOf(this.petHealthInfo.vaccineStatus))
  122. this.defaultDeworming=[].push(this.expellingActions[0].indexOf(this.petHealthInfo.dewormingStatus))
  123. this.defaultSterilization=[].push(this.sterilizationActions[0].indexOf(this.petHealthInfo.sterilization))
  124. this.defaultDoglicense=[].push(this.dogActions[0].indexOf(this.petHealthInfo.doglicenseStatus))
  125. },
  126. methods: {
  127. // getVaccineList(){
  128. // getDictList('pet_vaccine_status').then(res=>{
  129. // if (res.code == 200) {
  130. // let vaccineType = res.data.map(e=>e.dictLabel)
  131. // this.vaccineActions=[vaccineType]
  132. // } else {
  133. // this.$modal.showToast('获取免疫类型失败')
  134. // }
  135. // })
  136. // },
  137. // getDewormingList(){
  138. // getDictList('pet_deworming_status').then(res=>{
  139. // if (res.code == 200) {
  140. // let dewormingType = res.data.map(e=>e.dictLabel)
  141. // this.expellingActions=[dewormingType]
  142. // } else {
  143. // this.$modal.showToast('获取驱虫情况失败')
  144. // }
  145. // })
  146. // },
  147. getHealthDataList(){
  148. getDictList('pet_health_status').then(res=>{
  149. if (res.code == 200) {
  150. this.healthData = res.data.map(e=>e.dictLabel)
  151. } else {
  152. this.$modal.showToast('获取健康类型失败')
  153. }
  154. })
  155. },
  156. vaccineSelect(e) {
  157. this.petHealthInfo.vaccineStatus = e.value[0];
  158. this.showVaccine = false;
  159. this.updatePetHealthInfo();
  160. },
  161. expellingSelect(e) {
  162. this.petHealthInfo.dewormingStatus = e.value[0];
  163. this.showExpelling = false;
  164. this.updatePetHealthInfo();
  165. },
  166. sterilizationSelect(e) {
  167. this.petHealthInfo.sterilization = e.value[0];
  168. this.showSterilization = false;
  169. this.updatePetHealthInfo();
  170. },
  171. dogSelect(e){
  172. this.petHealthInfo.doglicenseStatus = e.value[0];
  173. this.showDog = false;
  174. this.updatePetHealthInfo();
  175. },
  176. healthsSelect() {
  177. this.showHealths = !this.showHealths;
  178. this.$nextTick(() => {
  179. uni.pageScrollTo({
  180. scrollTop: 2000,
  181. duration: 300
  182. })
  183. })
  184. },
  185. checkboxChange(n) {
  186. console.log('change', n);
  187. this.updatePetHealthInfo();
  188. },
  189. changeRemark(e){
  190. debugger;
  191. this.petHealthInfo.remark=e
  192. this.updatePetHealthInfo()
  193. },
  194. updatePetHealthInfo() {
  195. // 触发 update 事件,将修改后的 petHealthInfo 对象发送给父组件
  196. this.$emit('update:petHealthInfo', this.petHealthInfo);
  197. }
  198. }
  199. }
  200. </script>
  201. <style lang="scss">
  202. .personal-pet-health-info{
  203. background-color: #fff;
  204. padding: 10px 20px 0 20px;
  205. margin-top: 10px;
  206. }
  207. .health-select{
  208. background-color: #fffcf2;
  209. padding: 10px 20px;
  210. }
  211. .dog-tips{
  212. color: #A94F20;
  213. font-size: 12px;
  214. display: flex;
  215. align-items: baseline;
  216. margin-top: 5px;
  217. }
  218. </style>