123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <template>
- <a-modal
- centered
- class="bulkWarehousingOrder-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="bulkWarehousingOrder-basicInfo-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol" >
- <a-form-model-item label="供应商" prop="supplierSn">
- <a-select
- placeholder="请输入名称查询,如果没有请点击 '+' 新增"
- allowClear
- v-model="form.supplierSn"
- :showSearch="true"
- option-filter-prop="children"
- :filter-option="filterOption"
- id="bulkWarehousingOrder-supplierSn"
- style="width: 80%;">
- <a-select-option
- v-for="item in supplierList"
- :id="'supplierSn-'+item.supplierSn"
- :key="item.supplierSn"
- :pyCode="item.pyCode"
- :value="item.supplierSn"
- :disabled="item.enabledFlag==0">{{ item.supplierName }}</a-select-option>
- </a-select>
- <a-button icon="plus" size="small" @click="openSupplierModal=true" id="bulkWarehousingOrder-basicInfo-add-btn" style="margin-left: 10px;"></a-button>
- </a-form-model-item>
- <a-form-model-item label="散件入库类型" prop="sparePartsType">
- <a-select id="bulkWarehousingOrder-basicInfo-sparePartsType" placeholder="请选择散件入库类型" allowClear v-model="form.sparePartsType">
- <a-select-option v-for="item in sparePartsPutTypeList" :id="'sn-'+item.sparePartsPutTypeSn" :key="item.sparePartsPutTypeSn" :value="item.sparePartsPutTypeSn">{{ item.name }}</a-select-option>
- </a-select>
- </a-form-model-item>
- <a-form-model-item label="备注" prop="remarks">
- <a-textarea
- id="bulkWarehousingOrder-remarks"
- :maxLength="200"
- v-model="form.remarks"
- placeholder="请输入备注(最多200个字符)"
- allowClear />
- </a-form-model-item>
- </a-form-model>
- <div class="btn-cont">
- <a-button type="primary" id="bulkWarehousingOrder-basicInfo-modal-save" @click="handleSave">保存</a-button>
- <a-button id="bulkWarehousingOrder-basicInfo-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
- </div>
- </a-spin>
- <!-- 供应商 -->
- <supplier-info-edit-modal :openModal="openSupplierModal" @close="closeSupplierModal" @ok="handleOk" :isState="false" />
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { VSelect } from '@/components'
- import supplierInfoEditModal from '@/views/supplierManagement/supplierInfo/editModal.vue'
- import { supplierAllList } from '@/api/supplier'
- import { sparePartsPutTypeAllList } from '@/api/sparePartsPutType'
- import { sparePartsPurSave } from '@/api/sparePartsPur'
- export default {
- name: 'BulkWarehousingOrderBasicInfoModal',
- components: { VSelect, supplierInfoEditModal },
- mixins: [commonMixin],
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- }
- },
- data () {
- return {
- spinning: false,
- isShow: this.openModal, // 是否打开弹框
- formItemLayout: {
- labelCol: { span: 4 },
- wrapperCol: { span: 18 }
- },
- form: {
- supplierSn: undefined, // 供应商
- sparePartsType: undefined, // 散件类型
- remarks: '' // 备注
- },
- rules: {
- supplierSn: [
- { required: true, message: '请选择供应商', trigger: 'change' }
- ],
- sparePartsType: [
- { required: true, message: '请选择散件入库类型', trigger: 'change' }
- ]
- },
- supplierList: [], // 供应商 下拉数据
- sparePartsPutTypeList: [], // 散件入库类型 下拉数据
- openSupplierModal: false // 供应商 弹框
- }
- },
- methods: {
- // 保存
- handleSave () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- const form = JSON.parse(JSON.stringify(_this.form))
- _this.spinning = true
- sparePartsPurSave(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 {
- return false
- }
- })
- },
- // 新增供应商 成功
- handleOk () {
- // 获取供应商数据列表,并赋值
- this.getSupplierList('val')
- },
- // 供应商名称筛选
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
- option.data.attrs.pyCode.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- },
- // 供应商下拉数据
- getSupplierList (val) {
- supplierAllList().then(res => {
- if (res.status == 200) {
- this.supplierList = res.data
- if (val) { // 需将新增加的供应商回填,即不需要用户再选一下
- this.form.supplierSn = this.supplierList[0].supplierSn
- this.$refs.ruleForm.clearValidate('supplierSn')
- }
- } else {
- this.supplierList = []
- }
- })
- },
- // 散件入库类型下拉数据
- getSparePartsPutTypeList () {
- sparePartsPutTypeAllList().then(res => {
- if (res.status == 200) {
- this.sparePartsPutTypeList = res.data
- } else {
- this.sparePartsPutTypeList = []
- }
- })
- },
- // 关闭供应商弹框
- closeSupplierModal () {
- this.openSupplierModal = false
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.$refs.ruleForm.resetFields()
- } else {
- this.getSupplierList()
- this.getSparePartsPutTypeList()
- }
- }
- }
- }
- </script>
- <style lang="less">
- .bulkWarehousingOrder-basicInfo-modal{
- .ant-modal-body {
- padding: 40px 40px 24px;
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|