123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <a-modal
- centered
- class="storeTransferOut-basicInfo-modal"
- :footer="null"
- :maskClosable="false"
- title="新增店内调出单"
- v-model="isShow"
- @cancel="isShow = false"
- :width="800">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-form-model
- id="storeTransferOut-basicInfo-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol"
- >
- <a-form-model-item label="调往对象" prop="putPersonType">
- <a-radio-group v-model="form.putPersonType" @change="putPersonTypeChange">
- <a-radio v-for="(item,index) in putPersonTypeList" :key="index" :value="item.code">{{ item.dispName }}</a-radio>
- </a-radio-group>
- </a-form-model-item>
- <a-form-model-item label="调往对象名称" :prop="isCustomer ? 'putPersonSn' : 'putPersonName'">
- <custList ref="custList" :isValidateEnabled="true" v-if="isCustomer" @change="custChange" v-model="form.putPersonSn"></custList>
- <a-input v-if="!isCustomer" v-model.trim="form.putPersonName" placeholder="请输入调往对象名称(最多30个字符)" allowClear :maxLength="30" />
- </a-form-model-item>
- <a-form-model-item label="调拨类型" prop="callOutType">
- <a-select v-model="form.callOutType" placeholder="请选择调拨类型" allowClear >
- <a-select-option v-for="item in storeCallOutTypeList" :key="item.storeCallOutTypeSn" :value="item.storeCallOutTypeSn">{{ item.name }}</a-select-option>
- </a-select>
- </a-form-model-item>
- <a-form-model-item label="备注" prop="remark">
- <a-textarea id="storeTransferOut-basicInfo-remark" :maxLength="120" v-model="form.remark" placeholder="请输入备注(最多120个字符)" allowClear />
- </a-form-model-item>
- </a-form-model>
- <div class="btn-cont">
- <a-button type="primary" id="storeTransferOut-basicInfo-modal-save" @click="handleSave">保存</a-button>
- <a-button id="storeTransferOut-basicInfo-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
- </div>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { VSelect } from '@/components'
- import { storeCallOutSave } from '@/api/storeCallOut'
- import { getLookUpData } from '@/api/data'
- import custList from '@/views/common/custList.vue'
- import { storeCallOutTypeAllList } from '@/api/storeCallOutType'
- export default {
- name: 'StoreTransferOutBasicInfoModal',
- components: { VSelect, custList },
- mixins: [commonMixin],
- props: {
- openModal: {
- // 弹框显示状态
- type: Boolean,
- default: false
- }
- },
- data () {
- return {
- spinning: false,
- isShow: this.openModal, // 是否打开弹框
- formItemLayout: {
- labelCol: { span: 4 },
- wrapperCol: { span: 18 }
- },
- form: {
- putPersonType: 'CUSTOMER',
- putPersonSn: undefined,
- putPersonName: '',
- callOutType: undefined,
- remark: ''
- },
- rules: {
- putPersonType: [{ required: true, message: '请选择调往对象', trigger: 'change' }],
- putPersonSn: [{ required: true, message: '请选择调往对象名称', trigger: 'change' }],
- putPersonName: [{ required: true, message: '请输入调往对象名称', trigger: 'blur' }],
- callOutType: [{ required: true, message: '请选择调拨类型', trigger: 'change' }]
- },
- putPersonTypeList: [], // 调往对象类型
- storeCallOutTypeList: [] // 调拨类型
- }
- },
- computed: {
- // 当前所选调往对象是否为客户
- isCustomer () {
- return this.form.putPersonType == 'CUSTOMER'
- }
- },
- methods: {
- // 保存
- handleSave () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const form = JSON.parse(JSON.stringify(_this.form))
- _this.spinning = true
- storeCallOutSave(form).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- setTimeout(() => {
- _this.isShow = false
- _this.$emit('ok', res.data)
- _this.spinning = false
- }, 1000)
- } else {
- _this.spinning = false
- }
- })
- } else {
- console.log('error submit!!')
- return false
- }
- })
- },
- // 调往对象名称 change
- custChange (obj) {
- this.form.putPersonSn = obj.key || undefined
- this.form.putPersonName = obj.row.customerName
- },
- // 调往对象 change
- putPersonTypeChange (e) {
- this.$refs.ruleForm.resetFields()
- this.form.putPersonSn = undefined
- this.form.putPersonName = ''
- this.form.putPersonType = e.target.value
- },
- // 调往对象类型
- getPutPersonTypeList () {
- const _this = this
- getLookUpData({
- pageNo: 1,
- pageSize: 1000,
- lookupCode: 'PUT_PERSON_TYPE'
- }).then(res => {
- if (res.status == 200) {
- _this.putPersonTypeList = res.data.list
- } else {
- _this.putPersonTypeList = []
- }
- })
- },
- // 调拨类型
- getStoreCallOutTypeAllList () {
- storeCallOutTypeAllList().then(res => {
- if (res.status == 200) {
- this.storeCallOutTypeList = res.data
- } else {
- this.storeCallOutTypeList = []
- }
- })
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.$refs.ruleForm.resetFields()
- this.$refs.custList.resetForm()
- } else {
- this.getPutPersonTypeList()
- this.getStoreCallOutTypeAllList()
- }
- }
- }
- }
- </script>
- <style lang="less">
- .storeTransferOut-basicInfo-modal {
- .ant-modal-body {
- padding: 40px 40px 24px;
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|