guarantee.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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.data.insurance_name"
  60. v-if="verifyKey('insurance_name')"></en-input>
  61. <en-select label="保险类型" placeholder="请选择保险类型" v-model="item.data.insurance_type"
  62. v-if="verifyKey('insurance_type')" :local-data="insuranceTypeData"></en-select>
  63. <en-input label="年交费额" type="number" v-model="item.data.year_money" v-if="verifyKey('year_money')"
  64. placeholder="请输入年交费额" rightText="元"></en-input>
  65. <en-radio label="满足缴费情况" v-model="item.data.is_fees" v-if="verifyKey('is_fees')"
  66. :list="payData"></en-radio>
  67. <en-date label="保单有效期" v-model="item.data.validity_date" v-if="verifyKey('validity_date')"
  68. item="选择保单有效期"></en-date>
  69. <en-upload label="上传保单相关图片" v-model="item.data.insurance_img" v-if="verifyKey('insurance_img')"
  70. :imageWidth="180"></en-upload>
  71. <en-input label="备注" v-model="item.data.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. 'value': 1,
  123. 'text': '满足'
  124. }, {
  125. 'value': 0,
  126. 'text': '未足'
  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. console.log(this.payData)
  161. },
  162. methods: {
  163. getTypeText(val){
  164. val=val*1
  165. for (const typeKey in this.insuranceTypeData) {
  166. if(val===this.insuranceTypeData[typeKey].value){
  167. return this.insuranceTypeData[typeKey].text
  168. }
  169. }
  170. },
  171. onDeleteInfo(itemKey) {
  172. uni.showModal({
  173. title: '是否删除当前资产信息',
  174. content: '确定删除?',
  175. success: (res) => {
  176. if (res.confirm) {
  177. this.insuranceList.splice(itemKey, 1)
  178. this.editIndex = itemKey-1
  179. }
  180. }
  181. })
  182. },
  183. onEditInfo(index){
  184. this.editIndex = index
  185. },
  186. addItem() {
  187. tools.showLoading()
  188. getSn().then((res) => {
  189. if (res.code === 1) {
  190. this.insuranceList.push({
  191. 'property_type': 3,
  192. 'property_sn': res.data,
  193. 'data': JSON.parse(JSON.stringify(this.insuranceItem))
  194. })
  195. this.editIndex=this.insuranceList.length-1
  196. this.$emit('onResize')
  197. } else {
  198. tools.error('编号生成失败')
  199. }
  200. tools.hideLoading()
  201. })
  202. },
  203. setSendMd5() {
  204. let str = JSON.stringify(this.value)
  205. this.sendMd5 = md5(JSON.stringify(this.insuranceList))
  206. return md5(str)
  207. },
  208. setValue() {
  209. if (this.value) {
  210. let sendMd5 = this.setSendMd5()
  211. if (sendMd5 !== this.sendMd5) {
  212. this.insuranceList = this.value
  213. }
  214. }
  215. },
  216. verifyKey(field) {
  217. return this.showKeys.indexOf(field) >= 0
  218. },
  219. async getTaskOptions() {
  220. const res = await getTaskOptions({
  221. 'type': 4
  222. })
  223. if (res.code === 1) {
  224. res.data.insuranceType.forEach((val) => {
  225. this.insuranceTypeData.push({
  226. 'text': val.name,
  227. 'value': val.value
  228. })
  229. })
  230. }
  231. },
  232. delItem() {
  233. uni.showModal({
  234. title: '警告',
  235. content: '是否删除当前保单信息!',
  236. success: (res) => {
  237. if (res.confirm) {
  238. this.$emit('delItem', this.itemKey)
  239. }
  240. }
  241. });
  242. }
  243. }
  244. }
  245. </script>
  246. <style>
  247. .house-button {
  248. height: 70rpx;
  249. line-height: 70rpx;
  250. background: #FFFFFF;
  251. border: 1rpx solid #0FB160;
  252. }
  253. </style>