guarantee.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="">
  3. <view class="data-from" v-for="(item,index) in insuranceList">
  4. <view class="p-t30" v-if="editIndex!==index">
  5. <view class="sys-from-background-color p-20 r-20">
  6. <view class="row-justify-sb center">
  7. <text class="size-28 sys-weight-600">房产信息({{index+1}})</text>
  8. <view class="row-c sys-background-fff r-100 p-lr40 p-tb10">
  9. <image class="wh-30"
  10. src="/page_task/static/img/information/edit.png"
  11. mode="aspectFill" @click="onEditInfo(index)"></image>
  12. <view class="title-line m-lr20"></view>
  13. <image class="wh-30"
  14. src="/page_task/static/img/information/delete.png"
  15. mode="aspectFill" @click="onDeleteInfo(index)">
  16. </image>
  17. </view>
  18. </view>
  19. <view class="row p-t30" v-if="verifyKey('insurance_name')">
  20. <view class="text-color-666"><text></text>保险公司:</view>
  21. <text class="flex">{{item.data.insurance_name}}</text>
  22. </view>
  23. <view class="row p-t30" v-if="verifyKey('insurance_type')">
  24. <view class="text-color-666"><text></text>保险类型:</view>
  25. <text class="flex">{{getTypeText(item.data.insurance_type,1)}}</text>
  26. </view>
  27. <view class="row p-t30" v-if="verifyKey('year_money')">
  28. <view class="text-color-666"><text></text>年交费额:</view>
  29. <text class="flex">{{item.data.year_money}}</text>
  30. </view>
  31. <view class="row p-t30" v-if="verifyKey('is_fees')">
  32. <view class="text-color-666"><text></text>满足缴费情况:</view>
  33. <text class="flex">{{item.data.is_fees===1?'满足':'未满足'}}</text>
  34. </view>
  35. <view class="row p-t30" v-if="verifyKey('validity_date')">
  36. <view class="text-color-666"><text></text>保单有效期:</view>
  37. <text class="flex">{{item.data.validity_date}}</text>
  38. </view>
  39. <view class="row p-t30" v-if="verifyKey('insurance_img')">
  40. <view class="text-color-666"><text></text>保单相关图片:</view>
  41. <EnImage :img="item.data.insurance_img"></EnImage>
  42. </view>
  43. <view class="row p-t30">
  44. <view class="text-color-666"><text></text>备注:</view>
  45. <text class="flex">{{item.data.remark}}</text>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="p-t30" v-else>
  50. <view class="row-justify-sb center p-b10">
  51. <text class="size-28 sys-weight-600">房产信息({{index+1}})</text>
  52. <view class="row-c sys-background-fff r-100">
  53. <image class="wh-30"
  54. src="/page_task/static/img/information/delete.png"
  55. mode="aspectFill" @click="onDeleteInfo(index)">
  56. </image>
  57. </view>
  58. </view>
  59. <en-input label="保险公司" type="text" placeholder="请输入保险公司名称" v-model="item.insurance_name"
  60. v-if="verifyKey('insurance_name')"></en-input>
  61. <en-select label="保险类型" placeholder="请选择保险类型" v-model="item.insurance_type"
  62. v-if="verifyKey('insurance_type')" :local-data="insuranceTypeData"></en-select>
  63. <en-input label="年交费额" type="number" v-model="item.year_money" v-if="verifyKey('year_money')"
  64. placeholder="请输入年交费额" rightText="元"></en-input>
  65. <en-radio label="满足缴费情况" v-model="item.is_fees" v-if="verifyKey('is_fees')"
  66. :radio-data="payData"></en-radio>
  67. <en-date label="保单有效期" v-model="item.validity_date" v-if="verifyKey('validity_date')"
  68. item="选择保单有效期"></en-date>
  69. <en-upload label="上传保单相关图片" v-model="insuranceItem.insurance_img" v-if="verifyKey('insurance_img')"
  70. :imageWidth="180"></en-upload>
  71. <en-input label="备注" v-model="item.remark" v-if="verifyKey('remark')" type="text" placeholder="请输入备注信息"
  72. :noBox="true"></en-input>
  73. </view>
  74. </view>
  75. <en-blank message="暂无保单信息,快来添加吧!" v-if="insuranceList.length<=0"></en-blank>
  76. <button class="size-26 r-10 button-color house-button m-t30" hover-class="is-hover"
  77. @click="addItem">+添加保单</button>
  78. </view>
  79. </template>
  80. <script>
  81. import enInput from "@/components/en-from/en-input/en-input.vue"
  82. import EnCity from "@/components/en-from/en-city/en-city.vue";
  83. import EnUpload from "@/components/en-from/en-upload/en-upload.vue";
  84. import EnSelect from "@/components/en-from/en-select/en-select.vue";
  85. import {
  86. getTaskOptions
  87. } from "@/api/task";
  88. import md5 from "js-md5";
  89. import EnDate from "@/components/en-from/en-date/en-date.vue";
  90. import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";
  91. import tools from "@/service/tools";
  92. import {
  93. getSn
  94. } from "@/api/common";
  95. import EnImage from "@/components/en-utils/en-image/en-image.vue";
  96. export default {
  97. name: 'property-guarantee',
  98. components: {
  99. EnImage,
  100. EnBlank,
  101. EnDate,
  102. EnSelect,
  103. EnUpload,
  104. EnCity,
  105. enInput
  106. },
  107. props: {
  108. 'showKeys': {
  109. default: []
  110. },
  111. 'value': {
  112. default: {}
  113. },
  114. 'itemKey': {
  115. default: 0
  116. }
  117. },
  118. data() {
  119. return {
  120. editIndex: 0,
  121. payData: [{
  122. 'id': 1,
  123. 'name': '满足'
  124. }, {
  125. 'id': 0,
  126. 'name': '未足'
  127. }],
  128. insuranceTypeData: [],
  129. insuranceItem: {
  130. 'insurance_name': '',
  131. 'insurance_type': '',
  132. 'year_money': '',
  133. 'is_fees': '1',
  134. 'validity_date': '',
  135. 'insurance_img': [],
  136. 'remark': '',
  137. },
  138. insuranceList: []
  139. }
  140. },
  141. watch: {
  142. 'insuranceList': {
  143. handler() {
  144. this.$emit("input", this.insuranceList);
  145. },
  146. deep: true
  147. },
  148. 'value': {
  149. handler() {
  150. if (this.value) {
  151. this.setValue()
  152. }
  153. },
  154. deep: true
  155. },
  156. },
  157. mounted() {
  158. this.getTaskOptions()
  159. this.setValue()
  160. },
  161. methods: {
  162. getTypeText(val){
  163. val=val*1
  164. for (const typeKey in this.insuranceTypeData) {
  165. if(val===this.insuranceTypeData[typeKey].value){
  166. return this.insuranceTypeData[typeKey].text
  167. }
  168. }
  169. },
  170. onDeleteInfo(itemKey) {
  171. uni.showModal({
  172. title: '是否删除当前资产信息',
  173. content: '确定删除?',
  174. success: (res) => {
  175. if (res.confirm) {
  176. this.insuranceList.splice(itemKey, 1)
  177. this.editIndex = itemKey-1
  178. }
  179. }
  180. })
  181. },
  182. onEditInfo(index){
  183. this.editIndex = index
  184. },
  185. addItem() {
  186. tools.showLoading()
  187. getSn().then((res) => {
  188. if (res.code === 1) {
  189. this.insuranceList.push({
  190. 'property_type': 3,
  191. 'property_sn': res.data,
  192. 'data': JSON.parse(JSON.stringify(this.insuranceItem))
  193. })
  194. this.editIndex=this.insuranceList.length-1
  195. this.$emit('onResize')
  196. } else {
  197. tools.error('编号生成失败')
  198. }
  199. tools.hideLoading()
  200. })
  201. },
  202. setSendMd5() {
  203. let str = JSON.stringify(this.value)
  204. this.sendMd5 = md5(JSON.stringify(this.insuranceList))
  205. return md5(str)
  206. },
  207. setValue() {
  208. if (this.value) {
  209. let sendMd5 = this.setSendMd5()
  210. if (sendMd5 !== this.sendMd5) {
  211. this.insuranceList = this.value
  212. }
  213. }
  214. },
  215. verifyKey(field) {
  216. return this.showKeys.indexOf(field) >= 0
  217. },
  218. async getTaskOptions() {
  219. const res = await getTaskOptions({
  220. 'type': 4
  221. })
  222. if (res.code === 1) {
  223. res.data.insuranceType.forEach((val) => {
  224. this.insuranceTypeData.push({
  225. 'text': val.name,
  226. 'value': val.value
  227. })
  228. })
  229. }
  230. },
  231. delItem() {
  232. uni.showModal({
  233. title: '警告',
  234. content: '是否删除当前保单信息!',
  235. success: (res) => {
  236. if (res.confirm) {
  237. this.$emit('delItem', this.itemKey)
  238. }
  239. }
  240. });
  241. }
  242. }
  243. }
  244. </script>
  245. <style>
  246. .house-button {
  247. height: 70rpx;
  248. line-height: 70rpx;
  249. background: #FFFFFF;
  250. border: 1rpx solid #0FB160;
  251. }
  252. </style>