123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- <template>
- <a-modal
- centered
- class="purchaseReturn-basicInfo-modal"
- :footer="null"
- :maskClosable="false"
- :title="itemSn?'编辑':'新增'"
- v-model="isShow"
- @cancel="isShow=false"
- :width="800">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-form-model
- id="purchaseReturn-basicInfo-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol" >
- <a-form-model-item label="供应商名称" prop="supplierSn">
- <supplier v-model="form.supplierSn" isPermission placeholder="请输入供应商名称"></supplier>
- </a-form-model-item>
- <a-form-model-item label="仓库仓位" prop="warehouseSn">
- <a-select
- v-if="warehouseCascadeData && warehouseCascadeData.length>0"
- id="purchaseReturn-basicInfo-warehouseSn"
- @change="changeWarehouse"
- placeholder="请选择仓库"
- :allowClear="false"
- v-model="form.warehouseSn"
- style="width: 49%;margin-right:1%;">
- <a-select-option
- v-for="
- item
- in
- warehouseCascadeData"
- :value="item.warehouseSn">
- {{ item.name }}
- </a-select-option>
- </a-select>
- <a-select
- id="purchaseReturn-basicInfo-warehouseLocationSn"
- placeholder="请选择仓位"
- :allowClear="false"
- v-model="form.warehouseLocationSn"
- :disabled="!cascadeList"
- style="width: 50%;">
- <a-select-option v-for="con in cascadeList" :value="con.warehouseLocationSn">
- {{ con.name }}
- </a-select-option>
- </a-select>
- </a-form-model-item>
- <a-form-model-item label="客户名称" >
- <span>{{ itemData.dealerName||'--' }}</span>
- </a-form-model-item>
- <a-form-model-item label="关联单号" >
- <span>{{ itemData.lockBizNo||'--' }}</span>
- </a-form-model-item>
- <a-form-model-item label="备注">
- <span>{{ itemData.bizRemark||'--' }}</span>
- </a-form-model-item>
- </a-form-model>
- <div class="btn-cont">
- <a-button id="purchaseReturn-basicInfo-modal-back" @click="isShow = false">取消</a-button>
- <a-button style="margin-left: 15px;" type="primary" id="purchaseReturn-modal-save" @click="handleSave">确定</a-button>
- </div>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- // 组件
- import { VSelect } from '@/components'
- import supplier from '@/views/common/supplier.js'
- import warehouse from '@/views/common/chooseWarehouse.js'
- // 接口
- import { detailBaseSave } from '@/api/purchase'
- import { warehouseCascadeList } from '@/api/warehouse'
- export default {
- name: 'PurchaseReceiptBasicInfoModal',
- mixins: [commonMixin],
- components: { VSelect, supplier, warehouse },
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- },
- itemSn: {
- type: [Number, String],
- default: ''
- },
- itemData: {
- type: Object,
- default: () => {}
- }
- },
- data () {
- return {
- isShow: this.openModal, // 是否打开弹框
- spinning: false,
- formItemLayout: {
- labelCol: { span: 5 },
- wrapperCol: { span: 16 }
- },
- warehouseCascadeData: [], // 仓库仓位级联列表
- cascadeList: null, // 仓位列表
- form: {
- supplierSn: undefined, // 供应商
- warehouseSn: undefined, // 仓库
- warehouseLocationSn: undefined // 仓位
- },
- rules: {
- supplierSn: [
- { required: true, message: '请选择供应商名称', trigger: 'change' }
- ],
- warehouseSn: [{ required: true, message: '请选择入库仓库', trigger: 'change' }]
- }
- }
- },
- methods: {
- // 获取仓库仓位 级联列表
- getWarehouseCascade () {
- const _this = this
- warehouseCascadeList({}).then(res => {
- if (res.status == 200) {
- this.warehouseCascadeData = res.data
- } else {
- this.warehouseCascadeData = []
- }
- })
- },
- // 仓库 change
- changeWarehouse (val) {
- const pos = this.warehouseCascadeData.findIndex(item => item.warehouseSn === val)
- if (pos != -1) {
- this.cascadeList = this.warehouseCascadeData[pos].warehouseLocationList || null
- this.form.warehouseLocationSn = (this.cascadeList && this.cascadeList.length > 0) ? this.cascadeList[0].warehouseLocationSn : undefined
- }
- },
- // 保存
- handleSave () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const form = JSON.parse(JSON.stringify(_this.form))
- if (!form.warehouseLocationSn) {
- _this.$message.warning('请选择仓位')
- return
- }
- form.sparePartsSn = _this.itemSn
- _this.spinning = true
- detailBaseSave(form).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- setTimeout(() => {
- _this.isShow = false
- _this.$emit('ok')
- _this.spinning = false
- }, 1000)
- } else {
- _this.spinning = false
- }
- })
- } else {
- return false
- }
- })
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.$nextTick(() => {
- this.$refs.ruleForm.resetFields()
- })
- } else {
- this.getWarehouseCascade()
- }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .purchaseReturn-basicInfo-modal{
- .ant-modal-body {
- padding: 40px 40px 24px;
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- .ant-form-item:nth-child(5){
- margin-bottom: 0px !important;
- }
- }
- </style>
|