|
@@ -95,6 +95,16 @@
|
|
|
label="入仓时间"
|
|
|
width="100"
|
|
|
/>
|
|
|
+ <el-table-column
|
|
|
+ label="截止时间"
|
|
|
+ width="200"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <div>
|
|
|
+ {{ formatCutOffDateTime(scope.row.Cut_Off_Date_Time) }}
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column
|
|
|
prop="Status"
|
|
|
label="状态"
|
|
@@ -248,7 +258,7 @@
|
|
|
size="small"
|
|
|
type="primary"
|
|
|
class="custom-button small"
|
|
|
- @click="commit"
|
|
|
+ @click="commitWithSDK"
|
|
|
>
|
|
|
保存更改
|
|
|
</el-button>
|
|
@@ -701,6 +711,8 @@ import {
|
|
|
} from 'element-plus'
|
|
|
import cloneDeep from 'lodash.clonedeep'
|
|
|
import dayjs from 'dayjs'
|
|
|
+import utc from 'dayjs/plugin/utc.js'
|
|
|
+import timezone from 'dayjs/plugin/timezone.js'
|
|
|
import debounce from 'lodash.debounce'
|
|
|
import compPrint from '@/components/print.vue'
|
|
|
import request from '@/utils/axios'
|
|
@@ -752,6 +764,9 @@ let tabs = [
|
|
|
},
|
|
|
]
|
|
|
|
|
|
+dayjs.extend(utc)
|
|
|
+dayjs.extend(timezone)
|
|
|
+
|
|
|
let finalTabs = ref([] as any[])
|
|
|
finalTabs.value = cloneDeep(tabs)
|
|
|
|
|
@@ -801,6 +816,9 @@ function getDefaultRange() {
|
|
|
}
|
|
|
dateRange.value = getDefaultRange()
|
|
|
|
|
|
+let formatCutOffDateTime = (str: string) =>
|
|
|
+ str?.length ? dayjs.utc(str).tz('Asia/Shanghai').format('YYYY-MM-DD HH:mm:ss') : ''
|
|
|
+
|
|
|
const clearSubList = () => {
|
|
|
subList.value = []
|
|
|
subListBackup = []
|
|
@@ -811,7 +829,7 @@ let getList = () => {
|
|
|
loading.value = true
|
|
|
zoho.CRM.API.coql({
|
|
|
select_query:
|
|
|
- 'select Container_Number,Name,Forwarder,ETD,ATD,ETA,ATA,Cut_Off_Date,Owner,Status,Modified_Time,SubscriptionId,Carrier,Booking_Number,GRN from Sea_Freight_Table' +
|
|
|
+ 'select Container_Number,Name,Forwarder,ETD,ATD,ETA,ATA,Cut_Off_Date,Owner,Status,Modified_Time,SubscriptionId,Carrier,Booking_Number,GRN,Cut_Off_Date_Time from Sea_Freight_Table' +
|
|
|
" where ETD between '" +
|
|
|
`${dateRange.value.map((i) => dayjs(i).format('YYYY-MM-DD')).join("' and '")}` +
|
|
|
"'",
|
|
@@ -1043,10 +1061,27 @@ const commit = async () => {
|
|
|
let formData = customMapData(temp.filter((i) => !i.deleteFlag))
|
|
|
|
|
|
const emptyUserNotesList: number[] = []
|
|
|
+ const emptyCartonList: number[] = [] // 箱数
|
|
|
+ const emptyMarksNosList: number[] = [] // 唛头
|
|
|
+ const emptyNameList: number[] = [] // 货物名称 Description_of_Goods
|
|
|
+ const emptyCubeList: number[] = [] // 体积
|
|
|
+
|
|
|
formData.forEach((i, index) => {
|
|
|
if (!i.User_Notes) {
|
|
|
emptyUserNotesList.push(index)
|
|
|
}
|
|
|
+ if (!i.Carton) {
|
|
|
+ emptyCartonList.push(index)
|
|
|
+ }
|
|
|
+ if (!i.Marks_Nos) {
|
|
|
+ emptyMarksNosList.push(index)
|
|
|
+ }
|
|
|
+ if (!i.Description_of_Goods) {
|
|
|
+ emptyNameList.push(index)
|
|
|
+ }
|
|
|
+ if (!i.Cube) {
|
|
|
+ emptyCubeList.push(index)
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
if (emptyUserNotesList.length) {
|
|
@@ -1057,6 +1092,38 @@ const commit = async () => {
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
+ if (emptyCartonList.length) {
|
|
|
+ ElNotification({
|
|
|
+ title: '请检查表单, 箱数是必填的',
|
|
|
+ message: `第 ${emptyCartonList.map((i) => i + 1).join(', ')} 行的箱数数据, 不能为空`,
|
|
|
+ duration: 5000,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (emptyMarksNosList.length) {
|
|
|
+ ElNotification({
|
|
|
+ title: '请检查表单, 唛头是必填的',
|
|
|
+ message: `第 ${emptyMarksNosList.map((i) => i + 1).join(', ')} 行的唛头数据, 不能为空`,
|
|
|
+ duration: 5000,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (emptyNameList.length) {
|
|
|
+ ElNotification({
|
|
|
+ title: '请检查表单, 货物名称是必填的',
|
|
|
+ message: `第 ${emptyNameList.map((i) => i + 1).join(', ')} 行的货物名称数据, 不能为空`,
|
|
|
+ duration: 5000,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (emptyCubeList.length) {
|
|
|
+ ElNotification({
|
|
|
+ title: '请检查表单, 体积是必填的',
|
|
|
+ message: `第 ${emptyCubeList.map((i) => i + 1).join(', ')} 行的体积数据, 不能为空`,
|
|
|
+ duration: 5000,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
formData = formData.concat(
|
|
|
temp
|
|
@@ -1161,6 +1228,166 @@ const commit = async () => {
|
|
|
loading.value = false
|
|
|
})
|
|
|
}
|
|
|
+const commitWithSDK = async () => {
|
|
|
+ let temp = cloneDeep(subList.value)
|
|
|
+ let formData = customMapData(temp.filter((i) => !i.deleteFlag))
|
|
|
+
|
|
|
+ const emptyUserNotesList: number[] = []
|
|
|
+ const emptyCartonList: number[] = [] // 箱数
|
|
|
+ const emptyMarksNosList: number[] = [] // 唛头
|
|
|
+ const emptyNameList: number[] = [] // 货物名称 Description_of_Goods
|
|
|
+ const emptyCubeList: number[] = [] // 体积
|
|
|
+
|
|
|
+ formData.forEach((i, index) => {
|
|
|
+ if (!i.User_Notes) {
|
|
|
+ emptyUserNotesList.push(index)
|
|
|
+ }
|
|
|
+ if (!i.Carton) {
|
|
|
+ emptyCartonList.push(index)
|
|
|
+ }
|
|
|
+ if (!i.Marks_Nos) {
|
|
|
+ emptyMarksNosList.push(index)
|
|
|
+ }
|
|
|
+ if (!i.Description_of_Goods) {
|
|
|
+ emptyNameList.push(index)
|
|
|
+ }
|
|
|
+ if (!i.Cube) {
|
|
|
+ emptyCubeList.push(index)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ if (emptyUserNotesList.length) {
|
|
|
+ ElNotification({
|
|
|
+ title: '请检查表单, 备注是必填的',
|
|
|
+ message: `第 ${emptyUserNotesList.map((i) => i + 1).join(', ')} 行的备注数据, 不能为空`,
|
|
|
+ duration: 5000,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (emptyCartonList.length) {
|
|
|
+ ElNotification({
|
|
|
+ title: '请检查表单, 箱数是必填的',
|
|
|
+ message: `第 ${emptyCartonList.map((i) => i + 1).join(', ')} 行的箱数数据, 不能为空`,
|
|
|
+ duration: 5000,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (emptyMarksNosList.length) {
|
|
|
+ ElNotification({
|
|
|
+ title: '请检查表单, 唛头是必填的',
|
|
|
+ message: `第 ${emptyMarksNosList.map((i) => i + 1).join(', ')} 行的唛头数据, 不能为空`,
|
|
|
+ duration: 5000,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (emptyNameList.length) {
|
|
|
+ ElNotification({
|
|
|
+ title: '请检查表单, 货物名称是必填的',
|
|
|
+ message: `第 ${emptyNameList.map((i) => i + 1).join(', ')} 行的货物名称数据, 不能为空`,
|
|
|
+ duration: 5000,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (emptyCubeList.length) {
|
|
|
+ ElNotification({
|
|
|
+ title: '请检查表单, 体积是必填的',
|
|
|
+ message: `第 ${emptyCubeList.map((i) => i + 1).join(', ')} 行的体积数据, 不能为空`,
|
|
|
+ duration: 5000,
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ let params = {
|
|
|
+ APIData: {
|
|
|
+ id: currentRow.value.id,
|
|
|
+ Sea_Freight_Details: formData,
|
|
|
+ },
|
|
|
+ Entity: 'Sea_Freight_Table',
|
|
|
+ trigger: ['workflow', 'approval'],
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(params, '保存 无转移的数据')
|
|
|
+ let formData2 = customMapData(temp.filter((i) => i.deleteFlag && i.Force_Send)).map((i) => {
|
|
|
+ // 转移之前覆盖 Parent_Id, 否则按照customMapData的逻辑会被存成原航次的id
|
|
|
+ let t = {
|
|
|
+ ...i,
|
|
|
+ Parent_Id: { id: tempShipID },
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ delete t.id // 相当于在新建记录.不删除原id的话, 不一点能转移成功(crm限制), 并且后面原航次的保存会把这个id对应的记录删除
|
|
|
+ delete t.parent_id
|
|
|
+ } catch {
|
|
|
+ console.log(t, '组装转移数据时删除id出错')
|
|
|
+ }
|
|
|
+ return t
|
|
|
+ })
|
|
|
+
|
|
|
+ let params2 = {
|
|
|
+ APIData: {
|
|
|
+ Temporary_Transform_Record: true,
|
|
|
+ Sea_Freight_Details: formData2,
|
|
|
+ Name: '临时调动记录(非真正航次)',
|
|
|
+ ETD: '1900-01-01',
|
|
|
+ ETA: '1900-01-01',
|
|
|
+ },
|
|
|
+ Entity: 'Sea_Freight_Table',
|
|
|
+ trigger: ['workflow', 'approval'],
|
|
|
+ }
|
|
|
+ console.log(params2, '保存 要转移的数据')
|
|
|
+ loading.value = true
|
|
|
+ let sendToTempShipFlag = true // (转移到临时航次) 的状态
|
|
|
+ if (formData2.length) {
|
|
|
+ let res2 = await zoho.CRM.API.insertRecord(params2)
|
|
|
+
|
|
|
+ if (
|
|
|
+ !(
|
|
|
+ Array.isArray(res2.data) &&
|
|
|
+ res2.data.length &&
|
|
|
+ res2.data.every((i: any) => i.status === 'success')
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ sendToTempShipFlag = false
|
|
|
+ ElNotification({
|
|
|
+ title: '部份内容转移失败',
|
|
|
+ message: '建议刷新再试或者联系管理员',
|
|
|
+ duration: 10000,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sendToTempShipFlag === false) {
|
|
|
+ loading.value = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ zoho.CRM.API.updateRecord(params)
|
|
|
+ .then((res: any) => {
|
|
|
+ if (
|
|
|
+ Array.isArray(res.data) &&
|
|
|
+ res.data.length &&
|
|
|
+ res.data.every((i: any) => i.status === 'success')
|
|
|
+ ) {
|
|
|
+ ElNotification({
|
|
|
+ title: '保存成功',
|
|
|
+ message: '正在刷新数据',
|
|
|
+ duration: 3000,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ ElNotification({
|
|
|
+ title: '部份内容保存失败',
|
|
|
+ message: '建议刷新再试或者联系管理员',
|
|
|
+ duration: 10000,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ getSubList(currentRow.value)
|
|
|
+ })
|
|
|
+ .catch((e: any) => {
|
|
|
+ console.log(e, 'commit error')
|
|
|
+ loading.value = false
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
let printDrawerVisible = ref(false)
|
|
|
let currentPrintRow = ref({} as any)
|
|
|
const print = (row: any) => {
|
|
@@ -1173,7 +1400,7 @@ let loading2 = ref(false)
|
|
|
|
|
|
const search = (keyword: string) => {
|
|
|
if (keyword.length < 2) return
|
|
|
-
|
|
|
+ keyword = keyword.trim().toUpperCase()
|
|
|
loading2.value = true
|
|
|
zoho.CRM.API.searchRecord({
|
|
|
Entity: 'QC_Record',
|
|
@@ -1389,6 +1616,7 @@ const openMapDrawer = (row: any) => {
|
|
|
id: 'mapDrawer',
|
|
|
carrierCode: row.Carrier, // 船公司代码
|
|
|
billNo: row.Booking_Number, // 提单号
|
|
|
+ language: 'en', // 语言
|
|
|
})
|
|
|
})
|
|
|
}
|