<!--case/pages/createCase/createCase.wxml-->
<!-- <navBar navName="创建病例"></navBar> -->
<view class="ui-navigatorbar" style="background: #FFFFFF">
    <van-icon name="arrow-left" bindtap="goBack" class="ui-navigatorbar-back" />
    <view class="ui-title">{{navName}}</view>
</view>

<view class="page">
    <van-tabs active="{{ active }}" wrap-class="tabwrap" use-before-change="{{ true }}" custom-class="tabbox" bind:before-change="onBeforeChange">
        <van-tab title="基本信息" class="vantab">
            <view class="basic {{!showSaveBtn?'active':''}}" >
                <view class="basiccon">
                    <view class="row">
                        <view class="left">
                            患者姓名(首字母大写)<text class="red">*</text>
                        </view>
                        <view class="right">
                            <input type="text" value="{{case.name}}" bindinput="handleIpt" class="ipt" data-id="name" placeholder="请输入" 
                            placeholder-class="placeholder" disabled="{{!showSaveBtn}}"/>
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">
                            患者ID号<text class="red">*</text>
                        </view>
                        <view class="right">
                            <input type="text" value="{{case.uid}}" bindinput="handleIpt" class="ipt" data-id="uid" placeholder="请输入" placeholder-class="placeholder" disabled="{{!showSaveBtn}}"/>
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">
                            性别<text class="red">*</text>
                        </view>
                        <view class="right">
                            <van-radio-group value="{{ case.sex }}" bind:change="onChange" 
                             disabled="{{!showSaveBtn}}"
                             direction="horizontal">
                                <van-radio name="{{1}}">男</van-radio>
                                <van-radio name="{{2}}">女</van-radio>
                            </van-radio-group>
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">
                            年龄<text class="red">*</text>
                        </view>
                        <view class="right">
                            <input type="number" value="{{case.age}}" bindinput="handleIpt" class="ipt" data-id="age" placeholder="请输入" placeholder-class="placeholder" disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">
                            入院时间<text class="red">*</text>
                        </view>
                        <view class="right" bind:tap="openTime">
                            <input type="text" value="{{case.admissionTime}}" class="ipt" placeholder="请输入" placeholder-class="placeholder" disabled />
                            <van-icon name="arrow" color="#83858a" size="38rpx" class="righticon" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">
                            病例类型<text class="red">*</text>
                        </view>
                        <view class="right" bind:tap="openType">
                            <input type="text" value="{{typeName}}" class="ipt" placeholder="请输入" placeholder-class="placeholder" disabled />
                            <van-icon name="arrow" color="#83858a" size="38rpx" class="righticon" />
                        </view>
                    </view>
                    <view class="row" style="flex-direction: column;">
                        <view class="left">
                            病案照片(可上传1-6张)<text class="red">*</text>
                        </view>
                        <view class="uploadbox">
                            <van-uploader file-list="{{ fileList_basic }}" name="basic" 
                            deletable="{{showSaveBtn}}"
                            show-upload="{{showSaveBtn}}"
                            bind:delete="deleteImg" max-count="6" multiple bind:after-read="afterRead" upload-text="上传" upload-icon="{{img_host+'/upload.png'}}" />
                        </view>
                    </view>
                </view>
                <view class="tip" style="padding-bottom: 130rpx;">注意：“病案首页”需包含患者住院号或姓名</view>
                <view class="btnbox" wx:if="{{showSaveBtn}}">
                    <view class="btn" bind:tap="saveBasic">下一步</view>
                 </view>
            </view>
          
        </van-tab>
        <van-tab title="临床资料" disabled="{{disable_ziliao}}">
            <view class="basic {{!showSaveBtn?'active':''}}" >
         
                <view class="ziliao"  wx:if="{{active!=0}}" >
                    <view class="row" style="flex-direction: column;overflow: hidden;position: relative;">
                        <view class="left" style="font-weight:bold">
                            病历摘要<text class="red"></text>
                        </view>
                        <textarea value="{{case.abstractStr}}" 
                         disabled="{{!showSaveBtn}}"
                          class="textArea"
                          placeholder="请输入病历摘要"
                          bind:input="onChangeAbstract"
                          bind:change="onChangeAbstract"
                          placeholder-style="color:rgba(0,0,0,0.25)"
                          confirm-type="done"
                          maxlength="500" 	auto-height="{{true}}"/>
                          <view class="word">{{wordLength}}/500</view>
                        <!-- <van-field value="{{case.abstractStr}}" 
                        name="abstractStr" label="" type="textarea" placeholder="请输入病历摘要" show-word-limit autosize="{{minHeight}}" border="{{ false }}" 
                        custom-style="font-size:15px;min-height:100px;background:red;word-wrap:break-word;word-break: break-all;" bind:input="onChangeAbstract" maxlength="500" /> -->
                    </view>
                 
                    <view class="row" style="flex-direction: column;" wx:if="{{!(fileList_abstract.length==0 && !showSaveBtn)}}">
                        <view class="left" style="font-weight:bold">
                            病历摘要图片(可上传1-6张)<text class="red"></text>
                        </view>
                        <view class="uploadbox">
                            <van-uploader file-list="{{ fileList_abstract }}" name="abstract" multiple max-count="6" 
                            deletable="{{showSaveBtn}}" 
                            show-upload="{{showSaveBtn}}"
                            bind:delete="deleteImg" bind:after-read="afterRead" upload-text="上传" upload-icon="{{img_host+'/upload.png'}}" />
                        </view>
                    </view>
                </view>
                <view class="btnbox" wx:if="{{showSaveBtn}}">
                    <view class="btn" bind:tap="saveAbstract">下一步</view>
                 </view>
                 <view class="tip" >注意：病历摘要，文字填写或者上传图片，二选一</view>
            </view>
        </van-tab>
        <van-tab title="DPMAS治疗记录" disabled="{{disable_record}}">
            <view class="basic {{!showSaveBtn?'active':''}}">
                <view class="recordcon">
                    <view class="record" wx:for="{{case.dpmas}}" wx:key="index">
                        <view class="title">
                            <view class="titlename">
                                <view class="bar"></view>
                                <view class="recordtime">第{{index+1}}次治疗</view>
                            </view>
                            <van-icon name="delete-o" size="22" bind:tap="confirmDelRecord" data-index="{{index}}" color="#b9bbbb" wx:if="{{index!=0 && showSaveBtn}}" />
                        </view>
                        <view class="row">
                            <view class="left">
                                治疗时间<text class="red">*</text>
                            </view>
                            <view class="right" bind:tap="openDealTime" data-index="{{index}}">
                                <input type="text" value="{{dpmas_list[index].treatTime}}" class="ipt" placeholder="请选择时间" placeholder-class="placeholder" disabled />
                                <text wx:if="{{dpmas_list[index].treatTime}}">h</text>
                                <van-icon name="arrow" color="#83858a" size="38rpx" class="righticon" />
                            </view>
                        </view>
                        <view class="row" style="flex-direction: column;border:none">
                            <view class="left" style="white-space: normal;display: block;">
                                治疗凭证，如医嘱、收费明细、处方单(可上传1-3张)<text class="red">*</text>
                            </view>
                            <view class="uploadbox">
                                <van-uploader file-list="{{ dpmas_list[index].fileList}}" bind:delete="deleteImg" multiple max-count="3" name="{{'record'+index}}" 
                                show-upload="{{showSaveBtn}}"
                                deletable="{{showSaveBtn}}"
                                bind:after-read="afterRead" upload-text="上传" upload-icon="{{img_host+'/upload.png'}}" />
                            </view>
                        </view>
                    </view>
                    <view class="addrecord" bind:tap="addRecord" wx:if="{{showSaveBtn}}">
                        <van-icon name="plus" size="38rpx" />
                        <view class="recordText">增加记录</view>
                    </view>
                </view>
                <view class="tip" style="padding-bottom: 120rpx;">
                    <text>
                        注意：“DPMAS治疗凭证”照片需包含患者住院号或姓名
                        1.4次及以上疗程化病例，每次治疗对应一张凭证照片；
                        2.早前期（INR≤1.5）的病例，上传第一次DPMAS治疗前最新的“INR检验报告单”
                        3.早前期（INR≤1.5）的病例，DPMAS治疗时间不能晚于INR出报告时间24小时。
                    </text>
                </view>
                <view class="btnbox" wx:if="{{showSaveBtn}}">
                    <view class="btn" bind:tap="saveRecord">下一步</view>
                 </view>
                <!-- <view class="bottom">
                    <view class="savebtn">保 存</view>
                </view> -->
            </view>
        </van-tab>
        <van-tab title="实验室检测" disabled="{{disable_check}}">
            <view class="basic record {{!showSaveBtn?'active':''}}" style="background-color: #fff;">
                <view class="message"> (早前期为首次治疗前后、4次及以上为疗程化治疗前后)</view>
                <view class="row">
                    <view class="left">
                        治疗前检测时间<text class="red">*</text>
                    </view>
                    <view class="right" bind:tap="openHeadTime">
                        <input type="text" value="{{case.headTime}}" class="ipt" placeholder="请选择时间" placeholder-class="placeholder" disabled />
                        <text wx:if="{{case.headTime}}">h</text>
                        <van-icon name="arrow" color="#83858a" size="38rpx" class="righticon" />
                    </view>
                </view>
                <view class="row">
                    <view class="left">
                        治疗后检测时间<text class="red">*</text>
                    </view>
                    <view class="right" bind:tap="openAfterTime">
                        <input type="text" value="{{case.afterTime}}" class="ipt" placeholder="请选择时间" placeholder-class="placeholder" disabled />
                        <text wx:if="{{case.afterTime}}">h</text>
                        <van-icon name="arrow" color="#83858a" size="38rpx" class="righticon" />
                    </view>
                </view>
                <view class="table">
                    <view class="t_title">
                        总胆红素(TB-umol/L)<text class="red">*</text>
                    </view>
                    <view class="row">
                        <view class="left">治疗前</view>
                        <view class="right">
                            <input type="digit" value="{{case.headTb}}" bindinput="handleIpt" class="ipt" data-id="headTb" 
                            data-type="number"
                            placeholder="请输入" placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">治疗后</view>
                        <view class="right">
                            <input type="digit" value="{{case.afterTb}}" bindinput="handleIpt" class="ipt" data-id="afterTb" 
                            data-type="number"
                            placeholder="请输入" placeholder-class="placeholder"   disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                </view>
                <!-- <view class="table">
                    <view class="t_title">
                        直接胆红素(DB-umol/L)<text class="red"></text>
                    </view>
                    <view class="row">
                        <view class="left">治疗前</view>
                        <view class="right">
                            <input type="digit" value="{{case.headDb}}" bindinput="handleIpt" class="ipt" data-id="headDb" 
                            data-type="number" 
                            placeholder="请输入" placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">治疗后</view>
                        <view class="right">
                            <input type="digit" value="{{case.afterDb}}" bindinput="handleIpt" class="ipt" data-id="afterDb" 
                            data-type="number" placeholder="请输入" placeholder-class="placeholder"  disabled="{{!showSaveBtn}}"  />
                        </view>
                    </view>
                </view> -->
                <!-- <view class="table">
                    <view class="t_title">
                        间接胆红素(IB-umol/L)<text class="red"></text>
                    </view>
                    <view class="row">
                        <view class="left">治疗前</view>
                        <view class="right">
                            <input type="digit" value="{{case.headIb}}" bindinput="handleIpt" class="ipt" data-id="headIb" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">治疗后</view>
                        <view class="right">
                            <input type="digit" value="{{case.afterIb}}" bindinput="handleIpt" class="ipt" data-id="afterIb" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                </view> -->
                <view class="table">
                    <view class="t_title">
                        谷丙转氨酶(ALT-U/L)<text class="red">*</text>
                    </view>
                    <view class="row">
                        <view class="left">治疗前</view>
                        <view class="right">
                            <input type="digit" value="{{case.headAlt}}" bindinput="handleIpt" class="ipt" data-id="headAlt" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">治疗后</view>
                        <view class="right">
                            <input type="digit" value="{{case.afterAlt}}" bindinput="handleIpt" class="ipt" data-id="afterAlt" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}"  />
                        </view>
                    </view>
                </view>
                <view class="table">
                    <view class="t_title">
                        谷草转氨酶(AST-U/L)<text class="red">*</text>
                    </view>
                    <view class="row">
                        <view class="left">治疗前</view>
                        <view class="right">
                            <input type="digit" value="{{case.headAst}}" bindinput="handleIpt" class="ipt" data-id="headAst" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">治疗后</view>
                        <view class="right">
                            <input type="digit" value="{{case.afterAst}}" bindinput="handleIpt" class="ipt" data-id="afterAst" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}"/>
                        </view>
                    </view>
                </view>
                <view class="table">
                    <view class="t_title">
                        国际标准化比值(INR)<text class="red">*</text>
                    </view>
                    <view class="row">
                        <view class="left">治疗前</view>
                        <view class="right">
                            <input type="digit" value="{{case.headInr}}" bindinput="handleIpt" class="ipt" data-id="headInr" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">治疗后</view>
                        <view class="right">
                            <input type="digit" value="{{case.afterInr}}" bindinput="handleIpt" class="ipt" data-id="afterInr" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                </view>
                <view class="table">
                    <view class="t_title">
                        白蛋白(ALB-g/L)<text class="red"></text>
                    </view>
                    <view class="row">
                        <view class="left">治疗前</view>
                        <view class="right">
                            <input type="digit" value="{{case.headAlb}}" bindinput="handleIpt" class="ipt" data-id="headAlb" 
                            data-type="number"
                            placeholder="请输入" placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">治疗后</view>
                        <view class="right">
                            <input type="digit" value="{{case.afterAlb}}" bindinput="handleIpt" class="ipt" data-id="afterAlb" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"   disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                </view>
                <view class="table">
                    <view class="t_title">
                        凝血酶原活动度(PTA-%)<text class="red"></text>
                    </view>
                    <view class="row">
                        <view class="left">治疗前</view>
                        <view class="right">
                            <input type="digit" value="{{case.headPta}}" bindinput="handleIpt" class="ipt" data-id="headPta" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">治疗后</view>
                        <view class="right">
                            <input type="digit" value="{{case.afterPta}}" bindinput="handleIpt" class="ipt" data-id="afterPta" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                </view>
               
              
                
                <view class="table">
                    <view class="t_title">
                        白介素6(IL-6-ng/L)<text class="red"></text>
                    </view>
                    <view class="row">
                        <view class="left">治疗前</view>
                        <view class="right">
                            <input type="digit" value="{{case.headIl6}}" bindinput="handleIpt" class="ipt" data-id="headIl6" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}"  />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">治疗后</view>
                        <view class="right">
                            <input type="digit" value="{{case.afterIl6}}" bindinput="handleIpt" class="ipt" data-id="afterIl6" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                </view>
                <view class="table">
                    <view class="t_title">
                        肿瘤坏死因子α(TNF-α-μg/L)<text class="red"></text>
                    </view>
                    <view class="row">
                        <view class="left">治疗前</view>
                        <view class="right">
                            <input type="digit" value="{{case.headTnf}}" bindinput="handleIpt" class="ipt" data-id="headTnf" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                    <view class="row">
                        <view class="left">治疗后</view>
                        <view class="right">
                            <input type="digit" value="{{case.afterTnf}}" bindinput="handleIpt" class="ipt" data-id="afterTnf" placeholder="请输入" 
                            data-type="number"
                            placeholder-class="placeholder"  disabled="{{!showSaveBtn}}" />
                        </view>
                    </view>
                </view>
                <view class="row" style="flex-direction: column;border:none;padding-bottom:120rpx;">
                    <view class="left">
                        检查报告单(可上传1-6张)<text class="red">*</text>
                    </view>
                    <view class="red rederror">至少包含国际标准化比值 （INR）治疗前结果报告</view>
                    <view class="uploadbox">
                        <van-uploader file-list="{{ fileList_check }}" multiple bind:delete="deleteImg" max-count="6" name="check" 
                        show-upload="{{showSaveBtn}}"
                        deletable="{{showSaveBtn}}" bind:after-read="afterRead" upload-text="上传" upload-icon="{{img_host+'/upload.png'}}" />
                    </view>
                </view>
                <view class="btnbox" wx:if="{{showSaveBtn}}">
                    <view class="btn" bind:tap="save">提交</view>
                 </view>
            </view>
        </van-tab>
    </van-tabs>
    <!-- <view class="btnbox">
        <view class="btn" bind:tap="save">保存</view>
    </view> -->
</view>
<van-popup show="{{ showTime }}" round position="bottom" custom-style="height: 50%" bind:close="cancelDate" bind:cancel="cancelDate">
    <van-datetime-picker bind:confirm="confirmDate" title="{{time_title}}" bind:cancel="cancelDate" type="{{time_type}}" value="{{ currentDate }}" bind:input="onInput" max-date="{{ maxDate }}" min-date="{{ minDate }}" formatter="{{ formatter }}" />
</van-popup>


<dialog showDialog="{{showAttention}}" showCancel="{{false}}" bind:confirm="onConfirmAttention" title="注意" confirmText="马上去完善" message="信息并未完善，请继续填写"></dialog>
<dialog showDialog="{{showTip}}" showCancel="{{false}}" bind:confirm="onConfirmTip" title="注意" confirmText="确定" message="所提交病例治疗时间需要在2024年度"></dialog>
<dialog showDialog="{{showDel}}" showCancel="{{true}}" bind:confirm="onConfirmDel" bind:cancel="onCancelDel" title="删除记录" confirmText="确定" message="确定删除此条治疗记录吗？"></dialog>
<dialog showDialog="{{showDraft}}" title="注意" message="是否保存草稿？" confirmText="保存" bind:confirm="onConfirmDraft" bind:cancel="onCancelDraft">
</dialog>
<dialog showDialog="{{showUseDraft}}" title="提示" message="加载上次草稿？" showCancel="{{false}}" confirmText="确定" bind:confirm="onConfirmUseDraft" bind:cancel="onCancelUseDraft">
</dialog>
<van-popup show="{{ showType }}" round position="bottom" custom-style="height: 50%">
    <van-picker columns="{{ columns }}" default-index="{{case.caseType}}" title="请选择病例类型" bind:cancel="onCancelType" show-toolbar bind:confirm="onConfirmType" />

</van-popup>