Commit 9c3b4d5b authored by miaojiale's avatar miaojiale

增加年龄字段,添加已增加调查时间,须检验其他需要的情况

parent 45bb256e
......@@ -67,14 +67,16 @@
<script>
let checkAge = (rule, value, callback) => {
if (!value) {
return callback(new Error("请选择出生日期"))
return callback(new Error(""))
}
let sex = sessionStorage.getItem("addSex")
if (!sex) {
let survey_time = sessionStorage.getItem("survey_time")
let birthday = sessionStorage.getItem("birthday")
if (!sex || !survey_time || !birthday) {
return
}
let birthday = new Date(value.replace(/-/g, "/"))
let d = new Date()
birthday = new Date(birthday.replace(/-/g, "/"))
let d = new Date(survey_time.replace(/-/g, "/"))
let age =
d.getFullYear() -
birthday.getFullYear() -
......
<template>
<el-row
:gutter="options.gutter"
class="form-content"
>
<template v-for="(item, columnIndex) in columns.column || columns.children.column">
<el-row :gutter="options.gutter" class="form-content">
<template
v-for="(item, columnIndex) in columns.column || columns.children.column"
>
<div
v-if="item.type === 'dynamic'"
v-show="item.display"
......@@ -96,10 +95,7 @@
:md="item.md || 24"
:lg="item.span || 12"
>
<div
class="form_title"
:style="item.styles"
>
<div class="form_title" :style="item.styles">
<span>{{ item.value }}</span>
</div>
</el-col>
......@@ -122,6 +118,7 @@
:item="item"
:columns="columns.column || columns.children.column"
:group="options.group"
:active-name="activeName"
@formChange="formChange"
@validateForm="validateForm"
@validUpload="validUpload"
......@@ -145,6 +142,7 @@ export default {
components: { FormItemSelf, FormDynamic, DentalTabForm, DentalTabTjForm },
props: {
activeName: { type: String },
form: {
type: Object,
default: () => {
......@@ -171,38 +169,38 @@ export default {
default: false,
},
},
data () {
data() {
return {}
},
computed: {
isShowIm () {
isShowIm() {
return function (val) {
return !this.isShowImportant ? true : val
}
},
paddingLeft () {
paddingLeft() {
const columns = this.columns
return columns.labelWidth ? `${columns.labelWidth}px` : ""
},
},
methods: {
clearAge () {
clearAge() {
for (let i = 0; i < this.$refs.formSelf.length; i++) {
this.$refs.formSelf[i].age = ""
}
},
validateForm () {
validateForm() {
this.$emit("validateForm")
},
validUpload (prop) {
validUpload(prop) {
this.$emit("validUpload", prop)
},
handleChange (key, val) {
handleChange(key, val) {
if (this.form.hasOwnProperty(key)) this.form[key] = val
},
// 切换不符合筛查条件的显示
formChange () {
formChange() {
// 入选,排除标准,一个填写是就不符合筛查条件
let arr = [
"is_one_year",
......@@ -211,7 +209,7 @@ export default {
"is_symptom",
"is_disease",
"is_tumour",
"is_Incomplete"
"is_Incomplete",
]
let flag = 0
for (let i = 0; i < arr.length; i++) {
......@@ -229,6 +227,9 @@ export default {
}
},
},
mounted() {
// console.log(this.activeName)
},
}
</script>
......
......@@ -327,7 +327,7 @@
@change="handleChange"
></el-date-picker>
<span
v-if="item.prop == 'birthday'"
v-if="item.prop == 'birthday' && activeName == 'index0'"
style="margin-left: 12px"
>{{ age + (age ? "岁" : "") }}</span
>
......@@ -449,6 +449,7 @@
* @description 自定义单组件
*/
import { getMedicalunionList } from "@/api/medicalunion-management"
import { mapGetters } from "vuex"
import ElUploadSelf from "@/components/Upload"
import FormItemText from "./FormItemText"
import DialogToothBit from "./DialogToothBit"
......@@ -480,6 +481,7 @@ export default {
},
},
props: {
activeName: {},
item: {
type: Object,
},
......@@ -496,7 +498,7 @@ export default {
},
data() {
return {
age: "",
// age: "",
pickerOptions,
rangeOptions,
unionList: [],
......@@ -504,6 +506,9 @@ export default {
}
},
computed: {
...mapGetters({
age: ["table/age"],
}),
getVwForm() {
return this.vwForm()
},
......@@ -555,6 +560,7 @@ export default {
},
mounted() {
this.showFormItem()
console.log(this.activeName)
},
beforeDestroy() {
this.$watch(
......@@ -710,10 +716,10 @@ export default {
},
// 根据生日设置年龄回显
getAge() {
if (this.form.birthday) {
if (this.form.birthday && this.form.survey_time) {
var birthday = new Date(this.form.birthday.replace(/-/g, "/"))
var d = new Date()
var age =
let d = new Date(this.form.survey_time.replace(/-/g, "/"))
let age =
d.getFullYear() -
birthday.getFullYear() -
(d.getMonth() < birthday.getMonth() ||
......@@ -721,11 +727,15 @@ export default {
d.getDate() < birthday.getDate())
? 1
: 0)
this.age = age + ""
this.$store.commit("table/setAge", age)
this.form.age = this.age
console.log(this.form.age, "---", age)
} else {
this.age = ""
let age = ""
this.$store.commit("table/setAge", age)
this.form.age = this.age
console.log(this.form.age, "---", age)
}
this.form.age = this.age
},
// 获取prop prop 以{}包裹
getProp(value) {
......@@ -957,6 +967,12 @@ export default {
this.handleAlgorithm()
// !设置年龄
if (this.item.prop == "birthday") {
sessionStorage.setItem("birthday", this.form.birthday)
this.getAge()
}
// ?survey_time 调查时间
if (this.item.prop == "survey_time") {
sessionStorage.setItem("survey_time", this.form.survey_time)
this.getAge()
}
if (this.item.prop == "sex") {
......
......@@ -34,6 +34,7 @@
:form="form"
:columns="g"
:options="options"
:active-name="activeName"
:is-show-important="isShowImportant"
@validateForm="validateForm"
></form-content>
......@@ -60,6 +61,7 @@
ref="formContent"
:form="form"
:columns="g"
:active-name="activeName"
:options="options"
:is-show-important="isShowImportant"
@showError="showError"
......@@ -138,6 +140,7 @@ export default {
return {}
},
},
activeName: {},
size: { type: String, default: "small" },
formStyle: { type: Object },
formEdit: {
......@@ -164,7 +167,7 @@ export default {
data() {
return {
collapseNames: [],
activeName: "0",
// activeName: "0",
loading: false,
isShowImportant: false,
form: {},
......@@ -209,7 +212,7 @@ export default {
methods: {
validateForm() {
// console.log(88845)
if (this.form.birthday) {
if (this.form.birthday && this.form.survey_time) {
this.$refs.form.validateField("birthday", (valid) => {
console.log(valid)
})
......@@ -245,7 +248,7 @@ export default {
if (next >= tabsLen) next = 0
this.activeName = String(next)
this.$emit("scrollTop")
console.log(this.activeName)
// console.log(this.activeName)
},
imFieldChange(val = false) {
......
......@@ -2,11 +2,13 @@ const state = {
fontSize: localStorage.getItem("fontSize") || 14,
selectedIndex: sessionStorage.getItem("selectedIndex") || "",
refreshFlag: 0,
age: "",
}
const getters = {
fontSize: (state) => state.fontSize,
selectedIndex: (state) => state.selectedIndex,
refreshFlag: (state) => state.refreshFlag,
age: (state) => state.age,
}
const mutations = {
setFontSize(state, fontSize) {
......@@ -23,6 +25,9 @@ const mutations = {
setRefreshFlag(state, refreshFlag) {
state.refreshFlag = refreshFlag
},
setAge(state, age) {
state.age = age
},
}
const actions = {}
export default {
......
......@@ -82,6 +82,7 @@ export default {
let data = {
birthday: v.form.birthday,
sex: v.form.sex,
survey_time: v.form.survey_time,
}
sessionStorage.setItem("index1Data", JSON.stringify(data))
}
......
......@@ -202,6 +202,7 @@ export default {
let data = {
birthday: v.form.birthday,
sex: v.form.sex,
survey_time: v.form.survey_time,
}
sessionStorage.setItem("index1Data", JSON.stringify(data))
}
......
......@@ -18,7 +18,12 @@ export default {
data() {
return {}
},
created() {},
created() {
sessionStorage.removeItem("survey_time")
sessionStorage.removeItem("birthday")
sessionStorage.removeItem("addSex")
this.$store.commit("table/setAge", "")
},
methods: {
// 处理部分逻辑
addMethods(v) {
......@@ -27,11 +32,15 @@ export default {
let data = {
birthday: v.form.birthday,
sex: v.form.sex,
survey_time: v.form.survey_time,
}
sessionStorage.setItem("index1Data", JSON.stringify(data))
}
},
},
// beforeRouteEnter(to, from, next) {
// next()
// },
}
</script>
......
......@@ -244,9 +244,9 @@ export default {
this.$nextTick(() => {
let index1Data = sessionStorage.getItem("index1Data")
if (index1Data) {
let { birthday, sex } = JSON.parse(index1Data)
let { birthday, sex, survey_time } = JSON.parse(index1Data)
let date = new Date(String(birthday).replace(/-/g, "/"))
let d = new Date()
let d = new Date(survey_time.replace(/-/g, "/"))
let age =
d.getFullYear() -
date.getFullYear() -
......@@ -259,6 +259,7 @@ export default {
birthday,
age,
sex,
survey_time,
}
}
})
......
......@@ -63,6 +63,7 @@
<custom-form
ref="form"
:options="widgetFormPreview"
:active-name="activeName"
:form-edit="formData.formEdit"
@scrollTop="scrollTop"
@handleConfirm="handleConfirm"
......
......@@ -298,6 +298,7 @@ export default {
let data = {
birthday: v.form.birthday,
sex: v.form.sex,
survey_time: v.form.survey_time,
}
sessionStorage.setItem("index1Data", JSON.stringify(data))
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment