basicInfoModal.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <a-modal
  3. centered
  4. class="purchaseReturn-basicInfo-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. :title="itemSn?'编辑':'新增'"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="800">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. id="purchaseReturn-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. <supplier v-model="form.supplierSn" isPermission placeholder="请输入供应商名称"></supplier>
  21. </a-form-model-item>
  22. <a-form-model-item label="仓库仓位" prop="warehouseSn">
  23. <a-select
  24. v-if="warehouseCascadeData && warehouseCascadeData.length>0"
  25. id="purchaseReturn-basicInfo-warehouseSn"
  26. @change="changeWarehouse"
  27. placeholder="请选择仓库"
  28. :allowClear="false"
  29. v-model="form.warehouseSn"
  30. style="width: 49%;margin-right:1%;">
  31. <a-select-option
  32. v-for="
  33. item
  34. in
  35. warehouseCascadeData"
  36. :value="item.warehouseSn">
  37. {{ item.name }}
  38. </a-select-option>
  39. </a-select>
  40. <a-select
  41. id="purchaseReturn-basicInfo-warehouseLocationSn"
  42. placeholder="请选择仓位"
  43. :allowClear="false"
  44. v-model="form.warehouseLocationSn"
  45. :disabled="!cascadeList"
  46. style="width: 50%;">
  47. <a-select-option v-for="con in cascadeList" :value="con.warehouseLocationSn">
  48. {{ con.name }}
  49. </a-select-option>
  50. </a-select>
  51. </a-form-model-item>
  52. <a-form-model-item label="客户名称" >
  53. <span>{{ itemData.dealerName||'--' }}</span>
  54. </a-form-model-item>
  55. <a-form-model-item label="关联单号" >
  56. <span>{{ itemData.lockBizNo||'--' }}</span>
  57. </a-form-model-item>
  58. <a-form-model-item label="备注">
  59. <span>{{ itemData.bizRemark||'--' }}</span>
  60. </a-form-model-item>
  61. </a-form-model>
  62. <div class="btn-cont">
  63. <a-button id="purchaseReturn-basicInfo-modal-back" @click="isShow = false">取消</a-button>
  64. <a-button style="margin-left: 15px;" type="primary" id="purchaseReturn-modal-save" @click="handleSave">确定</a-button>
  65. </div>
  66. </a-spin>
  67. </a-modal>
  68. </template>
  69. <script>
  70. import { commonMixin } from '@/utils/mixin'
  71. // 组件
  72. import { VSelect } from '@/components'
  73. import supplier from '@/views/common/supplier.js'
  74. import warehouse from '@/views/common/chooseWarehouse.js'
  75. // 接口
  76. import { detailBaseSave } from '@/api/purchase'
  77. import { warehouseCascadeList } from '@/api/warehouse'
  78. export default {
  79. name: 'PurchaseReceiptBasicInfoModal',
  80. mixins: [commonMixin],
  81. components: { VSelect, supplier, warehouse },
  82. props: {
  83. openModal: { // 弹框显示状态
  84. type: Boolean,
  85. default: false
  86. },
  87. itemSn: {
  88. type: [Number, String],
  89. default: ''
  90. },
  91. itemData: {
  92. type: Object,
  93. default: () => {}
  94. }
  95. },
  96. data () {
  97. return {
  98. isShow: this.openModal, // 是否打开弹框
  99. spinning: false,
  100. formItemLayout: {
  101. labelCol: { span: 5 },
  102. wrapperCol: { span: 16 }
  103. },
  104. warehouseCascadeData: [], // 仓库仓位级联列表
  105. cascadeList: null, // 仓位列表
  106. form: {
  107. supplierSn: undefined, // 供应商
  108. warehouseSn: undefined, // 仓库
  109. warehouseLocationSn: undefined // 仓位
  110. },
  111. rules: {
  112. supplierSn: [
  113. { required: true, message: '请选择供应商名称', trigger: 'change' }
  114. ],
  115. warehouseSn: [{ required: true, message: '请选择入库仓库', trigger: 'change' }]
  116. }
  117. }
  118. },
  119. methods: {
  120. // 获取仓库仓位 级联列表
  121. getWarehouseCascade () {
  122. const _this = this
  123. warehouseCascadeList({}).then(res => {
  124. if (res.status == 200) {
  125. this.warehouseCascadeData = res.data
  126. } else {
  127. this.warehouseCascadeData = []
  128. }
  129. })
  130. },
  131. // 仓库 change
  132. changeWarehouse (val) {
  133. const pos = this.warehouseCascadeData.findIndex(item => item.warehouseSn === val)
  134. if (pos != -1) {
  135. this.cascadeList = this.warehouseCascadeData[pos].warehouseLocationList || null
  136. this.form.warehouseLocationSn = (this.cascadeList && this.cascadeList.length > 0) ? this.cascadeList[0].warehouseLocationSn : undefined
  137. }
  138. },
  139. // 保存
  140. handleSave () {
  141. const _this = this
  142. this.$refs.ruleForm.validate(valid => {
  143. if (valid) {
  144. const form = JSON.parse(JSON.stringify(_this.form))
  145. if (!form.warehouseLocationSn) {
  146. _this.$message.warning('请选择仓位')
  147. return
  148. }
  149. form.sparePartsSn = _this.itemSn
  150. _this.spinning = true
  151. detailBaseSave(form).then(res => {
  152. if (res.status == 200) {
  153. _this.$message.success(res.message)
  154. setTimeout(() => {
  155. _this.isShow = false
  156. _this.$emit('ok')
  157. _this.spinning = false
  158. }, 1000)
  159. } else {
  160. _this.spinning = false
  161. }
  162. })
  163. } else {
  164. return false
  165. }
  166. })
  167. }
  168. },
  169. watch: {
  170. // 父页面传过来的弹框状态
  171. openModal (newValue, oldValue) {
  172. this.isShow = newValue
  173. },
  174. // 重定义的弹框状态
  175. isShow (newValue, oldValue) {
  176. if (!newValue) {
  177. this.$emit('close')
  178. this.$nextTick(() => {
  179. this.$refs.ruleForm.resetFields()
  180. })
  181. } else {
  182. this.getWarehouseCascade()
  183. }
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="less" scoped>
  189. .purchaseReturn-basicInfo-modal{
  190. .ant-modal-body {
  191. padding: 40px 40px 24px;
  192. }
  193. .btn-cont {
  194. text-align: center;
  195. margin: 35px 0 10px;
  196. }
  197. .ant-form-item:nth-child(5){
  198. margin-bottom: 0px !important;
  199. }
  200. }
  201. </style>