addModal.vue 6.4 KB

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