<template>
  <div class="auto">
    <validator name='a' @valid="addressValid(true)" @invalid="addressValid(false)">
      <form class="form-horizontal">
        <div class="row">
          <div class="col-sm-4 form-group">
            <label class="font_normal_body">用户姓名</label>
            <input type="text" v-model="model.f_user_name" disabled=disabled style="width: 60%" class="input_search">
          </div>
          <div class="col-sm-4 form-group">
            <label class="font_normal_body" title="参数:收费状态">收费状态</label>
            <input type="text" v-model="model.f_state" disabled=disabled style="width: 60%" class="input_search">
          </div>
          <div class="col-sm-4 form-group">
            <label class="font_normal_body" title="参数:付款方式查询">付款方式</label>
            <v-select :value.sync="model.f_payment" v-model="model.f_payment"
                      :options='payments' placeholder='付款方式'
                      :value-single="true"
                      :search="false"
                      close-on-select>
            </v-select>
          </div>
          <div class="col-sm-6 form-group">
            <label class="form-group">操作日期</label>
            <input type="text" v-model="model.f_operate_date" disabled=disabled  style="width: 60%" class="input_search">
          </div>
          <!--<div class="col-sm-4 form-group">-->
            <!--<label class="font_normal_body">收据类型</label>-->
            <!--<input type="text" v-model="model.f_bill_style" style="width: 60%" class="input_search">-->
          <!--</div>-->
        </div>

        <div class="row">
          <div class="col-sm-4 form-group">
            <label class="font_normal_body" title="参数:操作人员查询">操作人员</label>
            <input type="text" v-model="model.f_operator" disabled=disabled style="width: 60%" class="input_search">

<!--            <v-select :value.sync="model.f_operator"-->
<!--                      v-model="model.f_operator"-->
<!--                      :value-single="true"  @change="selectoperator()"-->
<!--                      :options='foperator'-->
<!--                      close-on-select></v-select>-->
            <!--                      @click="selectoperator"-->
          </div>
          <div class="col-sm-4 form-group">
            <label class="font_normal_body">所属部门</label>
            <input type="text" v-model="model.f_depname" disabled=disabled style="width: 60%" class="input_search">
          </div>
          <div class="col-sm-4 form-group">
            <label class="font_normal_body">所属公司</label>
            <input type="text" v-model="model.f_orgname" disabled=disabled style="width: 60%" class="input_search">
          </div>
        </div>
      </form>
      <div style="float: right">
        <button class="button_search" @click="save">保存</button>
        <button class="button_clear" @click="cancel">取消</button>
      </div>
    </validator>
  </div>
</template>
<script>
  import Vue from 'vue'
  import {HttpResetClass} from 'vue-client'
  import * as Util from "../../Util";
  var data
  export default {
    title: '基本信息',

    data () {
      return {
        equipmentType: this.$appdata.getParam('打印格式') ? [{label: '', value: ''}, ...this.$appdata.getParam('打印格式')] : [],
        // 构建数组来存储对象
        editbank: true,
        uploadText: '收费',
        showfiles: false,
        recordList: [],
        fileNameSet: {
          'f_payment': '收费形式',
          'f_serial_id': '流水号'
        }
      }
    },
    props: {
      oldmodel: Object,
      model: Object
    },

    ready () {
      if (this.$login.r.includes('维护银行转账信息')) {
        this.editbank = true
      }
      this.oldmodel = JSON.parse(JSON.stringify(this.model))
      this.model.f_bill_state = [this.oldmodel]
      console.log('看看收费id', this.oldmodel)
    },
    created () {
    },
    methods: {

      cancel () {
        this.$dispatch('close')
      },
      uploadFiles () {
        this.showfiles = !this.showfiles
      },
      addressValid (val) {
      },
      save () {
        this.recordList = []
        for (var item in this.model) {
          if (this.model.f_payment != this.oldmodel.f_payment && item==='f_payment' ) {
            var car = {
              chinesename: this.fileNameSet[item],
              fieldname: item,
              tablename: 't_flotsamprice',
              oldvalue: this.oldmodel[item],
              newvalue: this.model[item],
              state: '有效',
              modifitime: Util.toStandardTimeString(),
              operator: this.$login.f.name,
              garbage_id: this.model.id,
              f_operator : this.$login.f.name,
              f_operatorid : this.$login.f.id,
              f_orgid : this.$login.f.orgid,
              f_orgname : this.$login.f.orgs,
              f_depid : this.$login.f.depids,
              f_depname : this.$login.f.deps

            }
            this.recordList.push(car)
            // 该方法并未对chinesename fieldname operator等进行判断赋值，此暂写为定值
            console.log('看看car的值', car)
          }
        }

        this.$resetpost('rs/logic/saveGarbage', {data: {recordlist: this.recordList, newData: this.model}}).then((res) => {
          console.log('this.model', this.model)
        })
        this.$dispatch('close')
      }
    },
    computed: {
      foperator () {
        return [...this.$appdata.getParam('操作人员')]
      },
      positions () {
        return this.$appdata.getParam('收费状态')
      },
      payments () {
        return this.$appdata.getParam('付款方式查询')
      },
      writeCards () {
        return this.$appdata.getParam('写卡状态')
      },
      billStyles () {
        return this.$appdata.getParam('收据类型')
      }
    },
    watch: {

    }
  }
</script>
