basicInfoModal.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <a-modal
  3. centered
  4. class="bulkWarehousingOrder-basicInfo-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="新增散件入库单"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="800">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. id="bulkWarehousingOrder-basicInfo-form"
  14. ref="ruleForm"
  15. :model="form"
  16. :rules="rules"
  17. :label-col="formItemLayout.labelCol"
  18. :wrapper-col="formItemLayout.wrapperCol" >
  19. <a-form-model-item label="供应商" prop="supplierSn">
  20. <a-select
  21. placeholder="请输入名称查询,如果没有请点击 '+' 新增"
  22. allowClear
  23. v-model="form.supplierSn"
  24. :showSearch="true"
  25. option-filter-prop="children"
  26. :filter-option="filterOption"
  27. id="bulkWarehousingOrder-supplierSn"
  28. style="width: 80%;">
  29. <a-select-option
  30. v-for="item in supplierList"
  31. :id="'supplierSn-'+item.supplierSn"
  32. :key="item.supplierSn"
  33. :pyCode="item.pyCode"
  34. :value="item.supplierSn"
  35. :disabled="item.enabledFlag==0">{{ item.supplierName }}</a-select-option>
  36. </a-select>
  37. <a-button icon="plus" size="small" @click="openSupplierModal=true" id="bulkWarehousingOrder-basicInfo-add-btn" style="margin-left: 10px;"></a-button>
  38. </a-form-model-item>
  39. <a-form-model-item label="散件入库类型" prop="sparePartsType">
  40. <a-select id="bulkWarehousingOrder-basicInfo-sparePartsType" placeholder="请选择散件入库类型" allowClear v-model="form.sparePartsType">
  41. <a-select-option v-for="item in sparePartsPutTypeList" :id="'sn-'+item.sparePartsPutTypeSn" :key="item.sparePartsPutTypeSn" :value="item.sparePartsPutTypeSn">{{ item.name }}</a-select-option>
  42. </a-select>
  43. </a-form-model-item>
  44. <a-form-model-item label="备注" prop="remarks">
  45. <a-textarea
  46. id="bulkWarehousingOrder-remarks"
  47. :maxLength="200"
  48. v-model="form.remarks"
  49. placeholder="请输入备注(最多200个字符)"
  50. allowClear />
  51. </a-form-model-item>
  52. </a-form-model>
  53. <div class="btn-cont">
  54. <a-button type="primary" id="bulkWarehousingOrder-basicInfo-modal-save" @click="handleSave">保存</a-button>
  55. <a-button id="bulkWarehousingOrder-basicInfo-modal-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  56. </div>
  57. </a-spin>
  58. <!-- 供应商 -->
  59. <supplier-info-edit-modal :openModal="openSupplierModal" @close="closeSupplierModal" @ok="handleOk" :isState="false" />
  60. </a-modal>
  61. </template>
  62. <script>
  63. import { commonMixin } from '@/utils/mixin'
  64. import { VSelect } from '@/components'
  65. import supplierInfoEditModal from '@/views/supplierManagement/supplierInfo/editModal.vue'
  66. import { supplierAllList } from '@/api/supplier'
  67. import { sparePartsPutTypeAllList } from '@/api/sparePartsPutType'
  68. import { sparePartsPurSave } from '@/api/sparePartsPur'
  69. export default {
  70. name: 'BulkWarehousingOrderBasicInfoModal',
  71. components: { VSelect, supplierInfoEditModal },
  72. mixins: [commonMixin],
  73. props: {
  74. openModal: { // 弹框显示状态
  75. type: Boolean,
  76. default: false
  77. }
  78. },
  79. data () {
  80. return {
  81. spinning: false,
  82. isShow: this.openModal, // 是否打开弹框
  83. formItemLayout: {
  84. labelCol: { span: 4 },
  85. wrapperCol: { span: 18 }
  86. },
  87. form: {
  88. supplierSn: undefined, // 供应商
  89. sparePartsType: undefined, // 散件类型
  90. remarks: '' // 备注
  91. },
  92. rules: {
  93. supplierSn: [
  94. { required: true, message: '请选择供应商', trigger: 'change' }
  95. ],
  96. sparePartsType: [
  97. { required: true, message: '请选择散件入库类型', trigger: 'change' }
  98. ]
  99. },
  100. supplierList: [], // 供应商 下拉数据
  101. sparePartsPutTypeList: [], // 散件入库类型 下拉数据
  102. openSupplierModal: false // 供应商 弹框
  103. }
  104. },
  105. methods: {
  106. // 保存
  107. handleSave () {
  108. const _this = this
  109. this.$refs.ruleForm.validate(valid => {
  110. if (valid) {
  111. const form = JSON.parse(JSON.stringify(_this.form))
  112. _this.spinning = true
  113. sparePartsPurSave(form).then(res => {
  114. if (res.status == 200) {
  115. _this.$message.success(res.message)
  116. setTimeout(() => {
  117. _this.isShow = false
  118. _this.$emit('ok', res.data)
  119. _this.spinning = false
  120. }, 1000)
  121. } else {
  122. _this.spinning = false
  123. }
  124. })
  125. } else {
  126. return false
  127. }
  128. })
  129. },
  130. // 新增供应商 成功
  131. handleOk () {
  132. // 获取供应商数据列表,并赋值
  133. this.getSupplierList('val')
  134. },
  135. // 供应商名称筛选
  136. filterOption (input, option) {
  137. return (
  138. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0 ||
  139. option.data.attrs.pyCode.toLowerCase().indexOf(input.toLowerCase()) >= 0
  140. )
  141. },
  142. // 供应商下拉数据
  143. getSupplierList (val) {
  144. supplierAllList().then(res => {
  145. if (res.status == 200) {
  146. this.supplierList = res.data
  147. if (val) { // 需将新增加的供应商回填,即不需要用户再选一下
  148. this.form.supplierSn = this.supplierList[0].supplierSn
  149. this.$refs.ruleForm.clearValidate('supplierSn')
  150. }
  151. } else {
  152. this.supplierList = []
  153. }
  154. })
  155. },
  156. // 散件入库类型下拉数据
  157. getSparePartsPutTypeList () {
  158. sparePartsPutTypeAllList().then(res => {
  159. if (res.status == 200) {
  160. this.sparePartsPutTypeList = res.data
  161. } else {
  162. this.sparePartsPutTypeList = []
  163. }
  164. })
  165. },
  166. // 关闭供应商弹框
  167. closeSupplierModal () {
  168. this.openSupplierModal = false
  169. }
  170. },
  171. watch: {
  172. // 父页面传过来的弹框状态
  173. openModal (newValue, oldValue) {
  174. this.isShow = newValue
  175. },
  176. // 重定义的弹框状态
  177. isShow (newValue, oldValue) {
  178. if (!newValue) {
  179. this.$emit('close')
  180. this.$refs.ruleForm.resetFields()
  181. } else {
  182. this.getSupplierList()
  183. this.getSparePartsPutTypeList()
  184. }
  185. }
  186. }
  187. }
  188. </script>
  189. <style lang="less">
  190. .bulkWarehousingOrder-basicInfo-modal{
  191. .ant-modal-body {
  192. padding: 40px 40px 24px;
  193. }
  194. .btn-cont {
  195. text-align: center;
  196. margin: 35px 0 10px;
  197. }
  198. }
  199. </style>