editPriceModal.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <a-modal
  3. centered
  4. class="editPrice-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="自定义报价"
  8. v-model="isShow"
  9. @cancel="isShow = false"
  10. :width="800">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. id="editPrice-form"
  14. ref="ruleForm"
  15. :model="form"
  16. :label-col="formItemLayout.labelCol"
  17. :wrapper-col="formItemLayout.wrapperCol">
  18. <a-form-model-item label="产品编码" prop="code">
  19. <div>{{ form.code }}</div>
  20. </a-form-model-item>
  21. <a-form-model-item label="产品名称" prop="name">
  22. <div>{{ form.name }}</div>
  23. </a-form-model-item>
  24. <a-form-model-item label="终端价" prop="terminalPrice">
  25. <div>{{ form.terminalPrice?form.terminalPrice : '--' }}</div>
  26. </a-form-model-item>
  27. <a-form-model-item label="自定义终端价" prop="dealerProductPrice.terminalPrice">
  28. <a-input-number
  29. :min="0.01"
  30. :max="999999"
  31. :precision="2"
  32. v-model.trim="form.dealerProductPrice.terminalPrice"
  33. style="width: 90%;margin-right: 5px;"
  34. placeholder="请输入自定义终端价"
  35. allowClear /><span>元</span>
  36. </a-form-model-item>
  37. <a-form-model-item label="车主价" prop="carOwnersPrice">
  38. <div>{{ form.carOwnersPrice?form.carOwnersPrice:'--' }}</div>
  39. </a-form-model-item>
  40. <a-form-model-item label="自定义车主价" prop="dealerProductPrice.carOwnersPrice">
  41. <a-input-number
  42. :min="0.01"
  43. :max="999999"
  44. :precision="2"
  45. v-model.trim="form.dealerProductPrice.carOwnersPrice"
  46. placeholder="请输入自定义车主价"
  47. style="width: 90%;margin-right: 5px;"
  48. allowClear /><span>元</span>
  49. </a-form-model-item>
  50. </a-form-model>
  51. <div class="btn-cont">
  52. <a-button type="primary" size="large" id="editPrice-btn-submit" @click="handleSubmit">保存</a-button>
  53. <a-button id="editPrice-btn-back" size="large" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  54. </div>
  55. </a-spin>
  56. </a-modal>
  57. </template>
  58. <script>
  59. import { commonMixin } from '@/utils/mixin'
  60. import { productDetail, settingPrice } from '@/api/product.js'
  61. export default {
  62. name: 'EditPriceModal',
  63. mixins: [commonMixin],
  64. props: {
  65. openModal: {
  66. // 弹框显示状态
  67. type: Boolean,
  68. default: false
  69. },
  70. itemId: {
  71. type: [Number, String],
  72. default: ''
  73. }
  74. },
  75. data () {
  76. return {
  77. spinning: false,
  78. isShow: this.openModal, // 是否打开弹框
  79. formItemLayout: {
  80. labelCol: { span: 6 },
  81. wrapperCol: { span: 16 }
  82. },
  83. form: {
  84. code: '',
  85. name: '',
  86. terminalPrice: '', // 终端建议价
  87. carOwnersPrice: '', // 车主建议价
  88. dealerProductPrice: {
  89. terminalPrice: '',
  90. carOwnersPrice: ''
  91. }
  92. }
  93. }
  94. },
  95. methods: {
  96. // 详情
  97. getDetail () {
  98. const _this = this
  99. productDetail({ sn: this.itemId }).then(res => {
  100. if (res.status == 200) {
  101. const objInfo = {}
  102. objInfo.code = res.data.code
  103. objInfo.name = res.data.name
  104. objInfo.terminalPrice = (res.data.terminalPrice || res.data.terminalPrice == 0) ? _this.toThousands(res.data.terminalPrice) : ''
  105. objInfo.carOwnersPrice = (res.data.carOwnersPrice || res.data.carOwnersPrice == 0) ? _this.toThousands(res.data.carOwnersPrice) : ''
  106. objInfo.dealerProductPrice = {}
  107. Object.assign(objInfo.dealerProductPrice, { terminalPrice: res.data.dealerProductPrice && (res.data.dealerProductPrice.terminalPrice || res.data.dealerProductPrice.terminalPrice == 0) ? res.data.dealerProductPrice.terminalPrice : '', carOwnersPrice: res.data.dealerProductPrice && (res.data.dealerProductPrice.carOwnersPrice || res.data.dealerProductPrice.carOwnersPrice == 0) ? res.data.dealerProductPrice.carOwnersPrice : '' })
  108. _this.form = objInfo
  109. }
  110. })
  111. },
  112. // 保存
  113. handleSubmit (e) {
  114. e.preventDefault()
  115. const _this = this
  116. _this.spinning = true
  117. const ajaxData = {}
  118. ajaxData.productSn = this.itemId
  119. ajaxData.dealerProductPrice = {}
  120. Object.assign(ajaxData.dealerProductPrice, _this.form.dealerProductPrice)
  121. settingPrice(ajaxData).then(res => {
  122. if (res.status == 200) {
  123. _this.$message.success(res.message)
  124. _this.$emit('ok')
  125. _this.isShow = false
  126. _this.spinning = false
  127. } else {
  128. _this.spinning = false
  129. }
  130. })
  131. }
  132. },
  133. watch: {
  134. // 父页面传过来的弹框状态
  135. openModal (newValue, oldValue) {
  136. this.isShow = newValue
  137. },
  138. // 重定义的弹框状态
  139. isShow (newValue, oldValue) {
  140. if (!newValue) {
  141. this.$emit('close')
  142. } else {
  143. this.getDetail()
  144. }
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="less">
  150. .editPrice-modal {
  151. .ant-modal-body {
  152. padding: 40px 40px 24px;
  153. }
  154. .btn-cont {
  155. text-align: center;
  156. margin: 35px 0 10px;
  157. }
  158. }
  159. </style>