InsuranceContractForm.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <template>
  2. <div>
  3. <zj-form-container ref="formRef" :formData="formData" :formRules="formRules">
  4. <zj-form-module title="保险信息" label-width="110px" :formData="formData" :formItems="formItems" :column="3">
  5. </zj-form-module>
  6. </zj-form-container>
  7. <div v-if="type === 0 || type === 1" style="text-align: right">
  8. <el-button size="mini" @click="submit">提交</el-button>
  9. </div>
  10. </div>
  11. </template>
  12. <script>
  13. import { dateFormat } from '@/utils/util'
  14. import { policyOrderDetail, policyOrderUpdate } from '@/api/employerInsurance'
  15. import ImageUpload from '@/components/file-upload'
  16. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  17. export default {
  18. components: {
  19. ImageUpload
  20. },
  21. props: {
  22. type: {
  23. type: Number,
  24. default: null
  25. },
  26. item: {
  27. type: Object,
  28. default: null
  29. }
  30. },
  31. data() {
  32. return {
  33. disabled: this.type === 2,
  34. // 表单数据
  35. formData: {
  36. belongCompany: '',
  37. belongCompanyCode: '',
  38. buyUnit: '',
  39. buyUnitId: '',
  40. classWebsitId: '',
  41. classWebsitName: '',
  42. companyWechatId: '',
  43. companyWechatName: '',
  44. createBy: '',
  45. createTime: '',
  46. endTime: '',
  47. fileUrl: '',
  48. id: '',
  49. isPay: '',
  50. isReceipt: '',
  51. isSend: '',
  52. monthDate: '',
  53. payAmount: 0,
  54. payTime: '',
  55. policyId: '',
  56. policyName: '',
  57. policyNumber: '',
  58. policyOrderStatus: '',
  59. receiptTime: '',
  60. replaceIdcard: '',
  61. replaceName: '',
  62. replaceNumber: '',
  63. replacePhone: '',
  64. sendBatch: '',
  65. sendTime: '',
  66. startTime: '',
  67. transactionId: '',
  68. type: '',
  69. updateBy: '',
  70. updateTime: '',
  71. websitId: '',
  72. websitName: '',
  73. websitUserId: '',
  74. workerIdcard: '',
  75. workerMobile: '',
  76. workerName: '',
  77. workerNumber: ''
  78. },
  79. formRules: {}
  80. }
  81. },
  82. computed: {
  83. formItems() {
  84. return [
  85. {
  86. name: 'el-input',
  87. attributes: { disabled: this.disabled },
  88. formItemAttributes: { label: '保单编号', prop: 'policyNumber', rules: [...required] }
  89. },
  90. {
  91. name: 'el-date-picker',
  92. attributes: { disabled: this.disabled, type: 'date', style: { width: '100%' } },
  93. formItemAttributes: { label: '生效时间', prop: 'startTime', rules: [...required] }
  94. },
  95. {
  96. name: 'el-date-picker',
  97. attributes: { disabled: this.disabled, type: 'date', style: { width: '100%' } },
  98. formItemAttributes: { label: '失效时间', prop: 'endTime', rules: [...required] }
  99. },
  100. {
  101. md: 24,
  102. isShow: true,
  103. name: 'slot-component',
  104. formItemAttributes: {
  105. label: '上传附件',
  106. prop: 'fileUrl',
  107. rules: [...required]
  108. },
  109. render: (h, { props, onInput }) => {
  110. return (
  111. <div>
  112. <ImageUpload fileList={this.formData.fileUrl} limit={1} fileType={['image']} />
  113. <h4 style="color:#ffa700">上传图片</h4>
  114. </div>
  115. )
  116. }
  117. }
  118. ]
  119. }
  120. },
  121. created() {
  122. // 获取详情
  123. if (this.type !== 0) {
  124. policyOrderDetail({
  125. id: this.item.id
  126. }).then(res => {
  127. this.formData = { ...res.data, fileUrl: res.data.fileUrl ? [{ url: res.data.fileUrl }] : [] }
  128. })
  129. }
  130. },
  131. methods: {
  132. submit() {
  133. this.$refs['formRef'].validate(valid => {
  134. if (valid) {
  135. policyOrderUpdate({
  136. ...this.formData,
  137. startTime: dateFormat('YYYY-mm-dd HH:MM:SS', new Date(this.formData.startTime)),
  138. endTime: this.formData?.endTime
  139. ? `${dateFormat('YYYY-mm-dd HH:MM:SS', new Date(this.formData.endTime))?.split(' ')?.[0]} 23:59:59`
  140. : '',
  141. fileUrl: this.formData?.fileUrl?.[0]?.url
  142. }).then(res => {
  143. this.$message({
  144. type: 'success',
  145. message: `保存成功!`
  146. })
  147. this.$emit('success')
  148. })
  149. } else {
  150. console.log('error submit!!')
  151. return false
  152. }
  153. })
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped></style>