123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <template>
- <a-modal
- centered
- class="merchantInfoManagement-modal"
- :footer="null"
- :maskClosable="false"
- :title="title"
- v-model="isShow"
- @cancel="cansel"
- :width="600">
- <div>
- <a-spin :spinning="spinning" tip="Loading...">
- <a-form-model
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="labelCol"
- :wrapper-col="wrapperCol"
- >
- <a-form-model-item style="margin-bottom:10px;" label="产品名称">
- <div style="line-height:normal;padding-top:11px;">{{ productName }}</div>
- </a-form-model-item>
- <a-form-model-item style="margin-bottom:10px;" label="产品编码">
- {{ productCode }}
- </a-form-model-item>
- <a-form-model-item style="margin-bottom:10px;" label="供应商名称">
- {{ supplierName }}
- </a-form-model-item>
- <a-form-model-item style="margin-bottom:10px;" label="原成本价">
- {{ cost||'--' }}
- </a-form-model-item>
- <a-form-model-item label="变更成本价" prop="cost">
- <a-input-number
- id="setting-cost"
- v-model="form.cost"
- :precision="2"
- :min="0"
- :max="999999"
- placeholder="请输入"
- ref="cost"
- @keyup.enter.native="onSubmit"
- style="width: 100%;" />
- </a-form-model-item>
- <div style="display: flex;justify-content: center;padding: 30px 0;">
- <a-button type="primary" @click="onSubmit">
- 确定
- </a-button>
- <a-button style="margin-left: 15px;" @click="cansel">
- 取消
- </a-button>
- </div>
- </a-form-model></a-spin>
- </a-form-model>
- </div>
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { VSelect } from '@/components'
- import { settingCost } from '@/api/supplier'
- export default {
- name: 'SettingCost',
- mixins: [commonMixin],
- components: { VSelect },
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- }
- },
- data () {
- return {
- isShow: this.openModal, // 是否打开弹框
- spinning: false,
- title: '设置成本价',
- labelCol: { span: 4 },
- wrapperCol: { span: 18 },
- productName: '',
- productCode: '',
- supplierName: '',
- cost: '',
- form: {
- supplierSn: '',
- supplierProductSn: '',
- cost: ''
- },
- rules: {
- cost: [
- { required: true, message: '请输入成本价', trigger: 'change' }
- ]
- }
- }
- },
- methods: {
- setData (row) {
- this.form.supplierSn = row.supplierSn
- this.form.supplierProductSn = row.supplierProductSn
- this.cost = row.cost
- this.productName = row.product.name
- this.productCode = row.product.code
- this.supplierName = row.supplierName
- },
- onSubmit () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const params = JSON.parse(JSON.stringify(_this.form))
- _this.spinning = true
- settingCost(params).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$emit('ok')
- _this.cansel()
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- } else {
- return false
- }
- })
- },
- cansel () {
- this.$emit('close')
- this.productName = ''
- this.productCode = ''
- this.$refs.ruleForm.resetFields()
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- if (newValue) {
- // 默认首项获取焦点
- const _this = this
- setTimeout(() => {
- if (_this.$refs['cost']) {
- _this.$refs['cost'].focus()
- }
- }, 300)
- }
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- }
- }
- }
- }
- </script>
- <style lang="less">
- .merchantInfoManagement-modal{
- .ant-modal-body {
- padding: 40px 40px 24px;
- }
- }
- </style>
|