financeConfirmDialog.vue 6.19 KB
<!-- 财务确认弹窗 -->
<template>
  <!-- <d2-dialog title="财务确认"
             :is-visible.sync="financeConfirmVisible"
             width="600px"
             @confirmDialog="handleCashConfirm"
             @closeDialog="handleCashClose"> -->
  <baseDialog :dialog-config="dialogConfig"
              :is-show.sync="visible"
              class="accountDailog"
              @handleClick="handleCashConfirm">
    <!-- <span slot="sub-title">提现后不能撤回,确保资金安全,请谨慎操作!</span> -->
    <el-form ref="formRef"
             :model="cashForm"
             :rules="cashRules"
             label-width="120px">
      <el-form-item label="财务管理员:"
                    prop="administrators">
        <el-select v-model="cashForm.administrators"
                   filterable
                   style="width:310px">
          <el-option v-for="(item,index) in baseData.administratorsList"
                     :key="index"
                     :label="item.name + ' ' + item.phone"
                     :value="item.phone" />
        </el-select>
      </el-form-item>
      <el-form-item label="验证码:"
                    prop="smsCode"
                    class="pdt">
        <el-input v-model="cashForm.smsCode"
                  placeholder="请输入验证码"
                  maxlength="6"
                  style="width: 200px" />
        <el-button type="primary"
                   size="small"
                   @click="handleSend"
                   :disabled="isSend"
                   class="cash-btn">
          {{ isSend ? sendMsg + '秒后,重试' : '获取验证码' }}
        </el-button>
        <p v-show="showtips">
          已向尾号为{{ cashForm.administrators ? cashForm.administrators.slice(-4) : '' }}的手机号发送验证码,验证码30分钟内有效
        </p>
      </el-form-item>
      <el-form-item label="备注:"
                    prop="remark"
                    class="pdt">
        <el-input v-model="cashForm.remark"
                  type="textarea"
                  maxlength="50"
                  placeholder="请输入备注"
                  show-word-limit
                  :rows="4"
                  style="width: 310px" />
        <p>
          财务确认后,转账业务单据自动流转至银盛完成正式转账。
        </p>
      </el-form-item>
    </el-form>
    <!-- </d2-dialog> -->
  </baseDialog>
</template>

<script>
import { createWithdraw } from '@api/account'
import { sendToSmsCodeApi } from '@/api/sys.base'
import { getWithdrawTreasurerList, transferAccountsRecordUpdateStatus, batchTreasurerConfirm } from '@api/transferAccountsManage'
export default {
  name: 'FinanceConfirmDialog',
  data() {
    return {
      dialogConfig: {
        title: '财务确认',
        width: '600px'
      },
      cashForm: {
        administrators: '',
        smsCode: '',
        remark: ''
      },
      cashRules: {
        administrators: [{ required: true, message: '请选择财务管理员', trigger: 'change' }],
        smsCode: [{ required: true, message: '请输入验证码', trigger: 'change' }]
      },
      // 验证码
      showtips: false,
      isSend: false,
      sendMsg: '获取验证码',
      time: '',
      // 基本数据
      baseData: {
        administratorsList: []
      }
    }
  },

  props: {
    financeConfirmVisible: {
      type: Boolean,
      default: false
    },
    // cashForm: {
    //   type: Object,
    //   default: () => { }
    // }
    infoList: {
      type: Array,
      default: () => { }
    }
  },

  // watch: {
  //   financeConfirmVisible(newVal, val) {
  //     newVal ? this.reset() : this.closeReset()
  //   }
  // },
  computed: {
    visible: {
      get() {
        return this.financeConfirmVisible
      },
      set(newVal) {
        this.$emit('dialogClose', { flag: newVal, attrName: 'financeConfirmVisible' })
      }
    }
  },

  mounted() {
    this.getAdminList()
  },

  methods: {
    // reset() {
    //   this.$refs.formRef && this.$refs.formRef.resetFields()
    // },
    // closeReset() {
    //   this.isSend = false
    //   this.showtips = false
    //   this.time && clearTimeout(this.time)
    // },
    getAdminList() {
      getWithdrawTreasurerList({}).then(res => {
        this.baseData.administratorsList = res
        this.cashForm.administrators = res[0].phone
      })
    },

    handleCashConfirm() {
      this.$refs.formRef.validate(valid => {
        if (valid) {
          var params = {}
          params.remark = this.cashForm.remark
          params.smsCode = this.cashForm.smsCode
          params.phone = this.cashForm.administrators
          params.status = 3
          if (this.infoList.length > 1) {
            params.orderCodeList = this.infoList.map((item) => {
              return item.orderCode
            })
          } else {
            params.orderCode = this.infoList[0].orderCode
          }
          console.log(params)

          const _api = this.infoList.length > 1 ? batchTreasurerConfirm : transferAccountsRecordUpdateStatus
          _api(params).then(res => {
            this.notice.okTips('操作成功')
            this.visible = true
          })
          // createWithdraw({ totalAmount: (+this.cashForm.balance - 2), smsCode: this.cashForm.smsCode }).then(res => {
          //   this.notice.okTips()
          //   this.$emit('handleCashConfirm')
          // })
        }
      })
    },
    // handleCashClose() {
    //   this.$emit('dialogClose', true)
    // },
    handleSend() {
      if (!this.cashForm.administrators) {
        this.notice.warningTips('请选择管理员')
        return
      }
      sendToSmsCodeApi({ phone: this.cashForm.administrators }).then((res) => {
        this.notice.okTips('已发送,30分钟内有效')
        this.isSend = true
        this.showtips = true
        this.sendMsg = 60
        this.msgDown()
      })
    },
    msgDown() {
      this.time = setTimeout(() => {
        clearTimeout(this.time)
        if (this.sendMsg > 1) {
          --this.sendMsg
          this.msgDown()
        } else {
          this.isSend = false
        }
      }, 1000)
    }
  }
}

</script>
<style scoped>
p {
  margin: 0 0;
}
.cash-btn {
  margin-left: 20px;
}
.pdt {
  padding-top: 10px;
}
</style>