approve-component-batch.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <el-row style="margin-bottom: 20px;" v-loading="loading">
  3. <el-col :span="16">
  4. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  5. <el-row class="my-row">
  6. <el-form-item label="处理意见" prop="remark">
  7. <el-input type="textarea" v-model="dataForm.remark" placeholder="处理意见"></el-input>
  8. </el-form-item>
  9. </el-row>
  10. <el-row class="my-row">
  11. <upload-component :display-star="false" :title="'审批附件'" :accept="'*'" :file-obj-list="fileList" @uploadSuccess="uploadSuccess"/>
  12. </el-row>
  13. </el-form>
  14. </el-col>
  15. <el-col :span="8">
  16. <el-button style="margin-left: 20px" @click="dataFormSubmit(2)">不同意</el-button>
  17. <el-button type="primary" @click="dataFormSubmit(1)">同意</el-button>
  18. <el-button type="danger" @click="dataFormSubmit(3)">驳回</el-button>
  19. </el-col>
  20. </el-row>
  21. </template>
  22. <script>
  23. import UploadComponent from '../common/upload-component'
  24. export default {
  25. name: 'approve-component-batch',
  26. components: {UploadComponent},
  27. data () {
  28. return {
  29. dataForm: {},
  30. fileList: [],
  31. dataRule: {
  32. // remark: [{ required: true, message: '处理意见不能为空', trigger: 'blur' }]
  33. },
  34. loading: false
  35. }
  36. },
  37. methods: {
  38. async init (businessType, businessIds) {
  39. // console.log('[approve-component]businessType = ' + businessType)
  40. // console.log('[approve-component]businessId = ' + businessId)
  41. this.visible = true
  42. this.dataForm = {
  43. busiType: businessType || '',
  44. busiIds: businessIds || []
  45. }
  46. this.fileList = []
  47. },
  48. // 表单提交
  49. dataFormSubmit (val) {
  50. this.$refs['dataForm'].validate((valid) => {
  51. if (valid) {
  52. if (val !== '1') {
  53. if (!this.dataForm.remark) {
  54. this.$message.error('请填写审批意见')
  55. return
  56. }
  57. } else {
  58. this.dataForm.remark = this.dataForm.remark || '审批通过'
  59. }
  60. this.loading = true
  61. // 添加附件
  62. let fList = this.fileList
  63. if (fList.length > 0) {
  64. this.dataForm.attachList = []
  65. for (let i = 0; i < fList.length; i++) {
  66. this.dataForm.attachList.push({
  67. fileName: fList[i].name,
  68. url: fList[i].url
  69. })
  70. }
  71. }
  72. this.$http({
  73. url: this.$http.adornUrl(`/biz-service/business/batch/approval`),
  74. method: 'post',
  75. data: this.$http.adornData(
  76. {...this.dataForm,
  77. approvalType: val,
  78. userName: this.$store.state.user.name,
  79. orgId: this.$store.state.user.orgId
  80. })
  81. }).then(({data}) => {
  82. this.loading = false
  83. if (data && data.code === '200') {
  84. this.$message({
  85. message: '操作成功',
  86. type: 'success',
  87. duration: 1500,
  88. onClose: () => {
  89. this.visible = false
  90. this.$emit('approveFinished')
  91. }
  92. })
  93. } else {
  94. this.$message.error(data.msg)
  95. }
  96. }).catch(e => {
  97. this.loading = false
  98. })
  99. }
  100. })
  101. },
  102. validateField (type) {
  103. this.$refs.dataForm.validateField(type)
  104. },
  105. uploadSuccess (fileList) {
  106. this.fileList = fileList
  107. }
  108. }
  109. }
  110. </script>
  111. <style scoped>
  112. </style>