Merge branch 'frame' of http://60.209.125.238:20010/lijingjia/ds-wms-client-web into frame
commit
1c14c773d4
@ -1,157 +0,0 @@
|
||||
<template>
|
||||
<BasicModal
|
||||
v-bind="$attrs"
|
||||
:use-wrapper="true"
|
||||
:title="getTitle"
|
||||
width="50%"
|
||||
class="person-modal"
|
||||
:zIndex="1211"
|
||||
@register="registerModal"
|
||||
@ok="handleSave"
|
||||
>
|
||||
<!-- 包装表单 -->
|
||||
<BasicForm @register="registerForm" @linkageForm="linkageForm" >
|
||||
</BasicForm>
|
||||
<!--右下角按钮-->
|
||||
<template #footer>
|
||||
<a-button
|
||||
:loading="loading"
|
||||
style="margin-right: 0.8rem"
|
||||
@click="closeModal"
|
||||
>
|
||||
取消
|
||||
</a-button>
|
||||
<a-button
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="handleSave(true)"
|
||||
>
|
||||
保存
|
||||
</a-button>
|
||||
</template>
|
||||
</BasicModal>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, unref, onMounted } from 'vue'
|
||||
// 弹窗组件
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal'
|
||||
import { BasicForm, useForm } from '/@/components/Form/index'
|
||||
import { getDictOption } from '/@/utils/dictUtil'
|
||||
// 编辑往来单位联系人
|
||||
// import { ApiEdit } from '/@/views/baseinfo/infoclient/menu2/api'
|
||||
import emitter from '/@/utils/Bus'
|
||||
// 表单字段数据
|
||||
import { personFormSchema } from './baseInfo'
|
||||
// 相关接口
|
||||
import { EditBusinessOrderContact, GetBusinessOrderContactInfo } from '/@/views/operation/seaexport/api/BookingLedger'
|
||||
// 提示消息混入
|
||||
import { useMessage } from '/@/hooks/web/useMessage'
|
||||
// 声明Emits
|
||||
const emit = defineEmits(['success', 'register', 'getBaseInfo'])
|
||||
const isUpdate = ref(true)
|
||||
// 按钮loading
|
||||
const loading = ref(false)
|
||||
const rowId = ref('')
|
||||
const { createMessage } = useMessage()
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, updateSchema, getFieldsValue }] =
|
||||
useForm({
|
||||
labelWidth: 100,
|
||||
schemas: personFormSchema,
|
||||
showActionButtonGroup: false
|
||||
})
|
||||
// 业务id
|
||||
const id = ref()
|
||||
const [registerModal, { setModalProps, closeModal, updateFormField }] = useModalInner(async (data) => {
|
||||
resetFields()
|
||||
setModalProps({ confirmLoading: false, loading: true })
|
||||
isUpdate.value = !!data?.isUpdate
|
||||
id.value = data.id
|
||||
if (unref(isUpdate)) {
|
||||
setModalProps({ confirmLoading: true });
|
||||
updateFormField(updateSchema)
|
||||
rowId.value = data.record.id
|
||||
const res: API.DataResult = await GetBusinessOrderContactInfo({ id: unref(rowId) })
|
||||
console.log(res)
|
||||
if (res.succeeded) {
|
||||
setFieldsValue({
|
||||
...res.data,
|
||||
id: res.data.id
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// 新建设置默认值
|
||||
const arr = await getDictOption('infoclient-ArrclientTag')
|
||||
if (data.companyType) {
|
||||
const res = arr.filter(item => {
|
||||
return item.label == data.companyType
|
||||
})
|
||||
if (res && res.length) {
|
||||
setFieldsValue({ customerType: res[0].value })
|
||||
}
|
||||
}
|
||||
}
|
||||
setModalProps({ loading: false })
|
||||
})
|
||||
let changeType = ''
|
||||
// 选择客户属性带出客户名称
|
||||
const linkageForm = (item) => {
|
||||
if (item.key == 'customerType') {
|
||||
changeType = item.value
|
||||
emit('getBaseInfo', item.value)
|
||||
}
|
||||
}
|
||||
const getTitle = computed(() => (!unref(isUpdate) ? '新增' : '编辑'))
|
||||
// 选择联系人
|
||||
const personChange = (e, obj) => {
|
||||
setFieldsValue({
|
||||
customerContactId: e,
|
||||
name: obj.label
|
||||
})
|
||||
}
|
||||
async function handleSave(exit) {
|
||||
try {
|
||||
const values = await validate()
|
||||
if (!values.mobile && !values.tel) return createMessage.warning('请填写电话或者手机!')
|
||||
values['businessId'] = id.value
|
||||
if (getFieldsValue().id) {
|
||||
values['id'] = getFieldsValue().id
|
||||
}
|
||||
loading.value = true
|
||||
setModalProps({ confirmLoading: true, loading: true })
|
||||
const res: API.DataResult = await EditBusinessOrderContact(values)
|
||||
loading.value = false
|
||||
if (res.succeeded) {
|
||||
createMessage.success(res.message)
|
||||
emit('success', values)
|
||||
}
|
||||
exit && closeModal()
|
||||
} finally {
|
||||
setModalProps({ confirmLoading: false, loading: false })
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
emitter.on('sendBaseInfo', (v) => {
|
||||
if (changeType == 'controller') {
|
||||
setFieldsValue({
|
||||
customerName: v.customerName || null,
|
||||
customerId: v.customerId || null
|
||||
})
|
||||
} else if (changeType == 'booking') {
|
||||
setFieldsValue({
|
||||
customerId: v.forwarderId,
|
||||
customerName: v.forwarder
|
||||
})
|
||||
} else if (changeType == 'shippercn') {
|
||||
setFieldsValue({
|
||||
customerName: v.shipperCn,
|
||||
customerId: v.shipperCnId
|
||||
})
|
||||
} else {
|
||||
setFieldsValue({
|
||||
customerName: null,
|
||||
customerId: null
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue