basicInfoModal.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <a-modal
  3. centered
  4. class="purchaseOrder-basicInfo-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="新增采购退货单"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="600">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. id="purchaseOrder-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="returnTargetSn">
  20. <a-radio-group
  21. name="radioGroup"
  22. v-model="form.returnTargetSn"
  23. @change="tragetTypeChange"
  24. v-if="purchaseTragetType.length"
  25. id="purchaseOrder-basicInfo-returnTargetSn" >
  26. <a-radio v-for="item in purchaseTragetType" :key="item.purchaseTargetSn" :value="item.purchaseTargetSn" class="radio-s">{{ item.purchaseTargetName }}</a-radio>
  27. </a-radio-group>
  28. <span v-else>没有可选择的供应商</span>
  29. </a-form-model-item>
  30. <a-form-model-item label="是否抓单" prop="grabFlag">
  31. <v-select
  32. code="FLAG"
  33. showType="radio"
  34. id="purchaseOrder-grabFlag"
  35. v-model="form.grabFlag"
  36. @change="changeGrabFlag"
  37. allowClear
  38. placeholder="请选择"></v-select>
  39. </a-form-model-item>
  40. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;">
  41. <a-button type="primary" size="large" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">保存</a-button>
  42. <a-button @click="isShow=false" size="large" style="margin-left: 15px" id="chooseCustom-btn-back">取消</a-button>
  43. </a-form-model-item>
  44. </a-form-model>
  45. </a-spin>
  46. </a-modal>
  47. </template>
  48. <script>
  49. import { commonMixin } from '@/utils/mixin'
  50. import { VSelect } from '@/components'
  51. import { purchaseReturnSaveByNoSync, queryPurchaseReturnSupplierList } from '@/api/purchaseReturn'
  52. export default {
  53. name: 'BasicInfoModal',
  54. components: { VSelect },
  55. mixins: [commonMixin],
  56. props: {
  57. openModal: { // 弹框显示状态
  58. type: Boolean,
  59. default: false
  60. }
  61. },
  62. data () {
  63. return {
  64. spinning: false,
  65. confirmLoading: false,
  66. isShow: this.openModal, // 是否打开弹框
  67. settleStyleList: [], // 支付方式
  68. formItemLayout: {
  69. labelCol: { span: 4 },
  70. wrapperCol: { span: 18 }
  71. },
  72. form: {
  73. returnTargetType: '', // 供应商
  74. returnTargetSn: undefined,
  75. returnTargetName: '',
  76. grabFlag: '1'
  77. },
  78. rules: {
  79. returnTargetSn: [
  80. { required: true, message: '请选择供应商', trigger: 'change' }
  81. ],
  82. grabFlag: [
  83. { required: true, message: '请选择抓单类型', trigger: 'change' }
  84. ]
  85. },
  86. purchaseTragetType: []
  87. }
  88. },
  89. mounted () {
  90. this.getParentDealer()
  91. },
  92. methods: {
  93. changeGrabFlag (e) {
  94. console.log(e)
  95. },
  96. resetForm () {
  97. this.$refs.ruleForm.resetFields()
  98. this.form.returnTargetType = ''
  99. this.form.returnTargetSn = undefined
  100. this.form.returnTargetName = ''
  101. this.form.grabFlag = '1'
  102. },
  103. // 供应商change
  104. tragetTypeChange (e) {
  105. const val = e.target.value
  106. const ind = this.purchaseTragetType.findIndex(item => item.purchaseTargetSn == val)
  107. if (ind != -1) {
  108. this.form.returnTargetType = this.purchaseTragetType[ind].purchaseTargetType
  109. this.form.returnTargetName = this.purchaseTragetType[ind].purchaseTargetName
  110. }
  111. },
  112. // 保存
  113. handleSubmit (e) {
  114. e.preventDefault()
  115. const _this = this
  116. this.$refs.ruleForm.validate(valid => {
  117. if (valid) {
  118. _this.spinning = true
  119. purchaseReturnSaveByNoSync(_this.form).then(res => {
  120. if (res.status == 200) {
  121. _this.isShow = false
  122. _this.$emit('ok', res.data)
  123. _this.spinning = false
  124. _this.$message.info(res.message)
  125. } else {
  126. _this.spinning = false
  127. }
  128. })
  129. } else {
  130. return false
  131. }
  132. })
  133. },
  134. // 编辑信息
  135. setData (data) {
  136. this.form = JSON.parse(JSON.stringify(data))
  137. },
  138. getParentDealer () {
  139. const zb = this.$hasPermissions('B_PR_outSnycZB')
  140. const sj = this.$hasPermissions('B_PR_outSnycSJ')
  141. let params = {}
  142. // 只能向上级退货
  143. if (sj) {
  144. params.purchaseTargetType = 'DEALER_UP'
  145. }
  146. // 只能向总部退货
  147. if (zb) {
  148. params.purchaseTargetType = 'SUPPLIER_SYS'
  149. }
  150. // 总部和上级都可以
  151. if (sj && zb) {
  152. params = {}
  153. }
  154. console.log(params)
  155. queryPurchaseReturnSupplierList(params).then(res => {
  156. if (res.status == 200 && res.data[0]) {
  157. this.purchaseTragetType = res.data
  158. this.$emit('load', res.data)
  159. } else {
  160. this.purchaseTragetType = []
  161. }
  162. })
  163. }
  164. },
  165. watch: {
  166. // 父页面传过来的弹框状态
  167. openModal (newValue, oldValue) {
  168. this.isShow = newValue
  169. },
  170. // 重定义的弹框状态
  171. isShow (newValue, oldValue) {
  172. if (!newValue) {
  173. this.$emit('close')
  174. this.resetForm()
  175. } else {
  176. this.getParentDealer()
  177. }
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="less">
  183. .purchaseOrder-basicInfo-modal{
  184. .ant-modal-body {
  185. padding: 40px 40px 24px;
  186. }
  187. .radio-s{
  188. margin-bottom: 8px;
  189. }
  190. .btn-cont {
  191. text-align: center;
  192. margin: 35px 0 10px;
  193. }
  194. }
  195. </style>