<template>
  <div class="flex bg-white p-10 datapanel">
    <div class="form-group" style="height: 4.5%">
      <p align="center" style="font-size: 20px">操作记录</p>
    </div>
    <criteria-paged :model="model" v-ref:paged>
      <data-grid :model="model" v-ref:grid  partial='list'>
        <template partial='head'>
          <tr>
            <th><nobr>序号</nobr></th>
            <th><nobr>标题</nobr></th>
            <th><nobr>操作时间</nobr></th>
            <th><nobr>操作人</nobr></th>
            <th><nobr>操作类型</nobr></th>
            <th><nobr>操作原因</nobr></th>
            <th><nobr>修改内容</nobr></th>
            <th><nobr>原内容</nobr></th>
            <th><nobr>新内容</nobr></th>
          </tr>
        </template>
        <template partial='body'>
          <td style="text-align: center;">{{$index + 1}}</td>
          <td style="text-align: center;">{{row.f_title}}</td>
          <td style="text-align: center;">{{row.f_date}}</td>
          <td style="text-align: center;">{{row.f_operator}}</td>
          <td style="text-align: center;">{{row.f_type}}</td>
          <td style="text-align: center;">{{row.f_reason}}</td>
          <td style="text-align: center;">
            <div v-if = "row.f_change_name === `f_title`">标题</div>
            <div v-if = "row.f_change_name === `f_enddate`">结束日期</div>
            <div v-if = "row.f_change_name === `f_grade`">级别</div>
            <div v-if = "row.f_change_name === `f_filepath`">文件内容</div>
          </td>
          <td style="text-align: center;">
            <div v-if = "row.f_change_name === `f_filepath`">
              <a   @click="$parent.$parent.$parent.download1(row.f_original)">点击下载</a>
            </div>
            <div v-else>{{row.f_original}}</div>
          </td>
          <td style="text-align: center;">
            <div v-if = "row.f_change_name === `f_filepath`">
              <a   @click="$parent.$parent.$parent.download1(row.f_new)">点击下载</a>
            </div>
            <div v-else>{{row.f_new}}</div>
          </td>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>

<script>
  import { PagedList } from 'vue-client'
  export default {
    name: 'UserNoticeRecord',
    data () {
      return {
        model: new PagedList('rs/sql/getOperationrecord', 20, {orderitem: '`f_date DESC`'}),

        val: null
      }
    },
    props: {
      row: Object
    },
    created () {
    },
    ready () {
      this.search1()
    },
    methods: {
      download1 (filePath) {
        const url = `${filePath}`
        console.log('url:' + url)
        console.log('filePath:' + filePath)
        window.open(url)
        /* window.open ('https://dldir1.qq.com/qqfile/qq/PCQQ9.1.6/25786/QQ9.1.6.25786.exe') */
      },
      addrecord () {
        insertRecord(this)
      },
      search1 () {
        let condition = `f_change_type!='营业网点'`
        console.log(condition)
        this.model.search(condition)
      },
      search () {
        let condition = `f_change_type!='营业网点' and f_operation_id=` + this.val
        console.log(condition)
        this.model.search(condition)
      }
    },
    watch: {
      'row.id' (val) {
        console.log('row变化', val)
        this.val = val
        if (val) {
          this.search(val)
        }
      }
    }
  }
</script>

<style lang="less">
</style>
