fix:表格导出完善(枚举情况)
This commit is contained in:
parent
0d4145551f
commit
0a707478f7
|
|
@ -333,11 +333,18 @@ export default {
|
||||||
dataToExcel(this.hExportCols, this.tableData, this.hExportName?this.hExportName:'表格数据')
|
dataToExcel(this.hExportCols, this.tableData, this.hExportName?this.hExportName:'表格数据')
|
||||||
}else if (type === 2) {
|
}else if (type === 2) {
|
||||||
const extractHeaderKeys = (columns) =>{
|
const extractHeaderKeys = (columns) =>{
|
||||||
const keys = columns.map(item => {
|
const keys = [];
|
||||||
// 如果key中包含点号,只取点号前面的部分
|
columns.map(item => {
|
||||||
return item.key.split('.')[0];
|
if(item.is_notquery){
|
||||||
|
let key = item.key.split('.')[0];
|
||||||
|
if(key.indexOf('mio')>-1){
|
||||||
|
keys.push('mio');
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
let key = item.key.split('.')[0];// 如果key中包含点号,只取点号前面的部分
|
||||||
|
keys.push(key);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 去重并转回字符串
|
// 去重并转回字符串
|
||||||
return [...new Set(keys)].join(',');
|
return [...new Set(keys)].join(',');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ export const dataToExcel = (columns = [], data = [], name = 'data') => {
|
||||||
const dataList = data.map((item) => {
|
const dataList = data.map((item) => {
|
||||||
let obj = {};
|
let obj = {};
|
||||||
columns.forEach(col => {
|
columns.forEach(col => {
|
||||||
obj[col.header] = getNestedValue(item, col.key) ?? '';
|
obj[col.header] = getNestedValue(item, col.key, col.type_dict) ?? '';
|
||||||
});
|
});
|
||||||
return obj;
|
return obj;
|
||||||
});
|
});
|
||||||
|
|
@ -54,19 +54,30 @@ export const dataToExcel = (columns = [], data = [], name = 'data') => {
|
||||||
// URL.revokeObjectURL(blobUrl);
|
// URL.revokeObjectURL(blobUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getNestedValue = (obj, path, defaultValue = '') => {
|
const getNestedValue = (obj, path,type_dict, defaultValue = '') => {
|
||||||
if (!obj || !path) return defaultValue;
|
if (!obj || !path) return defaultValue;
|
||||||
|
|
||||||
const keys = path.split('.');
|
const keys = path.split('.');
|
||||||
let result = obj;
|
let result = obj;
|
||||||
|
if(type_dict!==undefined){
|
||||||
|
let dict_key = "";
|
||||||
|
if(path.indexOf(".")>-1){
|
||||||
|
let key0 = path.split(".")[0];
|
||||||
|
let key1 = path.split(".")[1];
|
||||||
|
let obj1 = result[key0];
|
||||||
|
let key2 = obj1[key1];
|
||||||
|
dict_key = key2;
|
||||||
|
}else{
|
||||||
|
dict_key = result[path];
|
||||||
|
}
|
||||||
|
result = type_dict[dict_key]
|
||||||
|
}else{
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
if (result === null || result === undefined) {
|
if (result === null || result === undefined) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
result = result[key];
|
result = result[key];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result !== undefined ? result : defaultValue;
|
return result !== undefined ? result : defaultValue;
|
||||||
};
|
};
|
||||||
const calculateColumnWidths = (columns, dataList) => {
|
const calculateColumnWidths = (columns, dataList) => {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<el-header>
|
<el-header>
|
||||||
<div class="right-panel">
|
<div class="right-panel">
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="query.mio__inout_date__gte"
|
v-model="params.mio__inout_date__gte"
|
||||||
type="date"
|
type="date"
|
||||||
placeholder="开始日期"
|
placeholder="开始日期"
|
||||||
format="YYYY-MM-DD"
|
format="YYYY-MM-DD"
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
style="width: 150px;"
|
style="width: 150px;"
|
||||||
/>
|
/>
|
||||||
<el-date-picker
|
<el-date-picker
|
||||||
v-model="query.mio__inout_date__lte"
|
v-model="params.mio__inout_date__lte"
|
||||||
type="date"
|
type="date"
|
||||||
format="YYYY-MM-DD"
|
format="YYYY-MM-DD"
|
||||||
value-format="YYYY-MM-DD"
|
value-format="YYYY-MM-DD"
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
/>
|
/>
|
||||||
<xtSelect
|
<xtSelect
|
||||||
:apiObj="apiObjm"
|
:apiObj="apiObjm"
|
||||||
v-model="query.material"
|
v-model="params.material"
|
||||||
v-model:obj="selectObj"
|
v-model:obj="selectObj"
|
||||||
:labelField="'full_name'"
|
:labelField="'full_name'"
|
||||||
style="width: 150px;"
|
style="width: 150px;"
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
<el-table-column label="物料" prop="full_name"></el-table-column>
|
<el-table-column label="物料" prop="full_name"></el-table-column>
|
||||||
</xtSelect>
|
</xtSelect>
|
||||||
<el-input
|
<el-input
|
||||||
v-model="query.search"
|
v-model="params.search"
|
||||||
placeholder="名称"
|
placeholder="名称"
|
||||||
clearable
|
clearable
|
||||||
style="width: 150px;"
|
style="width: 150px;"
|
||||||
|
|
@ -43,15 +43,18 @@
|
||||||
</div>
|
</div>
|
||||||
</el-header>
|
</el-header>
|
||||||
<el-main style="padding: 0;">
|
<el-main style="padding: 0;">
|
||||||
<el-table
|
<scTable
|
||||||
ref="table"
|
ref="table"
|
||||||
:data="tableData"
|
:apiObj="apiObj"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
stripe
|
stripe
|
||||||
border
|
border
|
||||||
style="height: 100%;"
|
:params="params"
|
||||||
:summary-method="getSummaries"
|
:summary-method="getSummaries"
|
||||||
show-summary
|
show-summary
|
||||||
|
:hExportCols = "hExportCols"
|
||||||
|
:hExportName="'辅料出入库记录'"
|
||||||
|
style="height: 100%;"
|
||||||
>
|
>
|
||||||
<el-table-column type="index" width="50" />
|
<el-table-column type="index" width="50" />
|
||||||
<el-table-column label="类型" width="80">
|
<el-table-column label="类型" width="80">
|
||||||
|
|
@ -155,21 +158,8 @@
|
||||||
>撤消</el-button>
|
>撤消</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</scTable>
|
||||||
</el-main>
|
</el-main>
|
||||||
<el-footer>
|
|
||||||
<el-pagination
|
|
||||||
background
|
|
||||||
:small="true"
|
|
||||||
:total="dataTotal"
|
|
||||||
layout="total, sizes, prev, pager, next, jumper"
|
|
||||||
:page-size="params.page_size"
|
|
||||||
:page-sizes="[20, 50, 100, 200]"
|
|
||||||
:current-page="params.page"
|
|
||||||
@current-change="getList"
|
|
||||||
@update:page-size="getList2"
|
|
||||||
></el-pagination>
|
|
||||||
</el-footer>
|
|
||||||
</el-container>
|
</el-container>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
|
@ -177,13 +167,14 @@ export default {
|
||||||
name: "mioitemlist",
|
name: "mioitemlist",
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
apiObj: null,
|
|
||||||
params: {
|
params: {
|
||||||
page:1,
|
|
||||||
page_size:20,
|
|
||||||
with_mio:'yes',
|
with_mio:'yes',
|
||||||
material__type:40,
|
material__type:40,
|
||||||
mio__state:20
|
mio__state:20,
|
||||||
|
mio__inout_date__gte:'',
|
||||||
|
mio__inout_date__lte:'',
|
||||||
|
material:'',
|
||||||
|
search:'',
|
||||||
},
|
},
|
||||||
mquery:{
|
mquery:{
|
||||||
page: 0,
|
page: 0,
|
||||||
|
|
@ -192,7 +183,6 @@ export default {
|
||||||
is_assemb: false,
|
is_assemb: false,
|
||||||
},
|
},
|
||||||
selection: [],
|
selection: [],
|
||||||
tableData:[],
|
|
||||||
nameFilters1: [],
|
nameFilters1: [],
|
||||||
nameFilters2: [],
|
nameFilters2: [],
|
||||||
nameFilters3: [],
|
nameFilters3: [],
|
||||||
|
|
@ -202,12 +192,6 @@ export default {
|
||||||
nameFilters7: [],
|
nameFilters7: [],
|
||||||
nameFilters8: [],
|
nameFilters8: [],
|
||||||
nameFilters9: [],
|
nameFilters9: [],
|
||||||
query: {
|
|
||||||
search : "",
|
|
||||||
material : "",
|
|
||||||
mio__inout_date__gte : "",
|
|
||||||
mio__inout_date__lte : "",
|
|
||||||
},
|
|
||||||
stateDict: {
|
stateDict: {
|
||||||
10: "创建中",
|
10: "创建中",
|
||||||
20: "已提交",
|
20: "已提交",
|
||||||
|
|
@ -221,35 +205,81 @@ export default {
|
||||||
other_out: "其他出库",
|
other_out: "其他出库",
|
||||||
},
|
},
|
||||||
selectObj: {},
|
selectObj: {},
|
||||||
project_code:'',
|
apiObj:this.$API.inm.mioitem.list,
|
||||||
dataTotal:0,
|
|
||||||
apiObjm:this.$API.mtm.material.list,
|
apiObjm:this.$API.mtm.material.list,
|
||||||
|
hExportCols:[{
|
||||||
|
header: "类型",
|
||||||
|
key: "mio_.type",
|
||||||
|
type_dict:{
|
||||||
|
do_out: "生产领料",
|
||||||
|
sale_out: "销售发货",
|
||||||
|
pur_in: "采购入库",
|
||||||
|
do_in: "生产入库",
|
||||||
|
other_in: "其他入库",
|
||||||
|
other_out: "其他出库",
|
||||||
|
},
|
||||||
|
is_notquery: true
|
||||||
|
}, {
|
||||||
|
header: "日期",
|
||||||
|
key: "inout_date"
|
||||||
|
}, {
|
||||||
|
header: "物料编号",
|
||||||
|
key: "material_.number"
|
||||||
|
}, {
|
||||||
|
header: "名称",
|
||||||
|
key: "material_.name"
|
||||||
|
}, {
|
||||||
|
header: "货位号",
|
||||||
|
key: "material_.bin_number_main"
|
||||||
|
}, {
|
||||||
|
header: "规格",
|
||||||
|
key: "material_.specification"
|
||||||
|
}, {
|
||||||
|
header: "品牌型号",
|
||||||
|
key: "material_.model"
|
||||||
|
}, {
|
||||||
|
header: "单位",
|
||||||
|
key: "material_.unit"
|
||||||
|
}, {
|
||||||
|
header: "入库数量",
|
||||||
|
key: "count"
|
||||||
|
}, {
|
||||||
|
header: "单价",
|
||||||
|
key: "unit_price"
|
||||||
|
}, {
|
||||||
|
header: "总金额",
|
||||||
|
key: "price",
|
||||||
|
is_notquery: true,
|
||||||
|
}, {
|
||||||
|
header: "入库人",
|
||||||
|
key: "mio_.submit_user_name",
|
||||||
|
is_notquery: true,
|
||||||
|
}, {
|
||||||
|
header: "入库凭证号",
|
||||||
|
key: "mio_.number",
|
||||||
|
is_notquery: true,
|
||||||
|
}, {
|
||||||
|
header: "供应商",
|
||||||
|
key: "supplier_name",
|
||||||
|
is_notquery: true,
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.checkTemplate = this.checkTemplate+"?t=" + new Date().getTime();
|
this.$nextTick(() => {
|
||||||
this.project_code = this.$TOOL.data.get("BASE_INFO").base.base_code;
|
this.getFilters();
|
||||||
this.params.mio = this.mioId;
|
});
|
||||||
let that = this;
|
|
||||||
that.getList();
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getList(val){
|
getFilters(){
|
||||||
let that = this;
|
let that = this;
|
||||||
that.params.page = val?val:1;
|
let datas = [];
|
||||||
that.params.with_mio = 'yes';
|
datas = that.$refs.table.tableData;
|
||||||
that.params.search = that.query.search;
|
console.log( datas);
|
||||||
that.params.mio__inout_date__gte = that.query.mio__inout_date__gte;
|
if(datas.length&&datas.length>0){
|
||||||
that.params.mio__inout_date__lte = that.query.mio__inout_date__lte;
|
|
||||||
if(that.query.material!==''||that.query.material!==undefined||that.query.material!==null){
|
|
||||||
that.params.material = that.query.material;
|
|
||||||
}
|
|
||||||
that.$API.inm.mioitem.list.req(that.params).then((res) => {
|
|
||||||
if (res.count > 0) {
|
|
||||||
that.tableData = res.results;
|
|
||||||
that.dataTotal = res.count;
|
|
||||||
let numberList=[],nameList = [],batchlist=[],specificationList=[],modelList=[],unitList=[],userList=[],mioNumberList=[],typeList=[];
|
let numberList=[],nameList = [],batchlist=[],specificationList=[],modelList=[],unitList=[],userList=[],mioNumberList=[],typeList=[];
|
||||||
res.results.forEach((ite) => {
|
datas.forEach((ite) => {
|
||||||
if (numberList.indexOf(ite.material_.number) > -1) {} else {
|
if (numberList.indexOf(ite.material_.number) > -1) {} else {
|
||||||
numberList.push(ite.material_.number);
|
numberList.push(ite.material_.number);
|
||||||
let obj = {};
|
let obj = {};
|
||||||
|
|
@ -315,16 +345,10 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}else{
|
}else{
|
||||||
that.tableData = [];
|
setTimeout(function(){
|
||||||
that.dataTotal = 0;
|
that.getFilters();
|
||||||
|
},500);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
},
|
|
||||||
getList2(val){
|
|
||||||
let that = this;
|
|
||||||
that.params.page = 1;
|
|
||||||
that.params.page_size = val;
|
|
||||||
that.getList(1);
|
|
||||||
},
|
},
|
||||||
handleCheckSuccess() {
|
handleCheckSuccess() {
|
||||||
this.$refs.table.refresh();
|
this.$refs.table.refresh();
|
||||||
|
|
@ -332,15 +356,11 @@ export default {
|
||||||
},
|
},
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
let that = this;
|
let that = this;
|
||||||
that.params.page = 1;
|
that.$refs.table.queryData(that.params);
|
||||||
that.getList(1);
|
|
||||||
},
|
|
||||||
resetQuery() {
|
|
||||||
this.query = {};
|
|
||||||
},
|
},
|
||||||
selectMaterialChange() {
|
selectMaterialChange() {
|
||||||
var that = this;
|
var that = this;
|
||||||
that.query.material = that.selectObj.id;
|
that.params.material = that.selectObj.id;
|
||||||
},
|
},
|
||||||
//打印物料标签
|
//打印物料标签
|
||||||
printMaterial(row,type){
|
printMaterial(row,type){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue