123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- <template>
- <div v-if="isShow">
- <a-modal
- centered
- class="merge-customer-modal"
- :footer="null"
- :maskClosable="false"
- v-drag
- title="合并"
- v-model="isShow"
- @cancle="isShow=false"
- width="35%">
- <a-form-model
- id="bulkPartsTypeEdit-form"
- ref="ruleForm"
- :model="form"
- :rules="rules"
- :label-col="formItemLayout.labelCol"
- :wrapper-col="formItemLayout.wrapperCol"
- >
- <a-form-model-item label="合并后客户:">
- <div>{{ mainCustomerName }}</div>
- </a-form-model-item>
- <a-form-model-item label="被合并的客户名称:" prop="customerSnSource">
- <custList
- ref="custList"
- :notSn="form.customerSnTarget"
- dealerFlag="all"
- dealerDisabled
- pageType="1"
- @change="custChange"
- placeholder="输入客户名称搜索"></custList>
- </a-form-model-item>
- </a-form-model>
- <div class="btn-cont">
- <a-button id="modal-back" @click="isShow = false" style="margin-right: 15px;">取消</a-button>
- <a-button type="primary" id="modal-save" @click="handleSave">确定</a-button>
- </div>
- </a-modal>
- </div>
- </template>
- <script>
- import { commonMixin } from '@/utils/mixin'
- import { custMerge } from '@/api/customer'
- import custList from '@/views/common/custList.vue'
- export default {
- name: 'SalesRecordModal',
- components: { custList },
- mixins: [commonMixin],
- props: {
- openModal: { // 弹框显示状态
- type: Boolean,
- default: false
- },
- params: {
- type: Object,
- default () {
- return {}
- }
- }
- },
- data () {
- return {
- isShow: this.openModal, // 是否打开弹框
- formItemLayout: {
- labelCol: { span: 6 },
- wrapperCol: { span: 16 }
- },
- form: {
- customerSnTarget: '', // 合并后客户sn
- customerSnSource: '' // 被合并客户sn
- },
- mainCustomerName: '', // 合并后客户名称
- rules: {
- customerSnSource: [
- { required: true, message: '输入客户名称搜索', trigger: 'blur' }
- ]
- }
- }
- },
- methods: {
- // 客户 change
- custChange (obj, row) {
- if (row) {
- this.form.customerSnSource = row && row.customerSn || undefined
- } else {
- this.form.customerSnSource = undefined
- }
- },
- handleSave () {
- const _this = this
- this.$refs.ruleForm.validate(valid => {
- if (valid) {
- _this.confirmedSubmit()
- } else {
- console.log('error submit!!')
- return false
- }
- })
- },
- confirmedSubmit () {
- const _this = this
- this.$confirm({
- title: '提示',
- content: '确定要合并吗?合并后数据不可恢复。',
- onOk () {
- _this.form.id = _this.params.id
- custMerge(_this.form).then(res => {
- if (res.status == 200) {
- _this.$message.info(res.message)
- _this.$emit('close', true)
- }
- })
- },
- onCancel () {
- console.log('Cancel')
- }
- })
- }
- },
- watch: {
- // 父页面传过来的弹框状态
- openModal (newValue, oldValue) {
- this.isShow = newValue
- },
- // 重定义的弹框状态
- isShow (newValue, oldValue) {
- if (!newValue) {
- this.$emit('close')
- this.form.customerSnSource = undefined
- this.form.customerSnTarget = undefined
- this.mainCustomerName = undefined
- this.$refs.custList.setData(undefined)
- } else {
- this.mainCustomerName = this.params.customerName
- this.form.customerSnTarget = this.params.customerSn
- }
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .merge-customer-modal{
- .ant-modal-body {
- padding: 20px;
- }
- .btn-cont {
- text-align: center;
- margin: 35px 0 10px;
- }
- }
- </style>
|