house.vue 5.0 KB

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