123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <template>
- <a-modal
- centered
- class="purchaseOrder-basicInfo-modal"
- :footer="null"
- :maskClosable="false"
- title="新增采购单"
- v-model="isShow"
- @cancel="isShow=false"
- :width="800">
- <a-spin :spinning="spinning" tip="Loading...">
- <a-form-model
- id="purchaseOrder-basicInfo-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol" >
- <a-form-model-item label="供应商" prop="returnTargetSn">
- <a-radio-group
- name="radioGroup"
- v-model="form.returnTargetSn"
- @change="tragetTypeChange"
- v-if="purchaseTragetType.length"
- id="purchaseOrder-basicInfo-returnTargetSn" >
- <a-radio v-for="item in purchaseTragetType" :key="item.purchaseTargetSn" :value="item.purchaseTargetSn" class="radio-s">{{ item.purchaseTargetName }}</a-radio>
- </a-radio-group>
- <span v-else>没有可选择的供应商</span>
- </a-form-model-item>
- <a-form-model-item label="是否抓单" prop="grabFlag">
- <v-select
- code="FLAG"
- showType="radio"
- id="purchaseOrder-grabFlag"
- v-model="form.grabFlag"
- @change="changeGrabFlag"
- allowClear
- placeholder="请选择"></v-select>
- </a-form-model-item>
- <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;">
- <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">保存</a-button>
- <a-button @click="isShow=false" style="margin-left: 15px" id="chooseCustom-btn-back">取消</a-button>
- </a-form-model-item>
- </a-form-model>
- </a-spin>
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { VSelect } from '@/components'
- import { purchaseTargetList } from '@/api/purchase'
- import { purchaseReturnSaveByNoSync } from '@/api/purchaseReturn'
- export default {
- name: 'BasicInfoModal',
- components: { VSelect },
- mixins: [commonMixin],
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- }
- },
- data () {
- return {
- spinning: false,
- confirmLoading: false,
- isShow: this.openModal, // 是否打开弹框
- settleStyleList: [], // 支付方式
- formItemLayout: {
- labelCol: { span: 4 },
- wrapperCol: { span: 18 }
- },
- form: {
- returnTargetType: '', // 供应商
- returnTargetSn: undefined,
- returnTargetName: '',
- grabFlag: '1'
- },
- rules: {
- returnTargetSn: [
- { required: true, message: '请选择供应商', trigger: 'change' }
- ],
- grabFlag: [
- { required: true, message: '请选择抓单类型', trigger: 'change' }
- ]
- },
- purchaseTragetType: []
- }
- },
- mounted () {
- this.getParentDealer()
- },
- methods: {
- changeGrabFlag (e) {
- console.log(e)
- },
- resetForm () {
- this.$refs.ruleForm.resetFields()
- this.form.returnTargetType = ''
- this.form.returnTargetSn = undefined
- this.form.returnTargetName = ''
- this.form.grabFlag = '1'
- },
- // 供应商change
- tragetTypeChange (e) {
- const val = e.target.value
- const ind = this.purchaseTragetType.findIndex(item => item.purchaseTargetSn == val)
- if (ind != -1) {
- this.form.returnTargetType = this.purchaseTragetType[ind].purchaseTargetType
- this.form.returnTargetName = this.purchaseTragetType[ind].purchaseTargetName
- }
- },
- // 保存
- handleSubmit (e) {
- e.preventDefault()
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- _this.spinning = true
- purchaseReturnSaveByNoSync(_this.form).then(res => {
- if (res.status == 200) {
- _this.isShow = false
- _this.$emit('ok', res.data)
- _this.spinning = false
- _this.$message.info(res.message)
- } else {
- _this.spinning = false
- }
- })
- } else {
- return false
- }
- })
- },
- // 编辑信息
- setData (data) {
- this.form = JSON.parse(JSON.stringify(data))
- },
- getParentDealer () {
- const zb = this.$hasPermissions('B_PR_outSnycZB')
- const sj = this.$hasPermissions('B_PR_outSnycSJ')
- let params = {}
- // 只能向上级退货
- if (sj) {
- params.purchaseTargetType = 'DEALER_UP'
- }
- // 只能向总部退货
- if (zb) {
- params.purchaseTargetType = 'SUPPLIER_SYS'
- }
- // 总部和上级都可以
- if (sj && zb) {
- params = {}
- }
- console.log(params)
- purchaseTargetList(params).then(res => {
- if (res.status == 200 && res.data[0]) {
- this.purchaseTragetType = res.data
- this.$emit('load', res.data)
- } else {
- this.purchaseTragetType = []
- }
- })
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.resetForm()
- } else {
- this.getParentDealer()
- }
- }
- }
- }
- </script>
- <style lang="less">
- .purchaseOrder-basicInfo-modal{
- .ant-modal-body {
- padding: 40px 40px 24px;
- }
- .radio-s{
- margin-bottom: 8px;
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|