123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <template>
- <a-modal
- centered
- class="relationshipBinding-modal"
- :footer="null"
- :maskClosable="false"
- title="关联下级"
- v-model="isShow"
- @cancel="isShow=false"
- :width="800">
- <!-- 表单 -->
- <div>
- <a-spin :spinning="spinning" tip="Loading...">
- <a-form-model
- id="relationshipBinding-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol"
- >
- <a-form-model-item label="上级名称" v-if="nowData">
- {{ nowData.dealerName }}
- </a-form-model-item>
- <a-form-model-item label="选择下级">
- <queryChild ref="queryChid" :dealerLevelList="dealerLevelList" @change="handleDisassociate"></queryChild>
- </a-form-model-item>
- </a-form-model>
- <div class="btn-cont">
- <a-button id="product-category-edit-modal-back" @click="isShow = false" >取消</a-button>
- <a-button type="primary" id="product-category-edit-modal-save" style="margin-left: 15px;" @click="handleSave">确定</a-button>
- </div>
- </a-spin>
- </div>
- </a-modal>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { bindRelation } from '@/api/dealerRelation'
- import queryChild from './queryChild.vue'
- export default {
- name: 'RelationshipBindingModal',
- mixins: [commonMixin],
- components: { queryChild },
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- },
- tabInd: {
- type: [Number, String],
- default: ''
- },
- nowData: {
- type: Object,
- default: null
- }
- },
- data () {
- return {
- isShow: this.openModal, // 是否打开弹框
- spinning: false,
- form: {},
- rules: {},
- formItemLayout: {
- labelCol: { span: 6 },
- wrapperCol: { span: 16 }
- },
- dealerLevelList: [],
- subDealerSn: '',
- isRelation: '' // 是否已被关联过
- }
- },
- methods: {
- handleDisassociate (val, parentDealerSn) {
- this.subDealerSn = val.key
- this.isRelation = parentDealerSn
- },
- // 保存
- handleSave () {
- const _this = this
- _this.$refs.ruleForm.validate(valid => {
- if (valid) {
- if (_this.subDealerSn == '') {
- this.$message.info('请选择下级')
- return
- }
- const formData = {
- subDealerSn: _this.subDealerSn,
- parentDealerSn: _this.nowData && _this.nowData.dealerSn ? _this.nowData.dealerSn : undefined
- }
- if (_this.isRelation) {
- _this.$confirm({
- title: '提示',
- content: '确认要解除原有绑定关系,建立新的绑定关系吗?',
- centered: true,
- closable: true,
- onOk () {
- _this.handleBind(formData)
- }
- })
- } else {
- _this.handleBind(formData)
- }
- } else {
- return false
- }
- })
- },
- handleBind (formData) {
- const _this = this
- _this.spinning = true
- bindRelation(formData).then(res => {
- if (res.status == 200) {
- _this.$message.success(res.message)
- _this.$emit('ok', formData.parentDealerSn)
- _this.isShow = false
- _this.spinning = false
- } else {
- _this.spinning = false
- }
- })
- },
- filterOption (input, option) {
- return (
- option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
- )
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.$refs.ruleForm.resetFields()
- this.$refs.queryChid.resetForm()
- this.subDealerSn = []
- } else {
- this.dealerLevelList = [this.tabInd == '1' ? 'CITY' : 'SPECIAL']
- }
- },
- tabInd (newValue, oldValue) {
- if (this.isShow && newValue) {
- this.dealerLevelList = [newValue == '1' ? 'CITY' : 'SPECIAL']
- }
- }
- }
- }
- </script>
- <style lang="less">
- .relationshipBinding-modal{
- .ant-modal-body {
- padding: 40px 40px 24px;
- }
- .search-opt{
- padding: 0;
- margin: 0;
- list-style: none;
- li{
- padding: 5px 15px;
- }
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|