990 lines
26 KiB
JavaScript
990 lines
26 KiB
JavaScript
var Basecomponent = {
|
||
template: `
|
||
<div>
|
||
<div id="" style="display: flex">
|
||
<el-input v-model="code_v" placeholder="编号" clearable style="width: 150px;" @change="input_change"></el-input>
|
||
<el-input v-model="name_v" placeholder="名称" clearable style="width: 150px;" @change="input_change"></el-input>
|
||
<el-input v-model="supplier_v" placeholder="供应商" clearable style="width: 150px;" @change="input_change"></el-input>
|
||
<el-date-picker
|
||
style="width: 150px;"
|
||
v-model="begin_t_v"
|
||
type="date"
|
||
placeholder="开始日期"
|
||
format="yyyy-MM-dd"
|
||
value-format="yyyy/MM/dd"
|
||
>
|
||
</el-date-picker>
|
||
<el-date-picker
|
||
style="width: 150px;"
|
||
v-model="end_t_v"
|
||
type="date"
|
||
placeholder="结束日期"
|
||
format="yyyy-MM-dd"
|
||
value-format="yyyy/MM/dd"
|
||
>
|
||
</el-date-picker>
|
||
<el-checkbox style="margin: 0px;" v-model="checked" @change="if_fin_cahnge" border>已删除</el-checkbox>
|
||
|
||
<el-button id ="bt_search" plain type="primary" icon="el-icon-search" @click="get_material()">搜索</el-button>
|
||
<el-button plain type="primary" icon="el-icon-circle-plus-outline" @click="importCsv()">导入审批物料</el-button>
|
||
<!--<el-button style="margin-left: 10px;" id ="bt_export" plain type="primary" icon="el-icon-document" @click="exportSap()">导出</el-button>
|
||
-->
|
||
|
||
<el-button id ="bt_del" plain type="primary" icon="el-icon-circle-plus-outline" @click="del_material()">删除</el-button>
|
||
|
||
</div>
|
||
<div>
|
||
<el-progress v-if="if_show_process" :percentage="percent_len" ></el-progress>
|
||
</div>
|
||
<div class="span">
|
||
<el-table
|
||
:data="tableData"
|
||
style="width: 100%"
|
||
:height="tHeight"
|
||
:cell-style="{background:'#fff'}"
|
||
border
|
||
@selection-change="handleSelectionChange"
|
||
>
|
||
|
||
<el-table-column
|
||
type="selection"
|
||
width="35">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
v-if="if_show_del_filed==true"
|
||
prop="del_user"
|
||
label="删除人员"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
v-if="if_show_del_filed==true"
|
||
prop="del_time"
|
||
label="删除时间"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="supplier"
|
||
label="供应商名称"
|
||
:width="flexColumnWidth('supplier',tableData)"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="supplier_code"
|
||
label="供应商编号"
|
||
:width="flexColumnWidth('supplier_code',tableData,5)"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="pt"
|
||
label="付款方式"
|
||
:width="flexColumnWidth('pt',tableData)"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="code"
|
||
label="六合编号"
|
||
:width="flexColumnWidth('code',tableData)"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="name"
|
||
label="名称"
|
||
:width="flexColumnWidth('name',tableData,2)+10">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="spec"
|
||
label="规格"
|
||
:width="flexColumnWidth('spec',tableData,2)">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="unit"
|
||
label="单位"
|
||
:width="flexColumnWidth('unit',tableData,2)">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="price"
|
||
label="单价"
|
||
:width="flexColumnWidth('price',tableData,2)"
|
||
:show-overflow-tooltip="true">
|
||
<template slot-scope="scope">
|
||
<div style="float: right; padding-right: 5px;">{{scope.row.price}}</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="update_date"
|
||
label="更新日期"
|
||
width="65"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="pc"
|
||
label="采购周期"
|
||
width="65"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="vpoq"
|
||
label="有效期"
|
||
width="45"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="effective_time"
|
||
label="有效时间"
|
||
:width="flexColumnWidth('price',tableData)"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="price_2"
|
||
label="单价2"
|
||
:width="flexColumnWidth('price_2',tableData,3)">
|
||
<template slot-scope="scope">
|
||
<div style="float: right;">{{scope.row.price_2}}</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="update_date_2"
|
||
label="更新2"
|
||
:width="flexColumnWidth('update_date_2',tableData,3)">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="price_3"
|
||
label="单价3"
|
||
:width="flexColumnWidth('price_3',tableData,3)">
|
||
<template slot-scope="scope">
|
||
<div style="float: right;">{{scope.row.price_3}}</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="update_date_3"
|
||
label="更新3"
|
||
:width="flexColumnWidth('update_date_3',tableData,3)">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="price_4"
|
||
label="单价4"
|
||
:width="flexColumnWidth('price_4',tableData,3)">
|
||
<template slot-scope="scope">
|
||
<div style="float: right;">{{scope.row.price_4}}</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="update_date_4"
|
||
label="更新4"
|
||
:width="flexColumnWidth('update_date_4',tableData,3)">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="price_5"
|
||
label="单价5"
|
||
:width="flexColumnWidth('price_5',tableData,3)">
|
||
<template slot-scope="scope">
|
||
<div style="float: right;">{{scope.row.price_5}}</div>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="update_date_5"
|
||
label="更新5"
|
||
:width="flexColumnWidth('update_date_5',tableData,3)">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="factory"
|
||
label="生产厂家"
|
||
:width="flexColumnWidth('factory',tableData)"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="factory_code"
|
||
label="厂商编号"
|
||
:width="flexColumnWidth('factory_code',tableData)"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="qs"
|
||
label="质量标准"
|
||
:width="flexColumnWidth('qs',tableData)"
|
||
:show-overflow-tooltip="true">
|
||
<template slot-scope="scope">
|
||
<el-button @click="down_qs_files(scope.row)" type="text" size="small">{{scope.row.qs}}</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column
|
||
label="操作"
|
||
width="80">
|
||
<template slot-scope="scope">
|
||
<el-upload
|
||
class="upload-demo"
|
||
ref="upload"
|
||
action="/pp/upload_ds_file"
|
||
:on-change="handleChange_file"
|
||
:file-list="fileList"
|
||
:show-file-list="false"
|
||
:on-success="upload_file_success"
|
||
:on-error="upload_file_error"
|
||
:data="upload_param(scope.row)">
|
||
<el-button slot="trigger" size="medium" type="success" >上传</el-button>
|
||
</el-upload>
|
||
</template>
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="as"
|
||
label="验收标准"
|
||
:width="flexColumnWidth('as',tableData)"
|
||
:show-overflow-tooltip="true">
|
||
<template slot-scope="scope">
|
||
<el-button @click="down_as_files(scope.row)" type="text" size="small">{{scope.row.as}}</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
label="操作"
|
||
width="80">
|
||
<template slot-scope="scope">
|
||
<el-upload
|
||
class="upload-demo"
|
||
ref="upload"
|
||
action="/pp/upload_ds_file"
|
||
:on-change="handleChange_file"
|
||
:file-list="fileList"
|
||
:show-file-list="false"
|
||
:on-success="upload_file_success"
|
||
:on-error="upload_file_error"
|
||
:data="upload_param_2(scope.row)">
|
||
<el-button slot="trigger" size="medium" type="success" >上传</el-button>
|
||
</el-upload>
|
||
</template>
|
||
</el-table-column>
|
||
|
||
|
||
<!--
|
||
<el-table-column
|
||
label="操作"
|
||
width="100">
|
||
<template slot-scope="scope">
|
||
<el-button @click="update_p(scope.row)" type="text" size="medium" >修改</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
-->
|
||
</el-table>
|
||
</div>
|
||
|
||
<div class="block">
|
||
<span class="demonstration"></span>
|
||
<el-pagination
|
||
@size-change="handleSizeChange"
|
||
@current-change="handleCurrentChange"
|
||
:current-page="currentPage"
|
||
:page-sizes="[50,100, 200, 300]"
|
||
:page-size="pagesize"
|
||
layout="total, sizes, prev, pager, next, jumper"
|
||
:total="recordTotal">
|
||
</el-pagination>
|
||
</div>
|
||
|
||
<el-dialog
|
||
title="产品信息"
|
||
:visible.sync="dialogVisible"
|
||
:lock-scroll ="false"
|
||
width="40%"
|
||
style="height: 100%;">
|
||
<el-form ref="form_p" :model="form" label-width="80px" :rules="rules">
|
||
<el-row :gutter="10">
|
||
<el-col :span="12">
|
||
<el-form-item label="产品编号" prop="p_id">
|
||
<el-input v-model="form.p_id" :disabled="disabled"></el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
<el-col :span="12">
|
||
<el-form-item label="产品名称" prop="p_name">
|
||
<el-input v-model="form.p_name" ></el-input>
|
||
</el-form-item>
|
||
</el-col>
|
||
</el-row>
|
||
</el-form>
|
||
<span slot="footer" class="dialog-footer">
|
||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||
<el-button id ="bt_ok" plain type="primary" @click="post_p()">确 定</el-button>
|
||
</span>
|
||
</el-dialog>
|
||
|
||
<el-dialog
|
||
title="导入审批物料"
|
||
:visible.sync="importdialogVisible"
|
||
:lock-scroll ="false"
|
||
:before-close="importDialog_close"
|
||
width="95%">
|
||
<div style="display: flex;">
|
||
<el-upload
|
||
class="upload-demo"
|
||
action=""
|
||
:on-change="handleChange"
|
||
:file-list="fileListUpload"
|
||
:show-file-list="false"
|
||
accept=".csv"
|
||
:auto-upload="false">
|
||
<el-button id ="bt_upload" size="small" plain type="primary">点击上传(csv文件)</el-button>
|
||
</el-upload>
|
||
<el-button id ="bt_import" size="small" plain type="primary" @click="importData" style="margin-left: 10px;">确认导入</el-button>
|
||
<el-button id ="bt_download" size="small" plain type="primary" @click="download_template" style="margin-left: 10px;">下载导入模板文件</el-button>
|
||
</div>
|
||
<div>
|
||
<el-progress v-if="if_show_process1" :percentage="percent_len" ></el-progress>
|
||
</div>
|
||
<el-table
|
||
:data="importTableData"
|
||
style="font-size:13px;margin-top: 10px;width: 100%;"
|
||
:height="tHeight"
|
||
:cell-style="{background:'#fff'}"
|
||
stripe border>
|
||
|
||
<el-table-column
|
||
prop="supplier"
|
||
label="供应商名称"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="supplier_code"
|
||
label="供应商编号"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="pt"
|
||
label="付款方式"
|
||
width="80"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="code"
|
||
label="六合编号"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="name"
|
||
label="名称"
|
||
width="120"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="spec"
|
||
label="规格"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="unit"
|
||
label="单位"
|
||
width="60"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="price"
|
||
label="单价"
|
||
width="60"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="update_date"
|
||
label="更新日期"
|
||
width="80"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="pc"
|
||
label="采购周期"
|
||
width="80"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="vpoq"
|
||
label="有效期"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
|
||
<el-table-column
|
||
prop="factory"
|
||
label="生产厂家"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="factory_code"
|
||
label="厂商编号"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="qs"
|
||
label="质量标准"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
<el-table-column
|
||
prop="as"
|
||
label="验收标准"
|
||
width="100"
|
||
:show-overflow-tooltip="true">
|
||
</el-table-column>
|
||
|
||
</el-table>
|
||
</el-dialog>
|
||
</div>
|
||
`,
|
||
data() {
|
||
// 获取当前屏幕的分辨率
|
||
let screenW = window.screen.width;
|
||
let screenH = window.innerHeight;
|
||
console.log("screen width:", screenW);
|
||
console.log("screen height:", screenH);
|
||
return {
|
||
tHeight: screenH - 40 - 232,
|
||
tableData: [],
|
||
currentPage: 1,
|
||
pagesize: 50,
|
||
recordTotal: 0,
|
||
code_v: '',
|
||
name_v: '',
|
||
supplier_v: '',
|
||
|
||
form: {
|
||
id: '',
|
||
p_id: '',
|
||
p_name: '',
|
||
},
|
||
dialogVisible: false,
|
||
oper_type: 0,
|
||
rules: {
|
||
p_id: [
|
||
{ required: true, message: '产品编号不可为空', trigger: 'blur' }
|
||
],
|
||
p_name: [
|
||
{ required: true, message: '产品名称不可为空', trigger: 'blur' }
|
||
],
|
||
},
|
||
multipleSelection: [],
|
||
importdialogVisible: false,
|
||
fileListUpload: [],
|
||
importTableData: [],
|
||
disabled: true,
|
||
|
||
if_show_process: false,
|
||
percent_len: 0,
|
||
interval: '',
|
||
if_show_process1: false,
|
||
|
||
begin_t_v: '',
|
||
end_t_v: '',
|
||
|
||
fileList: [],
|
||
|
||
checked: false,
|
||
|
||
if_show_del_filed: false,
|
||
}
|
||
},
|
||
mounted() {
|
||
|
||
this.get_material()
|
||
},
|
||
methods: {
|
||
if_fin_cahnge(val) {
|
||
if (val) {
|
||
this.$data.if_show_del_filed = true;
|
||
this.$data.tableData = [];
|
||
} else {
|
||
this.$data.if_show_del_filed = false;
|
||
this.$data.tableData = [];
|
||
}
|
||
|
||
this.get_material();
|
||
},
|
||
|
||
del_material() {
|
||
|
||
var ids = [];
|
||
for (var i = 0; i < this.$data.multipleSelection.length; i++) {
|
||
ids.push(this.$data.multipleSelection[i].id);
|
||
}
|
||
|
||
var _this = this;
|
||
|
||
axios.post('/pp/del_material', {
|
||
opuser: localStorage.getItem("online_user"),
|
||
opuser_uuid: localStorage.getItem("uuid"),
|
||
ids: ids,
|
||
})
|
||
.then(function (response) {
|
||
|
||
let r = response.data.r;
|
||
let s = ""
|
||
let errType = ""
|
||
if (r == 0) {
|
||
s = "删除成功!";
|
||
errType = "success"
|
||
|
||
// 操作日志
|
||
// _this.add_operation_log("删除序号:" + ids.toString() + "物料");
|
||
} else {
|
||
s = "删除失败!";
|
||
errType = "error"
|
||
}
|
||
|
||
_this.$message({
|
||
message: s,
|
||
type: errType,
|
||
duration: 1500
|
||
});
|
||
|
||
if (r == 0) {
|
||
_this.get_material();;//更新页面
|
||
}
|
||
|
||
})
|
||
.catch(function (error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
down_qs_files(row) {
|
||
var downUrl = '/pp/download_ds_file' + "?id=" + row.qs;
|
||
downloadUrl(row.qs, downUrl);
|
||
},
|
||
down_as_files(row) {
|
||
var downUrl = '/pp/download_ds_file' + "?id=" + row.as;
|
||
downloadUrl(row.as, downUrl);
|
||
},
|
||
upload_param_2(row) {
|
||
//console.log("---")
|
||
return {
|
||
id: row.id,
|
||
file_type: "2"
|
||
}
|
||
},
|
||
upload_param(row) {
|
||
console.log("---")
|
||
return {
|
||
id: row.id,
|
||
file_type: "1"
|
||
}
|
||
},
|
||
upload_file_error(response, file, fileList) {
|
||
this.$message({
|
||
message: "上传失败",
|
||
type: "error",
|
||
duration: 1500
|
||
});
|
||
},
|
||
upload_file_success(response, file, fileList) {
|
||
this.$message({
|
||
message: "上传成功",
|
||
type: "success",
|
||
duration: 1500
|
||
});
|
||
this.get_material();
|
||
this.add_operation_log("上传文件:" + file.name);
|
||
},
|
||
handleChange_file(file, fileList) {
|
||
console.log(file);
|
||
this.fileList = fileList.slice(-1);
|
||
},
|
||
|
||
download_template() {
|
||
document.getElementById("bt_download").blur();
|
||
|
||
var downUrl = '/pp/download_file' + "?id=" + "审批导入.csv";
|
||
downloadUrl("导入审批物料模版.csv", downUrl);
|
||
},
|
||
|
||
input_change(value) {
|
||
console.log(value);
|
||
this.get_material();
|
||
},
|
||
exportSap() {
|
||
document.getElementById("bt_export").blur();
|
||
|
||
var _this = this;
|
||
var objs;
|
||
axios.post('/u_ma/export_sap', {
|
||
opuser: localStorage.getItem("online_user"),
|
||
opuser_uuid: localStorage.getItem("uuid"),
|
||
p_id: _this.$data.p_id_v,
|
||
p_name: _this.$data.p_name_v,
|
||
})
|
||
.then(function (response) {
|
||
console.log(response.data);
|
||
var fileid = response.data.fileId;
|
||
|
||
var downUrl = '/u_ma/download_file' + "?id=" + fileid;
|
||
downloadUrl("产品编码名称.csv", downUrl);
|
||
})
|
||
.catch(function (error) {
|
||
console.log(error);
|
||
});
|
||
},
|
||
|
||
importData() {
|
||
document.getElementById("bt_import").blur();
|
||
if (this.$data.importTableData.length == 0) {
|
||
this.$message({
|
||
message: "请选择导入文件",
|
||
type: "warning",
|
||
duration: 1500
|
||
});
|
||
return;
|
||
}
|
||
|
||
this.$confirm('是否确认导入?', '提示', {
|
||
confirmButtonText: '确定',
|
||
cancelButtonText: '取消',
|
||
type: 'warning'
|
||
}).then(() => {
|
||
var _this = this;
|
||
_this.$data.percent_len = 0;
|
||
_this.$data.if_show_process1 = true;
|
||
_this.$data.interval = setInterval(() => {
|
||
if (_this.$data.percent_len >= 99) {
|
||
clearInterval(_this.$data.interval);
|
||
return;
|
||
}
|
||
|
||
if (_this.$data.percent_len < 98) {
|
||
_this.$data.percent_len += 2
|
||
}
|
||
}, 20)
|
||
|
||
axios.post('/pp/import_approve_m', {
|
||
opuser: localStorage.getItem("online_user"),
|
||
opuser_uuid: localStorage.getItem("uuid"),
|
||
data: this.$data.importTableData,
|
||
})
|
||
.then(function (response) {
|
||
|
||
let r = response.data.r;
|
||
let s = ""
|
||
let errType = ""
|
||
if (r == 0) {
|
||
let len = _this.$data.importTableData.length;
|
||
errType = "success"
|
||
s = "导入" + len + "条物料成功,批准后更新!";
|
||
_this.$data.percent_len = 100;
|
||
_this.$data.if_show_process1 = false;
|
||
|
||
// 操作日志
|
||
_this.add_operation_log("导入" + len + "条物料");
|
||
} else if (r == 1) {
|
||
errType = "error"
|
||
s = "正在导入物料,请稍后!";
|
||
clearInterval(_this.$data.interval);
|
||
} else if (r == 2) {
|
||
errType = "error"
|
||
s = response.data.context;
|
||
clearInterval(_this.$data.interval);
|
||
} else {
|
||
errType = "error"
|
||
s = "导入物料失败!";
|
||
clearInterval(_this.$data.interval);
|
||
}
|
||
|
||
console.log(s);
|
||
_this.$message({
|
||
message: s,
|
||
type: errType,
|
||
duration: 3000
|
||
});
|
||
|
||
_this.$data.importdialogVisible = false;
|
||
//更新页面
|
||
//_this.get_p();
|
||
})
|
||
.catch(function (error) {
|
||
console.log(error);
|
||
});
|
||
}).catch(() => {
|
||
this.$message({
|
||
type: 'info',
|
||
message: '已取消'
|
||
});
|
||
return;
|
||
});
|
||
},
|
||
handleChange(file, fileList) {
|
||
document.getElementById("bt_upload").blur();
|
||
|
||
this.fileTemp = file.raw
|
||
console.log("filetype:", this.fileTemp);
|
||
if (this.fileTemp) {
|
||
console.log("begin ...")
|
||
console.log(this.fileTemp.type);
|
||
if ((this.fileTemp.type == 'text/csv') || (this.fileTemp.type == '.csv') || (this.fileTemp.type == 'application/vnd.ms-excel')) {
|
||
let _this = this//如果需要点击事件结束之后对DOM进行操作使用)_this.xx=xx进行操作
|
||
Papa.parse(_this.fileTemp, {
|
||
encoding: 'gb2312',
|
||
complete(results) {
|
||
console.log(results)//这个是csv文件的数据
|
||
if (results.data.length > 5000) {
|
||
_this.$message({
|
||
type: 'warning',
|
||
message: '导入数据量过大,请分批导入!'
|
||
})
|
||
return;
|
||
}
|
||
let data = []
|
||
//遍历csv文件中的数据,存放到data中 方法不唯一,可自己更改
|
||
console.log(results.data)
|
||
for (let i = 0; i < results.data.length; ++i) {
|
||
if (i == 0) {
|
||
continue;
|
||
}
|
||
let obj = {}
|
||
obj.supplier = results.data[i][0]
|
||
if (obj.supplier == "" || obj.supplier == undefined) {
|
||
continue;
|
||
}
|
||
obj.supplier_code = results.data[i][1]
|
||
/*if(obj.supplier_code==""|| obj.supplier_code==undefined){
|
||
continue;
|
||
}*/
|
||
obj.pt = results.data[i][2]
|
||
/*if(obj.pt==""|| obj.pt==undefined){
|
||
continue;
|
||
}*/
|
||
|
||
obj.code = results.data[i][3]
|
||
/*if(obj.code==""|| obj.code==undefined){
|
||
continue;
|
||
}*/
|
||
|
||
obj.name = results.data[i][4]
|
||
/*if(obj.name==""|| obj.name==undefined){
|
||
continue;
|
||
}*/
|
||
|
||
obj.spec = results.data[i][5]
|
||
/*if(obj.spec==""|| obj.spec==undefined){
|
||
continue;
|
||
}*/
|
||
|
||
obj.unit = results.data[i][6]
|
||
/*if(obj.unit==""|| obj.unit==undefined){
|
||
continue;
|
||
}*/
|
||
|
||
obj.price = results.data[i][7]
|
||
/*if(obj.price==""|| obj.price==undefined){
|
||
continue;
|
||
}*/
|
||
|
||
obj.update_date = results.data[i][8]
|
||
/*if(obj.update_date==""|| obj.update_date==undefined){
|
||
continue;
|
||
}*/
|
||
|
||
obj.pc = results.data[i][9]
|
||
/*if(obj.pc==""|| obj.pc==undefined){
|
||
continue;
|
||
}*/
|
||
|
||
obj.vpoq = results.data[i][10]
|
||
/*if(obj.vpoq==""|| obj.vpoq==undefined){
|
||
continue;
|
||
}*/
|
||
obj.factory = results.data[i][11]
|
||
obj.factory_code = results.data[i][12]
|
||
obj.qs = results.data[i][13]
|
||
obj.as = results.data[i][14]
|
||
console.log(i, ":", obj);
|
||
data.push(obj)
|
||
}
|
||
//data.splice(0, 1)//将数组第一位的表格名称去除
|
||
let num = 0
|
||
console.log('data', data)
|
||
_this.$data.importTableData = data;
|
||
}
|
||
})
|
||
|
||
} else {
|
||
this.$data.fileListUpload = [];
|
||
this.$message({
|
||
type: 'warning',
|
||
message: '附件格式错误,请删除后重新上传!'
|
||
})
|
||
}
|
||
} else {
|
||
this.$message({
|
||
type: 'warning',
|
||
message: '请上传附件!'
|
||
})
|
||
}
|
||
},
|
||
|
||
importCsv() {
|
||
this.$data.fileListUpload = [];
|
||
this.$data.importTableData = [];
|
||
this.$data.importdialogVisible = true;
|
||
},
|
||
importDialog_close(done) {
|
||
done();
|
||
},
|
||
handleSelectionChange(val) {
|
||
console.log("已选择");
|
||
console.log(val);
|
||
this.multipleSelection = val;
|
||
},
|
||
|
||
post_p() {
|
||
this.$refs['form_p'].validate((valid) => {
|
||
if (valid) {
|
||
this.$data.dialogVisible = false;
|
||
|
||
var _this = this;
|
||
|
||
console.log(_this.$data.form);
|
||
|
||
var objs;
|
||
axios.post('/u_ma/post_p', {
|
||
opuser: localStorage.getItem("online_user"),
|
||
opuser_uuid: localStorage.getItem("uuid"),
|
||
id: _this.$data.form.id,
|
||
p_id: _this.$data.form.p_id,
|
||
p_name: _this.$data.form.p_name,
|
||
oper_type: _this.$data.oper_type,
|
||
})
|
||
.then(function (response) {
|
||
|
||
let r = response.data.r;
|
||
let s = ""
|
||
let errType = ""
|
||
if (r == 0) {
|
||
errType = "success"
|
||
} else {
|
||
errType = "error"
|
||
}
|
||
|
||
if (_this.$data.oper_type == 1) {
|
||
|
||
if (r == 0) {
|
||
s = "新增产品信息成功!";
|
||
} else if (r == 1) {
|
||
s = "已存在相同产品信息!";
|
||
} else {
|
||
s = "新增产品信息失败!";
|
||
}
|
||
|
||
} else if (_this.$data.oper_type == 2) {
|
||
|
||
if (r == 0) {
|
||
s = "修改产品信息成功!";
|
||
} else {
|
||
s = "修改产品信息失败!";
|
||
}
|
||
}
|
||
|
||
_this.$message({
|
||
message: s,
|
||
type: errType,
|
||
duration: 1500
|
||
});
|
||
|
||
//更新页面
|
||
_this.get_p();
|
||
})
|
||
.catch(function (error) {
|
||
console.log(error);
|
||
});
|
||
|
||
}
|
||
});
|
||
},
|
||
|
||
update_p(info) {
|
||
this.$data.disabled = true;
|
||
this.$data.oper_type = 2;
|
||
this.$data.form = {
|
||
id: info.id,
|
||
p_id: info.p_id,
|
||
p_name: info.p_name,
|
||
};
|
||
this.$nextTick(() => {
|
||
this.$refs['form_p'].clearValidate()
|
||
});
|
||
this.$data.dialogVisible = true;
|
||
},
|
||
|
||
get_material() {
|
||
document.getElementById("bt_search").blur();
|
||
|
||
//this.$data.currentPage=1;
|
||
|
||
var _this = this;
|
||
|
||
var objs;
|
||
axios.post('/pp/get_material', {
|
||
opuser: localStorage.getItem("online_user"),
|
||
opuser_uuid: localStorage.getItem("uuid"),
|
||
index: this.$data.currentPage,
|
||
count: this.$data.pagesize,
|
||
code: this.$data.code_v,
|
||
name: this.$data.name_v,
|
||
supplier: this.$data.supplier_v,
|
||
bt: this.$data.begin_t_v,
|
||
et: this.$data.end_t_v,
|
||
if_del: this.$data.checked,
|
||
})
|
||
.then(function (response) {
|
||
console.log(response.data);
|
||
objs = response.data.data;
|
||
rcnt = response.data.total;
|
||
_this.$data.tableData = objs;
|
||
_this.$data.recordTotal = rcnt;
|
||
})
|
||
.catch(function (error) {
|
||
console.log(error);
|
||
});
|
||
|
||
},
|
||
|
||
handleSizeChange(val) {
|
||
this.$data.pagesize = val;
|
||
|
||
this.get_material();
|
||
},
|
||
handleCurrentChange(val) {
|
||
this.$data.currentPage = val;
|
||
|
||
this.get_material();
|
||
},
|
||
// 根据内容设置列表宽度
|
||
flexColumnWidth(str, arr1, fontNum = 4, flag = 'max') {
|
||
return window.flexColumnWidth(str, arr1, fontNum, flag);
|
||
},
|
||
// 操作日志
|
||
add_operation_log(operation) {
|
||
axios.post('/pp/add_operation_log', {
|
||
opuser: localStorage.getItem("online_user"),
|
||
opuser_uuid: localStorage.getItem("uuid"),
|
||
operation: operation,
|
||
}).then(function (response) {
|
||
console.log(response);
|
||
}).catch(function (error) {
|
||
console.log(error);
|
||
})
|
||
|
||
}
|
||
}
|
||
}
|