<wxs src="../../../wxs/util-fun.wxs" module="util"></wxs>

<view>
  <view class="artical-title fc">
    {{info.title}}
  </view>
  <view class=" tc">
    <text> {{info.department}}</text>-
    <text> {{info.category}}</text>
    <i-icon type="flashlight" size="20" color="#80848f" />
    {{info.downloadCount}}
    <i-icon type="browse" size="20" color="#80848f" />
    {{info.viewCount}}
  </view>
  
  <view class="tc mt10 ">
    <i-button  bindtap="preview" class="bsmall"> 预览文件 </i-button>
    <i-button  bindtap="download" class="ml20 bsmall"> 下载文件</i-button>
    <i-button class="ml20 bsmall" bindtap="openDialog" data-id="confirmModal" wx:if="{{info.status==1 && isLeader == 2}}"> 审核文章</i-button>
    <i-button class="ml20 bsmall" bindtap="openDialog" data-id="publishModal" wx:if="{{info.status==2 && isLeader == 3}}"> 发布文章</i-button>
  </view>

  <view class="wxParse tc">
    <rich-text nodes="{{info.brief}}" space="emsp" ></rich-text>
  </view>

  <view wx:for="{{logs}}" wx:key="articalId" wx:for-index="index" class="mt20">
    <view wx:if="{{ index==0}}">
      <i-card extra="{{item.nickname}}" title="{{item.action}}" full wx:if="{{isLeader==2 && info.status==1}}">
        <view slot="content">操作描述: {{item.content}}
          <button class="fr" bindtap="confirm">审核</button>
        </view>
        <view slot="footer">
          操作时间:{{util.getDatetime(item.createAt)}}
        </view>
      </i-card>

      <i-card extra="{{item.nickname}}" title="{{item.action}}" full wx:elif="{{isLeader==3 && info.status==2}}">
        <view slot="content">操作描述: {{item.content}}
          <button class="fr" bindtap="publish">发布</button>
        </view>
        <view slot="footer">
          操作时间:{{util.getDatetime(item.createAt)}}
        </view>
      </i-card>

      <i-card extra="{{item.nickname}}" title="{{item.action}}" full wx:else>
        <view slot="content">操作描述: {{item.content}}
          <button class="fr" bindtap="confirm">审核</button>
        </view>
        <view slot="footer">操作时间:{{util.getDatetime(item.createAt)}}</view>
      </i-card>
    </view>

    <view wx:else>
      <i-card extra="{{item.nickname}}" title="{{item.action}}" full>
        <view slot="content">操作描述: {{item.content}}</view>
        <view slot="footer">操作时间:{{util.getDatetime(item.createAt)}}</view>
      </i-card>
    </view>
  </view>
</view>

<i-modal title="审核文章" 
  visible="{{ confirmModal }}" 
  bind:ok="confirmArtical" bind:cancel="closeDialog" data-id="confirmModal">
  <view class="btline">{{info.username||'管理员'}}:{{info.lastMsg||'添加文章'}}</view>
  <form>
    <textarea 
        bindinput='inputContent'
        class="tc p20 m10 w80"
        name="content" 
        type="textarea" 
        placeholder-style="color:red;"
        style="color:#f00;"
        placeholder="审核意见" />
    </form>
</i-modal>


<i-modal title="发布文章" 
  visible="{{ publishModal }}" 
  bind:ok="publishArtical" bind:cancel="closeDialog" data-id="publishModal">
  <view class="btline">{{info.username||'管理员'}}:{{info.lastMsg||'添加文章'}}</view>
  <form>
    <textarea 
        bindinput='inputContent'
        class="tc p20 m10 w80"
        name="content" 
        type="textarea" 
        style="color:#f00;"
        placeholder-style="color:red;"
        placeholder="发布意见" />
    </form>
</i-modal>