bankAddUpdate.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <view style="background: #F2F6FF;position: absolute;min-height: 92.2vh;width: 100%;">
  3. <view style="background: #fff;padding:0 20rpx;">
  4. <u-form :model="dataForm" ref="uForm" label-width="180rpx" :rules="rules">
  5. <u-form-item label="开户行:" prop="bankCreat" borderBottom>
  6. <u--input v-model="dataForm.bankCreat" border="false" placeholder='请输入开户行'></u--input>
  7. </u-form-item>
  8. <u-form-item label="银行卡号:" prop="bankNo" borderBottom>
  9. <u--input v-model="dataForm.bankNo" border="false" placeholder='请输入银行卡号'></u--input>
  10. </u-form-item>
  11. <u-form-item label="是否默认:" prop="defaultd" borderBottom>
  12. <u-radio-group v-model="dataForm.defaultd" placement="row">
  13. <u-radio label="是" :name="1">
  14. </u-radio>
  15. <u-radio label="否" :name="0">
  16. </u-radio>
  17. </u-radio-group>
  18. </u-form-item>
  19. </u-form>
  20. <u-button type="primary" style="margin-top: 100rpx;" @click="submit">提交</u-button>
  21. <u-button type="error" style="margin: 20rpx 0;" v-if="dataForm.id" @click="deletebank">删除</u-button>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. dataForm: {
  30. bankCreat: "",
  31. bankNo: "",
  32. defaultd: 0,
  33. },
  34. rules: {
  35. bankCreat: [{
  36. required: true,
  37. message: '请输入开户行',
  38. trigger: ['blur', 'change']
  39. }],
  40. bankNo: [{
  41. required: true,
  42. message: '请输入银行卡号',
  43. trigger: ['blur', 'change']
  44. }],
  45. }
  46. }
  47. },
  48. onReady() {
  49. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  50. this.$refs.uForm.setRules(this.rules)
  51. },
  52. onLoad(e) {
  53. if (JSON.parse(e.date)) {
  54. this.dataForm = JSON.parse(e.date)
  55. }
  56. },
  57. methods: {
  58. deletebank() {
  59. let postdata = {
  60. workId: uni.getStorageSync('userInfo').id,
  61. ids: [this.dataForm.id]
  62. }
  63. this.$api.to_http(`/employees/banklist/delete`, postdata, "POST").then((
  64. res) => {
  65. if (res.data.code != 0) {
  66. return uni.$u.toast(res.data.msg)
  67. }
  68. uni.$u.toast('操作成功')
  69. setTimeout(() => {
  70. uni.navigateBack(-1)
  71. }, 500)
  72. })
  73. },
  74. submit() {
  75. let that = this
  76. this.dataForm.refUserId = uni.getStorageSync('userInfo').userProfileId
  77. that.$refs.uForm.validate().then(res => {
  78. this.$api.to_http(`/employees/banklist/saveByWorkId`, that.dataForm, "POST").then((
  79. res) => {
  80. if (res.data.code != 0) {
  81. return uni.$u.toast(res.data.msg)
  82. }
  83. uni.$u.toast('操作成功')
  84. setTimeout(() => {
  85. uni.navigateBack(-1)
  86. }, 500)
  87. })
  88. }).catch(errors => {
  89. uni.$u.toast('请完成必填项')
  90. })
  91. }
  92. }
  93. }
  94. </script>
  95. <style lang="less" scoped>
  96. /deep/.u-radio {
  97. margin-right: 15rpx;
  98. }
  99. /deep/.u-button {
  100. margin: 20rpx 0;
  101. }
  102. </style>