  <template>
  <div id='app' >
    <criteria-paged :model="model" :pager='false' v-ref:paged>
      <criteria partial='criteria' @condition-changed='search' v-ref:criteria>
        <div novalidate class="form-inline auto" partial>
          <div class="form-group">
          营业网点:
          <v-select :value.sync="model.network" multiple
              :options='$parent.$parent.network' placeholder='请选择'
              close-on-select clear-button @change="$parent.$parent.makeOperator(model.network,'network')"
              v-model="model.network"></v-select>
          操作员姓名:
          <v-select :value.sync="model.operator"
              :options='$parent.$parent.operator' placeholder='请选择'
              close-on-select clear-button
              v-model="model.operator"></v-select>
          <label for="startDate">开始日期:</label>
          <datepicker id="startDate" placeholder="开始日期"
            v-model="model.startDate"
            :value.sync="model.startDate"
            :disabled-days-of-Week="[]"
            :format="'yyyy-MM-dd'"
            :show-reset-button="reset">
          </datepicker>
          <label for="endDate">结束日期:</label>
          <datepicker id="endDate" placeholder="结束日期"
            v-model="model.endDate"
            :value.sync="model.endDate"
            :disabled-days-of-Week="[]"
            :format="'yyyy-MM-dd'"
            :show-reset-button="reset">
          </datepicker>
          <button class="btn btn-default" @click="search()">查询</button>
          <report-print id='ysrb' top='1cm' left='0.5cm' width='100%' height='100%'></report-print>
          <report-excel id='ysrb' ></report-excel>
          </div>
        </div>
      </criteria>
      <div  partial='list' id='ysrb' >
        <table class='tableprint' style="margin: 0px auto">
          <thead>
            <tr>
              <th colspan='8' style="font-weight: normal; text-align: center;">
                <b>预售收入日报汇总表</b>
              </th>
            </tr>
            <tr>
              <th colspan='8' style="font-weight: normal; text-align: center;">
                网点：{{ model.model.network===''?'--': model.model.network }}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                操作员：{{ model.model.operator[0]===''?'--': model.model.operator[0] }}
              </th>

            </tr>
          <tr>
            <th colspan='8' style="font-weight: normal; text-align: center;">
              时间区间：{{model.model.startDate}}-{{ model.model.endDate }}
            </th>
          </tr>
          </thead>
            <tr>
              <td colspan='8'>
            {{{ model.data.substring(26,model.data.length-8) }}}
              </td>
          </tr>
          <tfoot>
            <tr style="text-align: center">
              <th colspan="2">部门主管：</th>
              <th colspan="2">出纳：</th>
              <th colspan="2">审核：</th>
              <th colspan="2">制表：</th>
            </tr>
          </tfoot>
        </table>
       </div>
    </criteria-paged>
  </div>
</template>

<script>
import DataModel from '../../stores/DataModel'
import * as Util from '../../stores/Util'
export default {
  title: '预售收入日报汇总表',
  data () {
    return {
      model: new DataModel('rs/report/weinanbill', {operator: 'this.model.operator[0]', network: 'this.network', startDate: 'this.model.startDate', endDate: 'this.model.endDate'})
    }
  },
  ready () {
    this.model.gasway = ''
    this.$refs.paged.$refs.criteria.model.startDate = Util.toStandardDateString()
    this.$refs.paged.$refs.criteria.model.endDate = Util.toStandardDateString()
    this.$refs.paged.$refs.criteria.model.network[0] = decodeURIComponent(Util.getUrlParames('network'))
    this.$refs.paged.$refs.criteria.model.operator[0] = decodeURIComponent(Util.getUrlParames('operator'))
  },
  computed: {
    operator () {
      return this.$getParams('操作员查询用', [{label: '全部', value: ''}])
    },
    network () {
      return this.$getParams('网点查询用', [{label: '全部', value: ''}])
    }
  },
  methods: {
  // 拼接多条件
    makeOperator (arr, field) {
      let str = ''
      arr.forEach((p) => {
        str += `'${p}',`
      })
      this.model[field] = `(${str.substring(0, str.length - 1)})`
      console.log('111111', this.model[field])
    }
  }
}
</script>
