|
|
@ -217,6 +217,20 @@ |
|
|
|
</u-radio-group> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<!-- 单选 有id --> |
|
|
|
<view v-if="colItem.type === 14"> |
|
|
|
<u-radio-group v-model="colItem.value"> |
|
|
|
<u-radio |
|
|
|
class="mb-2" |
|
|
|
@change="change($event, index, itemIndex, colItem.type)" |
|
|
|
v-for="(radioItem, radioIndex) in colItem.radioList" |
|
|
|
:key="radioIndex" |
|
|
|
:name="radioItem.id" |
|
|
|
> |
|
|
|
{{ radioItem.value }} |
|
|
|
</u-radio> |
|
|
|
</u-radio-group> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view v-else :key="itemIndex" class="flex justify-between items-center text-sm border-b"> |
|
|
@ -322,19 +336,15 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { mapGetters } from 'vuex'; |
|
|
|
import { infoList } from '@/config/yyInfo'; |
|
|
|
|
|
|
|
export default { |
|
|
|
name: 'Info', |
|
|
|
props: { personalInfo: { type: Object, default: null } }, |
|
|
|
|
|
|
|
data() { |
|
|
|
return { |
|
|
|
headStyle: { |
|
|
|
backgroundColor: '#fff', |
|
|
|
height: '46px', |
|
|
|
paddingLeft: '1rem', |
|
|
|
fontSize: '0.875rem', |
|
|
|
}, |
|
|
|
bodyStyle: { paddingLeft: '1rem' }, |
|
|
|
infoList, |
|
|
|
paramsDay: { |
|
|
|
year: true, |
|
|
@ -357,9 +367,19 @@ export default { |
|
|
|
city: true, |
|
|
|
area: false, |
|
|
|
}, |
|
|
|
isEdit: false, |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
computed: mapGetters('project', ['projectId']), |
|
|
|
|
|
|
|
mounted() { |
|
|
|
if (this.personalInfo && this.personalInfo.userName) { |
|
|
|
this.setDate(this.personalInfo); |
|
|
|
this.isEdit = true; |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
methods: { |
|
|
|
changeShow(index, itemIndex) { |
|
|
|
this.infoList[index][itemIndex].show = !this.infoList[index][itemIndex].show; |
|
|
@ -381,7 +401,9 @@ export default { |
|
|
|
} |
|
|
|
case 5: { |
|
|
|
// 多选 |
|
|
|
console.log('e: ', e); |
|
|
|
let checkerList = info.value; |
|
|
|
console.log('checkerList: ', checkerList); |
|
|
|
if (checkerList.length) { |
|
|
|
const i = checkerList.findIndex(item => item === e.name); |
|
|
|
if (i < 0) { |
|
|
@ -426,15 +448,15 @@ export default { |
|
|
|
} |
|
|
|
default: { |
|
|
|
info.value = e; |
|
|
|
if (e === '否' || e === '未知' || e === '素菜') { |
|
|
|
info.value = 0; |
|
|
|
} |
|
|
|
if (e === '是' || e === '男' || e === '荤菜') { |
|
|
|
info.value = 1; |
|
|
|
} |
|
|
|
if (e === '女' || e === '不知道') { |
|
|
|
info.value = 2; |
|
|
|
} |
|
|
|
// if (e === '否' || e === '未知' || e === '素菜') { |
|
|
|
// info.value = 0; |
|
|
|
// } |
|
|
|
// if (e === '是' || e === '男' || e === '荤菜') { |
|
|
|
// info.value = 1; |
|
|
|
// } |
|
|
|
// if (e === '女' || e === '不知道') { |
|
|
|
// info.value = 2; |
|
|
|
// } |
|
|
|
if (type === 1) { |
|
|
|
if (e === '其他') { |
|
|
|
info.showOther = true; |
|
|
@ -455,8 +477,11 @@ export default { |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
console.log('info++: ', info); |
|
|
|
this.$emit('saveInfo', info); |
|
|
|
if (!this.isEdit) { |
|
|
|
this.$emit('saveInfo', info); |
|
|
|
} else { |
|
|
|
this.updateTrainee(info); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
changeInput(e, index, itemIndex, type) { |
|
|
@ -505,6 +530,99 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 回显 |
|
|
|
setDate(date) { |
|
|
|
if (!date || !date.userName) return; |
|
|
|
const { infoList } = this; |
|
|
|
for (let i = 0; i < infoList.length; i++) { |
|
|
|
const info = infoList[i]; |
|
|
|
for (let j = 0; j < info.length; j++) { |
|
|
|
const item = info[j]; |
|
|
|
item.value = date[item.label]; |
|
|
|
if (item.label === 'jobTitle' || item.label === 'educateStatus' || item.label === 'diagnoseResult') { |
|
|
|
const list = item.radioList.find(i => i === date[item.label]); |
|
|
|
if (!list) { |
|
|
|
item.value = '其他'; |
|
|
|
item.otherValue = date[item.label]; |
|
|
|
item.showOther = true; |
|
|
|
} else { |
|
|
|
item.showOther = false; |
|
|
|
} |
|
|
|
} |
|
|
|
if (item.type === 5) { |
|
|
|
const array = date[item.label].split(','); |
|
|
|
console.log('array: ', array); |
|
|
|
item.value = array; |
|
|
|
for (let i = 0; i < item.checkList.length; i++) { |
|
|
|
const A = item.checkList[i]; |
|
|
|
for (let j = 0; j < array.length; j++) { |
|
|
|
const arr = array[j]; |
|
|
|
if (A.name === arr) { |
|
|
|
A.checked = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (item.type === 7) { |
|
|
|
item.value = date.minBloodPressure + '/' + date.maxBloodPressure; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改用户信息 |
|
|
|
*/ |
|
|
|
async updateTrainee(item) { |
|
|
|
try { |
|
|
|
console.log('item: ', item); |
|
|
|
if (!this.validationRequired(item)) return; |
|
|
|
const params = this.setParams(item); |
|
|
|
await this.$u.api.updateTrainee(params); |
|
|
|
this.$emit('showToast', 'success', `${item.name}修改成功`); |
|
|
|
} catch (error) { |
|
|
|
console.log('error: ', error); |
|
|
|
this.$emit('showToast', 'error', `${item.name}修改失败`); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 验证必填项 |
|
|
|
validationRequired(item) { |
|
|
|
if (item.showOther && !item.otherValue) { |
|
|
|
this.$t.ui.showToast(`请填写其他${item.name}`); |
|
|
|
return; |
|
|
|
} |
|
|
|
return true; |
|
|
|
}, |
|
|
|
|
|
|
|
// 设置参数 |
|
|
|
setParams(item) { |
|
|
|
let params = {}; |
|
|
|
params.projectId = this.projectId; |
|
|
|
params[item.label] = item.value; |
|
|
|
// 其他 |
|
|
|
if (item.value === '其他' && item.showOther && item.otherValue) { |
|
|
|
params[item.label] = item.otherValue; |
|
|
|
} |
|
|
|
// 血压 |
|
|
|
if (item.label === 'BloodPressure') { |
|
|
|
const arr = item.value.split('/'); |
|
|
|
params.minBloodPressure = arr[0]; |
|
|
|
params.maxBloodPressure = arr[1]; |
|
|
|
} |
|
|
|
// 疾病史 |
|
|
|
if (item.showType === 1 && item.type === 5) { |
|
|
|
let arrValue = ''; |
|
|
|
if (item.showOther && item.otherValue) { |
|
|
|
const index = item.value.indexOf('其他'); |
|
|
|
item.value.splice(index, 1, '其他:' + item.otherValue); |
|
|
|
} |
|
|
|
arrValue = item.value.toString(); |
|
|
|
params[item.label] = arrValue; |
|
|
|
} |
|
|
|
return params; |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
</script> |
|
|
|