settingCost.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <a-modal
  3. centered
  4. class="merchantInfoManagement-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. :title="title"
  8. v-model="isShow"
  9. @cancel="cansel"
  10. :width="600">
  11. <div>
  12. <a-spin :spinning="spinning" tip="Loading...">
  13. <a-form-model
  14. ref="ruleForm"
  15. :model="form"
  16. :rules="rules"
  17. :label-col="labelCol"
  18. :wrapper-col="wrapperCol"
  19. >
  20. <a-form-model-item style="margin-bottom:10px;" label="产品名称">
  21. <div style="line-height:normal;padding-top:11px;">{{ productName }}</div>
  22. </a-form-model-item>
  23. <a-form-model-item style="margin-bottom:10px;" label="产品编码">
  24. {{ productCode }}
  25. </a-form-model-item>
  26. <a-form-model-item style="margin-bottom:10px;" label="供应商名称">
  27. {{ supplierName }}
  28. </a-form-model-item>
  29. <a-form-model-item style="margin-bottom:10px;" label="原成本价">
  30. {{ cost||'--' }}
  31. </a-form-model-item>
  32. <a-form-model-item label="变更成本价" prop="cost">
  33. <a-input-number
  34. id="setting-cost"
  35. v-model="form.cost"
  36. :precision="2"
  37. :min="0"
  38. :max="999999"
  39. placeholder="请输入"
  40. ref="cost"
  41. @keyup.enter.native="onSubmit"
  42. style="width: 100%;" />
  43. </a-form-model-item>
  44. <div style="display: flex;justify-content: center;padding: 30px 0;">
  45. <a-button type="primary" @click="onSubmit">
  46. 确定
  47. </a-button>
  48. <a-button style="margin-left: 15px;" @click="cansel">
  49. 取消
  50. </a-button>
  51. </div>
  52. </a-form-model></a-spin>
  53. </a-form-model>
  54. </div>
  55. </a-modal>
  56. </template>
  57. <script>
  58. import { commonMixin } from '@/utils/mixin'
  59. import { VSelect } from '@/components'
  60. import { settingCost } from '@/api/supplier'
  61. export default {
  62. name: 'SettingCost',
  63. mixins: [commonMixin],
  64. components: { VSelect },
  65. props: {
  66. openModal: { // 弹框显示状态
  67. type: Boolean,
  68. default: false
  69. }
  70. },
  71. data () {
  72. return {
  73. isShow: this.openModal, // 是否打开弹框
  74. spinning: false,
  75. title: '设置成本价',
  76. labelCol: { span: 4 },
  77. wrapperCol: { span: 18 },
  78. productName: '',
  79. productCode: '',
  80. supplierName: '',
  81. cost: '',
  82. form: {
  83. supplierSn: '',
  84. supplierProductSn: '',
  85. cost: ''
  86. },
  87. rules: {
  88. cost: [
  89. { required: true, message: '请输入成本价', trigger: 'change' }
  90. ]
  91. }
  92. }
  93. },
  94. methods: {
  95. setData (row) {
  96. this.form.supplierSn = row.supplierSn
  97. this.form.supplierProductSn = row.supplierProductSn
  98. this.cost = row.cost
  99. this.productName = row.product.name
  100. this.productCode = row.product.code
  101. this.supplierName = row.supplierName
  102. },
  103. onSubmit () {
  104. const _this = this
  105. this.$refs.ruleForm.validate(valid => {
  106. if (valid) {
  107. const params = JSON.parse(JSON.stringify(_this.form))
  108. _this.spinning = true
  109. settingCost(params).then(res => {
  110. if (res.status == 200) {
  111. _this.$message.success(res.message)
  112. _this.$emit('ok')
  113. _this.cansel()
  114. _this.spinning = false
  115. } else {
  116. _this.spinning = false
  117. }
  118. })
  119. } else {
  120. return false
  121. }
  122. })
  123. },
  124. cansel () {
  125. this.$emit('close')
  126. this.productName = ''
  127. this.productCode = ''
  128. this.$refs.ruleForm.resetFields()
  129. }
  130. },
  131. watch: {
  132. // 父页面传过来的弹框状态
  133. openModal (newValue, oldValue) {
  134. this.isShow = newValue
  135. if (newValue) {
  136. // 默认首项获取焦点
  137. const _this = this
  138. setTimeout(() => {
  139. if (_this.$refs['cost']) {
  140. _this.$refs['cost'].focus()
  141. }
  142. }, 300)
  143. }
  144. },
  145. // 重定义的弹框状态
  146. isShow (newValue, oldValue) {
  147. if (!newValue) {
  148. this.$emit('close')
  149. }
  150. }
  151. }
  152. }
  153. </script>
  154. <style lang="less">
  155. .merchantInfoManagement-modal{
  156. .ant-modal-body {
  157. padding: 40px 40px 24px;
  158. }
  159. }
  160. </style>