|
<!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 type="text/javascript">
|
var pageVue = null;
|
function loadJsCss(callback) {
|
var jscss_urls = [];
|
window.top.initJsCss(document, jscss_urls, callback);
|
};
|
|
function initVue() {
|
new FormVue({
|
el: "#vbody",
|
data: {
|
dataname: "so_channel",
|
table_dataname: "so_channel_detail",
|
title: "渠道订单信息",
|
dataRequest: [],
|
oldFormData:[],
|
formAttr: {
|
istitle: false,
|
title: "表单名称",
|
columnnumber: 3,
|
labelwidth: "100px",
|
labelposition: "left",//"left",// right//top
|
size: "mini",
|
border: "5px solid #c6c6c600"
|
},
|
|
formFields: [],
|
|
newformData: {
|
type_code: 'platform',
|
type_name: "平台订单",
|
},
|
formData: {},
|
options_shipto_address: [],
|
accountPositions_options: [],
|
accountPositions_obj: {},
|
|
isRefresh: true,
|
tablebuttonClick:[],
|
tableFields: [],
|
newTableData: {},
|
tableData: [],
|
|
//按键权限设置
|
isedit: false,//提交前编辑,保存/提交
|
isrefuseedit: false,//拒绝后编辑,保存/再次提交
|
isapproval: false,//审批,同意/拒绝/转办/退回
|
|
iscommit: false,//提交标记
|
|
//弹窗参数
|
popupParames: {},
|
//字段设置
|
tablefieldClick: {},
|
formfieldClick: {},
|
dheight: 0,
|
qty_available:0,
|
operate: "",
|
|
//审批相关变量
|
loading_save: false,
|
loading_pass: false,
|
reasonvisible:false,//审批通过或拒绝填写原因
|
approveremark: "",//填写理由
|
passOrRefuse:false,
|
iscustomer:false,
|
tableAttr:{},
|
},
|
created() {
|
this.iscustomer = window.top.vue.isCustomer
|
|
if (this.iscustomer) {
|
this.newformData.customer_id = window.top.vue.userinfo.currentactor.target_id
|
this.newformData.company_id = window.top.vue.userinfo.currentactor.company_id
|
this.newformData.bu_id = window.top.vue.userinfo.currentactor.bu_id
|
this.newformData.org_id = window.top.vue.userinfo.org.id
|
this.newformData.customer_code = window.top.vue.userinfo.org.code
|
this.newformData.customer_name = window.top.vue.userinfo.org.name
|
}
|
|
this.dheight = document.documentElement.clientHeight - 92;
|
this.popupParames = clone(Root.popupParames);
|
this.operate = this.popupParames.sceneCode;
|
this.title = this.popupParames.title || this.popupParames.text
|
if (this.popupParames.data) {
|
this.formData = clone(this.popupParames.data);
|
|
if (this.formData.org_id) {
|
var shipto_ = {
|
name: "md_org_shipto",
|
dataname: "md_org_shipto",
|
isnotoption: false, //true:不是选项
|
code: "id",//是下拉选项时设置
|
label: "address",//是下拉选项时设置
|
filter: "parent_id='" + this.formData.org_id + "'",
|
orderby: "address"
|
}
|
|
this.dataRequest.push(shipto_);
|
}
|
}
|
|
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_);
|
|
if (this.iscustomer) {
|
var accountEntity_ = {
|
name: "accountEntity",
|
url: "root/data/getEntity",
|
paramsobj: {dataname: "md_org_account", id: window.top.vue.userinfo.currentactor.target_id},
|
isnotoption: true, //true:不是选项
|
}
|
this.dataRequest.push(accountEntity_);
|
}
|
|
this.isedit = true;
|
}
|
else if (this.popupParames.sceneCode == "browse") {//只读
|
this.formAttr.disabled = true;
|
this.isedit = false;
|
}
|
else if (this.popupParames.sceneCode == "edit") {//编辑
|
if (this.iscustomer) {
|
var accountEntity_ = {
|
name: "accountEntity",
|
url: "root/data/getEntity",
|
paramsobj: {dataname: "md_org_account", id: window.top.vue.userinfo.currentactor.target_id},
|
isnotoption: true, //true:不是选项
|
}
|
this.dataRequest.push(accountEntity_);
|
}
|
|
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;
|
//预加载数据
|
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]);
|
if (me.newformData) {
|
let formData_ = clone(formData);
|
|
for (var k in me.newformData) {
|
if (!formData_[k]) {
|
formData_[k] = me.newformData[k];
|
}
|
}
|
|
if (!formData_.doc_date) {
|
formData_.doc_date = formData_.create_time
|
}
|
|
me.formData = formData_;
|
}
|
}
|
|
if (me.dataRequestObj.accountEntity) {
|
var formData_ = clone(me.formData);
|
var dataname_acc = "md_org_account";
|
var dataname_acc_position = "md_org_account_position";
|
var formData_acc = clone(me.dataRequestObj.accountEntity.data[dataname_acc])
|
formData_.platform_customer_id = formData_acc.platform_account_id
|
formData_.platform_customer_code = formData_acc.platform_account_code
|
formData_.platform_customer_name = formData_acc.platform_account_name
|
formData_.platform_org_id = formData_acc.platform_org_id
|
me.formData = formData_;
|
|
var formData_acc_position = clone(me.dataRequestObj.accountEntity.data[dataname_acc_position]);
|
if (formData_acc_position.length) { // 多个业务负责人
|
var accountPositions_options_ = [];
|
var accountPositions_obj_ = {};
|
formData_acc_position.map(ap=>{
|
var e_ = ap.md_position_hierarchy__employee_name
|
var employee_ = {
|
code: e_,
|
value: e_
|
}
|
accountPositions_obj_[e_] = clone(ap);
|
accountPositions_options_.push(employee_);
|
})
|
me.accountPositions_options = clone(accountPositions_options_);
|
me.accountPositions_obj = clone(accountPositions_obj_);
|
// // 设置选择器,由进行选择
|
// formFields_.map(ff=>{
|
// if (ff.field == 'position_name') {
|
// ff.inputtype = "select"
|
// ff.options = accountPositions_options_
|
// }
|
// });
|
}
|
}
|
|
if (me.dataRequestObj.md_org_shipto) {
|
me.options_shipto_address = me.dataRequestObj.md_org_shipto
|
}
|
|
|
me.initData();
|
|
});
|
}
|
else {
|
this.initData();
|
}
|
|
// 以服务的方式调用的 Loading 需要异步关闭
|
this.$nextTick(() => {
|
hideLoading();
|
|
//重新设置弹窗宽高
|
this.$nextTick(function(){
|
//let w_ = this.$refs.popup_body.offsetWidth + "px";
|
let w_ = "900px";
|
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();
|
}
|
},
|
|
initData() {
|
let me = this
|
var id_ = null;
|
|
if (this.formData.id) {
|
id_ = this.formData.id;
|
}
|
me.tableButtonClick();
|
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 table_dataname_ = "";
|
for (var dataname_ in result.meta) {
|
if (dataname_ != me.dataname && !table_dataname_) {
|
table_dataname_ = dataname_;
|
}
|
}
|
var table_metas = [];
|
if (table_dataname_) {
|
me.table_dataname = table_dataname_;
|
table_metas = clone(result.meta[table_dataname_].fields);
|
|
}
|
|
var formFields_ = [];
|
var tableFields_ = [];
|
metas.map(f=>{
|
f.isshow = "T";
|
|
if (me.iscustomer) {
|
if(f.field == "customer_name") {
|
f.inputtype = "span";
|
}
|
}
|
|
if(f.field == "position_name") {
|
f.options = me.accountPositions_options
|
}
|
if (f.field == 'shipto_address_id') {
|
f.options = me.options_shipto_address
|
f.buttonarrayname = [{type: "", buttonname:"地址维护", icon: "el-icon-place", code:"showfile", classname: "form_showfile"},]
|
}
|
|
formFields_.push(clone(f));
|
})
|
table_metas.map(f=>{
|
f.isshow = "T";
|
if (f.field == "stock_type_code") {
|
f.options = me.dataRequestObj.wm_stock_type
|
var formatterjson_ = {};
|
me.dataRequestObj.wm_stock_type.map(r=>{
|
formatterjson_[r.code] = r.name;
|
})
|
f.formatterjson = formatterjson_
|
|
}
|
if (f.field == "qty") {
|
f.inputkeys = "number";//按键正整数
|
f.istablesum = true
|
}
|
tableFields_.push(clone(f));
|
})
|
|
if (!me.formFields || (me.formFields && me.formFields.length == 0)) {
|
me.formFields = clone(formFields_);
|
me.tableFields = clone(tableFields_);
|
}
|
}
|
|
if (me.rowData[me.dataname]) {
|
me.formData = me.rowData[me.dataname];
|
}
|
if (me.rowData[me.table_dataname]) {
|
me.tableData = me.rowData[me.table_dataname];
|
}
|
if (me.rowData["so_channel_file"] && me.rowData["so_channel_file"].length) {
|
var attachment_id_ = []
|
var attachment_approve_id_ = []
|
me.rowData["so_channel_file"].map(f=>{
|
if (f.sender_field_file_name == "attachment_id") {
|
var f_ = {
|
id: f.id,
|
file_name: f.file_name
|
}
|
attachment_id_.push(f_);
|
}
|
else if (f.sender_field_file_name == "attachment_approve_id") {
|
var f_ = {
|
id: f.id,
|
file_name: f.file_name
|
}
|
attachment_approve_id_.push(f_);
|
}
|
|
})
|
me.$set(me.formData, "attachment_approve_id", attachment_approve_id_);
|
me.$set(me.formData, "attachment_id", attachment_id_);
|
|
}
|
})
|
|
//字段数组转字段obj,目的为了筛选时获取字段属性
|
me.fieldsToFieldsObj();
|
|
//设置字段事件
|
me.tableFieldClick();
|
},
|
|
tableFieldClick() {
|
var me = this;
|
//表单字段事件设置
|
this.formfieldClick = {
|
platform_customer_name: {
|
popup: {
|
onclick: function(obj) {//弹窗点击事件
|
//打开开户库弹窗
|
me.openAccount("add", obj, function(popupobj){
|
let formData_ = clone(me.formData);
|
formData_.platform_org_id = popupobj.row.org_id;
|
formData_.platform_customer_id = popupobj.row.id;
|
formData_.platform_customer_code = popupobj.row.code;
|
formData_.platform_customer_name = popupobj.row.account_name;
|
|
me.formData = clone(formData_);
|
});
|
}
|
}
|
},
|
position_name: {
|
visible: {
|
onchange: function(obj,row,callback) {//下拉展开事件
|
if (!me.accountPositions_options.length) {
|
if (!me.formData.customer_id) {
|
Root.message({
|
type: 'warning',
|
message: '请先选择客商名称'
|
});
|
return
|
}
|
|
let param_ = {
|
dataname: "md_org_account_position",//获取经销商对应收货地址
|
filter:"parent_id='" + me.formData.customer_id + "'",
|
}
|
Server.call("root/data/getEntitySet", param_, function(result) {
|
if (result && result.data && result.data.entityset) {
|
var formData_acc_position = result.data.entityset;
|
var accountPositions_options_ = [];
|
var accountPositions_obj_ = {};
|
formData_acc_position.map(ap=>{
|
var e_ = ap.md_position_hierarchy__employee_name
|
var employee_ = {
|
code: e_,
|
value: e_
|
}
|
accountPositions_obj_[e_] = clone(ap);
|
accountPositions_options_.push(employee_);
|
})
|
me.accountPositions_options = clone(accountPositions_options_);
|
me.accountPositions_obj = clone(accountPositions_obj_);
|
|
var formFields_ = clone(me.formFields)
|
formFields_.map(f=>{
|
if(f.field == "position_name") {
|
f.options = accountPositions_options_
|
}
|
})
|
me.formFields = clone(formFields_)
|
}
|
});
|
}
|
|
}
|
},
|
select: {
|
onchange: function(obj,refreshCallback) {//下拉展开事件
|
var value = obj.selectoption.value
|
var region_id = ""
|
var region_name = ""
|
var position_id = ""
|
var position_name = ""
|
|
var a_position_ = clone(me.accountPositions_obj[value]);
|
position_id = a_position_.position_id;
|
position_name = a_position_.md_position_hierarchy__employee_name;
|
var position_list = a_position_.md_position_hierarchy__position_path.split(">>");
|
position_list.map(p=>{
|
if (p.indexOf('大区经理') != -1) {
|
var region_position = p.split("-");
|
region_name = region_position[0]
|
}
|
else if (p.indexOf('高级地区经理') != -1) {
|
var region_position = p.split("-");
|
region_name = region_position[0]
|
}
|
})
|
|
var formData_ = clone(me.formData);
|
formData_.region_id = region_id;
|
formData_.region_name = region_name;
|
formData_.position_id = position_id;
|
formData_.position_name = position_name;
|
|
me.formData = clone(formData_);
|
|
},
|
}
|
},
|
|
customer_name: {
|
popup: {
|
onclick: function(obj) {//弹窗点击事件
|
//打开开户库弹窗
|
me.openAccount("add", obj, function(popupobj){
|
let formData_ = clone(me.formData);
|
formData_.company_id = popupobj.row.company_id;
|
// formData_.company_name = popupobj.row.company_name;
|
// formData_.company_name = clone(me.options_company_name_map[popupobj.row.company_id])
|
formData_.bu_id = popupobj.row.bu_id;
|
// formData_.bu_name = popupobj.row.bu_name;
|
|
formData_.org_id = popupobj.row.org_id;
|
formData_.customer_id = popupobj.row.id;
|
formData_.customer_code = popupobj.row.code;
|
formData_.customer_name = popupobj.row.account_name;
|
formData_.settlement = popupobj.row.settlement;
|
formData_.shipto_address_id = "";
|
formData_.shipto_address = "";
|
formData_.shipto_contact = "";
|
formData_.shipto_phone = "";
|
|
formData_.region_id = "";
|
formData_.region_name = "";
|
formData_.position_id = "";
|
formData_.position_name = "";
|
|
formData_.platform_org_id = popupobj.row.platform_org_id;
|
formData_.platform_customer_id = popupobj.row.platform_account_id;
|
formData_.platform_customer_code = popupobj.row.platform_account_code;
|
formData_.platform_customer_name = popupobj.row.platform_account_name;
|
|
me.formData = clone(formData_);
|
|
me.accountPositions_options = [];
|
me.accountPositions_obj = {};
|
});
|
}
|
}
|
},
|
shipto_address_id: { //标识1:使收货地址对应经销商
|
buttonarray: {
|
onclick: function(obj) {
|
var data_ = {};
|
var url_ = "module/md/page/customer/page/customer_shipto.html";
|
var totab_ = true;
|
var filter_ = "";
|
if (!me.iscommit) {
|
if (!me.formData.org_id) {
|
Root.message({
|
type: 'warning',
|
message: '请先选择客商名称'
|
});
|
return
|
}
|
url_ = "module/md/page/customer/page/popup/popup_customer_shipto.html";
|
totab_ = false;
|
filter_ = " parent_id='" + me.formData.org_id + "'"
|
}
|
var config = {
|
totab: totab_, //true: 以Tab导航的方式打开
|
width: "850px",
|
height: "520px",
|
icon: "icon-product",
|
text: "收货地址列表",
|
id: "popup_customer_shipto",//totab: true时需设置,用于判断是否已打开此页面
|
url: url_,
|
data: data_,
|
delta: {org_id: me.formData.org_id},
|
// filter: "org_id='"+ me.selectedrow.org_id + "' and bu_id='" + me.selectedrow.bu_id + "'",
|
filter: filter_,
|
callback: function(popupobj, popupcallback) {
|
callback(popupobj);
|
if (popupcallback) {
|
popupcallback();
|
}
|
}
|
}
|
me.doPopupByPublic(config);
|
},
|
},
|
visible: {
|
onchange: function(obj,row,callback) {//下拉展开事件
|
let param_ = {
|
dataname: "md_org_shipto",//获取经销商对应收货地址
|
filter:"parent_id='" + row.org_id + "' and md_org_shipto.state_code='Open'",
|
}
|
Server.call("root/data/getEntitySet", param_, function(result) {
|
if (result && result.data && result.data.entityset) {
|
var options_ = []
|
result.data.entityset.map(address=>{
|
var option_ = {
|
code: address.id,
|
value: address.address,
|
contact_name: address.contact_name,
|
contact_phone: address.contact_phone
|
}
|
options_.push(option_)
|
})
|
var formFields_ = clone(me.formFields)
|
formFields_.map(f=>{
|
if(f.field == "shipto_address_id") {
|
f.options = options_
|
}
|
})
|
me.formFields = clone(formFields_)
|
|
}
|
});
|
}
|
},
|
select: {
|
onchange: function(obj,refreshCallback) {//下拉展开事件
|
obj.data.shipto_contact = obj.selectoption.contact_name
|
obj.data.shipto_phone = obj.selectoption.contact_phone
|
|
// obj.data.shipto_address_id = obj.selectoption.code
|
obj.data.shipto_address = obj.selectoption.value
|
refreshCallback();
|
},
|
},
|
},
|
|
attachment_id: {
|
buttonarray: {
|
onclick: function(obj) {
|
var filenamefield = obj.obj.field;
|
// var fileidfield = "contract_attachment_id";
|
var fileidfield = "";
|
if(obj.buttonobj && obj.buttonobj.code == "showfilebyfile"){
|
me.showFileImgByFileId_n(filenamefield, obj.buttonobj.fileobj, obj.formdata);
|
}else if (obj.buttonobj && obj.buttonobj.code == "uploadlist"){
|
me.onPopupByUploadFile_n(filenamefield, fileidfield, "so_channel", obj.formdata);
|
}else if (obj.buttonobj && obj.buttonobj.code == "delfilebyfile"){
|
me.deleteByFileId_n(filenamefield, obj.buttonobj.fileobj, obj.formdata);
|
}
|
|
},
|
|
}
|
},
|
};
|
|
//表格字段事件设置
|
this.tablefieldClick = {
|
qty: {
|
input: {
|
onchange: function(obj) {//输入更改事件
|
me.sumQTY(obj);//表单qty_total值改变
|
}
|
},
|
},
|
|
};
|
},
|
// 设置表格工具栏按键事件
|
tableButtonClick() {
|
var me = this;
|
var tablebuttonclick = [];
|
tablebuttonclick = [
|
{
|
name:"新增明细",
|
isbuttonshow: me.isedit, type: "primary",
|
code: "addDetail", isselected: false, classname:"",
|
|
onclick: function(obj) {
|
console.log(obj)
|
if(!me.formData.customer_id){ // || !me.formData.to_warehouse_name
|
Root.message({
|
type: 'warning',
|
message: '请先选择客商名称'
|
});
|
return;
|
}
|
|
me.openProductList("add", "", function(popupobj) { // qty买赠, amt折扣
|
// me.getProductPrice();
|
var list_h = clone(popupobj.list); //购物车返回一个数组
|
var tableData_ = clone(me.tableData);
|
list_h.map(h=>{
|
var h_ = {
|
product_name: h.product_name,
|
product_code: h.product_code,
|
product_id: h.product_id,
|
sku_id: h.id,
|
sku_nc_id: h.nc_id,
|
spec: h.spec,
|
unit: h.unit,
|
record_id: "",
|
record_no: "",
|
record_name: "",
|
qty: 1, // 订单数量
|
}
|
tableData_.unshift(clone(h_)); //unshift只能一个一个数组放
|
})
|
|
me.tableData = clone(tableData_);
|
me.sumQTY()
|
});
|
}
|
},
|
{
|
isbuttonshow: me.isedit, type: "danger",
|
code: "delete", isselected: true, classname:"",
|
disabled: function(selectRowList) {
|
var bo_ = true ;
|
if (selectRowList[0]) {
|
bo_ = false
|
}
|
return bo_;
|
},
|
onclick: function(obj) {
|
var row = obj.selectedList[0];
|
var txt = clone(row.product_name + row.spec);
|
me.deleteDataById(row.id, "wm_transfer_detail", "【" + txt + "】", function(){
|
me.tableData.splice(obj.selectRowIndex, 1);
|
})
|
}
|
}
|
]
|
me.tablebuttonClick = tablebuttonclick
|
},
|
|
openAccount(sceneCode, obj, callback) {
|
var me = this;
|
var data_ = {};
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "800px",
|
height: "520px",
|
icon: "icon-product",
|
text: "经销商选择",
|
id: "popup_account",//totab: true时需设置,用于判断是否已打开此页面
|
url: "module/md/page/popup/page/popup_account.html",
|
data: data_,
|
delta: {},
|
// filter: "org_id='"+ me.selectedrow.org_id + "' and bu_id='" + me.selectedrow.bu_id + "'",
|
filter: "md_org_account.state_code='Open' and actor_code='Second'",
|
sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(popupobj, popupcallback) {
|
callback(popupobj);
|
if (popupcallback) {
|
popupcallback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
|
openProductList(sceneCode, dataname, callback) {
|
var me = this;
|
var data_ = {};
|
var text_ = "产品";
|
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "1100px",
|
height: "520px",
|
icon: "icon-product",
|
text: text_ + "选择",
|
id: "popup_rebatedetail",//totab: true时需设置,用于判断是否已打开此页面
|
url: "module/md/page/popup/page/popup_product_sku.html",
|
dataname: "",
|
data: data_,
|
delta: {},
|
filter: "EXISTS ( SELECT * FROM md_bu_product where md_prod_sku.product_id = product_id and bu_id='" + me.formData.bu_id + "')",
|
sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(popupobj, popupcallback) {
|
callback(popupobj)
|
|
if (popupcallback) {
|
popupcallback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
|
sumQTY(obj) {
|
var me = this;
|
var formData_ = clone(me.formData)
|
var qty_total_ = 0; //订单总数量
|
|
me.tableData.map(row=>{
|
qty_total_ = (qty_total_ - 0) + (row.qty - 0)
|
});
|
formData_.qty_total = qty_total_
|
me.formData = clone(formData_)
|
},
|
|
deleteDataById(id, dataname, confirm_txt, callback) {
|
var me = this;
|
var formData_ = clone(me.formData);
|
Root.confirm('确定删除该' + confirm_txt + '吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
if (id) {
|
let param = {
|
dataname: dataname,
|
id: id
|
}
|
Server.call("root/data/deleteEntity", param, function(result) {
|
console.log(result);
|
if (result && result.data) {
|
callback();
|
}
|
});
|
}
|
else {
|
callback();
|
}
|
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
|
showFileImgByFileId_n(filenamefield, fileobj, objformdata){
|
let me = this;
|
var formData_ = clone(me.formData);
|
var file_id = fileobj.id
|
var file_name = fileobj.file_name
|
var dataname_ = this.dataname
|
|
this.zzimg = {};
|
this.zzimgList = [];
|
this.file_txt = false;
|
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 == ".jpeg" || suffix == ".pdf") {
|
var row = {
|
fileid: fileid,
|
dataname: dataname_,
|
filename: fileName
|
}
|
var config = {
|
totab: false,
|
width: "1200px",
|
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, dataname_);
|
}
|
}
|
},
|
onPopupByUploadFile_n(filenamefield, fileidfield, dataname, objformdata) {
|
var me = this;
|
var analysistype_ = "";
|
var sender_id_ = ""; // 业务数据id;
|
if (objformdata.id) {
|
sender_id_ = objformdata.id;
|
}
|
|
var delta_ = {filetypelist: [".png", ".jpg", ".jpeg",".pdf"]}; //, ".pdf"
|
var config = {
|
totab: false,
|
width: "500px",
|
icon: "icon-product",
|
text: "附件上传",
|
id: "popupByUploadFile",
|
url: "module/tool/page/popup_uploadFile.html",
|
data: {
|
dataName: dataname,
|
fileidfieldName: fileidfield,
|
id: sender_id_,
|
fileNamefieldName: filenamefield
|
},
|
delta: delta_,
|
callback: function(obj, callback) {
|
var f_ = {
|
id: obj.row[0].id,
|
file_name: decodeURI(obj.row[0].name)
|
}
|
if (!objformdata[filenamefield]) {
|
objformdata[filenamefield] = []
|
}
|
me.$message({
|
showClose: true,
|
message: '上传成功!',
|
type: 'success'
|
});
|
|
objformdata[filenamefield].push(f_);
|
if (!objformdata.id) {
|
objformdata.id = obj.row[0].sender_id;
|
}
|
|
if (callback) {
|
callback();
|
}
|
}
|
};
|
this.doPopupByPublic(config);
|
},
|
|
deleteByFileId_n(filenamefield, fileobj, objformdata){
|
var me = this;
|
var formData_ = clone(me.formData);
|
Root.confirm('确定删除附件【' + fileobj.file_name + '】吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
if (fileobj.id) {
|
let param = {
|
dataname: "so_channel_file",
|
id: fileobj.id
|
}
|
|
Server.call("root/data/deleteEntity", param, function(result) {
|
console.log(result);
|
if (result && result.data) {
|
objformdata[filenamefield].remove(fileobj);
|
// me.formData[filenamefield].remove(fileobj);
|
|
// me.formData = formData_;
|
Root.message({
|
type: 'success',
|
message: '删除成功!'
|
});
|
}
|
});
|
}
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
|
submitRowTable() {
|
var me = this;
|
var bo_ = true;
|
var batch_no_ = true;
|
|
var bo_ = this.$refs.form1.checkForm();
|
if (!bo_) {
|
bo_ = false;
|
Root.message({
|
type: 'error',
|
message: '请填写必填项'
|
});
|
return
|
}
|
|
if (me.tableData.length == 0) {
|
bo_ = false;
|
Root.message({
|
type: 'warning',
|
message: '请先添加明细数据'
|
});
|
return
|
}
|
|
me.tableData.map(r=>{
|
if (r.qty == null || r.qty === "" || isNaN(r.qty) || r.qty == 0) {
|
bo_ = false;
|
}
|
})
|
if (!bo_) {
|
Root.message({
|
type: 'error',
|
message: '明细中存在数量为空的数据'
|
});
|
return
|
}
|
|
this.iscommit = true;
|
this.saveRowTable();
|
},
|
|
saveRowTable() {
|
var me = this;
|
var operator_ = "saveEntity";//保存
|
if(me.iscommit) {
|
operator_ = "commit";// 提交
|
}
|
var entity_ = clone(this.formData);
|
var entity = {};
|
for (var r in entity_) {
|
if (entity_[r] || entity_[r] == "" || entity_[r] == false || entity_[r] == 0) {
|
entity[r] = entity_[r];
|
}
|
}
|
|
var tableData_ = [];
|
this.tableData.map(r=>{
|
var row_ = {};
|
for (var k in r) {
|
if (r[k]) {
|
row_[k] = r[k];
|
}
|
}
|
tableData_.push(row_);
|
})
|
|
if (tableData_.length == 0) {
|
Root.message({
|
type: 'warning',
|
message: '请先添加明细数据'
|
});
|
return
|
}
|
// if(me.iscommit) {
|
// entity.state_code = "Open"
|
// entity.state_name = "生效"
|
// }
|
let param = {
|
dataname: this.dataname,
|
data: {},
|
}
|
param.data[this.dataname] = entity;
|
param.data[this.table_dataname] = tableData_;
|
|
if (this.formData.id) {
|
param.id = this.formData.id
|
}
|
Server.call("root/data/" + operator_, param, function(result) {
|
console.log(result);
|
if (result.success) {
|
if(me.iscommit){
|
me.iscommit = false;
|
Root.message({
|
type: 'success',
|
message: '提交成功'
|
});
|
me.saveAfter();
|
}
|
else {
|
Root.message({
|
type: 'success',
|
message: '保存成功'
|
});
|
me.saveAfter();
|
}
|
}
|
}, function(errorresult) {
|
console.log("错误信息", errorresult);
|
|
if (errorresult.messages && errorresult.messages.count && errorresult.messages.count.error) {
|
me.iscommit = false;
|
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 {
|
if (me.iscommit) {
|
Root.message({
|
type: 'error',
|
message: '提交失败'
|
});
|
me.iscommit = false;
|
}
|
else {
|
Root.message({
|
type: 'error',
|
message: '保存失败'
|
});
|
}
|
|
}
|
});
|
},
|
|
// 通过或拒绝
|
onShowApproval(passOrRefuse) {
|
this.approveremark = "";
|
this.reasonvisible = true;//审批备注填写弹窗
|
this.passOrRefuse = passOrRefuse;// commit下一个状态;approve通过;gohome;//拒绝 goback;//回退
|
},
|
saveReason() {
|
this.loading_pass = true;
|
if(this.passOrRefuse == "commit" || this.passOrRefuse == "approve"){
|
this.doApproval();
|
}
|
else{
|
if(this.approveremark != ""){
|
this.doApproval();
|
}
|
else{
|
Root.message({
|
type: 'warning',
|
message: '请填写原因'
|
});
|
this.loading_pass = false;
|
}
|
}
|
},
|
doApproval(bo) {
|
var me = this;
|
this.getMachine(function(next_step, up_step) { //
|
me.doRunApproval(next_step, up_step);
|
});
|
},
|
|
getMachine(callback) {
|
var me = this;
|
let param = {
|
dataname: me.dataname,
|
}
|
Server.call("root/state/getMachine", param, function(result) {
|
var next_step = {}; // 向下流程
|
var up_step = {}; // 向上流程
|
|
if (result && result.machine && result.machine.detail) {
|
result.machine.detail.map(md=>{
|
next_step[md.from_code] = md.to_code;
|
up_step[md.to_code] = md.from_code;
|
})
|
|
callback(next_step, up_step);
|
}
|
})
|
},
|
|
doRunApproval(next_step, up_step) {
|
var me = this;
|
this.passOrRefuse;//首次开户-通过
|
// commit // 下一个状态
|
// approve // 通过
|
// gohome // 拒绝
|
// goback // 回退
|
|
var to_state_ = "";
|
if (this.passOrRefuse == "commit") {
|
to_state_ = next_step[this.formData.state_code];
|
}
|
else if (this.passOrRefuse == "approve") {
|
|
}
|
else if (this.passOrRefuse == "gohome") {
|
// to_state_ = up_step[this.formData.state_code];
|
}
|
else if (this.passOrRefuse == "goback") {
|
to_state_ = up_step[this.formData.state_code];
|
}
|
|
let param = {
|
dataname: me.dataname,
|
id: me.formData.id,
|
to_state: to_state_,
|
remark: this.approveremark
|
}
|
//
|
// return
|
Server.call("root/data/" + this.passOrRefuse, param, function(result) {
|
me.loading_pass = false;
|
console.log(result);
|
if (me.passOrRefuse == "commit" || me.passOrRefuse == "approve") {
|
Root.message({
|
type: 'success',
|
message: '审批成功'
|
});
|
}
|
else if (me.passOrRefuse == "goback") {
|
Root.message({
|
type: 'success',
|
message: '已退回'
|
});
|
}
|
else if (me.passOrRefuse == "gohome") {
|
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>
|
|
</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: dheight + '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>
|
|
<div class="h_dialog__body">
|
<h-table
|
v-if="isRefresh && tableFields.length"
|
ref="table1"
|
:table-fields="tableFields"
|
:table-data="tableData"
|
:is-within-edit-table-data="isedit || isrefuseedit"
|
:is-pagination="false"
|
:table-field-click="tablefieldClick"
|
:table-buttons-click="tablebuttonClick"
|
:is-selection="false"
|
:isfilterfield="false"
|
:isdraggableorder="false"
|
:is-highlight-row="true"
|
:show-summary="true"
|
|
v-on:get-data="getData"
|
>
|
</h-table>
|
</div>
|
<el-dialog title="填写原因" :visible.sync="reasonvisible" height="50%">
|
<el-input
|
type="textarea"
|
:autosize="{ minRows: 2, maxRows: 10}"
|
placeholder="请输入原因"
|
v-model="approveremark">
|
</el-input>
|
|
<div slot="footer" class="dialog-footer" >
|
<el-button type="primary" :loading="loading_pass" @click="saveReason">确 定</el-button>
|
<el-button type="default" @click="reasonvisible = false">取 消</el-button>
|
</div>
|
</el-dialog>
|
|
</div>
|
</div>
|
<div class="el-dialog__footer">
|
<el-button-group style="margin-right: 80px;" >
|
<el-button size="small" v-if="isapproval" type="warning" plain @click="onShowApproval('gohome')">退回到申请人</el-button>
|
<el-button size="small" v-if="isapproval" type="danger" plain @click="onShowApproval('goback')">退回到上一步</el-button>
|
</el-button-group>
|
<el-button size="small" type="default" @click="closeDialog">取 消</el-button>
|
<el-button size="small" v-if="isedit || isrefuseedit" type="primary" @click="saveRowTable":icon="buttonsconfig.save.icon">{{buttonsconfig.save.name}}</el-button>
|
<el-button size="small" v-if="isedit" type="success" @click="submitRowTable":icon="buttonsconfig.submit.icon">{{buttonsconfig.submit.name}}</el-button>
|
<el-button size="small" v-if="isapproval" type="success" @click="onShowApproval('approve')">通 过</el-button>
|
<!-- <el-button size="small" v-if="isapproval" type="primary" @click="">转 办</el-button> -->
|
<!-- <el-button size="small" v-if="isapproval" type="success" @click="">退 回</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>
|
</html>
|