basicInfoModal.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 :disabledFlag="itemSn?true:false" placeholder="请输入供应商名称"></supplier>
  21. </a-form-model-item>
  22. <a-form-model-item label="入库仓库" prop="warehouseSn" v-show="isShowWarehouse">
  23. <warehouse
  24. v-model="form.warehouseSn"
  25. id="purchaseReturn-basicInfo-warehouseSn"
  26. :disabled="itemSn?true:false"
  27. isPermission
  28. placeholder="请选择退货仓库"
  29. />
  30. </a-form-model-item>
  31. <a-form-model-item label="客户名称" >
  32. <span>客户名称</span>
  33. </a-form-model-item>
  34. <a-form-model-item label="关联单号" >
  35. <span>关联单号</span>
  36. </a-form-model-item>
  37. <a-form-model-item label="备注">
  38. <span>--</span>
  39. </a-form-model-item>
  40. </a-form-model>
  41. <div class="btn-cont">
  42. <a-button id="purchaseReturn-basicInfo-modal-back" @click="isShow = false">取消</a-button>
  43. <a-button style="margin-left: 15px;" type="primary" id="purchaseReturn-modal-save" @click="handleSave">确定</a-button>
  44. </div>
  45. </a-spin>
  46. </a-modal>
  47. </template>
  48. <script>
  49. import { commonMixin } from '@/utils/mixin'
  50. import { VSelect, Upload } from '@/components'
  51. import supplier from '@/views/common/supplier.js'
  52. import warehouse from '@/views/common/chooseWarehouse.js'
  53. import { sparePartsReturnSave, sparePartsReturnInfo } from '@/api/sparePartsReturn'
  54. export default {
  55. name: 'PurchaseReturnBasicInfoModal',
  56. mixins: [commonMixin],
  57. components: { VSelect, Upload, supplier, warehouse },
  58. props: {
  59. openModal: { // 弹框显示状态
  60. type: Boolean,
  61. default: false
  62. },
  63. itemSn: {
  64. type: [Number, String],
  65. default: ''
  66. }
  67. },
  68. data () {
  69. return {
  70. isShow: this.openModal, // 是否打开弹框
  71. spinning: false,
  72. formItemLayout: {
  73. labelCol: { span: 5 },
  74. wrapperCol: { span: 16 }
  75. },
  76. form: {
  77. supplierSn: undefined, // 供应商
  78. returnReason: '', // 退货原因
  79. explainInfo: '', // 补充说明
  80. warehouseSn: undefined,
  81. attachmentList: '',
  82. grabFlag: 1
  83. },
  84. attachList: [], // 附件
  85. rules: {
  86. supplierSn: [
  87. { required: true, message: '请选择供应商名称', trigger: 'change' }
  88. ],
  89. returnReason: [
  90. { required: true, message: '请选择退货原因', trigger: 'change' }
  91. ],
  92. warehouseSn: [{ required: true, message: '请选择退货仓库', trigger: 'change' }],
  93. grabFlag: [{ required: true, message: '请选择是否抓单', trigger: 'change' }]
  94. },
  95. attachAction: process.env.VUE_APP_API_BASE_URL + '/uploadGetFileInfo'
  96. }
  97. },
  98. methods: {
  99. // 附件上传
  100. changeAttach (file) {
  101. this.attachList = JSON.parse(file)
  102. this.attachList.map(item => {
  103. item.fileType = item.extName
  104. })
  105. },
  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. form.attachmentList = _this.attachList
  113. _this.spinning = true
  114. sparePartsReturnSave(form).then(res => {
  115. if (res.status == 200) {
  116. _this.$message.success(res.message)
  117. setTimeout(() => {
  118. _this.isShow = false
  119. _this.$emit('ok', res.data)
  120. _this.spinning = false
  121. }, 1000)
  122. } else {
  123. _this.spinning = false
  124. }
  125. })
  126. } else {
  127. return false
  128. }
  129. })
  130. },
  131. // 获取编辑详情
  132. getDetail () {
  133. sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
  134. if (res.status == 200) {
  135. const resultObj = res.data
  136. this.attachList = resultObj.attachmentList
  137. const obj = {
  138. supplierSn: resultObj.supplierSn,
  139. returnReason: resultObj.returnReason, // 退货原因
  140. explainInfo: resultObj.explainInfo, // 补充说明
  141. warehouseSn: resultObj.warehouseSn,
  142. sparePartsReturnSn: this.itemSn,
  143. grabFlag: Number(resultObj.grabFlag)
  144. }
  145. this.$nextTick(() => {
  146. this.$refs.attachList.setFileList(this.attachList)
  147. })
  148. this.form = { ...this.form, ...obj }
  149. } else {
  150. this.detailsData = null
  151. }
  152. })
  153. }
  154. },
  155. watch: {
  156. // 父页面传过来的弹框状态
  157. openModal (newValue, oldValue) {
  158. this.isShow = newValue
  159. },
  160. // 重定义的弹框状态
  161. isShow (newValue, oldValue) {
  162. if (!newValue) {
  163. this.$emit('close')
  164. this.attachList = []
  165. this.supplierName = null
  166. this.$nextTick(() => {
  167. this.$refs.attachList.setFileList('')
  168. this.$refs.ruleForm.resetFields()
  169. })
  170. } else {
  171. if (this.itemSn) {
  172. this.getDetail()
  173. } else {
  174. // 默认仓库
  175. this.form.warehouseSn = this.isShowWarehouse ? undefined : this.defWarehouse && this.defWarehouse.warehouseSn
  176. }
  177. }
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="less" scoped>
  183. .purchaseReturn-basicInfo-modal{
  184. .ant-modal-body {
  185. padding: 40px 40px 24px;
  186. }
  187. .btn-cont {
  188. text-align: center;
  189. margin: 35px 0 10px;
  190. }
  191. .ant-form-item:nth-child(5){
  192. margin-bottom: 0px !important;
  193. }
  194. }
  195. </style>