house.vue 4.9 KB

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