contract-change.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <div>
  3. <div class="my-title">合同更改</div>
  4. <!-- 表单 -->
  5. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
  6. <el-row class="my-row">
  7. <el-form-item label="更改内容描述" prop="changeContentDesc">
  8. <el-input type="textarea" v-model="dataForm.changeContentDesc" placeholder="请输入更改内容描述"></el-input>
  9. </el-form-item>
  10. </el-row>
  11. <el-row class="my-row">
  12. <upload-component :title="'合同更改通知单'" :accept="'*'" :file-obj-list="fileList" @uploadSuccess="uploadSuccess"/>
  13. </el-row>
  14. </el-form>
  15. <span slot="footer" class="dialog-footer">
  16. <el-button @click="onChose">取消</el-button>
  17. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  18. </span>
  19. </div>
  20. </template>
  21. <script>
  22. import UserComponents from '../common/user-components'
  23. import UploadComponent from '../common/upload-component'
  24. import { getContractDetail } from '@/api/sale'
  25. export default {
  26. name: 'contract-change',
  27. components: {
  28. UploadComponent,
  29. UserComponents
  30. },
  31. computed: {
  32. orgId: {
  33. get () { return this.$store.state.user.orgId }
  34. }
  35. },
  36. data () {
  37. return {
  38. visible: false,
  39. dataForm: {
  40. changeContentDesc: ''
  41. },
  42. id: 0,
  43. fileList: [],
  44. dataRule: {
  45. changeContentDesc: [{ required: true, message: '更改内容简述不能为空', trigger: 'blur' }]
  46. }
  47. }
  48. },
  49. methods: {
  50. onChose () {
  51. this.$emit('onChose')
  52. },
  53. async init (id) {
  54. this.fileList = []
  55. this.visible = true
  56. this.id = id || 0
  57. if (!id) return
  58. this.dataForm.contractId = id
  59. await getContractDetail(id).then(({data}) => {
  60. if (data && data.code === '200' && data.data) {
  61. this.dataForm.changeContentDesc = data.data.changeContentDesc
  62. if (data.data.noticeAttachList) {
  63. data.data.noticeAttachList.forEach((item) => {
  64. this.fileList.push({
  65. name: item.fileName,
  66. url: item.url,
  67. id: item.url
  68. })
  69. })
  70. }
  71. } else {
  72. this.$message.error(data.msg)
  73. }
  74. })
  75. },
  76. validateField (type) {
  77. this.$refs.dataForm.validateField(type)
  78. },
  79. // 表单提交
  80. dataFormSubmit () {
  81. // 附件
  82. let fList = this.fileList
  83. if (fList.length > 0) {
  84. this.dataForm.noticeAttachList = []
  85. for (let i = 0; i < fList.length; i++) {
  86. this.dataForm.noticeAttachList.push({
  87. fileName: fList[i].name,
  88. url: fList[i].url
  89. })
  90. }
  91. } else {
  92. this.$message.error('请上传文件')
  93. return
  94. }
  95. this.$refs['dataForm'].validate((valid) => {
  96. if (valid) {
  97. this.$http({
  98. url: this.$http.adornUrl(`/biz-service/purPurchaseContract/changeContract`),
  99. method: 'post',
  100. data: this.$http.adornData({...this.dataForm, orgId: this.orgId})
  101. }).then(({data}) => {
  102. if (data && data.code === '200') {
  103. this.$message({
  104. message: '操作成功',
  105. type: 'success',
  106. duration: 1500,
  107. onClose: () => {
  108. this.onChose()
  109. this.$emit('refreshDataList')
  110. }
  111. })
  112. } else {
  113. this.$message.error(data.msg)
  114. }
  115. })
  116. }
  117. })
  118. },
  119. uploadSuccess (fileList) {
  120. this.fileList = fileList
  121. }
  122. }
  123. }
  124. </script>
  125. <style scoped>
  126. </style>