<template>
  <div class="flex-row">
    <div class="basic-main">
      <criteria-paged :model="model" v-ref:paged @sort="sort">
        <criteria partial='criteria' class="search_area" @condition-changed='$parent.selfSearch' v-ref:criteria>
          <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>
                <input type="text" class="input_search" v-model="model.title"
                       condition="tui.f_userinfo_code like '%{}%'"
                       style="width: 60%" placeholder="示意图标题" >
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">示意图标题</label>
                <input type="text" class="input_search" v-model="model.title"
                       condition="tcs.title like '%{}%'"
                       style="width: 60%" placeholder="示意图标题" >
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">示意图id</label>
                <input type="text" class="input_search" v-model="model.blob_id"
                       condition="tcs.blob_id like '%{}%'"
                       style="width: 60%" placeholder="示意图id" >
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">单位名称</label>
                <input type="text" class="input_search" v-model="model.gas_point_name"
                       condition="tcs.gas_point_name like '%{}%'"
                       style="width: 60%" placeholder="单位名称" >
              </div>
              <div class="form-group col-sm-2" style="width: auto;margin-top:8px;float: right">
                <export-excel-safe :data="$parent.$parent.searchData"
                                   :field="$parent.$parent.excelHeaders"
                                   :choose-col="true"
                                   sqlurl="rs/logic/SafeExportExcel" sql-name="queryPaperEdit"
                                   template-name='图纸编辑'></export-excel-safe>
                <button class="button_spacing button_search" @click="$parent.$parent.search()">查询</button>
                <button class="button_spacing button_search" @click="$parent.$parent.change()">新建</button>
              </div>
            </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>
                <nobr>序号</nobr>
              </th>
              <th>
                <nobr>分公司</nobr>
              </th>
              <th>
                <nobr>单位编号</nobr>
              </th>
              <th>
                <nobr>单位名称</nobr>
              </th>
              <th>
                <nobr>示意图标题</nobr>
              </th>
              <th>
                <nobr>示意图id</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.gas_point_name }}</td>
            <td style="text-align: center">{{ row.gas_point_id }}</td>
            <td style="text-align: center">{{ row.gas_point_name }}</td>
            <td style="text-align: center">{{ row.title }}</td>
            <td style="text-align: center">{{ row.blob_id }}</td>

            <td style="text-align: center">
              <button class="button_spacing button_search-1" @click='$parent.$parent.$parent.change(row)'>查看</button>
            </td>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
    <modal :show.sync="showModal" v-ref:modal backdrop="false" :width="1200">
      <div slot="modal-header" class="modal-header">
        <h4 class="modal-title">
          打开图纸编辑
        </h4>
      </div>
      <div slot="modal-body" class="modal-body">
        <edit :row="rowData" v-if="showModal"></edit>
      </div>
      <div slot="modal-footer" class="modal-footer" style="text-align: center">
        <button class="button_search" @click="cancel">取消</button>
      </div>
    </modal>
  </div>
</template>

<script>
import {PagedList} from 'vue-client'
import Vue from 'vue'
import co from 'co'
import * as Util from '../Util'
import HttpResetClass from "vue-client/src/plugins/HttpResetClass";

export default {
  title: '图纸编辑页面',
  data() {
    return {
      searchData: {
        condition: "1=1",
      },
      model: new PagedList('rs/sql/queryPaperEdit', 20, {}),
      excelHeaders: {
        'id': '序号',
        'orgname': '分公司',
        'gas_point_id': '单位编号',
        'gas_point_name': '单位名称',
        'title': '示意图标题',
        'blob_id': '示意图id',
      },
      showModal: false,
      rowData:''
    }
  },
  methods: {
    change(row) {
      this.rowData = row
      this.showModal = true
      console.log(this)
    },
    search() {
      this.$refs.paged.$refs.criteria.search()
    },
    cancel() {
      this.showModal = false
    },
    selfSearch(args) {
      this.searchData.condition = args.condition
      this.model.search(args.condition, args.model, args.condValue)
    }
  },

  ready() {

  }
}
</script>
