Browse Source

12.2

master
lichong 3 weeks ago
parent
commit
4fd0151662
  1. 14
      src/renderer/src/components/tablecomponent.vue
  2. 26
      src/renderer/src/views/shujuguanli.vue

14
src/renderer/src/components/tablecomponent.vue

@ -4,11 +4,10 @@
<template #default="{ height, width }"> <template #default="{ height, width }">
<vxe-table show-overflow :data="tableData" round :height="height" :scroll-y="{ enabled: true, gt: 20 }" <vxe-table show-overflow :data="tableData" round :height="height" :scroll-y="{ enabled: true, gt: 20 }"
:checkbox-config="{ labelField: 'seq', highlight: true }" ref="tableRef" border :checkbox-config="{ labelField: 'seq', highlight: true }" ref="tableRef" border
:column-config="{ resizable: true }"> :column-config="{ resizable: true }" @resizable-change="resizableChange">
<vxe-column type="seq" width="70"></vxe-column> <vxe-column type="seq" width="70"></vxe-column>
<vxe-column :field="headerItem.prop" :title="headerItem.label" <vxe-column :field="headerItem.prop" :title="headerItem.label" :width="`${headerItem.width}`"
:min-width="`${headerItem.label.length * 23 + 24}`" v-for="(headerItem, headerIndex) in tableHeader" v-for="(headerItem, headerIndex) in tableHeader" :key="headerIndex" :sortable="headerItem.isSort">
:key="headerIndex" :sortable="headerItem.isSort">
<template #default="{ row }"> <template #default="{ row }">
<template v-if="headerItem.type === 'text'"> <template v-if="headerItem.type === 'text'">
<span>{{ row[headerItem.prop] }}</span> <span>{{ row[headerItem.prop] }}</span>
@ -52,7 +51,12 @@ export default {
dayjs: dayjs, dayjs: dayjs,
} }
}, },
methods: {}, methods: {
resizableChange({ $rowIndex, column, columnIndex, $columnIndex, $event }) {
let width = this.$refs.tableRef.getColumnWidth(column.field)
console.log(59, width);
}
},
async mounted() { }, async mounted() { },
watch: {}, watch: {},
computed: {} computed: {}

26
src/renderer/src/views/shujuguanli.vue

@ -48,7 +48,7 @@
</template> </template>
<script> <script>
import _ from 'lodash' import _, { min } from 'lodash'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import * as XLSX from 'xlsx'; import * as XLSX from 'xlsx';
import ExcelJS from "exceljs"; import ExcelJS from "exceljs";
@ -320,11 +320,29 @@ export default {
let that = this let that = this
let tableHeader = [] let tableHeader = []
let tableData = [] let tableData = []
let widthObj = {
"Order":105,
"Sku":165,
// "Description":126,
"Type of merchandise": 100,
"Quantity to deliver": 100,
"Store": 100,
"Quantity of containers": 100,
"Barcode": 100,
"Quantity per container": 102,
"Total": 60,
"Cluster": 60,
"": 60,
"_1": 60,
"_2": 160,
"_3": 75,
}
for (let key in that.fileData2[0]) { for (let key in that.fileData2[0]) {
tableHeader.push({ tableHeader.push({
prop: key, prop: key,
label: key, label: key,
type: "text" type: "text",
width: widthObj[key] || "",
}) })
} }
for (let index = 0; index < that.fileData2.length; index++) { for (let index = 0; index < that.fileData2.length; index++) {
@ -364,8 +382,8 @@ export default {
let cell = worksheet.getCell(1, index + 1); let cell = worksheet.getCell(1, index + 1);
cell.value = element; cell.value = element;
cell.font = { name: 'Arial', size: 10, color: { argb: '000000' } }; cell.font = { name: 'Arial', size: 10, color: { argb: '000000' } };
cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'EEEEEE' } }; cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'EEEEEE' }, };
cell.alignment = { horizontal: 'center', vertical: 'center' }; cell.alignment = { horizontal: 'center', vertical: 'top' };
}); });
// //

Loading…
Cancel
Save