| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- import HistoryRecord from '../components/HistoryRecord'
- import ImgLogo from '~/img/logo.png'
- import area from '../js/area'
- export default {
- components: {
- HistoryRecord
- },
- props: {
- data: {
- required: true,
- type: Object
- },
- loading: {
- required: true,
- type: Object
- },
- edataItem: {
- type: Object
- },
- configType: {
- type: Object
- }
- },
- data() {
- return {
- ImgLogo,
- areaList: {
- province_list: {},
- city_list: {},
- county_list: {}
- },
- show: {
- area: false,
- certificate: false
- },
- areaCom: {
- item: null
- },
- certificateCom: {
- item: {}
- },
- options: {
- certificate: [
- { name: '身份证' },
- { name: '护照' },
- { name: '军官证' },
- { name: '其它' }
- ]
- }
- }
- },
- methods: {
- async onSubmit () {
- try {
- let data = await new Promise((resolve, reject) => {
- this.$emit('submit', undefined, resolve, reject)
- })
- let ref = this.$refs['HistoryRecord']
- if (this.data.topic.id === 1 && ref) {
- let date = new Date()
- data.created = date.toString('yyyy-MM-dd HH:mm:ss')
- data.timer = date.getTime()
- let k = data.timer.toString(16)
- ref.setHistoryData(k, data)
- ref.inHistoryData()
- }
- } catch (err) {
- console.log(err)
- }
- },
- // 选择历史记录
- onConfirmHistory (topicObj) {
- let b = this.data && topicObj && this.data.topic.id === topicObj.topic.id
- b && this.data.result.slice(0, 4).forEach((item, index) => {
- let eItem = topicObj.result[index]
- if (item.title === eItem.title) {
- let sp = '<#>'
- let regSp = new RegExp(sp)
- if (item.type === 'area' && regSp.test(item.val)) {
- let arr = eItem.val.split(sp)
- let area = arr[0].split(',')
- item.area = area.join()
- item.val1 = arr[1]
- item.val2 = arr[2]
- item.val = arr[3]
- }
- else if (item.type === 'certificate' && regSp.test(item.val)) {
- let arr = eItem.val.split(sp)
- item.certificate = arr[0]
- item.val = arr[1]
- } else {
- item.val = eItem.val
- }
- console.log(`success:${item.title} <-匹配结果-> ${item.val}`)
- } else {
- console.log(`fail:${item.title} <-匹配失败[题目已被修改]-> ${eItem.title}`)
- }
- })
- },
- openArea (item) {
- this.show.area = !this.show.area
- this.$set(this.areaCom, 'item', this.show.area ? item : null)
- },
- // 确定选择区域
- onConfirmArea (result) {
- if (result && this.areaCom.item) {
- let val = result.map(item => item.name).join()
- this.$set(this.areaCom.item, 'area', val)
- this.openArea()
- }
- },
- openCertificate (item) {
- this.show.certificate = !this.show.certificate
- item && this.$set(this.certificateCom, 'item', item)
- },
- closeCertificate () {
- this.$set(this.certificateCom, 'item', null)
- },
- // 确定选择证件类型
- onConfirmCertificate(result) {
- if (result && this.certificateCom.item) {
- let val = result.name
- this.$set(this.certificateCom.item, 'certificate', val)
- setTimeout(() => this.openCertificate(), 300)
- }
- },
- inArea () {
- let province_list = area['86']
- let city_list = {}
- let county_list = {}
- Object.keys(province_list).forEach(code => {
- city_list = { ...area[code], ...city_list }
- })
- Object.keys(city_list).forEach(code => {
- county_list = { ...area[code], ...county_list }
- })
- this.$set(this, 'areaList', { province_list, city_list, county_list })
- }
- },
- created () {
- this.inArea()
- }
- }
|