<template>
  <div>
    <div style="display: flex">
      <div style="width: 50%">
        <el-form :model="dataOldForm" ref="dataForm" label-width="80px">
          <el-form-item label="日期" prop="outinDate">
            <el-date-picker
              disabled
              v-model="dataOldForm.outinDate"
              type="date"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="昨日余额" prop="outinYdayBalance">
            <el-input disabled v-model="dataOldForm.outinYdayBalance" placeholder="昨日余额"></el-input>
          </el-form-item>
          <el-form-item label="今日收入" prop="outinTdayIncome">
            <el-input disabled v-model="dataOldForm.outinTdayIncome" placeholder="今日收入"></el-input>
          </el-form-item>
          <el-form-item label="今日支出" prop="outinTdayOut">
            <el-input disabled v-model="dataOldForm.outinTdayOut" placeholder="今日支出"></el-input>
          </el-form-item>
          <el-form-item label="今日余额" prop="outinTdayBalance">
            <el-input disabled v-model="dataOldForm.outinTdayBalance" placeholder="今日余额"></el-input>
          </el-form-item>
          <el-form-item label="收款方式" prop="outinCreditingWay">
            <el-select
              disabled
              v-model="dataOldForm.outinCreditingWay"
              placeholder="选择收款方式"
              style="width: 90%;"
            >
              <el-option
                v-for="item in payList"
                :key="item.dictId"
                :label="item.name"
                :value="item.dictId"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="备注" prop="outinRemark">
            <el-input disabled v-model="dataOldForm.outinRemark" placeholder="备注"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div style="width: 50%">
        <el-form :model="dataForm" ref="dataForm" label-width="80px">
          <el-form-item label="日期" prop="outinDate">
            <el-date-picker
              disabled
              v-model="dataForm.outinDate"
              type="date"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="昨日余额" prop="outinYdayBalance">
            <el-input disabled v-model="dataForm.outinYdayBalance" placeholder="昨日余额"></el-input>
          </el-form-item>
          <el-form-item label="今日收入" prop="outinTdayIncome">
            <el-input disabled v-model="dataForm.outinTdayIncome" placeholder="今日收入"></el-input>
          </el-form-item>
          <el-form-item label="今日支出" prop="outinTdayOut">
            <el-input disabled v-model="dataForm.outinTdayOut" placeholder="今日支出"></el-input>
          </el-form-item>
          <el-form-item label="今日余额" prop="outinTdayBalance">
            <el-input disabled v-model="dataForm.outinTdayBalance" placeholder="今日余额"></el-input>
          </el-form-item>
          <el-form-item label="收款方式" prop="outinCreditingWay">
            <el-select
              disabled
              v-model="dataForm.outinCreditingWay"
              placeholder="选择收款方式"
              style="width: 90%;"
            >
              <el-option
                v-for="item in payList"
                :key="item.dictId"
                :label="item.name"
                :value="item.dictId"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="备注" prop="outinRemark">
            <el-input disabled v-model="dataForm.outinRemark" placeholder="备注"></el-input>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div style="text-align: center">
      <span slot="footer" class="dialog-footer">
        <el-button type="success" @click="pass()">通过</el-button>
        <el-button type="danger" @click="noPassed()">不通过</el-button>
      </span>
    </div>
  </div>
</template>

<script>
export default {
  components: {
  },
  data () {
    return {
      id: '',
      payList: [], // 支付方式
      approvalApply: '',
      dataForm: {// 总结表新数据
        id: '',
        start: '', // 起始位置日期
        outinDate: '',
        outinYdayBalance: '',
        outinTdayIncome: '',
        outinTdayOut: '',
        outinTdayBalance: '',
        outinCreditingWay: '',
        outinCreditingWayName: '', // 收款方式
        outinRemark: '',
        status: '',
        writeUserId: '', // 填写人id
        writeUser: '', // 填写人
        approval: ''
      },
      dataOldForm: { // 总结表原始数据
        id: '',
        start: '', // 起始位置日期
        outinDate: '',
        outinYdayBalance: '',
        outinTdayIncome: '',
        outinTdayOut: '',
        outinTdayBalance: '',
        outinCreditingWay: '',
        outinCreditingWayName: '', // 收款方式
        outinRemark: '',
        status: '',
        writeUserId: '', // 填写人id
        writeUser: '', // 填写人
        approval: ''
      }
    }
  },
  methods: {
    getDataList (id, approvalApply) {
      console.log(id)
      this.id = id || 0
      this.approvalApply = approvalApply
      this.visible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
        this.$http.request({
          url: this.$http.adornUrl('/business/businessapproval/info/' + id),
          method: 'get'
        }).then(({data}) => {
          // console.log(data);
          if (data && data.code === 0) {
            this.dataForm = {
              ...JSON.parse(data.businessApproval.approvalData)
            }
            this.dataOldForm = {
              ...JSON.parse(data.businessApproval.approvalOldData)
            }
          }
        })
        // 获取字典数据
        this.$http.request({
          url: this.$http.adornUrl('/business/businessdict/list'),
          method: 'get'
        }).then(({data}) => {
          // console.log(data);
          if (data && data.code === 0) {
            data.data.forEach((item) => {
              if (item.dictCode === 'pay_type') {
                this.payList = item.children
              }
            })
          }
        })
      })
    },
    pass () {
      this.$http.request({
        url: this.$http.adornUrl('/business/businessapproval/pass'),
        method: 'post',
        body: this.$http.adornData({
          'id': this.id,
          'approvalData': JSON.stringify(this.dataForm),
          'approvalType': 7
        })
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.$message('操作成功')
        }
      })
    },
    noPassed () {
      this.$http.request({
        url: this.$http.adornUrl('/business/businessapproval/noPass'),
        method: 'post',
        body: this.$http.adornData({
          'id': this.id,
          'approvalId': this.dataForm.id,
          'approvalType': 7
        })
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.$message('操作成功')
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
