180 lines
5.2 KiB
Vue
180 lines
5.2 KiB
Vue
<template>
|
|
<div>
|
|
<j-modal
|
|
:title="title"
|
|
:width="width"
|
|
:visible="visible"
|
|
:confirmLoading="confirmLoading"
|
|
switchFullscreen
|
|
@ok="handleOk"
|
|
@cancel="handleCancel"
|
|
cancelText="关闭">
|
|
<a-spin :spinning="confirmLoading">
|
|
<a-form :form="form">
|
|
<a-row>
|
|
<a-col>
|
|
<a-form-item label="快递公司:" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<j-dict-select-tag
|
|
v-decorator="['sendMethod', validatorRules.sendMethod]"
|
|
placeholder="请选择"
|
|
:trigger-change="true"
|
|
dict-code="mail_send"
|
|
></j-dict-select-tag>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row>
|
|
<a-col>
|
|
<a-form-item label="快递单号:" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<a-input
|
|
v-decorator="['postNo', validatorRules.postNo]"
|
|
placeholder="请输入快递单号"
|
|
></a-input>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row>
|
|
<a-col>
|
|
<a-form-item label="邮寄时间:" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<j-date
|
|
format="YYYY-MM-DD"
|
|
placeholder="请选择邮寄时间"
|
|
class="query-group-cust"
|
|
style="width: 100%"
|
|
v-decorator="['sendDate', validatorRules.sendDate]"
|
|
>
|
|
</j-date>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
<a-row>
|
|
<a-col>
|
|
<a-form-item label="备注:" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
|
<a-textarea
|
|
placeholder="请输入备注"
|
|
:auto-size="{ minRows: 3, maxRows: 6 }"
|
|
v-decorator="['remark']"
|
|
:maxLength='200'
|
|
@change="e => {e.target.value = (e.target.value + '').trim()}"/>
|
|
</a-form-item>
|
|
</a-col>
|
|
</a-row>
|
|
</a-form>
|
|
</a-spin>
|
|
</j-modal>
|
|
</div>
|
|
</template>
|
|
<script>
|
|
import pick from 'lodash.pick'
|
|
import JDictSelectTag from '@/components/dict/JDictSelectTag'
|
|
import JDate from '@comp/tools/JDate'
|
|
import { httpAction } from '@/api/manage'
|
|
|
|
export default {
|
|
name: 'MailContractModal',
|
|
components: {JDictSelectTag, JDate},
|
|
data() {
|
|
return {
|
|
title: '操作',
|
|
width: 500,
|
|
visible: false,
|
|
confirmLoading: false,
|
|
form: this.$form.createForm(this),
|
|
labelCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 5 }
|
|
},
|
|
wrapperCol: {
|
|
xs: { span: 24 },
|
|
sm: { span: 17 }
|
|
},
|
|
validatorRules: {
|
|
sendMethod: {
|
|
rules: [{required: true, message: '请选择快递公司'}],
|
|
validateTrigger: 'blur, change'
|
|
},
|
|
sendDate: {
|
|
rules: [{required: true, message: '请选择邮寄时间'}],
|
|
validateTrigger: 'blur, change'
|
|
},
|
|
postNo: {
|
|
rules: [{required: true, message: '请输入快递单号'}],
|
|
validateTrigger: 'blur'
|
|
},
|
|
},
|
|
url: {
|
|
edit: 'payMailContract/payMailContract/edit',
|
|
mail: 'payMailContract/payMailContract/mile'
|
|
}
|
|
}
|
|
},
|
|
methods: {
|
|
add(id) {
|
|
this.edit({id})
|
|
},
|
|
edit(record) {
|
|
this.form.resetFields()
|
|
this.model = Object.assign({}, record)
|
|
this.visible = true
|
|
console.log(this.model)
|
|
let date = new Date()
|
|
let sendDate = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
|
|
this.$nextTick(() => {
|
|
this.form.setFieldsValue({'sendDate': sendDate})
|
|
this.form.setFieldsValue(pick(this.model, 'sendMethod', 'sendDate', 'postNo', 'remark'))
|
|
})
|
|
// 默认邮寄方式--EMS
|
|
if (!this.model.sendMethod) {
|
|
this.$nextTick(() => {
|
|
this.form.setFieldsValue({'sendMethod': '1'})
|
|
})
|
|
}
|
|
},
|
|
close() {
|
|
this.$emit('close')
|
|
this.visible = false
|
|
},
|
|
handleOk() {
|
|
if (this.confirmLoading) {
|
|
return
|
|
}
|
|
this.confirmLoading = true
|
|
const that = this
|
|
// 触发表单验证
|
|
this.form.validateFields((err, values) => {
|
|
if (!err) {
|
|
that.confirmLoading = true
|
|
const formData = Object.assign(this.model, values)
|
|
console.log('表单提交数据', formData)
|
|
let url = ''
|
|
if (this.title === '邮寄') {
|
|
url = this.url.mail
|
|
} else {
|
|
url = this.url.edit
|
|
}
|
|
httpAction(url, formData, 'post').then((res) => {
|
|
if (res.success) {
|
|
that.$message.success(res.message)
|
|
that.$emit('ok')
|
|
that.confirmLoading = false
|
|
that.close()
|
|
} else {
|
|
that.$message.warning(res.message)
|
|
}
|
|
}).finally(() => {
|
|
setTimeout(() => {
|
|
this.confirmLoading = false
|
|
}, 1000)
|
|
})
|
|
} else {
|
|
this.confirmLoading = false
|
|
}
|
|
})
|
|
},
|
|
handleCancel() {
|
|
this.close()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
<style scoped lang="less"></style> |