<!doctype html>
|
<html>
|
<head>
|
<meta charset="utf-8"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Cache" content="no-cache">
|
<title>协议信息</title>
|
<script src="../../../jsnew/elementDefault.js?v=20220425"></script>
|
<script src="../../../jsnew/vue/vue.js"></script>
|
<script src="../../../jsnew/vue/element-ui/element-ui_15/index.js"></script>
|
<script src="../../../jsnew/myelement.js?v=20220425"></script>
|
<script src="../../../jsnew/page.js?v=20220425"></script>
|
<!-- <script src="../../../setting.js"></script> -->
|
|
<link href="../../../jsnew/vue/element-ui/element-ui_15/theme-chalk/index.css" rel="stylesheet">
|
<link href="../../../jsnew/myelement.css?v=20220426" rel="stylesheet">
|
<link href="../../../jsnew/theme.css?v=20220426" rel="stylesheet">
|
<link href="../../../css/iconfont.css" rel="stylesheet">
|
<link href="../../../jsnew/page.css?v=20220425" rel="stylesheet">
|
<link href="//at.alicdn.com/t/font_2374495_13ltsxm2eor.css" rel="stylesheet">
|
</head>
|
|
<body style="margin: 0px;">
|
<div v-cloak id="vbody">
|
<div id="page_root">
|
<div ref="popup_body" style="padding: 0 20px;">
|
<div class="el-dialog__header">
|
<div class="dialog-title">
|
<i class="iconfont icon-customermanagement"></i>
|
<span> {{title}}</span>
|
</div>
|
</div>
|
|
<div :style="{height: p_height + 'px', 'overflow-y': 'auto'}">
|
<div class="el-dialog__body">
|
<h-form
|
ref="form1"
|
:form-attr="formAttr"
|
:table-fields="formFields"
|
:form-data="formData"
|
:table-field-click="formfieldClick"
|
>
|
</h-form>
|
|
<!-- 审批时的原因 -->
|
<el-dialog title="填写原因" :visible.sync="reasonvisible" height="50%">
|
<el-input
|
type="textarea"
|
:autosize="{ minRows: 2, maxRows: 10}"
|
placeholder="请输入原因"
|
v-model="textarea2">
|
</el-input>
|
|
<div slot="footer" class="dialog-footer" >
|
<el-button type="default" @click="reasonvisible = false">取 消</el-button>
|
<el-button type="primary" :loading="loading_pass" @click="saveReason">确 定</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</div>
|
|
<div class="el-dialog__footer">
|
<el-button size="small" type="default" @click="closeDialog">取 消</el-button>
|
<el-button size="small" v-if="isedit" type="primary" :loading="loading_save" @click="saveRowTable":icon="buttonsconfig.save.icon">保 存</el-button>
|
<el-button size="small" v-if="isedit" type="success" :loading="iscommit" @click="submitRowTable":icon="buttonsconfig.submit.icon">提 交</el-button>
|
|
<el-button size="small" v-if="isapproval" type="danger" @click="onRefuseApproval">拒 绝</el-button>
|
<el-button size="small" v-if="isapproval" type="success" @click="onPassApproval">通 过</el-button>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 50vh;">
|
<div class="spinner">
|
<div class="cube1"></div>
|
<div class="cube2"></div>
|
</div>
|
</div>
|
|
<script type="text/javascript">
|
// function loadJsCss(callback) {
|
// var jscss_urls = [];
|
// window.top.initJsCss(document, jscss_urls, callback);
|
// };
|
function initVue() {
|
new FormVue({
|
el: "#vbody",
|
data: {
|
dataname: "agm_agreement",
|
title: "协议信息",
|
|
formAttr: {
|
istitle: false,
|
title: "表单名称",
|
columnnumber: 2,
|
labelwidth: "140px",
|
labelposition: "left",//"left",// right//top
|
size: "mini",
|
border: "10px solid #c6c6c600"
|
},
|
formFields: [
|
{isshow: "F", field: "category_id", name: "协议类型", inputtype: "span"},
|
{isshow: "T", field: "category_name", name: "协议类型", inputtype: "span"},
|
{isshow: "T", field: "template_name", name: "模板名称", inputtype: "span"},
|
{isshow: "T", field: "template_attachment_name", name: "模板附件", inputtype: "uploadfile", readonly: true},
|
{isshow: "T", field: "customer_code", name: "经销商编码", width: "150", type: "span",},
|
{isshow: "T", field: "customer_name", name: "甲方", width: "200", type:"span",},
|
{isshow: "T", field: "partyB", name: "乙方", width: "200", type:"span",},
|
{isshow: "T", required: true, field: "begin_date", name: "开始日期", inputtype: "date"},
|
{isshow: "T", required: true, field: "end_date", name: "终止日期", inputtype: "date"},
|
{isshow: "T", field: "remark", name: "备注", inputtype: "textarea"},
|
],
|
newformData: {
|
status: "Open",
|
state_name: "生效",
|
// creator_id:
|
},
|
formData: {},
|
//字段设置
|
formfieldClick: {},
|
|
//按键权限设置
|
isedit: false,//提交前编辑,保存/提交
|
isrefuseedit: false,//拒绝后编辑,保存/再次提交
|
isapproval: false,//审批,同意/拒绝/转办/退回
|
iscommit: false,//提交标记
|
loading_save: false,
|
|
//审批相关变量
|
reasonvisible:false,//审批通过或拒绝填写原因
|
textarea2: '',//填写理由
|
passOrRefuse:false,
|
loading_pass: false,
|
|
//高度
|
p_height: null,
|
|
//弹窗参数
|
popupParames: {},
|
|
dataRequest: [],
|
|
copyAdd: false,
|
formDatas_old: [],
|
},
|
created() {
|
this.popupParames = clone(Root.popupParames);
|
this.title = this.popupParames.title || this.popupParames.text;
|
|
if (this.popupParames.data) {
|
this.formData = clone(this.popupParames.data);
|
}
|
if (this.popupParames.delta || this.popupParames.delta.rows) {
|
this.formDatas_old = clone(this.popupParames.delta.rows);
|
console.log(this.formDatas_old);
|
}
|
|
if (this.popupParames.sceneCode) {
|
if (this.popupParames.sceneCode == "add") {//新增
|
//动态获取默认数据
|
// var newEntity_ = {
|
// name: "newEntity",
|
// url: "root/data/newEntity",
|
// paramsobj: {dataname: this.dataname},
|
// isnotoption: true, //true:不是选项
|
// }
|
// this.dataRequest.push(newEntity_);
|
this.isedit = true;
|
}
|
else if (this.popupParames.sceneCode == "browse") {//只读
|
this.formAttr.disabled = true;
|
}
|
else if (this.popupParames.sceneCode == "copyAdd") {//只读
|
this.copyAdd = true;
|
this.isedit = true;
|
}
|
else if (this.popupParames.sceneCode == "edit") {//编辑
|
this.isedit = true;
|
}
|
else if (this.popupParames.sceneCode == "approval") {//审批
|
this.formAttr.disabled = true;
|
this.isapproval = true;
|
}
|
else if (this.popupParames.sceneCode == "refuseedit") {//拒绝后的编辑
|
this.isrefuseedit = true;
|
}
|
}
|
},
|
|
mounted() {
|
var me = this;
|
me.p_height = document.documentElement.clientHeight*1 - 91;
|
|
//预加载数据
|
if (this.dataRequest && this.dataRequest.length) {
|
var result = {};
|
this.loadRequestData(this.dataRequest, result, function(data) {
|
me.dataRequestObj = data;
|
//预加载数据后给哪些字段设置options或formatterjson
|
if (me.dataRequestObj.newEntity) {
|
var formData = clone(me.dataRequestObj.newEntity.data[me.dataname]);
|
// formData.product_category_name = [];
|
if (me.newformData) {
|
let formData_ = clone(formData);
|
|
for (var k in me.newformData) {
|
if (!formData_[k]) {
|
formData_[k] = me.newformData[k];
|
}
|
}
|
|
me.formData = formData_;
|
}
|
}
|
|
me.initData();
|
});
|
|
if (me.popupParames.sceneCode == "add" || me.popupParames.sceneCode == "copyAdd") {
|
me.initField();
|
}
|
else {
|
me.initData();
|
}
|
}
|
else {
|
if (me.popupParames.sceneCode == "add" || me.popupParames.sceneCode == "copyAdd") {
|
me.initField();
|
}
|
else {
|
me.initData();
|
}
|
}
|
|
// 以服务的方式调用的 Loading 需要异步关闭
|
this.$nextTick(() => {
|
hideLoading();
|
|
//重新设置弹窗宽高
|
this.$nextTick(function(){
|
//let w_ = this.$refs.popup_body.offsetWidth "px";
|
let w_ = "1200px";
|
let h_ = this.$refs.popup_body.offsetHeight + "px";
|
|
Root.setPopupWH(w_, h_);
|
})
|
});
|
},
|
|
methods:{
|
//关闭弹窗
|
closeDialog() {
|
var me = this;
|
if (me.popupParames.totab){
|
Root.tab.removeItem(Root.tab.selected);
|
Root.tab.open(me.popupParames.parentOption, false);
|
}
|
else {
|
Root.hidePopup();
|
}
|
},
|
//关闭前调回调
|
saveAfter() {
|
var me = this;
|
if(this.popupParames.callback) {
|
let obj = {
|
//row: this.formData
|
}
|
this.popupParames.callback(obj, function() {
|
me.closeDialog();
|
});
|
}
|
else {
|
me.closeDialog();
|
}
|
},
|
|
initField() {
|
this.showTemplate();
|
|
// this.tableFieldClick();
|
},
|
|
showTemplate() {
|
var me = this;
|
var url = "popup_agreement_mould.html";
|
if (me.copyAdd) {
|
url = "popup_agreement_mould_copy.html"
|
}
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "800px",
|
height: "400px",
|
icon: "icon-product",
|
text: "创建协议",
|
id: url,//totab: true时需设置,用于判断是否已打开此页面
|
url: "../agreement/agreement/" + url,
|
data: {},
|
delta: {},
|
filter: "1=1",
|
sceneCode: "add", //"add"//"browse",
|
closecallback: function() {
|
me.closeDialog();
|
},
|
callback: function(obj, callback) {
|
console.log(obj);
|
|
// me.initData();
|
|
if (obj.form0) {
|
if (obj.form0.category_id) {
|
me.formData.category_id = obj.form0.category_id;
|
}
|
if (obj.form0.category_name) {
|
me.formData.category_name = obj.form0.category_name;
|
}
|
if (obj.form0.template_id) {
|
me.formData.template_id = obj.form0.template_id;
|
}
|
if (obj.form0.template_name) {
|
me.formData.template_name = obj.form0.template_name;
|
}
|
if (obj.form0.template_attachment_id) {
|
me.formData.template_attachment_id = obj.form0.template_attachment_id;
|
}
|
if (obj.form0.template_attachment_name) {
|
me.formData.template_attachment_name = obj.form0.template_attachment_name;
|
}
|
}
|
if (obj.form1) {
|
if (obj.form1.customer_id) {
|
me.formData.customer_id = obj.form1.customer_id;
|
}
|
if (obj.form1.customer_code) {
|
me.formData.customer_code = obj.form1.customer_code;
|
}
|
if (obj.form1.customer_name) {
|
me.formData.customer_name = obj.form1.customer_name;
|
}
|
}
|
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
|
initData() {
|
let me = this;
|
var id_ = null;
|
// if (this.formData.id) {
|
// id_ = this.formData.id;
|
// }
|
// this.getRowDataById(id_, function(result) {//查询后的回调,用于获取字段的
|
// if (result.meta && result.meta[me.dataname] && result.meta[me.dataname].fields) {
|
// var metas = clone(result.meta[me.dataname].fields);
|
// var formFields_ = [];
|
|
// metas.map(f=>{
|
// f.isshow = "T";
|
// if (f.field == "template_attachment_name") {
|
// f.readonly = true;
|
// }
|
|
// if ((me.formData && me.formData.state_code && me.formData.state_code != 'Open') || me.copyAdd) {
|
// if (f.field == 'agreement_no') {
|
// f.isshow = "F";
|
// }
|
// }
|
|
// if (me.copyAdd) {
|
// if (f.field == "customer_code" || f.field == "customer_name") {
|
// f.isshow = 'F';
|
// }
|
// }
|
|
// if (me.formData.state_code != 'Open') {
|
// if (f.field == "logistics_code") {
|
// f.isshow = 'F';
|
// }
|
// }
|
|
// formFields_.push(clone(f));
|
// })
|
// if (!me.formFields || (me.formFields && me.formFields.length == 0)) {
|
// me.formFields = clone(formFields_);
|
|
// //字段数组转字段obj
|
// me.fieldsToFieldsObj();
|
|
// //设置字段事件
|
// me.tableFieldClick();
|
// }
|
// }
|
// })
|
},
|
|
tableFieldClick() {
|
var me = this;
|
//表单字段事件设置
|
this.formfieldClick = {
|
template_attachment_name: {//字段事件设置
|
buttonarray: {
|
onclick: function(obj) {
|
var filenamefield = obj.obj.field;
|
var fileidfield = "template_attachment_id";
|
if(obj.buttonobj && obj.buttonobj.code == "showfile"){
|
me.showFileImgByFileId(filenamefield, fileidfield);
|
}
|
}
|
},
|
},
|
|
date_from: {//起始日期
|
val: {
|
onchange: function(obj) {
|
//开始日期要早于截止日期
|
if (obj.data.date_from && obj.data.date_to) {
|
if (new Date(obj.data.date_from) > new Date(obj.data.date_to)) {
|
Root.message({
|
type: 'warning',
|
message: '起始日期不能晚于终止日期'
|
});
|
obj.data.date_from = null;
|
}
|
}
|
}
|
}
|
},
|
|
date_to: {//终止日期
|
val: {
|
onchange: function(obj) {
|
//截止日期要晚于开始日期
|
if (obj.data.date_from && obj.data.date_to) {
|
if (new Date(obj.data.date_from) > new Date(obj.data.date_to)) {
|
Root.message({
|
type: 'warning',
|
message: '终止日期不能早于起始日期'
|
});
|
obj.data.date_to = null;
|
}
|
}
|
}
|
}
|
},
|
};
|
},
|
|
showFileImgByFileId(filenamefield, fileidfield) {
|
let me = this;
|
var file_name = me.formData[filenamefield];
|
var file_id = me.formData[fileidfield];
|
if(file_id) {
|
var fileid = file_id;
|
let fileName = clone(file_name);
|
let index1 = fileName.lastIndexOf(".");
|
let index2 = fileName.length;
|
let suffix = fileName.substring(index1, index2).toLowerCase(); //后缀名
|
if (suffix == ".png" || suffix == ".jpg" || suffix == ".pdf") {
|
var row = {
|
fileid: fileid,
|
filename: fileName
|
}
|
|
var config = {
|
totab: false,
|
width: "1000px",
|
height: 800,
|
icon: "icon-product",
|
text: "附件预览",
|
id: "pdf_" + fileid,
|
url: "module/tool/page/popup_file_pdf.html",
|
data: row,
|
delta: {},
|
callback: function(obj, callback) {
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
this.doPopupByPublic(config);
|
}
|
else {//只可下载,不可预览
|
// handleDownloadUrl(fileid,false);
|
handleDownload(fileid);
|
}
|
}
|
},
|
|
//提交
|
submitRowTable() {
|
this.iscommit = true;
|
//必填项校验
|
var bo1 = this.$refs.form1.checkForm();
|
if(!bo1){
|
Root.message({
|
type: 'error',
|
message: '请填写必填项'
|
});
|
this.iscommit = false;
|
return;
|
}
|
this.saveRowTable();
|
},
|
|
//保存
|
saveRowTable() {
|
var me = this;
|
var operator_ = "saveEntity";//保存
|
me.loading_save = true;
|
if(me.iscommit) {
|
operator_ = "commit";//提交
|
}
|
|
var entity_ = clone(me.formData);
|
|
if (me.copyAdd) {
|
var entitys = clone(me.formDatas_old);
|
var entity = [];
|
entitys.map(es => {
|
for (var f in es) {
|
if (f == "id") {
|
es.source_id = es[f];
|
}
|
if (f == "agreement_no" || f == "contract_attachment_id" || f == "contract_attachment_name" || f == "state_detail_code" || f == "state_detail_name" || f == "id" || f == "creator_id" || f == "creator_name" || f == "create_time" || f == "update_time") {
|
es[f] = "";
|
}
|
if (f == "state_code") {
|
es[f] = "Input";
|
}
|
if (f == "state_name") {
|
es[f] = "草稿";
|
}
|
if (f == "category_id" || f == "category_name" || f == "date_from" || f == "date_to" || f == "remark" || f == "template_attachment_id" || f == "template_attachment_name" || f == "template_id" || f == "template_name") {
|
es[f] = entity_[f];
|
}
|
}
|
entity.push(es);
|
})
|
}
|
else {
|
var entity = {};
|
for (var r in entity_) {
|
if (entity_[r]) {
|
entity[r] = entity_[r];
|
}
|
}
|
}
|
|
let param = {
|
dataname: me.dataname,
|
data: {},
|
}
|
param.data[me.dataname] = entity;
|
|
Server.call("root/data/"+operator_, param, function(result) {
|
if (result.success) {
|
if (me.iscommit) {
|
me.iscommit = false;
|
me.loading_save = false;
|
Root.message({
|
type: 'success',
|
message: '提交成功'
|
});
|
}
|
else {
|
me.loading_save = false;
|
Root.message({
|
type: 'success',
|
message: '保存成功'
|
});
|
}
|
me.saveAfter();
|
}
|
}, function(errorresult) {
|
console.log("错误信息", errorresult);
|
if (errorresult.messages && errorresult.messages.count && errorresult.messages.count.error) {
|
if (errorresult.messages.list) {
|
me.iscommit = false;
|
me.loading_save = false;
|
var config = {
|
totab: false,
|
// width: "1200px",
|
// height: 800,
|
icon: "icon-product",
|
text: "错误信息",
|
url: "module/tool/page/popup_error_messages.html",
|
data: {},
|
delta: errorresult.messages.list,
|
callback: function(obj, callback) {
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
}
|
}
|
else {
|
if(me.iscommit) {
|
me.iscommit = false;
|
Root.message({
|
type: 'error',
|
message: '提交失败'
|
});
|
}
|
else {
|
me.loading_save = false;
|
Root.message({
|
type: 'error',
|
message: '保存失败'
|
});
|
}
|
}
|
});
|
},
|
|
//审批通过相关数据赋值
|
onPassApproval() {
|
this.textarea2 = "";
|
this.reasonvisible = true;
|
this.passOrRefuse = true;
|
},
|
|
//审批拒绝相关数据赋值
|
onRefuseApproval(){
|
this.textarea2 = "";
|
this.reasonvisible = true;
|
this.passOrRefuse = false;
|
},
|
|
//保存通过/拒绝原因
|
saveReason(){
|
this.loading_pass = true;
|
if(this.passOrRefuse){
|
this.doPassApproval(true);
|
}else{
|
if(this.textarea2 != ""){
|
this.doPassApproval(false);
|
}
|
else{
|
Root.message({
|
type: 'warning',
|
message: '请填写原因'
|
});
|
this.loading_pass = false;
|
}
|
}
|
},
|
|
//审批通过/拒绝
|
doPassApproval(bo) {
|
var me = this;
|
var state_ = "approve"
|
if (!bo) {
|
state_ = "reject"
|
}
|
|
let param = {
|
dataname: me.dataname,
|
id: me.formData.id,
|
remark: me.textarea2,
|
}
|
Server.call("root/data/" + state_, param, function(result) {
|
me.loading_pass = false;
|
console.log(result);
|
if (bo) {
|
Root.message({
|
type: 'success',
|
message: '审批成功'
|
});
|
me.saveAfter();
|
}
|
|
else {
|
Root.message({
|
type: 'success',
|
message: '已拒绝'
|
});
|
me.saveAfter();
|
}
|
}, function(errorresult) {
|
console.log("错误信息", errorresult);
|
me.loading_pass = false;
|
if (errorresult.messages && errorresult.messages.count && errorresult.messages.count.error) {
|
if (errorresult.messages.list) {
|
var config = {
|
totab: false,
|
// width: "1200px",
|
// height: 800,
|
icon: "icon-product",
|
text: "错误信息",
|
url: "module/tool/page/popup_error_messages.html",
|
data: {},
|
delta: errorresult.messages.list,
|
callback: function(obj, callback) {
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
}
|
}
|
else {
|
Root.message({
|
type: 'error',
|
message: '审批失败'
|
});
|
}
|
});
|
},
|
}
|
});
|
};
|
|
// loadJsCss(function () {
|
initVue();
|
// });
|
</script>
|
<style>
|
/* 在vue.js中 v-cloak 这个指令是防止页面加载时出现 vuejs 的变量名而设计的 */
|
[v-cloak] {
|
display: none !important;
|
}
|
</style>
|
</body>
|
</html>
|