house.vue 4.6 KB

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