layout.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import HistoryRecord from '../components/HistoryRecord'
  2. import ImgLogo from '~/img/logo.png'
  3. import area from '../js/area'
  4. export default {
  5. components: {
  6. HistoryRecord
  7. },
  8. props: {
  9. data: {
  10. required: true,
  11. type: Object
  12. },
  13. loading: {
  14. required: true,
  15. type: Object
  16. },
  17. edataItem: {
  18. type: Object
  19. },
  20. configType: {
  21. type: Object
  22. }
  23. },
  24. data() {
  25. return {
  26. ImgLogo,
  27. areaList: {
  28. province_list: {},
  29. city_list: {},
  30. county_list: {}
  31. },
  32. show: {
  33. area: false,
  34. certificate: false
  35. },
  36. areaCom: {
  37. item: null
  38. },
  39. certificateCom: {
  40. item: {}
  41. },
  42. options: {
  43. certificate: [
  44. { name: '身份证' },
  45. { name: '护照' },
  46. { name: '军官证' },
  47. { name: '其它' }
  48. ]
  49. }
  50. }
  51. },
  52. methods: {
  53. async onSubmit () {
  54. try {
  55. let data = await new Promise((resolve, reject) => {
  56. this.$emit('submit', undefined, resolve, reject)
  57. })
  58. let ref = this.$refs['HistoryRecord']
  59. if (this.data.topic.id === 1 && ref) {
  60. let date = new Date()
  61. data.created = date.toString('yyyy-MM-dd HH:mm:ss')
  62. data.timer = date.getTime()
  63. let k = data.timer.toString(16)
  64. ref.setHistoryData(k, data)
  65. ref.inHistoryData()
  66. }
  67. } catch (err) {
  68. console.log(err)
  69. }
  70. },
  71. // 选择历史记录
  72. onConfirmHistory (topicObj) {
  73. let b = this.data && topicObj && this.data.topic.id === topicObj.topic.id
  74. b && this.data.result.slice(0, 4).forEach((item, index) => {
  75. let eItem = topicObj.result[index]
  76. if (item.title === eItem.title) {
  77. let sp = '<#>'
  78. let regSp = new RegExp(sp)
  79. if (item.type === 'area' && regSp.test(item.val)) {
  80. let arr = eItem.val.split(sp)
  81. let area = arr[0].split(',')
  82. item.area = area.join()
  83. item.val1 = arr[1]
  84. item.val2 = arr[2]
  85. item.val = arr[3]
  86. }
  87. else if (item.type === 'certificate' && regSp.test(item.val)) {
  88. let arr = eItem.val.split(sp)
  89. item.certificate = arr[0]
  90. item.val = arr[1]
  91. } else {
  92. item.val = eItem.val
  93. }
  94. console.log(`success:${item.title} <-匹配结果-> ${item.val}`)
  95. } else {
  96. console.log(`fail:${item.title} <-匹配失败[题目已被修改]-> ${eItem.title}`)
  97. }
  98. })
  99. },
  100. openArea (item) {
  101. this.show.area = !this.show.area
  102. this.$set(this.areaCom, 'item', this.show.area ? item : null)
  103. },
  104. // 确定选择区域
  105. onConfirmArea (result) {
  106. if (result && this.areaCom.item) {
  107. let val = result.map(item => item.name).join()
  108. this.$set(this.areaCom.item, 'area', val)
  109. this.openArea()
  110. }
  111. },
  112. openCertificate (item) {
  113. this.show.certificate = !this.show.certificate
  114. item && this.$set(this.certificateCom, 'item', item)
  115. },
  116. closeCertificate () {
  117. this.$set(this.certificateCom, 'item', null)
  118. },
  119. // 确定选择证件类型
  120. onConfirmCertificate(result) {
  121. if (result && this.certificateCom.item) {
  122. let val = result.name
  123. this.$set(this.certificateCom.item, 'certificate', val)
  124. setTimeout(() => this.openCertificate(), 300)
  125. }
  126. },
  127. inArea () {
  128. let province_list = area['86']
  129. let city_list = {}
  130. let county_list = {}
  131. Object.keys(province_list).forEach(code => {
  132. city_list = { ...area[code], ...city_list }
  133. })
  134. Object.keys(city_list).forEach(code => {
  135. county_list = { ...area[code], ...county_list }
  136. })
  137. this.$set(this, 'areaList', { province_list, city_list, county_list })
  138. }
  139. },
  140. created () {
  141. this.inArea()
  142. }
  143. }