wuHanReimbursementForm.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <el-dialog
  3. :title="title"
  4. :close-on-click-modal="false"
  5. v-dialogDrag
  6. :visible.sync="visible">
  7. <el-form size="small" :model="inputForm" ref="inputForm" @keyup.enter.native="doSubmit()"
  8. label-width="120px" v-loading="loading" :class="method==='view'?'readonly':''" :disabled="method==='view'" @submit.native.prevent>
  9. <el-row :gutter="15">
  10. <el-col :span="12">
  11. <el-form-item label="随机报销批次" prop="randomType">
  12. <el-radio-group v-model="inputForm.randomType" @change="changeRadio(inputForm.randomType)">
  13. <el-radio label="1">是</el-radio>
  14. <el-radio label="0">否</el-radio>
  15. </el-radio-group>
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="12" v-if="this.isShow">
  19. <el-form-item label="报销批次" prop="businessCode" :rules=" [{required: true ,max: 50, message: '报销批次不能为空', trigger: 'blur'}]">
  20. <el-input v-model="inputForm.businessCode" placeholder="报销批次"></el-input>
  21. </el-form-item>
  22. </el-col>
  23. </el-row>
  24. </el-form>
  25. <span slot="footer" class="dialog-footer">
  26. <el-button size="small" @click="visible = false" icon="el-icon-circle-close">关闭</el-button>
  27. <el-button size="small" v-if="method != 'view'" type="primary" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
  28. </span>
  29. </el-dialog>
  30. </template>
  31. <script>
  32. import ReimbursementSys from '@/api/reimbursementSys/wuHanReimbursementSysService'
  33. export default {
  34. data () {
  35. return {
  36. isShow: false,
  37. title: '',
  38. method: '',
  39. visible: false,
  40. loading: false,
  41. inputForm: {
  42. id: '',
  43. name: '',
  44. randomType: '',
  45. parent: {
  46. id: ''
  47. },
  48. businessCode: '' // 报销批次
  49. }
  50. }
  51. },
  52. reimbursementSys: null,
  53. created () {
  54. this.reimbursementSys = new ReimbursementSys()
  55. },
  56. methods: {
  57. init (method, obj) {
  58. this.method = method
  59. if (method === 'editBusiness') {
  60. this.title = '修改报销批次'
  61. } else if (method === 'view') {
  62. this.title = '查看报销批次'
  63. }
  64. this.visible = true
  65. this.$nextTick(() => {
  66. this.$refs['inputForm'].resetFields()
  67. this.inputForm.id = obj.id
  68. this.inputForm.parent.id = obj.parent.id
  69. this.inputForm.parent.name = obj.parent.name
  70. if (method === 'editBusiness' || method === 'view') { // 修改或者查看
  71. this.loading = true
  72. this.reimbursementSys.queryBusinessById(this.inputForm.id).then(({data}) => {
  73. this.inputForm = this.recover(this.inputForm, data)
  74. if (this.inputForm.randomType === '1') {
  75. this.isShow = false
  76. } else {
  77. this.isShow = true
  78. }
  79. this.loading = false
  80. })
  81. }
  82. if (method === 'editInvoiceBusiness') { // 修改或者查看
  83. this.loading = true
  84. this.reimbursementSys.queryBusinessByInvoiceId(this.inputForm.id).then(({data}) => {
  85. this.inputForm = this.recover(this.inputForm, data)
  86. if (this.inputForm.randomType === '1') {
  87. this.isShow = false
  88. } else {
  89. this.isShow = true
  90. }
  91. this.loading = false
  92. })
  93. }
  94. })
  95. },
  96. changeRadio (randomType) {
  97. if (randomType === '1') {
  98. this.isShow = false
  99. } else {
  100. this.isShow = true
  101. }
  102. },
  103. // 表单提交
  104. doSubmit () {
  105. this.$refs['inputForm'].validate((valid) => {
  106. if (valid) {
  107. this.loading = true
  108. this.reimbursementSys.saveBusiness(this.inputForm).then(({data}) => {
  109. this.loading = false
  110. this.$message({
  111. message: '操作成功',
  112. type: 'success',
  113. duration: 1500
  114. })
  115. this.visible = false
  116. this.$emit('refreshDataList')
  117. }).catch(() => {
  118. this.loading = false
  119. })
  120. }
  121. })
  122. }
  123. }
  124. }
  125. </script>