basicInfoModal.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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="800">
  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" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">保存</a-button>
  42. <a-button @click="isShow=false" 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 { purchaseTargetList } from '@/api/purchase'
  52. import { purchaseReturnSaveByNoSync } from '@/api/purchaseReturn'
  53. export default {
  54. name: 'BasicInfoModal',
  55. components: { VSelect },
  56. mixins: [commonMixin],
  57. props: {
  58. openModal: { // 弹框显示状态
  59. type: Boolean,
  60. default: false
  61. }
  62. },
  63. data () {
  64. return {
  65. spinning: false,
  66. confirmLoading: false,
  67. isShow: this.openModal, // 是否打开弹框
  68. settleStyleList: [], // 支付方式
  69. formItemLayout: {
  70. labelCol: { span: 4 },
  71. wrapperCol: { span: 18 }
  72. },
  73. form: {
  74. returnTargetType: '', // 供应商
  75. returnTargetSn: undefined,
  76. returnTargetName: '',
  77. grabFlag: '1'
  78. },
  79. rules: {
  80. returnTargetSn: [
  81. { required: true, message: '请选择供应商', trigger: 'change' }
  82. ],
  83. grabFlag: [
  84. { required: true, message: '请选择抓单类型', trigger: 'change' }
  85. ]
  86. },
  87. purchaseTragetType: []
  88. }
  89. },
  90. mounted () {
  91. this.getParentDealer()
  92. },
  93. methods: {
  94. changeGrabFlag (e) {
  95. console.log(e)
  96. },
  97. resetForm () {
  98. this.$refs.ruleForm.resetFields()
  99. this.form.returnTargetType = ''
  100. this.form.returnTargetSn = undefined
  101. this.form.returnTargetName = ''
  102. this.form.grabFlag = '1'
  103. },
  104. // 供应商change
  105. tragetTypeChange (e) {
  106. const val = e.target.value
  107. const ind = this.purchaseTragetType.findIndex(item => item.purchaseTargetSn == val)
  108. if (ind != -1) {
  109. this.form.returnTargetType = this.purchaseTragetType[ind].purchaseTargetType
  110. this.form.returnTargetName = this.purchaseTragetType[ind].purchaseTargetName
  111. }
  112. },
  113. // 保存
  114. handleSubmit (e) {
  115. e.preventDefault()
  116. const _this = this
  117. this.$refs.ruleForm.validate(valid => {
  118. if (valid) {
  119. _this.spinning = true
  120. purchaseReturnSaveByNoSync(_this.form).then(res => {
  121. if (res.status == 200) {
  122. _this.isShow = false
  123. _this.$emit('ok', res.data)
  124. _this.spinning = false
  125. _this.$message.info(res.message)
  126. } else {
  127. _this.spinning = false
  128. }
  129. })
  130. } else {
  131. return false
  132. }
  133. })
  134. },
  135. // 编辑信息
  136. setData (data) {
  137. this.form = JSON.parse(JSON.stringify(data))
  138. },
  139. getParentDealer () {
  140. const zb = this.$hasPermissions('B_PR_outSnycZB')
  141. const sj = this.$hasPermissions('B_PR_outSnycSJ')
  142. let params = {}
  143. // 只能向上级退货
  144. if (sj) {
  145. params.purchaseTargetType = 'DEALER_UP'
  146. }
  147. // 只能向总部退货
  148. if (zb) {
  149. params.purchaseTargetType = 'SUPPLIER_SYS'
  150. }
  151. // 总部和上级都可以
  152. if (sj && zb) {
  153. params = {}
  154. }
  155. console.log(params)
  156. purchaseTargetList(params).then(res => {
  157. if (res.status == 200 && res.data[0]) {
  158. this.purchaseTragetType = res.data
  159. this.$emit('load', res.data)
  160. } else {
  161. this.purchaseTragetType = []
  162. }
  163. })
  164. }
  165. },
  166. watch: {
  167. // 父页面传过来的弹框状态
  168. openModal (newValue, oldValue) {
  169. this.isShow = newValue
  170. },
  171. // 重定义的弹框状态
  172. isShow (newValue, oldValue) {
  173. if (!newValue) {
  174. this.$emit('close')
  175. this.resetForm()
  176. } else {
  177. this.getParentDealer()
  178. }
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="less">
  184. .purchaseOrder-basicInfo-modal{
  185. .ant-modal-body {
  186. padding: 40px 40px 24px;
  187. }
  188. .radio-s{
  189. margin-bottom: 8px;
  190. }
  191. .btn-cont {
  192. text-align: center;
  193. margin: 35px 0 10px;
  194. }
  195. }
  196. </style>