addModal.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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="purchaseTargetSn">
  20. <a-radio-group
  21. name="radioGroup"
  22. v-model="form.purchaseTargetSn"
  23. @change="tragetTypeChange"
  24. v-if="purchaseTragetType.length"
  25. id="purchaseOrder-basicInfo-purchaseTargetSn" >
  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. allowClear
  37. placeholder="请选择"></v-select>
  38. </a-form-model-item>
  39. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;">
  40. <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">保存</a-button>
  41. <a-button @click="isShow=false" style="margin-left: 15px" id="chooseCustom-btn-back">取消</a-button>
  42. </a-form-model-item>
  43. </a-form-model>
  44. </a-spin>
  45. </a-modal>
  46. </template>
  47. <script>
  48. import { commonMixin } from '@/utils/mixin'
  49. import { VSelect } from '@/components'
  50. import { purchaseTargetList } from '@/api/purchase'
  51. import { purchaseReturnSaveByNoSync } 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. purchaseTargetType: '', // 供应商
  74. purchaseTargetSn: undefined,
  75. purchaseTargetName: '',
  76. grabFlag: '1'
  77. },
  78. rules: {
  79. purchaseTargetSn: [
  80. { required: true, message: '请选择供应商', trigger: 'change' }
  81. ],
  82. grabFlag: [
  83. { required: true, message: '请选择抓单类型', trigger: 'change' }
  84. ]
  85. },
  86. purchaseTragetType: []
  87. }
  88. },
  89. methods: {
  90. resetForm () {
  91. this.$refs.ruleForm.resetFields()
  92. this.form.purchaseTargetType = ''
  93. this.form.purchaseTargetSn = undefined
  94. this.form.purchaseTargetName = ''
  95. },
  96. // 供应商change
  97. tragetTypeChange (e) {
  98. const val = e.target.value
  99. const ind = this.purchaseTragetType.findIndex(item => item.purchaseTargetSn == val)
  100. if (ind != -1) {
  101. this.form.purchaseTargetType = this.purchaseTragetType[ind].purchaseTargetType
  102. this.form.purchaseTargetName = this.purchaseTragetType[ind].purchaseTargetName
  103. }
  104. },
  105. // 保存
  106. handleSubmit (e) {
  107. e.preventDefault()
  108. const _this = this
  109. this.$refs.ruleForm.validate(valid => {
  110. if (valid) {
  111. _this.spinning = true
  112. purchaseReturnSaveByNoSync(_this.form).then(res => {
  113. if (res.status == 200) {
  114. _this.isShow = false
  115. _this.$emit('ok', res.data)
  116. _this.spinning = false
  117. _this.$message.info(res.message)
  118. } else {
  119. _this.spinning = false
  120. }
  121. })
  122. } else {
  123. return false
  124. }
  125. })
  126. },
  127. // 编辑信息
  128. setData (data) {
  129. this.form = JSON.parse(JSON.stringify(data))
  130. },
  131. getParentDealer () {
  132. const zb = this.$hasPermissions('B_PR_outSnycZB')
  133. const sj = this.$hasPermissions('B_PR_outSnycSJ')
  134. let params = {}
  135. // 只能向上级退货
  136. if (sj) {
  137. params.purchaseTargetType = 'DEALER_UP'
  138. }
  139. // 只能向总部退货
  140. if (zb) {
  141. params.purchaseTargetType = 'SUPPLIER_SYS'
  142. }
  143. // 总部和上级都可以
  144. if (sj && zb) {
  145. params = {}
  146. }
  147. purchaseTargetList(params).then(res => {
  148. if (res.status == 200 && res.data[0]) {
  149. this.purchaseTragetType = res.data
  150. } else {
  151. this.purchaseTragetType = []
  152. }
  153. })
  154. }
  155. },
  156. watch: {
  157. // 父页面传过来的弹框状态
  158. openModal (newValue, oldValue) {
  159. this.isShow = newValue
  160. },
  161. // 重定义的弹框状态
  162. isShow (newValue, oldValue) {
  163. if (!newValue) {
  164. this.$emit('close')
  165. this.resetForm()
  166. } else {
  167. this.getParentDealer()
  168. }
  169. }
  170. }
  171. }
  172. </script>
  173. <style lang="less">
  174. .purchaseOrder-basicInfo-modal{
  175. .ant-modal-body {
  176. padding: 40px 40px 24px;
  177. }
  178. .radio-s{
  179. margin-bottom: 8px;
  180. }
  181. .btn-cont {
  182. text-align: center;
  183. margin: 35px 0 10px;
  184. }
  185. }
  186. </style>