123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771 |
- <template>
- <div>
- <table v-show="false">
- <tr>
- <td colspan="18">达州钢铁每日船舶动态明细表</td>
- <td colspan="4">{{deadline}}</td>
- </tr>
- </table>
- <el-table
- :show-summary="isShowSum"
- :data="tableData"
- :height="height"
- style="width: 100%"
- :span-method="objectSpanMethod"
- :border="true"
- :header-cell-style="headerCellStyle"
- >
- <el-table-column
- v-if="isShowBox"
- type="selection"
- width="50"
- align="center"
- >
- </el-table-column>
- <template>
- <column-item
- v-for="item in col"
- :key="item.label"
- :col="item"
- ></column-item>
- </template>
- <template #empty>
- <div class="empty" style="height:12.5rem;">
- <span class="empty-desc">暂无数据</span>
- </div>
- </template>
- <div slot="append" style="width: 100%;">
- <!-- 下游港口库存 -->
- <div class="appendSlot" style="margin-top:20px">
- <span class="normalFirst"
- >下游港口库存<span style="color:blue">{{
- this.downStockMap.downStockTonnage
- }}</span
- ><span>吨:</span></span
- >
- <span
- v-for="item in downStockStringArr"
- :class="item.class"
- :key="item.value"
- >{{ item.value }}</span
- >
- </div>
- <el-divider></el-divider>
- <!-- 万港库存 -->
- <div class="appendSlot">
- <span class="normalFirst"
- >万港库存<span style="color:blue">{{
- this.stockMap.stockTonnage
- }}</span
- ><span>吨:</span></span
- >
- <span
- v-for="item in stockStringArr"
- :class="item.class"
- :key="item.value"
- >{{ item.value }}</span
- >
- </div>
- <el-divider></el-divider>
- <!-- 在途库存 -->
- <div class="appendSlot">
- <span class="normalFirst"
- >在途货物<span style="color:blue">{{
- this.runStockMap.runStockTonnage
- }}</span
- ><span>吨(含万港/待卸船舶):</span></span
- >
- <span
- v-for="item in runStockStringArr"
- :class="item.class"
- :key="item.value"
- >{{ item.value }}</span
- >
- </div>
- <el-divider></el-divider>
- <!-- 库存表 -->
- <table v-show="false">
- <tr>
- <td colspan="22">{{ downStockString }}</td>
- </tr>
- <tr>
- <td colspan="22">{{ stockString }}</td>
- </tr>
- <tr>
- <td colspan="22">{{ runStockString }}</td>
- </tr>
- <tr>
- <td colspan="22"></td>
- </tr>
- </table>
- <!-- 万州港装车数据 -->
- <div class="appendSlot">
- <el-table
- ref="loadTable"
- highlight-current-row
- border
- show-summary
- :data="loadTable"
- :span-method="objectSpanMethod1"
- :row-style="{ height: '40px' }"
- style="font-size: 18px"
- >
- <el-table-column label="万州港发货信息">
- <el-table-column
- align="center"
- prop="materialName"
- width="200px"
- label="物资名"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="resultForeignShipName"
- width="200px"
- label="船号"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="num"
- width="200px"
- label="装车量"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="time"
- width="200px"
- label="时间"
- >
- </el-table-column>
- <el-table-column width="200px" label="备注"> </el-table-column>
- </el-table-column>
-
- </el-table>
- </div>
- <el-divider></el-divider>
- <!-- 等闸线 -->
- <div class="appendSlot">
- <el-table
- highlight-current-row
- border
- :data="controlLinesTable"
- :row-style="{ height: '40px' }"
- style="font-size: 12px"
- >
- <el-table-column label="控制线等闸船舶动态">
- <!-- 4 -->
- <el-table-column
- align="center"
- prop="lineDate4"
- width="100px"
- label="日期"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="up4"
- width="80px"
- label="上行等闸数"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="down4"
- width="80px"
- label="下行等闸数"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="count4"
- width="80px"
- label="总计"
- >
- </el-table-column>
- <!-- 3 -->
- <el-table-column
- align="center"
- prop="lineDate3"
- width="100px"
- label="日期"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="up3"
- width="80px"
- label="上行等闸数"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="down3"
- width="80px"
- label="下行等闸数"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="count3"
- width="80px"
- label="总计"
- >
- </el-table-column>
- <!-- 2 -->
- <el-table-column
- align="center"
- prop="lineDate2"
- width="100px"
- label="日期"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="up2"
- width="80px"
- label="上行等闸数"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="down2"
- width="80px"
- label="下行等闸数"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="count2"
- width="80px"
- label="总计"
- >
- </el-table-column>
- <!-- 1 -->
- <el-table-column
- align="center"
- prop="lineDate1"
- width="100px"
- label="日期"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="up1"
- width="80px"
- label="上行等闸数"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="down1"
- width="80px"
- label="下行等闸数"
- >
- </el-table-column>
- <el-table-column
- align="center"
- prop="count1"
- width="80px"
- label="总计"
- >
- </el-table-column>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </el-table>
- </div>
- </template>
- <script>
- import ColumnItem from './columnItem'
- export default {
- name: 'TableItem',
- components: {
- ColumnItem
- },
- props: {
- // 表格数据
- tableData: {
- type: Array,
- default: () => []
- },
- // 树型结构表头数据
- col: {
- type: Array,
- default: () => []
- },
- // 是否在表格下方显示合计
- isShowSum: {
- type: Boolean,
- default: false
- },
- // 判断单元格文字是居中还是左对齐显示,默认居中
- alignType: {
- type: String,
- default: 'center'
- },
- // 设置表格高度,固定表头
- height: {
- type: String,
- default: null // 默认不固定表头
- },
- // 判断是否显示多选框
- isShowBox: {
- type: Boolean,
- default: false // 默认不展示
- }
- },
- data() {
- return {
- stockString: null,
- downStockString: null,
- runStockString: null,
- stockStringArr: [],
- downStockStringArr: [],
- downStockMap: {},
- stockMap: {},
- runStockMap: {},
- runStockStringArr: [],
- spanArr: [],
- loadTable: [],
- controlLinesTable: [],
- deadline:null
- }
- },
- mounted() {
- this.getStockString()
- this.getDownStockString()
- this.getRunStockList()
- this.searchLoadData()
- this.getControlLines()
- this.initialDate()
- },
- methods: {
- initialDate(){
- let now=new Date();
- this.deadline=now.getFullYear()+'年'+(now.getMonth()+1)+'月'+now.getDate()+'日';
- if(now.getHours()>=8&&now.getHours()<18){
- this.deadline+='(数据截止于8:00)';
- }else{
- this.deadline+='(数据截止于18:00)';
- }
- console.log("deadline:",this.deadline);
- },
- getStockString() {
- let that = this
- this.axios
- .post(
- '/api/v1/wmsh/getLoadPortStockList?apiId=158&pageSize=1000&pageNum=1'
- )
- .then(res => {
- console.log(res)
- if (res.status == '200') {
- let resultActualInstallations = 0
- res.data.data.list.forEach(e => {
- resultActualInstallations =
- resultActualInstallations + e.gmTonnage
- })
- console.log(res.data.data, '万港')
- this.stockMap.stockTonnage = `${resultActualInstallations.toFixed(
- 2
- )}`
- let arr1 = []
- console.log(res.data.data.list, '万港')
- res.data.data.list.forEach(e => {
- let arr = []
- arr = res.data.data.list
- .map(e1 => {
- if (e.type == e1.type && !arr.includes(e)) {
- return e1
- }
- })
- .filter(e2 => {
- return typeof e2 !== 'undefined'
- })
- if (arr1.length == 0) {
- arr1.push(arr)
- } else {
- if (arr1[arr1.length - 1][0]['type'] != arr[0]['type']) {
- arr1.push(arr)
- }
- }
- })
- console.log(arr1, 'arr1')
- let index = 2.1
- arr1.forEach(e => {
- this.stockStringArr.push({
- class: 'type',
- value: `${index.toFixed(1)}${e[0]['type']}${
- e[0]['typeTotalTonnage']
- }吨:`
- })
- index = index + 0.1
- e.forEach(e1 => {
- this.stockStringArr.push({
- class: 'normal',
- value: `${e1['materialName']}/“${e1['resultForeignShipName']}”/${e1['gmTonnage']}吨;`
- })
- })
- })
- //处理打印字符串
- this.stockString =
- '万港库存:' + this.stockMap.stockTonnage + '吨:'
- this.stockStringArr.forEach(item => {
- this.stockString += item.value
- })
- }
- })
- },
- getDownStockString() {
- let that = this
- this.axios.post('/api/v1/wmsh/getDownPortStockList').then(res => {
- console.log('下游港口吨位')
- console.log(res.data.data)
- if (res.status == '200') {
- console.log(res.data.data)
- let resultActualInstallations = 0
- res.data.data.forEach(e => {
- resultActualInstallations = resultActualInstallations + e.gmTonnage
- })
- this.downStockMap.downStockTonnage = `${resultActualInstallations.toFixed(
- 2
- )}`
- let arr1 = []
- res.data.data.forEach(e => {
- let arr = []
- arr = res.data.data
- .map(e1 => {
- if (e1.type == e.type && !arr.includes(e)) {
- return e1
- }
- })
- .filter(e2 => {
- return typeof e2 !== 'undefined'
- })
- if (arr1.length == 0) {
- arr1.push(arr)
- } else {
- if (arr1[arr1.length - 1][0]['type'] != arr[0]['type']) {
- arr1.push(arr)
- }
- }
- })
- console.log(arr1, 'arr1')
- let index = 1.1
- arr1.forEach(e => {
- this.downStockStringArr.push({
- class: 'type',
- value: `${index.toFixed(1)}${e[0]['type']}${
- e[0]['typeTotalTonnage']
- }吨:`
- })
- index = index + 0.1
- e.forEach(e1 => {
- this.downStockStringArr.push({
- class: 'normal',
- value: `${e1['portName']}/${e1['materialName']}/“${e1['resultForeignShipName']}”/${e1['gmTonnage']}吨;`
- })
- })
- })
- //处理打印字符串
- this.downStockString =
- '下游港口库存:' + this.downStockMap.downStockTonnage + '吨:'
- this.downStockStringArr.forEach(item => {
- this.downStockString += item.value
- })
- }
- })
- },
- getRunStockList() {
- let that = this
- this.axios.post('/api/v1/wmsh/getRunStockList').then(res => {
- console.log(res)
- if (res.status == '200') {
- let resultActualInstallations = 0
- res.data.data.forEach(e => {
- resultActualInstallations = resultActualInstallations + e.gmTonnage
- })
- this.runStockMap.runStockTonnage = `${resultActualInstallations.toFixed(
- 2
- )}`
- let arr1 = []
- res.data.data.forEach(e => {
- let arr = []
- arr = res.data.data
- .map(e1 => {
- if (e1.type == e.type && !arr.includes(e)) {
- return e1
- }
- })
- .filter(e2 => {
- return typeof e2 !== 'undefined'
- })
- if (arr1.length == 0) {
- arr1.push(arr)
- } else {
- if (arr1[arr1.length - 1][0]['type'] != arr[0]['type']) {
- arr1.push(arr)
- }
- }
- })
- console.log(arr1, 'arr1')
- let index = 3.1
- arr1.forEach(e => {
- this.runStockStringArr.push({
- class: 'type',
- value: `${index.toFixed(1)}${e[0]['type']}${
- e[0]['typeTotalTonnage']
- }吨:`
- })
- index = index + 0.1
- //按物资分
- let temp = [];
- e.forEach(e1 => {
- this.runStockStringArr.push({
- class: 'normal',
- value: `${e1['materialName']}:/“${e1['resultForeignShipName']}”/${e1['gmTonnage']}吨;`
- })
- })
- })
- //处理打印字符串
- this.runStockString =
- '在途货物:' + this.runStockMap.runStockTonnage + '吨:'
- this.runStockStringArr.forEach(item => {
- this.runStockString += item.value
- })
- }
- })
- },
- headerCellStyle({ row, column, rowIndex, columnIndex }) {
- let columnIndexList1 = [5]
- let columnIndexList2 = [6]
- let columnIndexList3 = [7]
- let columnIndexList4 = [8]
- if (columnIndexList1.includes(columnIndex) && rowIndex == 0) {
- //如果有多个css样式,使用;隔开
- return 'color:#fff;cursor: pointer;background-color:red !important'
- }
- if (columnIndexList2.includes(columnIndex) && rowIndex == 0) {
- //如果有多个css样式,使用;隔开
- return 'color:#fff;cursor: pointer;background-color:green !important'
- }
- if (columnIndexList3.includes(columnIndex) && rowIndex == 0) {
- //如果有多个css样式,使用;隔开
- return 'color:#fff;cursor: pointer;background-color:blue !important'
- }
- if (columnIndexList4.includes(columnIndex) && rowIndex == 0) {
- //如果有多个css样式,使用;隔开
- return 'color:#000;cursor: pointer;background-color:yellow !important '
- }
- },
- flitterData(arr) {
- var spanOneArr = []
- let concatOne = 0
- arr.forEach((item, index) => {
- if (index === 0) {
- spanOneArr.push(1)
- } else {
- // name 修改
- if (item.batchInfacoryId === arr[index - 1].batchInfacoryId) {
- // 第一列需合并相同内容的判断条件
- spanOneArr[concatOne] += 1
- spanOneArr.push(0)
- } else {
- spanOneArr.push(1)
- concatOne = index
- }
- }
- })
- return {
- one: spanOneArr
- }
- },
- flitterData1(arr) {
- var spanOneArr = []
- let concatOne = 0
- arr.forEach((item, index) => {
- if (index === 0) {
- spanOneArr.push(1)
- } else {
- // name 修改
- if (item.materialType === arr[index - 1].materialType) {
- // 第一列需合并相同内容的判断条件
- spanOneArr[concatOne] += 1
- spanOneArr.push(0)
- } else {
- spanOneArr.push(1)
- concatOne = index
- }
- }
- })
- return {
- one: spanOneArr
- }
- },
- objectSpanMethod({ row, column, rowIndex, columnIndex }) {
- if (columnIndex === 0) {
- const _row = this.flitterData1(this.tableData).one[rowIndex]
- const _col = _row > 0 ? 1 : 0
- return {
- rowspan: _row,
- colspan: _col
- }
- }
- if (columnIndex === 1) {
- // this.tableData 修改
- const _row = this.flitterData(this.tableData).one[rowIndex]
- const _col = _row > 0 ? 1 : 0
- return {
- rowspan: _row,
- colspan: _col
- }
- }
- if (columnIndex === 4) {
- // this.tableData 修改
- const _row = this.flitterData(this.tableData).one[rowIndex]
- const _col = _row > 0 ? 1 : 0
- return {
- rowspan: _row,
- colspan: _col
- }
- }
- if (columnIndex === 2) {
- // this.tableData 修改
- const _row = this.flitterData(this.tableData).one[rowIndex]
- const _col = _row > 0 ? 1 : 0
- return {
- rowspan: _row,
- colspan: _col
- }
- }
- if (columnIndex === 3) {
- // this.tableData 修改
- const _row = this.flitterData(this.tableData).one[rowIndex]
- const _col = _row > 0 ? 1 : 0
- return {
- rowspan: _row,
- colspan: _col
- }
- }
- if (row.type === 1) {
- return {
- rowspan: 1,
- colspan: 17
- }
- }
- },
- //查询装车数据
- searchLoadData() {
- let map = {}
- this.axios.post('/api/v1/tms/getLoadData', map).then(res => {
- if (res.data.code == '200') {
- this.getSpanArr(res.data.data)
- this.loadTable = res.data.data
- this.count = 0
- this.loadTable.forEach(item => {
- this.count += item.num
- })
- } else {
- this.$message({
- type: 'error',
- message: res.data.data
- })
- }
- })
- },
- //处理数据,得到合并数组
- getSpanArr(data) {
- this.spanArr = []
- for (let i = 0; i < data.length; i++) {
- if (i == 0) {
- this.spanArr.push(1)
- this.spanIndex = 0
- } else {
- // 判断当前行与前一行内容是否相同
- if (data[i].materialName == data[i - 1].materialName) {
- this.spanArr[this.spanIndex] += 1 // 相同的话,当前下标所代表的值加一,例如:第一列的前三行可合并
- this.spanArr.push(0) // 记录完毕后,再往数组里添加一个元素0,作为下一次合并的初始值
- } else {
- this.spanArr.push(1) // 否则,依旧是一行
- this.spanIndex = i
- }
- }
- }
- },
- objectSpanMethod1({ row, column, rowIndex, columnIndex }) {
- if (columnIndex === 0) {
- const _row = this.spanArr[rowIndex] // 行数
- const _col = _row > 0 ? 1 : 0 // 列数
- return {
- rowspan: _row,
- colspan: _col
- }
- } else if (rowIndex === 0 && columnIndex === 3) {
- return {
- rowspan: this.loadTable.length,
- colspan: 1
- }
- }
- },
- //查询控制线数据
- getControlLines() {
- let map = {
- year: new Date().getFullYear(),
- month: new Date().getMonth() + 1
- }
- this.axios.post('/api/v1/tms/getControlLinesTable', map).then(res => {
- if (res.data.code == '200') {
- this.controlLinesTable = res.data.data
- } else {
- this.$message({
- type: 'error',
- message: res.data.data
- })
- }
- })
- }
- }
- }
- </script>
- <style>
- /* 处理表格表头和内容错位问题 */
- .el-table th.gutter {
- display: table-cell !important;
- }
- .el-table th,
- .el-table td {
- padding: 0.4375rem 0 !important;
- }
- </style>
- <style lang="scss" scoped>
- .el-table {
- .appendSlot {
- margin-left: 1%;
- font-size: 18px;
- line-height: 20px;
- // .normalFirst {
- // margin-left: 42px;
- // }
- .normal {
- margin-left: 20px;
- font-weight: 500;
- }
- .type {
- margin-left: 20px;
- color: red;
- font-weight: 600;
- margin-right: 10px;
- }
- // display: flex;
- // // align-items: center;
- // // justify-content: center;
- .black {
- font-weight: 700;
- }
- }
- }
- </style>
|