EditPlan.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <!--
  2. * @Author: liuzl 461480418@qq.com
  3. * @Date: 2023-01-09 15:34:20
  4. * @LastEditors: liuzhenlin
  5. * @LastEditTime: 2023-01-09 16:13:14
  6. * @Description: file content
  7. * @FilePath: \订单全流程管理系统\src\views\contract\components\EditPlan.vue
  8. -->
  9. <template>
  10. <el-dialog :title="title" :visible.sync="editVisible" @close="handleClose">
  11. <el-form ref="editForm" :model="editForm" :rules="editRules">
  12. <el-row :gutter="20">
  13. <el-col :span="12">
  14. <el-form-item label="合同编号" prop="contractCode">
  15. <el-input v-model="editForm.contractCode" disabled placeholder="请输入合同编号" />
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="12">
  19. <el-form-item label="计划回款金额" prop="planAmount">
  20. <el-input v-model.number="editForm.planAmount" clearable placeholder="请输入计划回款金额" />
  21. </el-form-item>
  22. </el-col>
  23. </el-row>
  24. <el-row :gutter="20">
  25. <el-col :span="12">
  26. <el-form-item label="计划回款日期" prop="planDatetime">
  27. <el-date-picker
  28. v-model="editForm.planDatetime"
  29. placeholder="选择计划回款日期"
  30. style="width: 100%"
  31. type="date"
  32. value-format="yyyy-MM-dd" />
  33. </el-form-item>
  34. </el-col>
  35. <el-col :span="12">
  36. <el-form-item label="备注" prop="remark">
  37. <el-input v-model="editForm.remark" clearable placeholder="请输入备注" />
  38. </el-form-item>
  39. </el-col>
  40. </el-row>
  41. </el-form>
  42. <span slot="footer">
  43. <el-button v-show="!editForm.id" type="primary" @click="collectionPlanSave">保存</el-button>
  44. <el-button v-show="editForm.id" type="primary" @click="contractEdit">保存</el-button>
  45. <el-button @click="editVisible = false">取消</el-button>
  46. </span>
  47. </el-dialog>
  48. </template>
  49. <script>
  50. import to from 'await-to-js'
  51. import collectionPlanApi from '@/api/contract/collectionPlan'
  52. export default {
  53. props: {
  54. details: {
  55. type: Object,
  56. default: () => {},
  57. },
  58. },
  59. data() {
  60. return {
  61. title: '新建回款计划',
  62. editVisible: false,
  63. editForm: {
  64. planDatetime: '', //计划回款日期
  65. contractCode: '', //合同编号
  66. contractId: null, //合同id
  67. planAmount: '', //计划回款金额
  68. remark: '', //备注
  69. },
  70. editRules: {
  71. contractCode: [{ required: true, trigger: 'blur', message: '请选择合同' }],
  72. planAmount: [{ required: true, trigger: 'blur', message: '请输入计划回款金额' }],
  73. planDatetime: [
  74. { required: true, trigger: 'change', validator: this.pickerOptionsStart, message: '请选择计划回款日期' },
  75. ],
  76. },
  77. }
  78. },
  79. mounted() {},
  80. methods: {
  81. async init(id) {
  82. if (!id) {
  83. this.title = '新建回款计划'
  84. if (this.details) {
  85. this.editForm.contractCode = this.details.contractCode
  86. this.editForm.contractId = this.details.id
  87. }
  88. } else {
  89. this.title = '编辑回款计划'
  90. const [err, res] = await to(collectionPlanApi.getDetails({ id }))
  91. if (err) return
  92. if (res.data) {
  93. this.editForm = res.data
  94. }
  95. }
  96. this.editVisible = true
  97. },
  98. // 保存回款计划
  99. async collectionPlanSave() {
  100. let params = { ...this.editForm }
  101. const [valid] = await to(this.$refs.editForm.validate())
  102. if (valid == false) return
  103. const [err, res] = await to(collectionPlanApi.addCollectionPlan(params))
  104. if (err) return
  105. if (res.code == 200) this.$message.success(res.msg)
  106. else return
  107. this.editVisible = false
  108. this.$emit('collectionPlanSave')
  109. },
  110. // 编辑回款计划
  111. async contractEdit() {
  112. let params = { ...this.editForm }
  113. const [valid] = await to(this.$refs.editForm.validate())
  114. if (valid == false) return
  115. const [err, res] = await to(collectionPlanApi.updateCollectionPlan(params))
  116. if (err) return
  117. if (res.code == 200) this.$message.success(res.msg)
  118. else return
  119. this.editVisible = false
  120. this.$emit('collectionPlanSave')
  121. },
  122. handleClose() {
  123. this.editForm = {
  124. planDatetime: '', //计划回款日期
  125. contractCode: '', //合同编号
  126. contractId: null, //合同id
  127. planAmount: '', //计划回款金额
  128. remark: '', //备注
  129. }
  130. this.$refs.editForm.resetFields()
  131. },
  132. },
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .mb10 {
  137. margin-bottom: 10px;
  138. }
  139. .proj-col {
  140. text-align: right;
  141. }
  142. </style>