<template>
  <div class="flex-row">
    <div class="basic-main">
      <criteria-paged :model="model" v-ref:paged>
        <criteria partial='criteria' class="search_area" @condition-changed='$parent.selfSearch' v-ref:criteria>
          <div partial>
            <div class="row">
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">用户名称：</label>
                <input style="width: 60%" class="input_search" v-model="model.f_user_name"
                       placeholder="请输入用户名称（可模糊查询）" condition="f_user_name like '%{}%'">
              </div>
              <div class="col-sm-4 form-group">
                <label class="font_normal_body">安检年份：</label>
                <input style="width: 60%" class="input_search" v-model="model.year">
              </div>
              <div style="float: right">
                <export-excel-safe :data="$parent.$parent.searchData"
                                   :field="$parent.$parent.excelHeaders"
                                   progress="safeGetExportProgress"
                                   sqlurl="rs/logic/SafeExportExcel" sql-name="communityTypeDetailG"
                                   template-name='工商情况明细表' :choose-col="true"></export-excel-safe>
              </div>
<!--              <print-data-safe :sum-field="$parent.$parent.excelHeaders" :model="$parent.$parent.print_model" :field="$parent.$parent.excelHeaders"-->
<!--                          :defaultfield="$parent.$parent.defaultPrint" :chooserow="true"-->
<!--                          :titletable="'工商情况明细表'" :starthead="$parent.$parent.getstart"-->
<!--              ></print-data-safe>-->
              <button class="button_spacing button_search" @click="search()">查询</button>
            </div>
          </div>
        </criteria>
        <data-grid class="list_area table_sy" style="overflow: hidden" :model="model" partial='list' v-ref:grid>
          <template partial='head'>
            <tr>
              <th rowspan="2">序号</th>
              <th rowspan="2">用户名称</th>
              <th colspan="2">1季度完成情况</th>
              <th colspan="2">2季度完成情况</th>
              <th colspan="2">3季度完成情况</th>
              <th colspan="2">4季度完成情况</th>
            </tr>
            <tr>
              <th>已安检</th>
              <th>未安检原因</th>
              <th>已安检</th>
              <th>未安检原因</th>
              <th>已安检</th>
              <th>未安检原因</th>
              <th>已安检</th>
              <th>未安检原因</th>
            </tr>
          </template>
          <template partial='body'>
            <td style="text-align: center">{{ $index + 1 }}</td>
            <td style="text-align: center">{{ row.f_user_name }}</td>
            <td style="text-align: center">{{ row.m1_safe }}</td>
            <td style="text-align: center">{{ row.m1_remarks }}</td>
            <td style="text-align: center">{{ row.m2_safe }}</td>
            <td style="text-align: center">{{ row.m2_remarks }}</td>
            <td style="text-align: center">{{ row.m3_safe }}</td>
            <td style="text-align: center">{{ row.m3_remarks }}</td>
            <td style="text-align: center">{{ row.m4_safe }}</td>
            <td style="text-align: center">{{ row.m4_remarks }}</td>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

<script>
import {PagedList} from "vue-client";

export default {
  name: "communityTypeDetailG",
  title: "工商情况明细表",
  data() {
    let model = new PagedList("/rs/sql/communityTypeDetailG", 20, {year: 'this.year'})
    model.year = ''
    return {
      model: model,
      resids: {},
      print_model:{},
      searchData: {
        condition: "1=1",
        year: null
      },
      excelHeaders: {
        'f_user_name': '用户名称',
        'm1_safe': '1季度完成安检',
        'm1_remarks': '1季度未安检原因',
        'm2_safe': '2季度完成安检',
        'm2_remarks': '2季度未安检原因',
        'm3_safe': '3季度完成安检',
        'm3_remarks': '3季度未安检原因',
        'm4_safe' : '4季度完成安检',
        'm4_remarks' : '4季度未安检原因'
      },
      printshow: false,
    }
  },
  ready() {
    this.$refs.paged.$refs.criteria.model.year = new Date().getFullYear()
    // this.model.search('1=1')
  },
  methods: {
    selfSearch(args) {
      this.model.year = args.model.year
      args.condition += ` and uf.f_user_type = '非民用' `
      this.searchData.condition = args.condition
      this.searchData.year = args.model.year
      this.model.search(args.condition, args.model, args.condValue)
      this.print_model.totalPage = 0
    },
    getRes(obj) {
      //tag
      this.resids = {res: obj.res[0], resids: obj.resids[0]}
      this.model.f_filialeids = this.$login.convertToIn(obj.resids);
    },
    // 打印
    stamp() {
      this.printshow = true
    },
    close() {
      this.printshow = false
    }
  },
  computed: {
    getstart() {
      return `开始时间：${this.$refs.paged.$refs.criteria.model.start_time} 结束时间：${this.$refs.paged.$refs.criteria.model.end_time}`
    },
  }
}
</script>

<style scoped>

</style>
