<template>
  <div class="flex-row">
    <div class="basic-main">
      <criteria-paged :model="model" v-ref:cp>
        <criteria partial='criteria' @condition-changed='$parent.searchCondition' v-ref:cri>
          <div 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" style="width: 60%" v-model="model.f_apply_num"
                       v-on:keyup.enter="$parent.$parent.search()" condition="t.f_apply_num like '%{}%'"
                       placeholder='报建编号'>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">用户名称：</label>
                <input type="text" class="input_search" style="width: 60%" v-model="model.f_user_name"
                       v-on:keyup.enter="$parent.$parent.search()" condition="t.f_user_name like '%{}%'"
                       placeholder='用户名称'>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">报建类型：</label>
                <v-select
                  v-model="model.f_apply_type"
                  placeholder='请选择'
                  condition="t.f_apply_type = '{}'"
                  :value.sync="model.f_apply_type"
                  :options='$parent.$parent.applytype'
                  class="select select_list"
                  :value-single="true"
                  @change="$parent.$parent.applyTypeChange()"
                  close-on-select></v-select>
              </div>
              <div class="form-group col-sm-2">
                <label class="font_normal_body">办理环节：</label>
                <v-select
                  v-model="model.defname"
                  placeholder='办理环节'
                  :value.sync="model.defname"
                  :options='$parent.$parent.defnames1'
                  class="select select_list"
                  :value-single="true"
                  @change="$parent.$parent.defnameChange()"
                  close-on-select ></v-select>
              </div>
              <div class="form-group col-sm-3 button-range">
                <button class="button_search button_spacing" @click="$parent.$parent.search()" v-el:cx>查询</button>
                <button class="button_clear button_spacing" @click="$parent.$parent.clear()">清空</button>
                <export-excel :data="$parent.$parent.getCondition"
                              :field="$parent.$parent.getfield"
                              sqlurl="rs/logic/applyExportfile"
                              sql-name="applyGetAllActivityTime"
                              template-name='报建时间环节信息导出'
                              :choose-col="true"></export-excel>
                <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-3">
                <label for="startDate" class="font_normal_body">报建申请时间：</label>
                <datepicker id="startDate" placeholder="开始日期"
                            style="width: 60%!important;"
                            v-model="model.sq_startDate"
                            :value.sync="model.sq_startDate"
                            :format="'yyyy-MM-dd 00:00:00'"
                            :show-reset-button="true"
                            condition="sq_sendtime >= '{}'">
                </datepicker>
              </div>
              <div class="form-group col-sm-3">
                <label for="endDate" class="font_normal_body">报建申请时间：</label>
                <datepicker id="endDate" placeholder="结束日期"
                            style="width: 60%!important;"
                            v-model="model.sq_endDate"
                            :value.sync="model.sq_endDate"
                            :format="'yyyy-MM-dd 23:59:59'"
                            :show-reset-button="true"
                            condition="sq_sendtime<= '{}'">
                </datepicker>
              </div>
              <div class="form-group col-sm-3">
                <label for="startDate" class="font_normal_body">报建完成时间：</label>
                <datepicker id="startDate" placeholder="开始日期"
                            style="width: 60%!important;"
                            v-model="model.wc_startDate"
                            :value.sync="model.wc_startDate"
                            :format="'yyyy-MM-dd 00:00:00'"
                            :show-reset-button="true"
                            condition="sq_finishtime>= '{}'">
                </datepicker>
              </div>
              <div class="form-group col-sm-3">
                <label for="endDate" class="font_normal_body">报建完成时间：</label>
                <datepicker id="endDate" placeholder="结束日期"
                            style="width: 60%!important;"
                            v-model="model.wc_endDate"
                            :value.sync="model.wc_endDate"
                            :format="'yyyy-MM-dd 23:59:59'"
                            :show-reset-button="true"
                            condition="sq_finishtime<= '{}'">
                </datepicker>
              </div>
              <div class="form-group col-sm-3">
                <label for="startDate" class="font_normal_body">环节开始时间：</label>
                <datepicker id="startDate" placeholder="开始日期"
                            style="width: 60%!important;"
                            v-model="model.hjks_startDate"
                            :value.sync="model.hjks_startDate"
                            :format="'yyyy-MM-dd 00:00:00'"
                            :show-reset-button="true"
              >
                </datepicker>
              </div>
              <div class="form-group col-sm-3">
                <label for="endDate" class="font_normal_body">环节开始时间：</label>
                <datepicker id="endDate" placeholder="结束日期"
                            style="width: 60%!important;"
                            v-model="model.hjks_endDate"
                            :value.sync="model.hjks_endDate"
                            :format="'yyyy-MM-dd 23:59:59'"
                            :show-reset-button="true"
              >
                </datepicker>
              </div>
              <div class="form-group col-sm-3" v-if="$parent.$parent.defnameShow">
                <label for="startDate" class="font_normal_body">环节结束时间：</label>
                <datepicker id="startDate" placeholder="开始日期"
                            style="width: 60%!important;"
                            v-model="model.hjjs_startDate"
                            :value.sync="model.hjjs_startDate"
                            :format="'yyyy-MM-dd 00:00:00'"
                            :show-reset-button="true"
               >
                </datepicker>
              </div>
              <div class="form-group col-sm-3" v-if="$parent.$parent.defnameShow">
                <label for="endDate" class="font_normal_body">环节结束时间：</label>
                <datepicker id="endDate" placeholder="结束日期"
                            style="width: 60%!important;"
                            v-model="model.hjjs_endDate"
                            :value.sync="model.hjjs_endDate"
                            :format="'yyyy-MM-dd 23:59:59'"
                            :show-reset-button="true"
                >
                </datepicker>
              </div>
              <div class="form-group col-sm-2" v-if="$parent.$parent.typeShow">
                <label class="font_normal_body">派工类型：</label>
                <v-select
                  v-model="model.f_dispatching_type"
                  placeholder='工队/维修'
                  condition="f_dispatching_type = '{}'"
                  :value.sync="model.f_dispatching_type"
                  :options='$parent.$parent.dispatching'
                  class="select select_list"
                  :value-single="true"
                  close-on-select ></v-select>
              </div>
            </div>
          </div>
        </criteria>
        <data-grid :model="model" partial='list' v-ref:grid style="overflow: auto" class="list_area table_sy">
          <template partial='head'>
            <tr>
              <th style="white-space: nowrap;">序号</th>
              <th style="white-space: nowrap;">报建编号</th>
              <th style="white-space: nowrap;">报建类型</th>
              <th style="white-space: nowrap;">用户名称</th>
              <th style="white-space: nowrap;">电话</th>
              <th style="white-space: nowrap;">报装申请时间</th>
              <th style="white-space: nowrap;">报装申请完成时间</th>
              <th style="white-space: nowrap;">报建受理</th>
              <th style="white-space: nowrap;">报建受理完成时间</th>
              <th style="white-space: nowrap;">现场勘察</th>
              <th style="white-space: nowrap;">现场勘察完成时间</th>
              <th style="white-space: nowrap;">收费标准</th>
              <th style="white-space: nowrap;">收费标准完成时间</th>
              <th style="white-space: nowrap;">报装缴费</th>
              <th style="white-space: nowrap;">报装缴费完成时间</th>
              <th style="white-space: nowrap;">合同签订</th>
              <th style="white-space: nowrap;">合同签订完成时间</th>
              <th style="white-space: nowrap;">设计出图</th>
              <th style="white-space: nowrap;">设计出图完成时间</th>
              <th style="white-space: nowrap;">工程派工</th>
              <th style="white-space: nowrap;">工程派工完成时间</th>
              <th style="white-space: nowrap;">工程队派工</th>
              <th style="white-space: nowrap;">工程队派工完成时间</th>
              <th style="white-space: nowrap;">监理单位派工</th>
              <th style="white-space: nowrap;">监理单位派工完成时间</th>
              <th style="white-space: nowrap;">工程施工</th>
              <th style="white-space: nowrap;">工程施工完成时间</th>
              <th style="white-space: nowrap;">点火通气</th>
              <th style="white-space: nowrap;">点火通气完成时间</th>
              <th style="white-space: nowrap;">核算费用</th>
              <th style="white-space: nowrap;">核算费用完成时间</th>
              <th style="white-space: nowrap;">部长审核</th>
              <th style="white-space: nowrap;">部长审核完成时间</th>
              <th style="white-space: nowrap;">经理审核</th>
              <th style="white-space: nowrap;">经理审核完成时间</th>
              <th style="white-space: nowrap;">维修派单</th>
              <th style="white-space: nowrap;">维修派单完成时间</th>
              <th style="white-space: nowrap;">安检维修施工</th>
              <th style="white-space: nowrap;">安检维修施工完成时间</th>
              <th style="white-space: nowrap;">图纸变更</th>
              <th style="white-space: nowrap;">图纸变更完成时间</th>
              <th style="white-space: nowrap;">核对气量</th>
              <th style="white-space: nowrap;">核对气量完成时间</th>
              <th style="white-space: nowrap;">工程查看</th>
              <th style="white-space: nowrap;">工程查看完成时间</th>
              <th style="white-space: nowrap;">完工时间</th>
           </tr>
          </template>
          <template partial='body'>
            <tr>
              <td style="text-align: center;">
                <nobr><font>{{ $index + 1 }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.f_apply_num }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.f_apply_type }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.f_user_name }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.f_phone }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.sq_sendtime ? row.sq_sendtime : row.sl_sendtime }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.sq_finishtime ? row.sq_finishtime : row.sl_sendtime }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.sl_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.sl_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.kc_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.kc_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.bz_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.bz_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.jf_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.jf_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.ht_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.ht_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.ct_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.ct_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.pg_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.pg_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.gdpg_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.gdpg_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.jlpg_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.jlpg_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.sg_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.sg_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.tq_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.tq_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.hs_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.hs_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.bzsh_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.bzsh_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.jlsh_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.jlsh_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.wxpd_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.wxpd_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.wxsg_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.wxsg_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.tzbg_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.tzbg_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.hdql_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.hdql_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.gcck_sendtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.gcck_finishtime  }}</font></nobr>
              </td>
              <td style="text-align: center;">
                <nobr><font>{{ row.wg_sendtime  }}</font></nobr>
              </td>
            </tr>
          </template>
        </data-grid>
      </criteria-paged>
    </div>
  </div>
</template>

<script>
import {HttpResetClass, PagedList} from 'vue-client'
import {isEmpty} from "../../Util";


export default {
  title: '报建环节时间节点',
  data () {
    return {
      model: new PagedList('rs/sql/applyGetAllActivityTime', 20, {
        data: {
          f_filiale: "榆林."+this.$login.f.orgs
        }
      }),
      applytype: [{label: '全部', value: ''}, ...this.$appdata.getParam('报建类型')?this.$appdata.getParam('报建类型'):[]],
      dispatching:  [{label: '全部', value: ''}, {label: '施工工队', value: '施工工队'}, {label: '安检维修中心', value: '安检维修中心'}],
      defnames1: [{label: '全部', value: ''},
        {label: '报装申请', value: 'sq_'},
        {label: '报建受理', value: 'sl_'},
        {label: '现场勘察', value: 'kc_'},
        {label: '收费标准', value: 'bz_'},
        {label: '报装缴费', value: 'jf_'},
        {label: '合同签订', value: 'ht_'},
        {label: '设计出图', value: 'ct_'},
        {label: '工程派工', value: 'pg_'},
        {label: '工程队派工', value: 'gdpg_'},
        {label: '监理单位派工', value: 'jlpg_'},
        {label: '工程施工', value: 'sg_'},
        {label: '点火通气', value: 'tq_'},
        {label: '核算费用', value: 'hs_'},
        {label: '部长审核', value: 'bzsh_'},
        {label: '经理审核', value: 'jlsh_'},
        {label: '维修派单', value: 'wxpd_'},
        {label: '安检维修施工', value: 'wxsg_'},
        {label: '图纸变更', value: 'tzbg_'},
        {label: '核对气量', value: 'hdql_'},
        {label: '工程查看', value: 'gcck_'},
        {label: '完工', value: 'wg_'}
      ],
      criteriaShow: false,
      defnameShow: true,
      typeShow:false,
      getfield: {
        'f_apply_num': ' 报 建 编 号 ',
        'f_apply_type': ' 报 建 类 型 ',
        'f_user_name': ' 用 户 名 称 ',
        'f_phone': '  电      话  ',
        'sq_sendtime':'报装申请时间',
        'sq_finishtime':'报装申请完成时间',
        'sl_sendtime':'报建受理',
        'sl_finishtime':'报建受理完成时间',
        'kc_sendtime':'现场勘察',
        'kc_finishtime':'现场勘察完成时间',
        'bz_sendtime':'收费标准',
        'bz_finishtime':'收费标准完成时间',
        'jf_sendtime':'报装缴费',
        'jf_finishtime':'报装缴费完成时间',
        'ht_sendtime':'合同签订',
        'ht_finishtime':'合同签订完成时间',
        'ct_sendtime':'设计出图',
        'ct_finishtime':'设计出图完成时间',
        'pg_sendtime':'工程派工',
        'pg_finishtime':'工程派工完成时间',
        'gdpg_sendtime':'工程队派工',
        'gdpg_finishtime':'工程队派工完成时间',
        'jlpg_sendtime':'监理单位派工',
        'jlpg_finishtime':'监理单位派工完成时间',
        'sg_sendtime':'工程施工',
        'sg_finishtime':'工程施工完成时间',
        'tq_sendtime':'点火通气',
        'tq_finishtime':'点火通气完成时间',
        'hs_sendtime':'核算费用',
        'hs_finishtime':'核算费用完成时间',
        'bzsh_sendtime':'部长审核',
        'bzsh_finishtime':'部长审核完成时间',
        'jlsh_sendtime':'经理审核',
        'jlsh_finishtime':'经理审核完成时间',
        'wxpd_sendtime':'维修派单',
        'wxpd_finishtime':'维修派单完成时间',
        'wxsg_sendtime':'安检维修施工',
        'wxsg_finishtime':'安检维修施工完成时间',
        'tzbg_sendtime':'图纸变更',
        'tzbg_finishtime':'图纸变更完成时间',
        'hdql_sendtime':'核对气量',
        'hdql_finishtime':'核对气量完成时间',
        'gcck_sendtime':'工程查看',
        'gcck_finishtime':'工程查看完成时间',
        'f_address':'地址',
        'wg_sendtime':'完工时间'
      }
    }
  },
  ready () {
    // 调用查询
    this.search()
  },
  methods: {
    searchCondition (args) {
      if(!isEmpty(args.model.defname)){
         //判断是否选了时间，没有则提示
        if(args.model.defname=='wg_'){
          if(isEmpty(args.model.hjks_startDate)){
            this.$showMessage('请选择完工环节开始时间')
            return
          }
        }else{
          if(isEmpty(args.model.hjks_startDate)){
            this.$showMessage('请选择环节开始时间')
            return
          }
        }
      }
      if(!isEmpty(args.model.hjks_startDate)){
        args.condition+= " AND " +`${args.model.defname}`+'sendtime'+'>='+`'${args.model.hjks_startDate}'`
      }
      if(!isEmpty(args.model.hjks_endDate)){
        args.condition+= " AND " +`${args.model.defname}`+'sendtime'+'<='+`'${args.model.hjks_endDate}'`
      }
      if(!isEmpty(args.model.hjjs_startDate)){
        args.condition+= " AND " +`${args.model.defname}`+'finishtime'+'>='+`'${args.model.hjjs_startDate}'`
      }
      if(!isEmpty(args.model.hjjs_endDate)){
        args.condition+= " AND " +`${args.model.defname}`+'finishtime'+'<='+`'${args.model.hjjs_endDate}'`
      }
      this.model.search(args.condition, args.model)
    },
    defnameChange(){
      //选择的是完工，则隐藏环节结束时间
      if(this.$refs.cp.$refs.cri.model.defname=='wg_'){
        this.typeShow=true
       this.defnameShow=false
      }else{
        this.typeShow=false
        this.defnameShow=true
      }
    },
    async applyTypeChange () {
      if (!isEmpty(this.$refs.cp.$refs.cri.model.f_apply_type)) {
        let http = new HttpResetClass()
        let res = await http.load('POST', 'rs/logic/getDefnameByType', {
            f_apply_type: this.$refs.cp.$refs.cri.model.f_apply_type},
          {resolveMsg: null, rejectMsg: '流程标识获取失败！！！'}
        )
        this.defnames = [{label: '全部', value: ''}, ...res.data]
      } else {
        this.defnames = isEmpty(this.$appdata.getParam('办理环节')) ? [{label: '全部', value: ''}] : [{label: '全部', value: ''}, ...this.$appdata.getParam('办理环节')]
      }
    },
    clear () {
      Object.keys(this.$refs.cp.$refs.cri.model).forEach((key) => {
        this.$refs.cp.$refs.cri.model[key] = []
      })
    },
    // 查询
    search () {
      this.$refs.cp.$refs.cri.search()
    }
  },
  computed: {
    getCondition () {

      return {
        condition: this.model.condition,
        data: {
          f_filiale: "榆林."+this.$login.f.orgs
        }
      }
    }
  }
}
</script>

<style scoped>

</style>
