先在文本宽输入内容,点击单选后
- 发布:2024-08-08 16:25
- 更新:2024-08-09 11:25
- 阅读:114
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 16.8
HBuilderX类型: 正式
HBuilderX版本号: 4.24
第三方开发者工具版本号: 1.06
基础库版本号: 3.49
项目创建方式: HBuilderX
操作步骤:
预期结果:
文本输入后点击单选 文字随着文本框内容下移到指定位置
文本输入后点击单选 文字随着文本框内容下移到指定位置
实际结果:
文本输入后点击单选内容,输入的文字脱离了input输入框并站位在了原来停留的位置
文本输入后点击单选内容,输入的文字脱离了input输入框并站位在了原来停留的位置
bug描述:
<template>
<view class="dataInput">
<view class="mainheader">
<view class="mainTitle_left">
<view class="" style="margin-top: 2px;">
<u-icon name="calendar-fill" color="#009487" size="40"></u-icon>
</view>
<text style="padding-top: 2px;font-size: 14px;"
class="maring-text">{{subjInfo.subjNo}}>{{subjInfo.svisitName}}>{{subjInfo.sfromName}}</text>
</view>
<!-- 保存按钮 -->
<view class="mainTitle_right_box" v-if="userInfo.isAdd">
<view class="mainTitle_rigth_identify" @click="onIdentify">
识别
</view>
<view class="mainTitle_rigth" @click="submitClick('preSubmit')">
提交
</view>
</view>
<!-- ./保存按钮 -->
</view>
<!-- :style="{top:distanceTop + 'rpx'}" -->
<view class="data_box" :style="{top:distanceTop + 'px'}">
<view class="" v-for="(item,index) in itemList.items" :key='index'>
<view class="data_box_list" v-show="item.show"
:class="[item.type == 12?'data_box_grid':'',item.type == 17 ? 'data_box_grid':'']">
<!-- 普通标题 -->
<view class="data_box_list_title" v-if="item.type != 12 && item.type != '17'"
:class="[item.level == 2 ?'leverClass' :'',item.type == '6' &&item.options == undefined ? 'data_box_list_title_no' :'']">
<text class="data_box_list_title_left" v-if="item.required">*</text>
<view class="data_box_list_title_right">
<view class="check" @click="onCheked(item)" :class="[item.checked ? 'checkSelsect':'']"
v-if="item.options == undefined && item.type == 6">
{{item.checked ?'√':''}}
</view>
<text class="">
{{item.name}} </text>
</view>
</view>
<!-- ./普通标题 -->
<!-- grid -->
<view class="data_box_list_title_grid" v-if="item.type == 12">
<view class="grid_left">
{{item.name}}
</view>
<view class="grid_tips">
<view class="grid_tips_center">
提示 : 请先提交数据后,再添加【{{item.name}}】 数据
</view>
</view>
<!-- <view class="grid_right" @click="onGtidAdd(item)">
<u-icon name="plus" color="#fff" size="40"></u-icon>
</view> -->
</view>
<!-- ./grid -->
<!-- 实验室 -->
<view class="data_list_title_label " v-if="item.type == '17'">
<view class="grid_left">
{{item.name}}
</view>
<!-- v-if="item.type == '17'" -->
<view class="labsOption">
<view class="labsOption_Box" @click="onLabsChange">
<text>{{normalOption.optionText}}</text>
<view class="labsOption_Icon">
<u-icon name="arrow-down" color="#767676" size="35"></u-icon>
</view>
</view>
<!-- 下拉内容 -->
<view class="labsSelect" v-if="normalOption.show">
<view class="angle">
</view>
<view class="select">
<view class="selectBox">
<view class="selectItem"
:class="[normalOption.code == normalItem.value ? 'selectItemHover':'']"
v-for="(normalItem,normalIndex) in normalOption.option" :key="normalIndex"
@click="onOption(normalItem,item)">
{{normalItem.label}}
</view>
</view>
</view>
</view>
</view>
</view>
<!-- ./实验室 -->
<view class="data_box_list_center"
:style="{marginTop:item.type ==6&& item.options == undefined ? 0 :'5px',marginLeft:item.level == 2?'18px':''}">
<!-- 1:未使用;
2:日期;
3:文本;
4:单选;
5:显示;
6:多选;
7:未使用;
8:文本域;
9:数字;
10:未使用;
11:下拉;
12:GRID;
13:计算;//文本框,只读;值通过规则显示
14:GRID数据源;//按下拉渲染
15:药包) //文本框,只读;值通过规则显示
17:实验室 -->
<view class="data_box_list_center_public" v-if="item.type == '2'">
<!-- 日历 -->
<emdDate :dateObj="item" @onDateChange="onDateChange($event,item)"></emdDate>
</view>
<!-- 文本 -->
<view class="data_box_list_center_public " v-if="item.type == '3'"
:class="item.level != 0 ?'data_box_list_center_public_level':''">
<input type="text" v-model="item.value" @blur="onInputBlur(item.rules)" :focus="true" :always-embed="true"
class="data_box_list_center_public_input" />
</view>
<!-- ./文本 -->
<!-- 单选 -->
<view class="data_box_list_center_public" v-if="item.type == '4'"
:class="item.level != 0 ?'data_box_list_center_public_level':''">
<view class="radio_Portrait" :class="[item.alignment == 'HORIZONTAL' ? 'radioBox':'']">
<!-- radioBox - 横向 -->
<!-- radio_Portrait -->
<view class="radioItem" v-for="(citem,cindex) in item.options" :key="cindex"
:label="citem.label" :name="citem.value"
@click="onGroupChange(item.code,item.rules,item,citem)">
<view class="radioIcon " :class="[citem.checked ? 'radioIconSelect':'']">
{{citem.checked ?'√':''}}
</view>
<view class="radioText" :style="{width:citem.label.length>14?'97%':''}">
{{citem.label}}
</view>
</view>
</view>
</view>
<!-- ./单选 -->
<!-- 显示 -->
<view class="data_box_list_center_public" v-if="item.type == '5'"
:class="item.level != 0 ?'data_box_list_center_public_level':''">
<text>{{item.value}}</text>
</view>
<!-- ./显示 -->
<!-- 多选 -->
<view class="data_box_list_center_public" v-if="item.type == '6'"
:class="item.level != 0 ?'data_box_list_center_public_level':''">
<!-- type-99 -->
<!-- <view class="check" @click="onCheked(item)" :class="[item.checked ? 'checkSelsect':'']"
v-if="item.options == undefined">
{{item.checked ?'√':''}}
</view> -->
<!--./type-99 -->
<!-- 有多选 -->
<!-- @change="onCheckbox(item,citem)" -->
<u-checkbox-group v-model="item.value" size='35' v-if="item.options != undefined"
:placement="item.alignment == 'HORIZONTAL' ? 'row': 'column'">
<u-checkbox activeColor="#009487" labelSize='30'
:style="{marginRight: item.alignment == 'HORIZONTAL' ? '20rpx': '0'}"
v-for="(citem,cindex) in item.options" :key="cindex" :label="citem.label"
:name="citem.value">
</u-checkbox>
</u-checkbox-group>
<!-- ./有多选 -->
</view>
<!-- ./多选 -->
<!-- 大文本框 -->
<view class="data_box_list_center_public" v-if="item.type=='8'"
:class="item.level != 0 ?'data_box_list_center_public_level':''">
<u-textarea style="border: 1px solid #767676;" v-model="item.value" :height="300"
class="data_box_list_center_public_textarea" />
</view>
<!-- ./大文本框 -->
<!-- 带有单位 -->
<view class="data_box_list_center_public data_box_list_center_public_unit"
v-if="item.type == '9'">
<view class="">
<u-input v-model="item.value" type="digit" inputmode="decimal" :focus="true">
</u-input>
</view>
<view class="data_box_list_center_unit">
{{item.unit}}
</view>
</view>
<!-- ./带有单位 -->
<!-- 下拉选项框 -->
<view class="data_box_list_center_public " v-if="item.type == '11'" style="width: 94%;"
:class="item.level != 0 ?'data_box_list_center_public_level':''">
<view class="data_box_list_center_public_picker"
@click="pickerClick(item.code,item.options,item.rules)">
<view class="data_box_list_center_public_picker_left">
<view v-if="item.value" class="" style="padding-left:10rpx ;">{{item.valueTxt}}
</view>
<view v-else style="color:#ccc;font-size: 16px;padding-left:10rpx ;">请选择</view>
</view>
<view class="data_box_list_center_public_picker_right">
<u-icon name="arrow-down" size="30"></u-icon>
</view>
</view>
</view>
<!-- ./ 下拉选项框-->
<!-- 自动计算类型 -->
<view class=" data_box_list_center_public data_box_list_center_Count" v-if="item.type=='13'">
<u-input v-model="item.value" :disabled="true" placeholder="自动计算" type="number"></u-input>
</view>
<!-- ./ 自动计算类型-->
<!-- grid -->
<view class="components_emdGrid" v-if="item.type == '12' && item.gridInfo.gridData.length > 0">
<emdGrid :gridList="item.gridInfo.gridData" :gridItems="item.gridInfo.gridItems"
@onDeleteChange="onDeleteChange" @onEditChange="onGridEditChange($event,item)"
@onDetilChange="onDetilChange($event,item)" @onRestoreChange="onRestoreChange">
</emdGrid>
</view>
<!-- ./grid -->
<!-- 实验室 -->
<view class="components_emdLabel" v-if="item.type == '17'">
<emdLabel :labInfo="item.labInfo" :read="false"
@onLabelConfirm="onLabelConfirm($event,item)">
</emdLabel>
</view>
<!-- ./实验室 -->
<view class="query" v-if="item.querys && item.querys.length > 0">
<!-- 质疑列表 -->
<view class="queryList" v-for="(queryItem,queryIndex) in item.querys" :key="queryIndex">
<view class="queryIcon">
</view>
<view class="queryText">
{{queryItem.content}}
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<!-- 下拉组件 -->
<view class="">
<u-picker :show="pickerShow" :columns="picker.columns" keyName="label" @confirm="pickerConfirm"
itemHeight="80" :immediateChange="true" @cancel="pickerClose" @close="pickerClose"></u-picker>
</view>
<!-- ./下拉组件 -->
<u-modal :show="modal.show" title="系统提示" :showCancelButton="showCancelButton" @confirm="modalConfirm"
@cancel="modalClose" @close="modalClose">
<view class="modalCenter">
{{modal.content}}
</view>
</u-modal>
<!-- loding加载 -->
<view v-if="loading" class="custom-mask"></view>
</view>
</template>
<script>
// 获取当前日期
var date = new Date();
var edcYear = date.getFullYear(); //获取完整的年份(4位)
var edcMonth = date.getMonth() + 1 < 10 ?
"0" + (date.getMonth() + 1) :
date.getMonth() + 1;
var edcDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); // 获取日期
var edcHH = date.getHours() + 1; //获取当前小时数(0-23)
var edcMM = date.getMinutes() + 1; //获取当前分钟数(0-59)
var edcdates = new Date(edcYear, edcMonth, 0).getDate();
var patterns = /[`\-':;',\\\[\]\.<>\/?~!@#¥……&*()——{}【】';: ""'。,、?\s]/g;
import emdGrid from '@/components/data/EmGrid.vue'
import emdDate from '@/components/data/EmDate.vue'
import emdLabel from '@/components/data/EmdLabel.vue'
import Api from "@/utils/api.js";
export default {
components: {
emdGrid,
emdDate,
emdLabel
},
data() {
return {
size: 30,
titleStyle: {
color: '#fff'
},
leftIconColor: '#ffffff',
bgColor: '#32a99f',
itemList: {},
pickerShow: false, //下拉组件
columns: [], //下拉数据
userInfo: {},
normalOption: {
option: [],
show: false, //正常值显示
optionText: '请选择正常值',
code: 0
},
modal: {
show: false,
content: '',
type: 'success', //error-代表错误确认 ,success-代表提交录入确认 grid-代表grid行删除
gridIndex: '', //单行grid的行索引
},
submitParam: {},
loading: false,
subjInfo: {}, //访视信息
showCancelButton: true,
saveRules: {}, //规则
picker: {
code: '',
columns: []
},
gridSatus: false,
distanceTop: 0, //距离顶部高度
titleLenght: 0,
}
},
onShow() {
this.userInfo = uni.getStorageSync('userInfo')
},
async onLoad(opt) {
this.subjInfo = await JSON.parse(decodeURIComponent(opt.subjInfo));
uni.setNavigationBarTitle({
title: this.subjInfo.sfromName, // 标题文本
success: function() {
console.log('标题设置成功');
},
fail: function(err) {
console.error('标题设置失败', err);
}
});
this.$nextTick(() => {
var query = uni.createSelectorQuery().in(this);
query.select('.mainheader').boundingClientRect(data => {
if (data) {
this.distanceTop = data.height;
}
}).exec();
this.getSubmitItemInfos()
})
},
methods: {
/**
* 录入表单数据
*/
async getSubmitItemInfos() {
var param = {
subjId: this.subjInfo.subjId,
sformId: this.subjInfo.sformId
}
let res = await Api.submitItemInfos(param);
let {
code,
data,
msg
} = res;
if (code == 100) {
let itemLength = 0;
itemLength = data.items.length;
data.items.map(async item => {
// if(itemLength == 1 && item.type == 12 && item.show){
// this.gridSatus = true;
// }
item.initShow = item.show;
// 设置下拉的显示状态
item.setShow = false;
// type为4代表单选类型需要手动给单选项加一个选中状态
if (item.type == '4') {
item.options.map(optItme => {
optItme.checked = false;
})
}
// 多选组数据添加
if (item.type == '6') {
// 如过options没有代表是99类型数据,需要添加checked字段
if (item.options == undefined) {
item.checked = false;
}
}
if (item.type == '17') {
// 实验室标准
let stdData = []
let labItems = item.labInfo.labItems;
// 初始化判断实验室单位是否可以输入
labItems.map(labItemUnit => {
labItemUnit.unitState = false;
labItemUnit.ocrInfo = {};
labItemUnit.ocrInfo.words = [];
// TOD
// 5.0没有指定字符 暂时模拟
console.log(labItemUnit.name.includes('('), '=包含')
console.log(labItemUnit.name.includes('('))
if (labItemUnit.name.includes('(')) {
labItemUnit.ocrInfo.words.push(labItemUnit.name.split('(')[1]
.split(')')[0])
} else {
labItemUnit.ocrInfo.words.push(labItemUnit.name.split('(')[1]
.split(')')[0])
}
if (labItemUnit.unit == '') {
labItemUnit.unitState = true;
}
})
if (data.stdOptions != null) {
this.normalOption.option = data.stdOptions;
this.normalOption.option.unshift({
value: 0,
label: ' '
})
console.log('normalOption', this.normalOption)
if (data.stdOptions.length == 2) {
this.normalOption.code = data.stdOptions[1].value;
this.normalOption.optionText = data.stdOptions[1].label;
console.log('----')
let stdRes = await this.getStdItemInfos()
if (stdRes.code == 100) {
stdData = stdRes.data;
}
}
}
console.log('stdData', stdData)
stdData.map(dataItem => {
labItems.map(lableItem => {
if (dataItem.code == lableItem.code) {
// 判断值是否为空,空值不赋值
lableItem.lbLowerLimit = dataItem.stdList[0]
.lowerLimit;
lableItem.lbUpperLimit = dataItem.stdList[0]
.upperLimit;
lableItem.unit = dataItem.stdList[0].unit;
lableItem.isContainLowerLimit = dataItem.stdList[0]
.isContainLowerLimit;
lableItem.isContainUpperLimit = dataItem.stdList[0]
.isContainUpperLimit;
let stdListLength = dataItem.stdList.length;
// 处理多单位的上线下线匹配问题
if (stdListLength > 1) {
if (lableItem.units || lableItem.units.length >
1) {
lableItem.units.map(unitItem => {
dataItem.stdList.map(
staItem => {
if (staItem
.upperLimit !=
null && staItem
.lowerLimit !=
null) {
if (unitItem
.label ==
staItem
.unit) {
unitItem
.lowerLimit =
staItem
.lowerLimit;
unitItem
.upperLimit =
staItem
.upperLimit;
unitItem
.isContainUpperLimit =
staItem
.isContainUpperLimit;
unitItem
.isContainLowerLimit =
staItem
.isContainLowerLimit;
unitItem
.unitState =
false;
}
}
})
})
}
}
}
})
})
}
// 如果只有grid的情况下
})
// if(!this.gridSatus){
this.itemList = data;
console.log('item', this.itemList)
// }
} else {
}
console.log('录入表单', res)
},
// 单选
onGroupChange(code, rules, item, radioItem) {
console.log('单选', item)
item.value = radioItem.value;
item.valueTxt = radioItem.label;
// 单选选中状态显示
if (item.value == radioItem.value) {
radioItem.checked = !radioItem.checked;
if (!radioItem.checked) {
item.value = '';
item.valueTxt = '';
}
}
item.options.map(optItem => {
if (optItem.value != radioItem.value) {
optItem.checked = false;
}
})
if (rules) {
this.formatRules(rules, radioItem.checked, item)
}
},
// 规则处理
async formatRules(rules, checked, listItems) {
rules.map((item, ruleIndex) => {
let actions = this.formatAction(item.action);
try {
let boolean = this.formatCondition(item.condition);
// boolean规则为true的时候并且checked为false 则规则不生效
if (!checked && checked != undefined) {
if (boolean) {
boolean = false
}
}
console.log('[规则=boolean]', boolean)
console.log('[规则=actions]', actions)
this.itemList.items.find(listItem => {
actions.map(citem => {
//如果循环的actions规则里没有匹配上,先查询一下是否是实验室里的数据
if (listItem.code == citem) {
listItem.show = boolean;
if (!boolean) {
console.log('规则为false', boolean)
if (listItem.checked) {
listItem.checked = boolean;
if (listItem.rules) {
listItem.rules.map(listRules => {
let RulesActions = this
.formatAction(
listRules.action);
RulesActions.map(
rulesActionsItem => {
this.itemList.items
.map(newItem => {
if (newItem
.code ==
rulesActionsItem
) {
newItem
.show =
boolean
}
})
})
})
}
}
// 有关联的规则下查询一下规则下的item的规则里的显示状态,为true的情况下需要修改成return false;
// listItem.show = false;
if (listItem.rules) {
listItem.rules.map(listRule => {
let rulesAction = this.formatAction(
listRule.action);
if (listRule.action) {
rulesAction.map(rulesActItem => {
let newListItem = this
.itemList.items
.find(findItme =>
findItme
.code ==
rulesActItem);
if (newListItem.show) {
newListItem.show =
false;
}
})
}
})
}
} else {
if (listItem.rules) {
listItem.rules.map(listRule => {
let rulesAction = this.formatAction(
listRule.action);
let rulesBoolean = this
.formatCondition(listRule
.condition);
if (listRule.action) {
rulesAction.map(rulesActItem => {
let newListItem = this
.itemList.items
.find(findItme =>
findItme
.code ==
rulesActItem);
newListItem.show =
rulesBoolean;
})
}
})
}
}
} else {
// actions规则里
if (listItem.type == '17') {
let labItems = listItem.labInfo.labItems;
// 实验规则处理
// 实验室规则执行规则初始的时候会把实验室下的每个labitem的code返回
// 规则执行后 先判断当前实验室的item的显示是否为false ,的话则需要把当前item改为true
// 实验室的item为true的情况下
console.log('citem', citem)
if (!listItem.show) {
labItems.map(labItem => {
if (citem == labItem.code) {
labItem.show = boolean;
listItem.show = boolean;
}
})
} else {
labItems.map(labItem => {
if (citem == labItem.code) {
labItem.show = boolean;
listItem.show = boolean;
}
})
}
}
}
})
})
// console.log('数据',this.itemList.items)
} catch (error) {}
})
},
/**
* @param {Object} str
* type为99的时候单独处理
*/
getRuleType(str) {
let reg = /\$\{(.+?)\}/g;
let result = null;
result = reg.exec(str);
let value = null;
value = this.findItemValue(result[1]);
// return value
},
/**
* @param {Object} str
* @param {Object} checkItem
* 改造成直接判断是否为true/false
*/
formatCondition(str, checkItem) {
let reg = /\$\{(.+?)\}/g;
let result = null;
result = reg.exec(str);
let value = null;
value = this.findItemValue(result[1]);
const stringObj = this.getContentAfterEquals(str);
str = str.replace(result[0], value + '=');
let contrastValue = false;
if (stringObj.matchs == '==') {
contrastValue = value == stringObj.content;
} else if (stringObj.matchs == '!=') {
contrastValue = value != stringObj.content;
} else if (stringObj.matchs == '>=') {
contrastValue = value >= stringObj.content;
} else if (stringObj.matchs == '<=') {
contrastValue = value <= stringObj.content;
}
return contrastValue
},
formatAction(str) {
let array = str.split('|');
return array;
},
findItemValue(field) {
console.log('field', field)
let str = null;
this.itemList.items.find(item => {
if (item.code == field) {
str = item.value;
}
})
return str;
},
getContentAfterEquals(str) {
// const match = str.match(/==(.*)/);
// console.log('match', match)
const regex = /([^=!<>]+)([=!<>]+)([^=!<>]+)/;
const matchs = str.match(regex);
console.log('matchs===', matchs)
if (matchs) {
return {
matchs: matchs[2].trim(),
content: matchs[3].trim()
};
}
return null;
// return matchs ? matchs[3].trim() : '';
},
evalFuntion(fn) {
let Fn = Function;
return new Fn(`return ${fn}`)()
},
// 登录
async submitClick(type) {
this.submitParam.subjId = this.subjInfo.subjId;
this.submitParam.sformId = this.subjInfo.sformId;
this.submitParam.svisitId = this.subjInfo.svisitId;
this.submitParam.sldId = this.normalOption.code;
if (type == 'preSubmit') {
this.submitParam.verify = true;
this.itemList.items.map(allItem => {
if (allItem.type == '12') {
allItem.gridInfo.gridData.map(allGrid => {
allGrid.items.map(allGridItem => {
if (allGridItem.querys != undefined) {
console.log('allGridItem', allGridItem)
// 删除之前提交的当前行的质疑字段
delete allGridItem["querys"]
}
})
})
}
})
} else {
this.submitParam.verify = false;
}
let array = [];
let isValidDateShow = true;
let timeTips = '请填写正确时间格式';
this.itemList.items.map(item => {
let object = {};
// object.id = item.itemId;
//
object.itemId = item.itemId;
object.code = item.code;
object.unit = '';
// 时间校验
if (item.type == '2') {
console.log('[shijian]', item.value)
if (item.value != '') {
// 输入的里没有UK 需要校验
if (!item.value.includes('UK')) {
let formatObj = this.getFormat(item.format);
console.log('可以输入未来')
if (!formatObj.futureStatus) {
var currentDate = new Date();
var newCurentDate = new Date(item.value)
// 比较日期
if (newCurentDate.getTime() > currentDate.getTime()) {
isValidDateShow = false;
timeTips = `日期不能大于[${edcYear}-${edcMonth}-${edcDate}],请检查后重新输入`
} else {
}
}
}
}
}
if (item.units) {
if (item.units.length == 1) {
object.unit = item.units[0].value;
} else {
object.unit = item.unit;
}
}
if (item.type == '6') {
if (Array.isArray(item.value)) {
object.value = item.value.join(',');
} else {
object.value = item.value
}
} else {
object.value = item.value;
}
object.na = item.na;
object.nd = item.nd;
object.uk = item.uk;
if (type === 'submit') {
object.querys = item.querys;
}
if (type === 'preSubmit') {
item.querys = [];
}
if (item.type == '12') {
let newGridData = []
item.gridInfo.gridData.map(val => {
let gridObj = {};
gridObj.fillStatus = 2;
gridObj.gridNum = val.gridNum;
gridObj.items = []
val.items.map(vitem => {
let gridDataObj = {};
if (vitem.type === '6' && Array.isArray(vitem.value)) {
vitem.value = vitem.value.join(',')
}
gridDataObj.itemId = vitem.itemId;
gridDataObj.sitemId = vitem.sitemId;
gridDataObj.code = vitem.code;
gridDataObj.value = vitem.value;
gridDataObj.valueTxt = vitem.valueTxt;
gridDataObj.nd = vitem.nd;
gridDataObj.na = vitem.na;
gridDataObj.uk = vitem.uk;
gridDataObj.querys = vitem.querys;
if (vitem.show) {
gridObj.items.push(gridDataObj)
}
})
newGridData.push(gridObj)
})
// object.gridData = newGridData;
object.gridData = [];
object.na = item.na || false;
object.nd = item.nd || false;
object.uk = item.uk || false;
}
if (item.type == '17') {
// Too
// 正常值id 没有接口暂时写成0
object.sldId = this.normalOption.code;
object.labData = {};
object.labData.stdId = this.normalOption.code;
let temp = [];
console.log('提交------', item.labInfo.labItems)
item.labInfo.labItems.map(labItems => {
let obj = {};
obj.itemId = labItems.itemId;
obj.sitemId = "0";
obj.code = labItems.code;
obj.na = labItems.na || false;
obj.nd = labItems.nd || false;
obj.uk = labItems.uk || false;
obj.value = labItems.value;
obj.unit = labItems.unit;
obj.lbHighOrLow = labItems.lbHighOrLow;
obj.lbLowerLimit = labItems.lbLowerLimit;
obj.lbRemark = labItems.lbRemark;
obj.lbRemark2 = labItems.lbRemark2;
obj.lbRemark3 = labItems.lbRemark3;
obj.lbResultId = labItems.lbResultId;
obj.lbResultTxt = labItems.lbResultTxt;
obj.lbTypeId = labItems.lbTypeId;
obj.lbTypeTxt = labItems.lbTypeTxt;
obj.lbUpperLimit = labItems.lbUpperLimit;
if (labItems.query != undefined) {
obj.querys = labItems.query.querys;
}
temp.push(obj)
})
object.labData.items = temp;
}
// 下拉
if (item.options) {
item.options.map(optItem => {
if (optItem.value == object.value) {
object.valueTxt = optItem.label
}
})
}
if (item.show) {
array.push(object);
}
})
this.submitParam.data = array;
// console.log('isValidDateShow', isValidDateShow)
if (!isValidDateShow) {
uni.showToast({
title: timeTips,
icon: "none"
})
} else {
console.log('array', array)
this.loading = true;
uni.showLoading({
title: '提交中',
mask: true
});
console.log('提交数据submitParam', this.submitParam)
let res = await Api.submitItemInfosAction(this.submitParam)
const {
code,
data,
msg
} = res;
if (code == 100) {
uni.hideLoading();
setTimeout(() => {
// const pages = getCurrentPages() // 获取所有页面栈实例列表
// const prevPage = pages[pages.length - 2] // 上一页面的数据
// // 通过调用上一页的方法实现
// prevPage.$vm.getNavigateBack() // e是需要传递的数据
// uni.navigateBack({
// delta: 1
// })
uni.redirectTo({
url: `/pagesA/data/detali?subjInfo=${encodeURIComponent(JSON.stringify(this.subjInfo))}`
})
}, 1100)
} else if (code == 201) {
// 质疑
uni.hideLoading();
this.loading = false;
this.modal.type = 'success';
this.modal.show = true;
this.showCancelButton = true;
this.modal.content = '您当前有 尚未填写或有 不符合要求的内容,您确认要保存吗?';
this.itemList.items.map(item => {
data.map(dataItem => {
if (item.code == dataItem.code) {
if (dataItem.infos != undefined) {
item.querys = dataItem.infos;
} else {
// grid质疑处理
if (item.type == 12) {
const gridData = item.gridInfo.gridData;
gridData.map((gridItem, gridIndex) => {
// 提交grid质疑数据
let gridQuery = dataItem.verifys
let querysAll = [];
gridItem.querysLength = 0;
gridQuery.map((queryItem, queryIndex) => {
// 用提交的行索引和质疑数组索引匹配
if (gridIndex == queryIndex) {
console.log('数据质疑grid',
queryItem)
if (queryItem.length > 0) {
// gridItem.items是所有gridData下所有item
// queryItem是grid每一行后端返回的质疑数据
gridItem.items.map(
gridItems => {
queryItem.map(
queryItems => {
// console.log('queryItems',queryItems)
// 循环后端质疑后端数据 gridItem下的code和质疑的code对比 如果一致显示质疑
if (gridItems
.code ==
queryItems
.code
) {
gridItems
.querys =
queryItems
.infos;
//将某一行有质疑的item数据添加的本行内的数组里querysAll
querysAll
.push(
...
queryItems
.infos
)
}
})
})
}
}
})
gridItem.querysLength = querysAll.length;
});
}
}
} else {
// 实验室处理质疑
if (item.type == 17) {
// 6.0实验室质疑处理方式
// if(item.code == dataItem.code){
// item.querys = dataItem.infos;
// }
var labItems = item.labInfo.labItems;
console.log('实验室质疑', dataItem)
labItems.map((labItem) => {
if (labItem.code == dataItem.code) {
labItem.query = {};
labItem.query.querys = dataItem.infos;
}
});
console.log('实验室', labItems)
}
}
})
})
} else {
}
}
},
/**
* 弹窗确认
*/
modalConfirm() {
this.modal.show = false;
if (this.modal.type == 'success') {
this.submitClick('submit');
} else if (this.modal.type == 'grid') {
// modal.gridIndex
// grid行录入数据删除
this.itemList.items.map(item => {
if (item.type == '12') {
let gridInfo = item.gridInfo;
let gridData = gridInfo.gridData;
console.log('gridData', gridData.length)
if (gridData.length > 0) {
gridData.map((gridItem, gridIndex) => {
if (gridIndex == this.modal.gridIndex) {
item.gridInfo.gridData.splice(gridIndex, 1)
}
})
}
}
})
}
},
/**
* 弹窗取消
*/
modalClose() {
this.modal.show = false;
},
/**
* @param {Object} value
* 日期
*/
onDateChange(value) {
console.log('日期', value)
this.itemList.items.map(item => {
if (item.itemId == value.itemId) {
item.value = value.value;
item.valueTxt = value.value;
}
})
console.log('日期赋值', this.itemList.items)
},
/**
* @param {Object} item
* 新增grid
*/
onGtidAdd(item) {
console.log('新增', item)
let gridItems = item.gridInfo.gridItems;
uni.navigateTo({
url: '/pagesA/data/inputGrid?obj=' + encodeURIComponent(JSON.stringify(gridItems))
})
},
/**
* @param {Object} item
* grid详情
*/
onDetilChange(item) {
console.log('grid详情')
uni.showModal({
title: '提示',
content: '当前数据未提交,请先提交数据后,填写内容',
showCancel: false,
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})
},
/**
* @param {Object} item
* grid编辑
*/
onEditChange(obj) {
console.log('grid编辑', obj)
uni.navigateTo({
url: '/pagesA/data/inputGrid?pathStaus=inputEdit' + '&gridNum=' + obj.item.gridNum + '&obj=' +
encodeURIComponent(JSON.stringify(obj.item.items))
})
},
/**
* @param {Object} item
* grid删除
*/
onDeleteChange(index) {
console.log('grid删除', index)
this.modal.content = '确认要删除当前数据吗?';
this.modal.type = 'grid'
this.modal.show = true;
this.modal.gridIndex = index;
},
/**
* @param {Object} e
* grid录入返回内容回调方法
*/
getNavigateBack(e) {
console.log('this.itemList', this.itemList)
let param = e
this.itemList.items.map(item => {
if (item.type == '12') {
let gridData = item.gridInfo.gridData;
console.log('gridData', gridData.length)
let obj = {};
// gridData为空的时候从1开始
if (param.gridNum == null) {
console.log('新增grid行', gridData.length)
// 新增grid行
obj.gridNum = Number(gridData.length) + 1;
obj.items = param.item;
obj.fillStatus = '2'
obj.gridSatus = 0
gridData.push(obj)
} else {
// 编辑grid行
console.log('编辑grid行')
gridData.map(gridItem => {
if (gridItem.gridNum == param.gridNum) {
gridItem.items = param.item
console.log('gridItem', gridItem)
}
})
}
console.log('gridData', gridData)
}
})
},
/**
* 正常值下拉显示
*/
onLabsChange() {
this.normalOption.show = !this.normalOption.show;
},
/**
* @param {Object} rules
* 输入规则处理
*/
onInputBlu(rules) {
if (rules) {
this.formatRules(rules)
}
},
/**
* @param {Object} obj
* @param {Object} item
* 单个label保存回调
*/
onLabelConfirm(obj) {
this.itemList.items.map(item => {
if (item.type == '17') {
let labItems = item.labInfo.labItems;
labItems.map((labItem, labIndex) => {
if (obj.labelIndex == labIndex) {
console.log('保存实验室', labItem)
Object.assign(labItem, obj.labelItem);
console.log('保存实验室1', labIndex, '----', labItem)
}
})
}
})
},
/**
* 多选为type-99处理
*/
onCheked(item) {
console.log('item', item)
item.checked = !item.checked;
if (item.checked) {
item.value = '99';
} else {
item.value = '';
}
if (item.rules) {
this.formatRules(item.rules)
}
},
// 正常值选择
async onOption(item, listItem) {
this.normalOption.optionText = item.label;
this.normalOption.show = false;
this.normalOption.code = item.value;
let labItems = listItem.labInfo.labItems;
let stdRes = await this.getStdItemInfos();
if (stdRes.code == 100) {
let stdData = stdRes.data;
console.log('实验室', stdData)
// 正常值匹配单位
stdData.map(dataItem => {
labItems.map(lableItem => {
if (dataItem.code == lableItem.code) {
// 选择空白恢复初始
if (item.value == 0) {
lableItem.unit = '';
lableItem.lbLowerLimit = '';
lableItem.lbUpperLimit = '';
lableItem.isContainLowerLimit = '';
lableItem.isContainUpperLimit = '';
lableItem.unitState = true;
return
}
// 判断值是否为空,空值不赋值
if (dataItem.stdList[0].lowerLimit != null && dataItem.stdList[0]
.upperLimit != null) {
lableItem.unit = dataItem.stdList[0].unit;
lableItem.lbLowerLimit = dataItem.stdList[0].lowerLimit;
lableItem.lbUpperLimit = dataItem.stdList[0].upperLimit;
lableItem.isContainLowerLimit = dataItem.stdList[0]
.isContainLowerLimit;
lableItem.isContainUpperLimit = dataItem.stdList[0]
.isContainUpperLimit;
lableItem.unitState = false;
}
let stdListLength = dataItem.stdList.length;
// 处理多单位的上线下线匹配问题
if (stdListLength > 1) {
if (lableItem.units || lableItem.units.length > 1) {
lableItem.units.map(unitItem => {
console.log('unitItem', unitItem)
dataItem.stdList.map(staItem => {
if (staItem.upperLimit != null &&
staItem.lowerLimit != null) {
if (unitItem.label == staItem
.unit) {
unitItem.lowerLimit = staItem
.lowerLimit;
unitItem.upperLimit = staItem
.upperLimit;
unitItem.isContainUpperLimit =
staItem
.isContainUpperLimit;
unitItem.isContainLowerLimit =
staItem
.isContainLowerLimit;
unitItem.unitState = false;
}
}
})
})
}
}
}
})
})
this.$forceUpdate()
}
},
/**
* @param {Object} item
* 正常值接口
*/
async getStdItemInfos(item) {
console.log('subjInfo', this.subjInfo)
let res = await Api.stdItemInfos({
subjId: this.subjInfo.subjId,
sformId: this.subjInfo.sformId,
stdId: this.normalOption.code
})
let {
code,
data,
msg
} = res;
console.log('正常值', res)
console.log('正常值', res)
return res
},
onBack() {
uni.navigateBack({
delta: 1
})
},
/**
* @param {Object} code
* @param {Object} options
* @param {Object} rules
* 下拉选择
*/
pickerClick(code, options, rules) {
this.saveRules = rules;
this.pickerShow = true;
this.picker.code = code;
this.picker.columns[0] = options;
},
/**
* @param {Object} e
* 确认下拉
*/
pickerConfirm(e) {
this.itemList.items.map(item => {
if (item.code == this.picker.code) {
item.value = e.value[0].value;
item.label = e.value[0].label;
item.valueTxt = e.value[0].label;
}
})
let arr = JSON.stringify(this.saveRules)
if (arr) {
this.formatRules(this.saveRules);
this.saveRules = {}
}
this.pickerShow = false;
},
/**
* 关闭下拉选择
*/
pickerClose() {
this.pickerShow = false;
},
/**
* @param {Object} dateString
* 校验时间格式
*/
isValidDate(dateString) {
// 正则表达式匹配大多数常见日期格式
var regex = /^\d{1,4}[./-]\d{1,2}[./-]\d{1,4}$/;
// 测试日期格式是否正确
var isValid = regex.test(dateString);
// 如果格式正确,再尝试将其转换为日期
if (isValid) {
var date = new Date(dateString);
// 检查转换后的日期是否有效
isValid = !isNaN(date.getTime());
}
return isValid;
},
/**
* 日期格式处理
*
*/
getFormat(format) {
let formatArr = format.split(patterns);
console.log('formatArr', formatArr)
let newFormat = 'yyyy-MM-dd';
let futureStatus = false;
// 判断转换数组的长度判断格式
// 6位带时分秒
if (formatArr.length == 6) {
// 判断是可以输入未来的
newFormat = 'yyyy-mm-dd hh:MM:ss';
if (formatArr[0].includes('FU')) {
futureStatus = true;
}
} else if (formatArr.length == 5) {
newFormat = 'yyyy-mm-dd hh:MM';
if (formatArr[0].includes('FU')) {
futureStatus = true;
}
} else if (formatArr.length == 3) {
newFormat = 'yyyy-mm-dd';
if (formatArr[0].includes('FU')) {
futureStatus = true;
}
} else if (formatArr.length == 2) {
// 长度是2的可能是时分,月日,
if (formatArr[0] == 'yyyy' || formatArr[0] == 'YYYY') {
newFormat = 'yyyy-mm';
} else if (formatArr[0] == 'MM' || formatArr[0] == 'mm') {
newFormat = 'mm-dd';
} else if (formatArr[0] == 'HH' || formatArr[0] == 'hh') {
newFormat = 'hh:mm';
}
if (formatArr[0].includes('FU')) {
futureStatus = true;
}
}
return {
futureStatus: futureStatus,
newFormat: newFormat
}
},
/**
* 图片识别功能
*
*/
onIdentify() {
uni.navigateTo({
url: '/pagesA/photograph/index?itemList=' + encodeURIComponent(JSON.stringify(this.itemList)) +
'&subjInfo=' + encodeURIComponent(JSON.stringify(this.subjInfo)) + "&normalOption=" +
encodeURIComponent(JSON.stringify(this.normalOption)) + '&path=input'
})
},
/**
* 录入里的输入宽的宽度处理
*/
publicWidth(level) {
let name = 'data_box_list_center_public'
if (level == 2) {
name = 'data_box_list_center_public_level'
} else if (name == 3) {
name = 'data_box_list_center_public_level'
} else if (name == 4) {
name = 'data_box_list_center_public_level'
} else if (name == 5) {
name = 'data_box_list_center_public_level'
}
return data_box_list_center_public_level
},
/**
* @param {Object} rules
* 输入规则处理
*/
onInputBlur(rules) {
if (rules) {
this.formatRules(rules)
}
},
}
}
</script>
<style lang="scss" scoped>
.dataInput {
width: 100%;
height: 100vh;
background: #eee;
overflow: hidden;
}
.data_box {
width: 100%;
// margin-top: 36.5%;
background: #eee;
height: calc(100% - 60px);
overflow: hidden;
overflow-y: auto;
padding-bottom: 20px;
position: relative;
top: 52px;
padding-bottom: 100rpx;
}
.data_box_list {
// width: 97%;
margin: 0 auto;
padding: 20rpx 20rpx;
background-color: #ffffff;
border-radius: 6rpx;
margin-bottom: 20rpx;
}
::v-deep .u-navbar__content {
top: -1px;
}
.data_box_list_title {
display: flex;
align-items: center;
flex-direction: row;
& .data_box_list_title_left {
color: red;
}
}
.data_box_list_title_no {
margin-left: 0 !important;
}
.data_box_list_title_right {
margin-left: 10rpx;
font-size: 28rpx;
display: flex;
align-items: center;
}
.data_box_list_center {
margin-top: 10rpx;
// padding-bottom: 20rpx;
}
.data_box_list_center_public {
padding: 0 20rpx;
// margin-top: 20rpx;
width: 92%;
}
.data_box_list_center_public_input {
width: 100%;
height: 60rpx;
border: 2rpx solid #767676;
border-radius: 6rpx;
padding-left: 20rpx;
font-size: 30rpx;
color: #333;
}
.radioBox {
// width: 100%;
display: flex;
align-items: center;
flex-wrap: wrap !important;
justify-content: flex-start;
flex-direction: row;
}
.radioItem {
display: flex;
align-items: center;
margin-right: 30rpx;
margin-top: 10rpx;
flex-direction: row;
// margin-top: 20rpx;
}
.radio_Portrait {
width: 100%;
}
.radioIcon {
width: 30rpx;
height: 30rpx;
border: 2rpx solid #767676;
border-radius: 100%;
}
.radioIconSelect {
color: #fff;
text-align: center;
font-size: 28rpx;
line-height: 30rpx;
background: #009487 !important;
}
.radioText {
font-size: 30rpx;
line-height: 55rpx;
margin-left: 10rpx;
font-size: 28rpx;
// width: 97%;
}
.check {
width: 30rpx;
height: 30rpx;
border: 1rpx solid #767676;
border-radius: 4rpx;
margin-right: 20rpx;
margin-left: 6px;
}
.checkSelsect {
color: #fff;
text-align: center;
font-size: 18rpx;
line-height: 30rpx;
background: #009487 !important;
}
.data_box_list_center_public_textarea {
height: 400rpx;
}
.data_box_list_center_public_unit {
display: flex;
flex-direction: row;
align-items: center;
}
.data_box_list_center_unit {
margin-left: 10rpx;
font-size: 28rpx;
}
.data_box_list_center_public_picker {
height: 60rpx;
border: 1rpx solid #767676;
border-radius: 6rpx;
line-height: 60rpx;
display: flex;
justify-content: space-between;
flex-direction: row;
align-items: center;
width: 46%;
}
.data_box_list_center_public_picker_left {
width: 90%;
font-size: 26rpx;
& view {
width: 100%;
overflow: hidden;
/* 确保超出容器的文本被裁剪 */
white-space: nowrap;
/* 确保文本在一行内显示 */
text-overflow: ellipsis;
}
}
.data_box_list_center_public_picker_right {
margin-right: 20rpx;
}
.data_btn {
width: 100%;
position: fixed;
bottom: 0%;
height: 150rpx;
background: #fff;
}
.login_input_list_btn {
width: 60%;
margin-left: 20%;
margin-top: 60rpx;
}
.data_box_list_title_grid {
// display: flex;
// flex-direction: row;
// justify-content: space-between;
// align-items: center;
}
.grid_left {
margin-left: 24rpx;
padding-top: 20rpx;
}
.grid_right {
width: 60rpx;
height: 60rpx;
background: #009487;
border-radius: 100%;
justify-content: center;
display: flex;
align-items: center;
margin-right: 20rpx;
}
.components_emdGrid {
// height: 30px;
// background: darkgreen;
}
.data_list_title_label {
display: flex;
justify-content: space-between;
flex-direction: row;
align-items: center;
padding-bottom: 30rpx;
}
.labelStyleOptions {
background-color: darkgrey;
}
.labsOption {
position: relative;
right: 5px;
display: inline-block;
top: 5px;
}
.labsOption_Box {
// display: flex;
width: 300rpx;
height: 55rpx;
border: 1rpx solid #767676;
border-radius: 4rpx;
line-height: 60rpx;
font-size: 30rpx;
padding-left: 10rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
.labsOption_Icon {
margin-right: 10rpx;
}
.labsSelect {
width: 310rpx;
min-height: 200rpx;
position: absolute;
z-index: 10;
top: 16px;
& .select {
width: 100%;
max-height: 350rpx;
border: 1rpx solid #767676;
border-radius: 4rpx;
background-color: #fff;
position: absolute;
top: 14px;
z-index: 13;
.selectBox {
width: 100%;
height: 100%;
overflow-y: auto;
}
}
}
.selectItem {
width: 100%;
text-align: center;
line-height: 30rpx;
font-size: 30rpx;
color: #606266;
padding: 15rpx 0;
border-bottom: 1rpx solid #767676;
}
.selectItem:first-child {
padding: 25rpx 0;
}
.selectItem:last-child {
border-bottom: none;
}
.selectItem:hover {
background: #009487;
color: #fff;
}
.selectItemHover {
background: #009487;
color: #fff;
}
.components_emdLabel {
width: 100%;
margin: 0 auto;
// margin-top: 25rpx;
}
.query {
display: block;
margin-top: 20rpx;
}
.queryList {
// padding: 0 20rpx;
display: flex;
align-items: center;
margin-top: 10rpx;
}
.queryIcon {
width: 10rpx;
height: 10rpx;
background-color: #ef3434;
border-radius: 100%;
margin-right: 10rpx;
}
.queryText {
width: calc(100% - 10px);
color: #ef3434;
font-size: 14px;
}
.grid_tips {
width: 90%;
margin: 0 auto;
background: #faf2da;
font-size: 25rpx;
padding: 22rpx;
margin-top: 7px;
border-radius: 6rpx;
color: #6d6d6d;
line-height: 22rpx;
display: flex;
align-items: center;
}
.grid_tips_center {
margin-left: 10rpx;
line-height: 40rpx;
}
.detali_box_title {
background-color: #32a99f;
display: flex;
justify-content: space-between;
border-bottom: 1px solid #eee;
width: 100%;
position: fixed;
top: 10.5%;
z-index: 10;
height: 100rpx;
align-items: center;
}
.mainTitle {
display: flex;
flex-direction: row;
align-items: center;
margin-left: 20rpx;
color: #fff;
& text {
font-size: 30rpx;
}
}
.button-bar {
width: 100rpx;
height: 60rpx;
background-color: #fff;
color: #009487;
line-height: 60rpx;
font-size: 30rpx;
border-radius: 6rpx;
text-align: center;
margin-right: 20rpx;
}
::v-deep .u-checkbox {
padding: 20rpx 0 !important;
}
::v-deep .u-textarea {
height: 300rpx !important;
}
.main_nav {
width: 100%;
height: 300rpx;
display: flex;
justify-content: space-between;
flex-direction: row;
align-items: center;
position: fixed;
top: 0;
z-index: 99;
background-color: #32a99f;
align-items: center;
}
.main_nav_left {
width: 100%;
display: flex;
align-items: center;
flex-direction: row;
margin-top: 150rpx;
}
.main_nav_logo {
margin-left: 30rpx;
}
// .main_nav_title {
// margin-left: 10rpx;
// color: #ffffff;
// }
.main_nav_title {
margin-left: 10rpx;
color: #ffffff;
width: 80%;
text-align: center;
}
.main_nav_right {
// margin-right: 20rpx;
// margin-top: 150rpx;
}
::v-deep .u-checkbox-group--row {
flex-wrap: wrap;
}
::v-deep .u-checkbox-label--left {
margin-right: 13px !important;
}
.leverClass {
margin-left: 30rpx;
}
.data_box_grid {
padding: 0;
}
::v-deep .u-input--square {
border: 2rpx solid #767676 !important;
font-size: 30rpx !important;
font-weight: 400 !important;
padding-top: 2px !important;
padding-bottom: 2px !important;
}
::v-deep .u-textarea {
border: 2rpx solid #767676 !important;
font-size: 30rpx !important;
font-weight: 400 !important;
}
::v-deep .u-checkbox__icon-wrap--square {
border: 2rpx solid #767676 !important;
}
.mainheader {
width: 100%;
padding: 20rpx;
background-color: rgba(0, 148, 135, 0.1);
position: fixed;
top: 0;
display: flex;
justify-content: space-between;
box-sizing: border-box;
align-items: center;
}
.mainTitle_left {
display: flex;
align-items: flex-start;
margin-right: 20rpx;
box-sizing: border-box;
}
.mainTitle_rigth {
width: 104rpx;
background: #009487;
color: #fff;
font-size: 28rpx;
line-height: 65rpx;
text-align: center;
border-radius: 6rpx;
height: 65rpx;
box-sizing: border-box;
}
.mainTitle_right_box {
display: flex;
}
.mainTitle_rigth_identify {
width: 104rpx;
border-radius: 6rpx;
font-size: 28rpx;
line-height: 65rpx;
text-align: center;
background-color: #fff;
margin-right: 10rpx;
height: 65rpx;
}
.u-nav-main-right-title {
font-size: 32rpx;
}
.data_box_list_center_Count {
width: 49%;
}
.data_box_list_center_widht {
width: 46%;
}
.data_box_list_center_public_level {
width: 88%;
}
</style>