house.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="">
  3. <view class="data-from" v-for="item in houseList">
  4. <en-input label="产权人" type="text" placeholder="请输入产权人" v-model="item.property_owner" v-if="verifyKey('property_owner')"></en-input>
  5. <en-input label="房产证号" v-model="item.deed_num" v-if="verifyKey('deed_num')" type="text" placeholder="请输入房产证号"></en-input>
  6. <en-city label="房产城市" v-model="item.house_city" v-if="verifyKey('house_city')" placeholder="请选择省、市、区"></en-city>
  7. <en-input label="房产地址" v-model="item.house_address" v-if="verifyKey('house_address')" type="text" placeholder="请输入房产详细地址"></en-input>
  8. <en-select label="房屋用途" v-model="item.house_use" v-if="verifyKey('house_use')" placeholder="请选择房屋用途" :local-data="houseTypeData" ></en-select>
  9. <en-date label="建成年份" v-model="item.build_date" v-if="verifyKey('build_date')" placeholder="选择房屋建成年份"></en-date>
  10. <en-radio label="材料费" v-model="item.is_pay" v-if="verifyKey('is_pay')" :radio-data="payData"></en-radio>
  11. <en-input label="建筑面积" v-model="item.covered_area" v-if="verifyKey('covered_area')" type="digit" placeholder="请输入建筑面积" rightText="㎡"></en-input>
  12. <en-upload label="上传房产证件" v-model="item.certificate_img" v-if="verifyKey('certificate_img')" :imageWidth="180"></en-upload>
  13. <en-upload label="上传房产关联图片" v-model="item.property" v-if="verifyKey('property')" :imageWidth="180"></en-upload>
  14. <en-input label="备注" v-model="item.remark" v-if="verifyKey('remark')" type="text" placeholder="请输入备注信息" :noBox="true"></en-input>
  15. </view>
  16. <en-blank message="暂无房产信息,快来添加吧!" v-if="houseList.length<=0"></en-blank>
  17. <button class="size-26 r-10 button-color house-button m-t30" hover-class="is-hover"
  18. @click="addHouse">+添加房产</button>
  19. </view>
  20. </template>
  21. <script>
  22. import enInput from "@/components/en-from/en-input/en-input.vue"
  23. import EnCity from "@/components/en-from/en-city/en-city.vue";
  24. import EnUpload from "@/components/en-from/en-upload/en-upload.vue";
  25. import EnSelect from "@/components/en-from/en-select/en-select.vue";
  26. import {getTaskOptions} from "@/api/task";
  27. import md5 from "js-md5";
  28. import EnDate from "@/components/en-from/en-date/en-date.vue";
  29. import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";
  30. export default {
  31. components: {
  32. EnBlank,
  33. EnDate,
  34. EnSelect,
  35. EnUpload,
  36. EnCity,
  37. enInput
  38. },
  39. props: {
  40. 'showKeys': {
  41. default: []
  42. },
  43. 'value': {
  44. default: {
  45. }
  46. },
  47. 'itemKey': {
  48. default: 0
  49. }
  50. },
  51. data() {
  52. return {
  53. payData:[{'id':1,'name':'已支付'},{'id':2,'name':'未支付'}],
  54. houseTypeData:[],
  55. houseItem:{
  56. 'property_owner':'',
  57. 'deed_num':'',
  58. 'house_city':'',
  59. 'house_address':'',
  60. 'house_use':'',
  61. 'build_date':'',
  62. 'is_pay':'',
  63. 'covered_area':'',
  64. 'certificate_img':[],
  65. 'property':[],
  66. 'remark':'',
  67. },
  68. houseList:[]
  69. }
  70. },
  71. watch: {
  72. 'houseList': {
  73. handler() {
  74. this.$emit("input", this.houseList);
  75. },
  76. deep: true
  77. },
  78. 'value': {
  79. handler() {
  80. console.log('houseItem:', this.value)
  81. if (this.value) {
  82. this.setValue()
  83. }
  84. },
  85. deep: true
  86. },
  87. },
  88. mounted() {
  89. this.getTaskOptions()
  90. this.setValue()
  91. },
  92. methods: {
  93. addHouse(){
  94. this.houseList.push(this.houseItem)
  95. },
  96. setSendMd5() {
  97. let str = JSON.stringify(this.value)
  98. this.sendMd5=md5(JSON.stringify(this.houseList))
  99. return md5(str)
  100. },
  101. setValue(){
  102. if (this.value) {
  103. let sendMd5 = this.setSendMd5()
  104. if (sendMd5 !== this.sendMd5) {
  105. this.houseList=this.value
  106. }
  107. }
  108. },
  109. verifyKey(field) {
  110. return this.showKeys.indexOf(field) >= 0
  111. },
  112. async getTaskOptions() {
  113. const res = await getTaskOptions({'type':3})
  114. if (res.code === 1) {
  115. res.data.houseTypeArr.forEach((val)=>{
  116. this.houseTypeData.push({'text':val.name,'value':val.value})
  117. })
  118. }
  119. },
  120. delItem(){
  121. uni.showModal({
  122. title: '警告',
  123. content: '是否删除当前资产信息!',
  124. success: (res) => {
  125. if (res.confirm) {
  126. this.$emit('delItem',this.itemKey)
  127. }
  128. }
  129. });
  130. }
  131. }
  132. }
  133. </script>
  134. <style>
  135. .house-button {
  136. height: 70rpx;
  137. line-height: 70rpx;
  138. background: #FFFFFF;
  139. border: 1rpx solid #0FB160;
  140. }
  141. </style>