guarantee.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="">
  3. <view class="data-from" v-for="item in insuranceList">
  4. <en-input label="保险公司" type="text" placeholder="请输入保险公司名称" v-model="item.insurance_name"
  5. v-if="verifyKey('insurance_name')"></en-input>
  6. <en-select label="保险类型" placeholder="请选择保险类型" v-model="item.insurance_type"
  7. v-if="verifyKey('insurance_type')" :local-data="insuranceTypeData"></en-select>
  8. <en-input label="年交费额" type="number" v-model="item.year_money" v-if="verifyKey('year_money')"
  9. placeholder="请输入年交费额" rightText="元"></en-input>
  10. <en-radio label="满足缴费情况" v-model="item.is_fees" v-if="verifyKey('is_fees')"
  11. :radio-data="payData"></en-radio>
  12. <en-date label="保单有效期" v-model="item.validity_date" v-if="verifyKey('validity_date')"
  13. item="选择保单有效期"></en-date>
  14. <en-upload label="上传保单相关图片" v-model="insuranceItem.insurance_img" v-if="verifyKey('insurance_img')"
  15. :imageWidth="180"></en-upload>
  16. <en-input label="备注" v-model="item.remark" v-if="verifyKey('remark')" type="text" placeholder="请输入备注信息"
  17. :noBox="true"></en-input>
  18. </view>
  19. <en-blank message="暂无保单信息,快来添加吧!" v-if="insuranceList.length<=0"></en-blank>
  20. <button class="size-26 r-10 button-color house-button m-t30" hover-class="is-hover"
  21. @click="addItem">+添加保单</button>
  22. </view>
  23. </template>
  24. <script>
  25. import enInput from "@/components/en-from/en-input/en-input.vue"
  26. import EnCity from "@/components/en-from/en-city/en-city.vue";
  27. import EnUpload from "@/components/en-from/en-upload/en-upload.vue";
  28. import EnSelect from "@/components/en-from/en-select/en-select.vue";
  29. import {
  30. getTaskOptions
  31. } from "@/api/task";
  32. import md5 from "js-md5";
  33. import EnDate from "@/components/en-from/en-date/en-date.vue";
  34. import EnBlank from "@/components/en-utils/en-blank/en-blank.vue";
  35. import tools from "@/service/tools";
  36. import {
  37. getSn
  38. } from "@/api/common";
  39. export default {
  40. name: 'property-guarantee',
  41. components: {
  42. EnBlank,
  43. EnDate,
  44. EnSelect,
  45. EnUpload,
  46. EnCity,
  47. enInput
  48. },
  49. props: {
  50. 'showKeys': {
  51. default: []
  52. },
  53. 'value': {
  54. default: {}
  55. },
  56. 'itemKey': {
  57. default: 0
  58. }
  59. },
  60. data() {
  61. return {
  62. payData: [{
  63. 'id': 1,
  64. 'name': '满足'
  65. }, {
  66. 'id': 0,
  67. 'name': '未足'
  68. }],
  69. insuranceTypeData: [],
  70. insuranceItem: {
  71. 'insurance_name': '',
  72. 'insurance_type': '',
  73. 'year_money': '',
  74. 'is_fees': '1',
  75. 'validity_date': '',
  76. 'insurance_img': [],
  77. 'remark': '',
  78. },
  79. insuranceList: []
  80. }
  81. },
  82. watch: {
  83. 'insuranceList': {
  84. handler() {
  85. this.$emit("input", this.insuranceList);
  86. },
  87. deep: true
  88. },
  89. 'value': {
  90. handler() {
  91. if (this.value) {
  92. this.setValue()
  93. }
  94. },
  95. deep: true
  96. },
  97. },
  98. mounted() {
  99. this.getTaskOptions()
  100. this.setValue()
  101. },
  102. methods: {
  103. addItem() {
  104. tools.showLoading()
  105. getSn().then((res) => {
  106. if (res.code === 1) {
  107. this.insuranceList.push({
  108. 'property_type': 3,
  109. 'property_sn': res.data,
  110. 'data': this.insuranceItem
  111. })
  112. this.$emit('onResize')
  113. } else {
  114. tools.error('编号生成失败')
  115. }
  116. tools.hideLoading()
  117. })
  118. },
  119. setSendMd5() {
  120. let str = JSON.stringify(this.value)
  121. this.sendMd5 = md5(JSON.stringify(this.insuranceList))
  122. return md5(str)
  123. },
  124. setValue() {
  125. if (this.value) {
  126. let sendMd5 = this.setSendMd5()
  127. if (sendMd5 !== this.sendMd5) {
  128. this.insuranceList = this.value
  129. }
  130. }
  131. },
  132. verifyKey(field) {
  133. return this.showKeys.indexOf(field) >= 0
  134. },
  135. async getTaskOptions() {
  136. const res = await getTaskOptions({
  137. 'type': 4
  138. })
  139. if (res.code === 1) {
  140. res.data.insuranceType.forEach((val) => {
  141. this.insuranceTypeData.push({
  142. 'text': val.name,
  143. 'value': val.value
  144. })
  145. })
  146. }
  147. },
  148. delItem() {
  149. uni.showModal({
  150. title: '警告',
  151. content: '是否删除当前保单信息!',
  152. success: (res) => {
  153. if (res.confirm) {
  154. this.$emit('delItem', this.itemKey)
  155. }
  156. }
  157. });
  158. }
  159. }
  160. }
  161. </script>
  162. <style>
  163. .house-button {
  164. height: 70rpx;
  165. line-height: 70rpx;
  166. background: #FFFFFF;
  167. border: 1rpx solid #0FB160;
  168. }
  169. </style>