dispatch-arrived.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="任务单送达"
  5. width="50%"
  6. :close-on-click-modal="false"
  7. :visible.sync="visible">
  8. <!-- 表单 -->
  9. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  10. <el-row class="my-row">
  11. <el-col>
  12. <el-form-item label="送达数量" prop="cnt">
  13. <el-input-number v-model="dataForm.cnt" :min="0" :max="Number(max)"></el-input-number>
  14. </el-form-item>
  15. </el-col>
  16. </el-row>
  17. <el-row class="my-row">
  18. <upload-component :display="false" :title="'签收附件'" :accept="'*'" :file-obj-list="fileList" @uploadSuccess="uploadSuccess"/>
  19. </el-row>
  20. </el-form>
  21. <span slot="footer">
  22. <el-button @click="onChose">取消</el-button>
  23. <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
  24. </span>
  25. </el-dialog>
  26. </div>
  27. </template>
  28. <script>
  29. import UploadComponent from '../common/upload-component'
  30. export default {
  31. name: 'dispatch-arrived',
  32. components: { UploadComponent },
  33. data () {
  34. return {
  35. visible: false,
  36. fileList: [],
  37. dataForm: {},
  38. max: 0,
  39. dataRule: {
  40. cnt: [{ required: true, message: '请输入送达数量', trigger: 'change' }]
  41. }
  42. }
  43. },
  44. methods: {
  45. onChose () {
  46. this.visible = false
  47. this.$emit('onChose')
  48. },
  49. async init (deliverId, max) {
  50. if (!deliverId) return
  51. this.max = max
  52. this.fileList = []
  53. this.dataForm = {
  54. deliverId: deliverId
  55. }
  56. this.visible = true
  57. },
  58. uploadSuccess (fileList) {
  59. this.fileList = fileList
  60. },
  61. validateField (type) {
  62. this.$refs.dataForm.validateField(type)
  63. },
  64. // 表单提交
  65. dataFormSubmit () {
  66. this.$refs['dataForm'].validate((valid) => {
  67. if (valid) {
  68. // 附件检查
  69. let fList = this.fileList
  70. if (fList.length > 0) {
  71. this.dataForm.attachList = []
  72. for (let i = 0; i < fList.length; i++) {
  73. this.dataForm.attachList.push({
  74. fileName: fList[i].name,
  75. url: fList[i].url
  76. })
  77. }
  78. } else {
  79. this.$message.error('请上传文件')
  80. return
  81. }
  82. this.$http({
  83. url: this.$http.adornUrl(`/biz-service/deliver/arrive`),
  84. method: 'post',
  85. data: this.$http.adornData({...this.dataForm})
  86. }).then(({data}) => {
  87. if (data && data.code === '200') {
  88. this.$message({
  89. message: '操作成功',
  90. type: 'success',
  91. duration: 1500,
  92. onClose: () => {
  93. this.onChose()
  94. this.$emit('refreshDataList')
  95. }
  96. })
  97. } else {
  98. this.$message.error(data.msg)
  99. }
  100. })
  101. }
  102. })
  103. }
  104. }
  105. }
  106. </script>
  107. <style scoped>
  108. </style>