<template>
  <div class="auto basic-main" style="height:95%">
    <criteria-paged :model="model" v-ref:paged>
      <criteria partial='criteria' @condition-changed='$parent.selfSearch' v-ref:cri>
        <div novalidate class="form-horizontal select-overspread container-fluid auto" partial>
          <div class="row">
            <div class="form-group col-sm-2">
              <label class="font_normal_body">推送类型</label>
              <v-select id="f_bill_state"
                        style="width:60%"
                        v-model="model.send_type"
                        placeholder='推送类型'
                        condition="send_type ='{}'"
                        :value.sync="model.send_type"
                        :options='$parent.$parent.sendtypes'
                        :search="false"
                        close-on-select clear-button>
              </v-select>
            </div>
            <div class="form-group col-sm-2">
              <label class="font_normal_body">推送内容</label>
              <input type="text" class="form-control" v-model="model.f_user_name" style="width:60%"
                     condition="send_data like '%{}%'" placeholder="返回内容(模糊)"
              >
            </div>
            <div class="form-group col-sm-2">
              <label class="font_normal_body">返回内容</label>
              <input type="text" class="form-control" v-model="model.f_user_name" style="width:60%"
                     condition="return_msg like '%{}%'" placeholder="返回内容(模糊)"
              >
            </div>
            <div class="form-group col-sm-2">
              <label class="font_normal_body">流水号</label>
              <input type="text" class="form-control" v-model="model.f_user_name" style="width:60%"
                     condition="order_code like '%{}%'" placeholder="流水号"
              >
            </div>
            <div style="float: right">
              <button class="button_search" @click="search()">查 询</button>
              <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</button>
              <div
                :class="{'button_shrink_top':$parent.$parent.criteriaShow,'button_shrink_bottom':!$parent.$parent.criteriaShow}"
                @click="$parent.$parent.criteriaShow=!$parent.$parent.criteriaShow"
                class="button_spacing"
                style="float: right"></div>
            </div>
          </div>
          <div class="row" v-show="$parent.$parent.criteriaShow">
            <div class="form-group col-sm-2">
              <label class="font_normal_body">操作日期</label>
              <datepicker id="f_operate_datestarthate" placeholder="开始日期"
                          v-model="model.f_operate_datestarthate"
                          :value.sync="model.f_operate_datestarthate"
                          format="yyyy-MM-dd"
                          condition="f_operate_date >= '{}'"
                          style="width:60%">
              </datepicker>
            </div>
            <div class="form-group col-sm-2">
              <label class="font_normal_body">&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
              <datepicker id="f_operate_dateendDate" placeholder="结束日期"
                          v-model="model.f_operate_dateendDate"
                          :value.sync="model.f_operate_dateendDate"
                          format="yyyy-MM-dd"
                          condition=" f_operate_date <= '{}'"
                          style="width:60%">
              </datepicker>
            </div>
            <button class="button_search" @click="$parent.$parent.nccpost('everyDayOtherFee')">日推其他收费收款单</button>
            <button class="button_search" @click="$parent.$parent.nccpost('everyShDayGasFee')">日推送散户收款单</button>
            <button class="button_search" @click="$parent.$parent.nccpost('everyDayGasFee')">日推明细收款单</button>
            <button class="button_search" @click="$parent.$parent.nccpost('everyDaySHChargePush')">日推散户气费销售订单</button>
            <button class="button_search" @click="$parent.$parent.nccpost('everyDayChargePush')">日推明细气费销售订单</button>
            <button class="button_search" @click="$parent.$parent.nccpost('everyDaySHHandPush')">月推送散户抄表结算销售订单</button>
            <button class="button_search" @click="$parent.$parent.nccpost('everyDayHandPush')">月推送明细抄表结算销售订单</button>
          </div>
        </div>
      </criteria>
      <data-grid :model="model" partial='list' class="list_area table_sy" v-ref:grid>
        <template partial='head'>
          <tr>
            <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' :model="model">
          <tr>
            <th style="text-align:center"><nobr>{{ row.f_operate_date }}</nobr></th>
            <th >
              <p :id="'send_data-'+$index" style="width:60em;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;overflow: hidden;margin: 0"
                 @click="$parent.$parent.$parent.p_click('send_data-'+$index,'send_datainput-'+$index)">
                {{row.send_data}}</p>
              <textarea rows="3" style="width:60em;display: none;margin: 0;border: 1px solid #e4f9f5"
                        @blur="$parent.$parent.$parent.input_blur('send_data-'+$index,'send_datainput-'+$index)"
                        :id="'send_datainput-'+$index" >{{row.send_data}}</textarea>
            </th>
            <th >
              <p :id="'return_msg-'+$index" style="width:50em;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;overflow: hidden;margin: 0"
                 @click="$parent.$parent.$parent.p_click('return_msg-'+$index,'return_msginput-'+$index)">
                {{row.return_msg}}</p>
              <textarea rows="3" style="width:50em;display: none;margin: 0;border: 1px solid #e4f9f5"
                        @blur="$parent.$parent.$parent.input_blur('return_msg-'+$index,'return_msginput-'+$index)"
                        :id="'return_msginput-'+$index" >{{row.return_msg}}</textarea>
            </th>
            <th style="text-align:center"><nobr>{{ row.send_type }}</nobr></th>
            <th style="text-align:center"><nobr>{{ row.order_code }}</nobr></th>
          </tr>
        </template>
      </data-grid>
    </criteria-paged>
  </div>
</template>
<script>

import {PagedList} from 'vue-client'

export default {
  title: '推送日志管理',
  data () {
    return {
      model: new PagedList('rs/sql/singleTable_OrderBy', 20, {
        items: `'*'`,
        tablename: `'log_record'`,
        orderitem: `'f_operate_date desc'`
      }),
      sendtypes: [],
      criteriaShow: false
    }
  },
  ready () {
    this.$resetpost('rs/sql/querySingleTable', {
      data: {
        items: 'distinct send_type',
        tablename: 'log_record',
        condition: ' 1 = 1 '
      }
    }, {resolveMsg: null, rejectMsg: '获取记录出错'}).then(res => {
      this.sendtypes = res.data.map(item => {
        return {label: item.send_type, value: item.send_type}
      })
    })
  },
  methods: {
    nccpost (val) {
      this.$resetpost(`ncc/rs/Driver/${val}`, {}, {resolveMsg: '推送记录成功', rejectMsg: '推送记录出错'})
    },
    // p标签点击方法
    p_click (p_id, i_id) {
      document.getElementById(p_id).style.display = 'none'
      document.getElementById(i_id).style.display = 'inline-block'
      document.getElementById(i_id).select()
      console.log(p_id, i_id)
    },
    // input失去焦点方法
    input_blur (p_id, i_id) {
      document.getElementById(p_id).style.display = '-webkit-box'
      document.getElementById(i_id).style.display = 'none'
      console.log(p_id, i_id)
    },
    search () {
      this.$refs.paged.$refs.cri.search()
    },
    selfSearch (args) {
      this.model.search(args.condition, args.model)
    }

  },
  computed: {
  },
  events: {
  },
  watch: {}
}
</script>
<style scoped>
th {
  text-align: center;
  padding: 2px;
}

td {
  text-align: center;
  padding: 2px;
}
</style>
