house.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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.data.property_owner" v-if="verifyKey('property_owner')"></en-input>
  5. <en-input label="房产证号" v-model="item.data.deed_num" v-if="verifyKey('deed_num')" type="text" placeholder="请输入房产证号"></en-input>
  6. <en-city label="房产城市" v-model="item.data.house_city" v-if="verifyKey('house_city')" placeholder="请选择省、市、区"></en-city>
  7. <en-input label="房产地址" v-model="item.data.house_address" v-if="verifyKey('house_address')" type="text" placeholder="请输入房产详细地址"></en-input>
  8. <en-select label="房屋用途" v-model="item.data.house_use" v-if="verifyKey('house_use')" placeholder="请选择房屋用途" :local-data="houseTypeData" ></en-select>
  9. <en-date label="建成年份" v-model="item.data.build_date" v-if="verifyKey('build_date')" placeholder="选择房屋建成年份"></en-date>
  10. <en-radio label="材料费" v-model="item.data.is_pay" v-if="verifyKey('is_pay')" :radio-data="payData"></en-radio>
  11. <en-input label="建筑面积" v-model="item.data.covered_area" v-if="verifyKey('covered_area')" type="digit" placeholder="请输入建筑面积" rightText="㎡"></en-input>
  12. <en-upload label="上传房产证件" v-model="item.data.certificate_img" v-if="verifyKey('certificate_img')" :imageWidth="180"></en-upload>
  13. <en-upload label="上传房产关联图片" v-model="item.data.property" v-if="verifyKey('property')" :imageWidth="180"></en-upload>
  14. <en-input label="备注" v-model="item.data.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. import tools from "@/service/tools";
  31. import {getSn} from "@/api/common";
  32. export default {
  33. name:'property-house',
  34. components: {
  35. EnBlank,
  36. EnDate,
  37. EnSelect,
  38. EnUpload,
  39. EnCity,
  40. enInput
  41. },
  42. props: {
  43. 'showKeys': {
  44. default: []
  45. },
  46. 'value': {
  47. default: {
  48. }
  49. },
  50. 'itemKey': {
  51. default: 0
  52. }
  53. },
  54. data() {
  55. return {
  56. payData:[{'id':1,'name':'已支付'},{'id':2,'name':'未支付'}],
  57. houseTypeData:[],
  58. houseItem:{
  59. 'property_owner':'',
  60. 'deed_num':'',
  61. 'house_city':'',
  62. 'house_address':'',
  63. 'house_use':'',
  64. 'build_date':'',
  65. 'is_pay':'',
  66. 'covered_area':'',
  67. 'certificate_img':[],
  68. 'property':[],
  69. 'remark':'',
  70. },
  71. houseList:[]
  72. }
  73. },
  74. watch: {
  75. 'houseList': {
  76. handler() {
  77. this.$emit("input", this.houseList);
  78. },
  79. deep: true
  80. },
  81. 'value': {
  82. handler() {
  83. if (this.value) {
  84. this.setValue()
  85. }
  86. },
  87. deep: true
  88. },
  89. },
  90. mounted() {
  91. this.getTaskOptions()
  92. this.setValue()
  93. },
  94. methods: {
  95. addHouse(){
  96. tools.showLoading()
  97. getSn().then((res)=>{
  98. if(res.code===1){
  99. this.houseList.push({'property_type':1,'property_sn':res.data,'data':this.houseItem})
  100. }else {
  101. tools.error('编号生成失败')
  102. }
  103. tools.hideLoading()
  104. })
  105. },
  106. setSendMd5() {
  107. let str = JSON.stringify(this.value)
  108. this.sendMd5=md5(JSON.stringify(this.houseList))
  109. return md5(str)
  110. },
  111. setValue(){
  112. if (this.value) {
  113. let sendMd5 = this.setSendMd5()
  114. if (sendMd5 !== this.sendMd5) {
  115. this.houseList=this.value
  116. }
  117. }
  118. },
  119. verifyKey(field) {
  120. return this.showKeys.indexOf(field) >= 0
  121. },
  122. async getTaskOptions() {
  123. const res = await getTaskOptions({'type':3})
  124. if (res.code === 1) {
  125. res.data.houseTypeArr.forEach((val)=>{
  126. this.houseTypeData.push({'text':val.name,'value':val.value})
  127. })
  128. }
  129. },
  130. delItem(){
  131. uni.showModal({
  132. title: '警告',
  133. content: '是否删除当前资产信息!',
  134. success: (res) => {
  135. if (res.confirm) {
  136. this.$emit('delItem',this.itemKey)
  137. }
  138. }
  139. });
  140. }
  141. }
  142. }
  143. </script>
  144. <style>
  145. .house-button {
  146. height: 70rpx;
  147. line-height: 70rpx;
  148. background: #FFFFFF;
  149. border: 1rpx solid #0FB160;
  150. }
  151. </style>