pp-web/scripts/pf.js

418 lines
10 KiB
JavaScript

var pfcomponent = {
template: `
<div>
<div id="" style="display: flex">
<el-input v-model="applicant_v" placeholder="申请人" clearable style="width: 160px;" @change="input_change"></el-input>
<el-button id ="bt_search" plain type="primary" icon="el-icon-search" @click="get_approve()">搜索</el-button>
<el-button id ="bt_del" plain type="primary" icon="el-icon-circle-plus-outline" @click="del_approve()">删除</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"
@cell-dblclick="celldblclick_1"
>
<el-table-column
type="selection"
width ="30">
</el-table-column>
<el-table-column
prop="id"
label="编号"
:width="flexColumnWidth('id', tableData,2)">
</el-table-column>
<el-table-column
prop="applicant"
label="申请人"
:width="flexColumnWidth('applicant', tableData,3)"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
prop="time"
label="日期"
width="80"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
prop="record_cnt"
label="申请数量"
:width="flexColumnWidth('record_cnt', tableData)"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
prop="update_cnt"
label="替换数量"
:width="flexColumnWidth('update_cnt', tableData)"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
prop="add_cnt"
label="新增数量"
:width="flexColumnWidth('add_cnt', tableData)"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
prop="state"
label="状态"
:width="flexColumnWidth('state', tableData,2)">
</el-table-column>
<!--
<el-table-column
label="操作"
width="120">
<template slot-scope="scope">
<el-button @click="update_process(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="update_visible"
:lock-scroll ="false"
width="80%"
style="height: 100%;">
<el-table
:data="tableData1"
style="width: 100%"
:cell-style="{background:'#fff'}"
border
>
<el-table-column
prop="op_type"
label="更新方式"
width="80"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
prop="price_span"
label="变化"
width="60"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
prop="last_price"
label="最新单价"
width="60"
: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="effective_time"
label="报价有效时间"
width="120"
:show-overflow-tooltip="true">
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button @click="update_visible = false">取 消</el-button>
<el-button v-if='state!="已批准"' id ="bt_ok" plain type="primary" @click="post_process()">确认入库</el-button>
</span>
</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: [],
tableData1: [],
currentPage: 1,
pagesize: 50,
recordTotal: 0,
applicant_v: '',
dialogVisible: false,
multipleSelection: [],
disabled: true,
if_show_process: false,
percent_len: 0,
interval: '',
if_show_process1: false,
update_visible: false,
form: {
id: '',
p_id: '',
process_name: '',
process_t: '',
},
rules: {
p_id: [
{ required: true, message: '产品编号不可为空', trigger: 'blur' }
],
process_name: [
{ required: true, message: '工序不可为空', trigger: 'blur' }
],
process_t: [
{ required: true, message: '工时不可为空', trigger: 'blur' }
],
},
id: 0,
state: '',
}
},
mounted() {
this.get_approve();
},
methods: {
celldblclick_1(row, column, cell, event) {
this.$data.tableData1 = JSON.parse(row.data);
this.$data.id = row.id,
this.$data.state = row.state,
this.$data.update_visible = true;
},
post_process() {
this.$data.update_visible = false;
var _this = this;
console.log(_this.$data.form);
var objs;
axios.post('/pp/approve_ok', {
opuser: localStorage.getItem("online_user"),
opuser_uuid: localStorage.getItem("uuid"),
id: _this.$data.id,
data: _this.$data.tableData1,
})
.then(function (response) {
let r = response.data.r;
let s = ""
let errType = ""
if (r == 0) {
errType = "success"
// 操作日志
_this.add_operation_log("导入物料编号:" + _this.$data.id + "确认入库");
} else {
errType = "error"
}
if (r == 0) {
s = "入库成功!";
} else {
s = "入库失败!";
}
_this.$message({
message: s,
type: errType,
duration: 1500
});
//更新页面
_this.get_approve();
})
.catch(function (error) {
console.log(error);
});
},
update_process(row) {
this.$data.form = {
id: row.id,
p_id: row.p_id,
process_name: row.process_name,
process_t: row.process_t
};
this.$nextTick(() => {
this.$refs['form_p'].clearValidate()
});
this.$data.update_visible = true;
},
input_change(value) {
console.log(value);
this.get_approve();
},
importDialog_close(done) {
done();
},
handleSelectionChange(val) {
console.log("已选择");
console.log(val);
this.multipleSelection = val;
},
del_approve() {
var _this = this;
axios.post('/pp/del_approve', {
opuser: localStorage.getItem("online_user"),
opuser_uuid: localStorage.getItem("uuid"),
ids: _this.$data.multipleSelection,
})
.then(function (response) {
let r = response.data.r;
let s = ""
let errType = ""
if (r == 0) {
s = "删除成功!";
errType = "success"
// 操作日志
// var list = [];
// _this.$data.multipleSelection.forEach(element => {
// list.push(element.id);
// });
// _this.add_operation_log("删除序号:" + list.toString() + "物料审批");
} else {
s = "删除失败!";
errType = "error"
}
_this.$message({
message: s,
type: errType,
duration: 1500
});
if (r == 0) {
_this.get_approve();//更新页面
}
})
.catch(function (error) {
console.log(error);
});
},
get_approve() {
document.getElementById("bt_search").blur();
var _this = this;
var objs;
axios.post('/pp/get_approve_m', {
opuser: localStorage.getItem("online_user"),
opuser_uuid: localStorage.getItem("uuid"),
index: this.$data.currentPage,
count: this.$data.pagesize,
applicant: this.$data.applicant_v,
})
.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_approve();
},
handleCurrentChange(val) {
this.$data.currentPage = val;
this.get_approve();
},
// 根据内容设置列表宽度
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);
})
}
}
}