|
@@ -34,6 +34,12 @@
|
|
|
Search
|
|
|
</el-button>
|
|
|
</el-tooltip>
|
|
|
+ <el-button
|
|
|
+ @click="openTempShip"
|
|
|
+ size="small"
|
|
|
+ >
|
|
|
+ 候选货物列表
|
|
|
+ </el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
|
|
@@ -229,7 +235,7 @@
|
|
|
class="custom-button"
|
|
|
size="small"
|
|
|
:disabled="subList.length < 1"
|
|
|
- @click="exportSubTable"
|
|
|
+ @click="exportSubTable(subList, currentRow.Name)"
|
|
|
>
|
|
|
导出Excel文档
|
|
|
</el-button>
|
|
@@ -479,6 +485,29 @@
|
|
|
</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="自动发送"
|
|
|
+ width="75"
|
|
|
+ fixed="right"
|
|
|
+ >
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tooltip
|
|
|
+ content="配合'删除'操作可转移到候选货物列表中, 下次新建航次CRM会自动将其加入"
|
|
|
+ >
|
|
|
+ <el-checkbox
|
|
|
+ :disabled="!['Arrangement'].includes(currentTab)"
|
|
|
+ @change="
|
|
|
+ () => {
|
|
|
+ if (scope.row.Force_Send) {
|
|
|
+ scope.row.editFlag = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ "
|
|
|
+ v-model="scope.row.Force_Send"
|
|
|
+ ></el-checkbox>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column
|
|
|
fixed="right"
|
|
|
label="重量 (KG)"
|
|
@@ -630,6 +659,12 @@
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</el-dialog>
|
|
|
+ <comp-temp-ship
|
|
|
+ v-model:visible="tempShipVisible"
|
|
|
+ :id="tempShipID"
|
|
|
+ :current-tab="currentTab"
|
|
|
+ :good-material-option="goodMaterialOption"
|
|
|
+ ></comp-temp-ship>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -653,10 +688,10 @@ import {
|
|
|
ElNotification,
|
|
|
ElDrawer,
|
|
|
ElDialog,
|
|
|
+ ElCheckbox,
|
|
|
} from 'element-plus'
|
|
|
import cloneDeep from 'lodash.clonedeep'
|
|
|
import dayjs from 'dayjs'
|
|
|
-import * as XLSX from 'xlsx'
|
|
|
import debounce from 'lodash.debounce'
|
|
|
import compPrint from '@/components/print.vue'
|
|
|
import request from '@/utils/axios'
|
|
@@ -671,7 +706,12 @@ import {
|
|
|
requesterSort,
|
|
|
salesPersonSort,
|
|
|
batchRecordSort,
|
|
|
+ customMapData,
|
|
|
+ calcSelectAble,
|
|
|
+ calcRowStyle,
|
|
|
+ exportSubTable,
|
|
|
} from './func'
|
|
|
+import compTempShip from './compTempShip.vue'
|
|
|
|
|
|
defineComponent({
|
|
|
name: 'ComponentCargoConsolidationRequest',
|
|
@@ -988,59 +1028,13 @@ const onBatchRecordChange = ($e: string, line = -1) => {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-// 给子表格加红绿背景. 颜色用的tailwind的 red green
|
|
|
-const calcRowStyle = ($e: any) => {
|
|
|
- const result = {} as any
|
|
|
- if ($e.row.addFlag) result['background-color'] = 'rgb(187, 247, 208)'
|
|
|
- if ($e.row.editFlag) result['background-color'] = 'rgb(187, 247, 208)'
|
|
|
- if ($e.row.deleteFlag) result['background-color'] = 'rgb(254, 202, 202)'
|
|
|
- return result
|
|
|
-}
|
|
|
-
|
|
|
-const commit = () => {
|
|
|
+const tempShipID = '4791186000388831863'
|
|
|
+const commit = async () => {
|
|
|
let temp = cloneDeep(subList.value)
|
|
|
- let result = temp
|
|
|
- .filter((i) => !i.deleteFlag)
|
|
|
- .map((i) => {
|
|
|
- return {
|
|
|
- id: i.id,
|
|
|
- Sample: i.Sample || false,
|
|
|
- Batch_Record: i.batchRecord
|
|
|
- ? {
|
|
|
- name: i.Batch_Record.name,
|
|
|
- id: i.Batch_Record.id,
|
|
|
- }
|
|
|
- : '',
|
|
|
- Parent_Id: {
|
|
|
- name: i.Parent_Id.name,
|
|
|
- id: i.Parent_Id.id || '',
|
|
|
- },
|
|
|
- Material_of_Goods: i.Material_of_Goods,
|
|
|
- Requester: i.Requester.name
|
|
|
- ? {
|
|
|
- name: i.Requester.name,
|
|
|
- id: i.Requester.id || '',
|
|
|
- }
|
|
|
- : '',
|
|
|
- Sales_Person: i.Sales_Person || '',
|
|
|
- Carton: i.Carton || '',
|
|
|
- Marks_Nos: i.Marks_Nos || '',
|
|
|
- Description_of_Goods: i.Description_of_Goods || '',
|
|
|
- Quantity: i.Quantity || '',
|
|
|
- Unit_Price: i.Unit_Price || '',
|
|
|
- Weight: i.Weight || '',
|
|
|
- Cube: i.Cube || '',
|
|
|
- Total_FOB: i.Total_FOB || '',
|
|
|
- User_Notes: i.User_Notes || '',
|
|
|
- Sales_Order: i.Sales_Order || '',
|
|
|
- Purchase_Order: i.Purchase_Order || '',
|
|
|
- Reference: i.Reference || '',
|
|
|
- PO_Number: i.PO_Number || '',
|
|
|
- }
|
|
|
- }) as any[]
|
|
|
+ let formData = customMapData(temp.filter((i) => !i.deleteFlag))
|
|
|
|
|
|
const emptyUserNotesList: number[] = []
|
|
|
- result.forEach((i, index) => {
|
|
|
+ formData.forEach((i, index) => {
|
|
|
if (!i.User_Notes) {
|
|
|
emptyUserNotesList.push(index)
|
|
|
}
|
|
@@ -1055,48 +1049,103 @@ const commit = () => {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- result = result.concat(
|
|
|
+ formData = formData.concat(
|
|
|
temp
|
|
|
.filter((i) => i.deleteFlag)
|
|
|
.map((i) => ({ id: i.id, _delete: null, Material_of_Goods: null })),
|
|
|
)
|
|
|
- console.log(result, 'submit result')
|
|
|
+ let params = {
|
|
|
+ id: currentRow.value.id,
|
|
|
+ Sea_Freight_array: formData,
|
|
|
+ Sales_Person: currentUserName.value,
|
|
|
+ Sales_Person_Obj: {
|
|
|
+ id: currentUser.value,
|
|
|
+ name: currentUserName.value,
|
|
|
+ },
|
|
|
+ }
|
|
|
+
|
|
|
+ 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对应的记录删除
|
|
|
+ } catch {
|
|
|
+ console.log(t, '组装转移数据时删除id出错')
|
|
|
+ }
|
|
|
+ return t
|
|
|
+ })
|
|
|
+
|
|
|
+ let params2 = {
|
|
|
+ id: tempShipID,
|
|
|
+ Sea_Freight_array: formData2,
|
|
|
+ Sales_Person: currentUserName.value,
|
|
|
+ Sales_Person_Obj: {
|
|
|
+ id: currentUser.value,
|
|
|
+ name: currentUserName.value,
|
|
|
+ },
|
|
|
+ }
|
|
|
+ console.log(params2, '保存 要转移的数据')
|
|
|
loading.value = true
|
|
|
+ let sendToTempShipFlag = true // (转移到临时航次) 的状态
|
|
|
+ if (formData2.length) {
|
|
|
+ let response2 = await request.post('/sea_freight/updateSeaFreightDataV2', params2)
|
|
|
+ if (response2.data.code !== 1) {
|
|
|
+ sendToTempShipFlag = false
|
|
|
+ ElMessage.error('转移到临时航次失败, 请稍后再试或者联系管理员')
|
|
|
+ loading.value = false
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let result2 = response2.data.result || { data: [] }
|
|
|
+ if (
|
|
|
+ !(
|
|
|
+ Array.isArray(result2.data) &&
|
|
|
+ result2.data.length &&
|
|
|
+ result2.data.every((i: any) => i.status === 'success')
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ sendToTempShipFlag = false
|
|
|
+ ElNotification({
|
|
|
+ title: '部份内容转移失败',
|
|
|
+ message: '建议刷新再试或者联系管理员',
|
|
|
+ duration: 10000,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (sendToTempShipFlag === false) {
|
|
|
+ loading.value = false
|
|
|
+ return
|
|
|
+ }
|
|
|
request
|
|
|
- .post('/sea_freight/updateSeaFreightDataV2', {
|
|
|
- id: newLineTemplate.Parent_Id.id,
|
|
|
- Sea_Freight_array: result,
|
|
|
- Sales_Person: currentUserName.value,
|
|
|
- Sales_Person_Obj: {
|
|
|
- id: currentUser.value,
|
|
|
- name: currentUserName.value,
|
|
|
- },
|
|
|
- })
|
|
|
+ .post('/sea_freight/updateSeaFreightDataV2', params)
|
|
|
.then((res) => {
|
|
|
- if (res.data.code === 1) {
|
|
|
- let result = res.data.result || { data: [] }
|
|
|
- if (
|
|
|
- Array.isArray(result.data) &&
|
|
|
- result.data.length &&
|
|
|
- result.data.every((i: any) => i.status === 'success')
|
|
|
- ) {
|
|
|
- ElNotification({
|
|
|
- title: '保存成功',
|
|
|
- message: '正在刷新数据',
|
|
|
- duration: 3000,
|
|
|
- })
|
|
|
- } else {
|
|
|
- ElNotification({
|
|
|
- title: '部份内容保存失败',
|
|
|
- message: '建议刷新再试或者联系管理员',
|
|
|
- duration: 10000,
|
|
|
- })
|
|
|
- }
|
|
|
- getSubList(currentRow.value)
|
|
|
- } else {
|
|
|
+ if (res.data.code !== 1) {
|
|
|
ElMessage.error('保存出错')
|
|
|
loading.value = false
|
|
|
+ return
|
|
|
}
|
|
|
+ let result = res.data.result || { data: [] }
|
|
|
+ if (
|
|
|
+ Array.isArray(result.data) &&
|
|
|
+ result.data.length &&
|
|
|
+ result.data.every((i: any) => i.status === 'success')
|
|
|
+ ) {
|
|
|
+ ElNotification({
|
|
|
+ title: '保存成功',
|
|
|
+ message: '正在刷新数据',
|
|
|
+ duration: 3000,
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ ElNotification({
|
|
|
+ title: '部份内容保存失败',
|
|
|
+ message: '建议刷新再试或者联系管理员',
|
|
|
+ duration: 10000,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ getSubList(currentRow.value)
|
|
|
})
|
|
|
.catch((e) => {
|
|
|
console.log(e, 'commit error')
|
|
@@ -1109,74 +1158,6 @@ const print = (row: any) => {
|
|
|
currentPrintRow.value = row
|
|
|
printDrawerVisible.value = true
|
|
|
}
|
|
|
-const exportSubTable = () => {
|
|
|
- const headers = [
|
|
|
- '箱数 Carton',
|
|
|
- '唛头 Marks & Nos',
|
|
|
- '货物名称 Description of Goods',
|
|
|
- '货物材质 Material goods',
|
|
|
- '数量 QTY',
|
|
|
- '单价 澳币/AUD Unit Price',
|
|
|
- '重量KG Weight',
|
|
|
- '体积m³ Cube',
|
|
|
- '总离岸价 澳币/AUD Total FOB',
|
|
|
- '负责人 Owner',
|
|
|
- 'Reference',
|
|
|
- ]
|
|
|
-
|
|
|
- const data: any[] = subList.value.map((i) => {
|
|
|
- return {
|
|
|
- '箱数 Carton': i.Carton || '',
|
|
|
- '唛头 Marks & Nos': i.Marks_Nos || '',
|
|
|
- '货物名称 Description of Goods': i.Description_of_Goods || '',
|
|
|
- '货物材质 Material goods': i.Material_of_Goods,
|
|
|
- '数量 QTY': i.Quantity || '',
|
|
|
- '单价 澳币/AUD Unit Price': i.Unit_Price || '',
|
|
|
- '重量KG Weight': i.Weight || '',
|
|
|
- '体积m³ Cube': i.Cube || '',
|
|
|
- '总离岸价 澳币/AUD Total FOB': i.Total_FOB || '',
|
|
|
- '负责人 Owner': i.Requester.name || '',
|
|
|
- Reference: i.Reference || i.PO_Number || '',
|
|
|
- }
|
|
|
- })
|
|
|
- if (data.length === 0) {
|
|
|
- throw new Error('Invalid data: Data array is empty.')
|
|
|
- }
|
|
|
-
|
|
|
- const worksheetData = []
|
|
|
- worksheetData.push(['发票/装箱单/INVOICE/PACKING LIST'])
|
|
|
- if (headers && headers.length > 0) {
|
|
|
- worksheetData.push(headers)
|
|
|
- } else {
|
|
|
- worksheetData.push(Object.keys(data[0]))
|
|
|
- }
|
|
|
- data.forEach((row) => {
|
|
|
- worksheetData.push(Object.values(row))
|
|
|
- })
|
|
|
- const wb = XLSX.utils.book_new()
|
|
|
- let ws = XLSX.utils.aoa_to_sheet(worksheetData)
|
|
|
- ws['!merges'] = [
|
|
|
- { s: { r: 0, c: 0 }, e: { r: 0, c: 9 } }, // 合并列作为标题
|
|
|
- ]
|
|
|
-
|
|
|
- ws['!cols'] = [
|
|
|
- { wpx: 80 },
|
|
|
- { wpx: 200 },
|
|
|
- { wpx: 180 },
|
|
|
- { wpx: 120 },
|
|
|
- { wpx: 90 },
|
|
|
- { wpx: 120 },
|
|
|
- { wpx: 100 },
|
|
|
- { wpx: 100 },
|
|
|
- { wpx: 120 },
|
|
|
- { wpx: 120 },
|
|
|
- { wpx: 100 },
|
|
|
- ]
|
|
|
-
|
|
|
- XLSX.utils.book_append_sheet(wb, ws, 'Sheet1')
|
|
|
- const name = encodeURIComponent(currentRow.value.Name || 'test') + '.xlsx'
|
|
|
- XLSX.writeFile(wb, name)
|
|
|
-}
|
|
|
|
|
|
let qcList = ref([] as any[])
|
|
|
let loading2 = ref(false)
|
|
@@ -1461,7 +1442,10 @@ let selectedRow = ref([] as any[])
|
|
|
const handleSelectionChange = (val: any[]) => {
|
|
|
selectedRow.value = val
|
|
|
}
|
|
|
-let calcSelectAble = (row: any) => !row.addFlag && !row.deleteFlag && !row.editFlag
|
|
|
+let tempShipVisible = ref(false)
|
|
|
+const openTempShip = () => {
|
|
|
+ tempShipVisible.value = true
|
|
|
+}
|
|
|
|
|
|
// 别说代码行数太长搞屎山, 这个页面的功能上线之后改了6个版本, 每次都往上堆功能, 能不长嘛
|
|
|
</script>
|