From f03401adbd894052307edd5ab6858fb305d2e782 Mon Sep 17 00:00:00 2001 From: lrw <18279117177@163.com> Date: Sun, 16 Feb 2020 18:16:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A1=AB=E6=8A=A5=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/fillIn/fillIn.vue | 187 +++++++++++++++++++++++----------- pages/fillInDay/fillInDay.vue | 146 ++++++++++++++++---------- 2 files changed, 220 insertions(+), 113 deletions(-) diff --git a/pages/fillIn/fillIn.vue b/pages/fillIn/fillIn.vue index f8d79ff..574b38b 100644 --- a/pages/fillIn/fillIn.vue +++ b/pages/fillIn/fillIn.vue @@ -5,8 +5,8 @@ + + @@ -134,7 +146,7 @@ - + @@ -145,21 +157,23 @@ import uniCollapse from '@/components/uni-collapse/uni-collapse.vue' import uniCollapseItem from '@/components/uni-collapse-item/uni-collapse-item.vue' import validate from '@/utils/validate.js' + import pickerAddress from '@/components/pickerAddress/pickerAddress.vue' export default { components: { uniCollapse, - uniCollapseItem + uniCollapseItem, + pickerAddress }, data() { return { modalName: false, - isRead:false, + isRead: false, list: [{ label: '单位名称', required: true, - value: 'orgName', + value: 'orgId', titleClass: 'title', - type: 'picker', + type: 'picker', opts: [] }, { @@ -191,7 +205,7 @@ titleClass: 'title', placeholder: '请输入11位数字手机号', type: 'input', - validator:validate.isPhone + validator: validate.isPhone }, { label: '国籍', @@ -1007,7 +1021,7 @@ value: "Zimbabwe" } ], - show: [8], + show: [8, 101], showValue: ['China'] }, @@ -1018,8 +1032,18 @@ titleClass: 'title', placeholder: '请输入身份证号/护照号', type: 'input', - validator:validate.isIdCard - + validator: validate.isIdCard + + }, + { + label: '户籍所在地', + required: true, + value: 'householdValues', + titleClass: 'title', + placeholder: '请选择', + type: 'pickerAddress', + num: 101, + hidden: true, }, { label: '户籍地址', @@ -1031,6 +1055,14 @@ num: 8, hidden: true, }, + { + label: '在沪居住所在地', + required: true, + value: 'residenceValue', + titleClass: 'title', + placeholder: '请选择', + type: 'pickerAddress', + }, { label: '在沪居住(暂住)地址', required: true, @@ -1303,31 +1335,31 @@ titleClass: 'title', type: 'pickerMore', opts: [{ - value: '已经确诊', + value: 'a', label: '已经确诊' }, { - value: '疑似诊断', + value: 'b', label: '疑似诊断' }, { - value: '亲密接触者', + value: 'c', label: '亲密接触者' }, { - value: '居家观察/正在接受集中医学观察', + value: 'd', label: '居家观察/正在接受集中医学观察' }, { - value: '已解除集中医学观察', + value: 'e', label: '已解除集中医学观察' }, { - value: '无上述情况', + value: 'f', label: '无上述情况' }], showList: [{ - value: '亲密接触者', + value: 'c', show: [32, 35, 38, 40, 43, 45, 47] }, { - value: '居家观察/正在接受集中医学观察', + value: 'd', show: [49, 50] }, ] @@ -1576,34 +1608,34 @@ titleClass: 'title', type: 'pickerMore', opts: [{ - value: '发热', + value: 'a', label: '发热' }, { - value: '咳嗽', + value: 'b', label: '咳嗽' }, { - value: '流涕', + value: 'c', label: '流涕' }, { - value: '咽痛', + value: 'd', label: '咽痛' }, { - value: '咳痰', + value: 'e', label: '咳痰' }, { - value: '胸痛', + value: 'f', label: '胸痛' }, { - value: '肌肉酸痛/关节痛', + value: 'g', label: '肌肉酸痛/关节痛' }, { - value: '气促', + value: 'h', label: '气促' }, { - value: '腹泻', + value: 'i', label: '腹泻' }, { - value: '以上均无', + value: 'j', label: '以上均无' }] }, @@ -1622,7 +1654,8 @@ householdAddress: '', residenceAddress: '', planReturnDate: '' - } + }, + formMat:{} } }, @@ -1630,8 +1663,6 @@ this.getOrg() this.getInfo() }, - - methods: { openModal() { if (!this.form.agree) { @@ -1666,12 +1697,14 @@ }, // 获取信息 getInfo() { - this.$http.get(`/sict-ncov/report`, this.form).then(res => { + this.$http.get(`/sict-ncov/report`, this.form).then(res => { const d = res.data - if(d.code == 1) { + if (d.code == 1) { this.isRead = true const data = d.object.reportContent || {} this.form = data + this.form['householdValues'] = data['householdProvince'] + "," +data['householdCity'] + "," +data['householdDistrict'] + this.form['residenceValue'] = data['residenceProvince'] + "," + data['residenceCity'] + "," +data['residenceDistrict'] // 赋值 for (let k in data) { const val = data[k] @@ -1682,22 +1715,36 @@ value: val }, item) if (item.type == "pickerMore") { - console.log(1,22) item.opts.forEach(opt => { val.split(',').forEach(v => { - if (v === opt.label) { - console.log(opt) + if (v === opt.value) { this.$set(opt, 'checked', true) } }) }) - + + } + if (item.type == "picker") { + item.opts.forEach(opt => { + if(opt.value == val) { + this.formMat[k] = opt.label + } + }) + + } + if (item.type == "pickerAddress") { + item.opts.forEach(opt => { + if(opt.value == val) { + this.formMat[k] = opt.label + } + }) + } } } } } - + }) }, // 更新复选框绑定的表单内容 @@ -1716,13 +1763,13 @@ this.$set(checkList[i], 'checked', false) } this.$set(checkList[checkList.length - 1], 'checked', true) - this.form[prop] = obj.label + this.form[prop] = obj.value } else { this.$set(checkList[checkList.length - 1], 'checked', false) const values = [] for (var i = 0, lenI = checkList.length; i < lenI; ++i) { if (checkList[i].checked) { - values.push(checkList[i].label) + values.push(checkList[i].value) } } this.form[prop] = values.join(',') @@ -1802,19 +1849,23 @@ this.form[props] = event.target.value }, // 输入框失去焦点 - inputBlur(e,item) { + inputBlur(e, item) { const val = e.detail.value - if(!val) { + if (!val) { return } - if(item.validator && !item.validator(val)) { + if (item.validator && !item.validator(val)) { uni.showToast({ icon: 'none', title: `${item.label }填写错误` }) } }, - + // pickerAddress地址改变 + addressChange(e, item) { + const val = e.data.join(',') + this.$set(this.form, item.value, val) + }, // 更新下拉框绑定的表单内容 updatePickerVal(event, item) { const opts = item.opts @@ -1824,12 +1875,8 @@ this.$set(this.form, prop, val) return } - if (prop == 'orgName') { - this.$set(this.form, 'orgId', opts[val].value) - this.$set(this.form, prop, opts[val].label) - } else { - this.$set(this.form, prop, opts[val].label) - } + this.$set(this.form, prop, opts[val].value) + this.$set(this.formMat, prop, opts[val].label) if (item.show) { this.showChange(event, item) @@ -1839,7 +1886,7 @@ formSubmit() { let flag = true let msg = '' - if(this.form.agree != 1) { + if (this.form.agree != 1) { uni.showToast({ icon: 'none', title: `请勾选知情同意书` @@ -1857,7 +1904,7 @@ }) break } - if(this.list[i].validator && !this.list[i].validator(val)) { + if (this.list[i].validator && !this.list[i].validator(val)) { flag = false uni.showToast({ icon: 'none', @@ -1874,13 +1921,33 @@ if (!flag) { return false } else { - this.$http.post(`/sict-ncov/report`, this.form).then(res => { + const data = {} + for (let k in this.form) { + if (this.form[k]) { + if (k == 'householdValues') { + // 户籍所在地 + const values = this.form[k].split(',') + data.householdProvince = values[0] + data.householdCity = values[1] + data.householdDistrict = values[2] + } else if (k == 'residenceValue') { + // 住所所在地 + const values = this.form[k].split(',') + data.residenceProvince = values[0] + data.residenceCity = values[1] + data.residenceDistrict = values[2] + } else { + data[k] = this.form[k] + } + } + } + this.$http.post(`/sict-ncov/report`, data).then(res => { const d = res.data if (d.code == 1) { uni.navigateBack() uni.showToast({ icon: 'success', - title:'提交成功' + title: '提交成功' }) } else { uni.showToast({ @@ -1931,9 +1998,11 @@ } } } - .content { - text-indent: 20px; - } + + .content { + text-indent: 20px; + } + uni-radio-group { border: 2upx solid #d3d3d3; border-radius: 8upx; diff --git a/pages/fillInDay/fillInDay.vue b/pages/fillInDay/fillInDay.vue index 51763ae..1557518 100644 --- a/pages/fillInDay/fillInDay.vue +++ b/pages/fillInDay/fillInDay.vue @@ -27,7 +27,7 @@ :style="{opacity: item.required ? 1 : 0}">*{{item.label}} - {{form[item.value]?form[item.value]:'请选择'}} + {{form[item.value]?formMat[item.value]:'请选择'}} @@ -98,7 +98,7 @@ - + @@ -116,8 +116,7 @@ }, data() { return { - id: '', - radio: [], + isRead: false, list: [ { @@ -127,31 +126,31 @@ titleClass: 'title', type: 'pickerMore', opts: [{ - value: '已经确诊', + value: 'a', label: '已经确诊' }, { - value: '疑似诊断', + value: 'b', label: '疑似诊断' }, { - value: '亲密接触者', + value: 'c', label: '亲密接触者' }, { - value: '居家观察/正在接受集中医学观察', + value: 'd', label: '居家观察/正在接受集中医学观察' }, { - value: '已解除集中医学观察', + value: 'e', label: '已解除集中医学观察' }, { - value: '无上述情况', + value: 'f', label: '无上述情况' }], showList: [{ - value: '亲密接触者', + value: 'c', show: [32, 35, 38, 40, 43, 45, 47] }, { - value: '居家观察/正在接受集中医学观察', + value: 'd', show: [49, 50] }, ] @@ -400,34 +399,34 @@ titleClass: 'title', type: 'pickerMore', opts: [{ - value: '发热', + value: 'a', label: '发热' }, { - value: '咳嗽', + value: 'b', label: '咳嗽' }, { - value: '流涕', + value: 'c', label: '流涕' }, { - value: '咽痛', + value: 'd', label: '咽痛' }, { - value: '咳痰', + value: 'e', label: '咳痰' }, { - value: '胸痛', + value: 'f', label: '胸痛' }, { - value: '肌肉酸痛/关节痛', + value: 'g', label: '肌肉酸痛/关节痛' }, { - value: '气促', + value: 'h', label: '气促' }, { - value: '腹泻', + value: 'i', label: '腹泻' }, { - value: '以上均无', + value: 'j', label: '以上均无' }] }, @@ -663,41 +662,60 @@ hidden: true, }, ], - form: {} + form: {}, + formMat: {} } }, onLoad(option) { // 获取信息 - this.$http.post(`/sict-ncov/report`, this.form).then(res => { - console.log(res) - }) - const data = { - currentStatus: '亲密接触者' - } - for (let k in data) { - const val = data[k] - if (val) { - const item = this.list.find(child => child.value == k) - if (item) { - this.showChange({ - value: val - }, item) - if (item.type == "pickerMore") { - console.log(1,22) - item.opts.forEach(opt => { - val.split(',').forEach(v => { - if (v === opt.label) { - console.log(opt) - this.$set(opt, 'checked', true) - } - }) - }) - + this.$http.get(`/sict-ncov/report/daily`).then(res => { + const d = res.data + if (d.code == 1) { + this.isRead = true + const data = d.object || {} + this.form = data + // 赋值 + for (let k in data) { + const val = data[k] + if (val) { + const item = this.list.find(child => child.value == k) + if (item) { + this.showChange({ + value: val + }, item) + if (item.type == "pickerMore") { + item.opts.forEach(opt => { + val.split(',').forEach(v => { + if (v === opt.value) { + this.$set(opt, 'checked', true) + } + }) + }) + + } + if (item.type == "picker") { + item.opts.forEach(opt => { + if (opt.value == val) { + this.formMat[k] = opt.label + } + }) + + } + if (item.type == "pickerAddress") { + item.opts.forEach(opt => { + if (opt.value == val) { + this.formMat[k] = opt.label + } + }) + + } + } } } } - } + }) + }, @@ -718,13 +736,13 @@ this.$set(checkList[i], 'checked', false) } this.$set(checkList[checkList.length - 1], 'checked', true) - this.form[prop] = obj.label + this.form[prop] = obj.value } else { this.$set(checkList[checkList.length - 1], 'checked', false) const values = [] for (var i = 0, lenI = checkList.length; i < lenI; ++i) { if (checkList[i].checked) { - values.push(checkList[i].label) + values.push(checkList[i].value) } } this.form[prop] = values.join(',') @@ -748,10 +766,11 @@ current.show.forEach(child => { this.list.forEach(row => { if (child == row.num) { - this.$set(row, 'hidden', !current.showValue.includes(val)) + this.$set(row, 'hidden', !current.showValue.includes(String(val))) } }) }) + break } } } @@ -773,7 +792,22 @@ } } - + if (type === 'picker') { + let val = evt.value || item.opts[evt.detail.value].value; + for (let i = 0; i < this.list.length; i++) { + const current = this.list[i] + if (current.value == prop && current.show) { + current.show.forEach(child => { + this.list.forEach(row => { + if (child == row.num) { + this.$set(row, 'hidden', !current.showValue.includes(val)) + } + }) + }) + break + } + } + } }, isShowChild() { @@ -796,7 +830,11 @@ this.$set(this.form, prop, val) return } - this.$set(this.form, prop, opts[val].label) + this.$set(this.form, prop, opts[val].value) + this.$set(this.formMat, prop, opts[val].label) + if (item.show) { + this.showChange(event, item) + } }, // 提交信息 formSubmit() { -- 2.22.0