<!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: "md_org_account_change",
|
dataname_account: "md_org_account",
|
table_dataname: "md_org_account_position",
|
|
title: "经销商开户信息",
|
// 预加载设置
|
dataRequest: [
|
{
|
name: "md_org_master", // 公司下拉项
|
dataname: "md_org_master",
|
// url: "root/data/newEntity",
|
// paramsobj: {dataname: "md_org_data"},
|
isnotoption: false, //true:不是选项
|
code:"id",//是下拉选项时设置
|
label:"short_name",//是下拉选项时设置
|
filter: "",
|
orderby: "name"
|
},
|
{
|
name: "md_bu", // BU下拉项
|
dataname: "md_bu_org",
|
// url: "root/data/newEntity",
|
// paramsobj: {dataname: "md_org_data"},
|
isnotoption: false, //true:不是选项
|
code:"bu_id",//是下拉选项时设置
|
label:"bu_name",//是下拉选项时设置
|
filter: "state_code='Open'",
|
orderby: ""
|
},
|
// {
|
// name: "md_bu_product", // 产品下拉项
|
// dataname: "md_bu_product",
|
// isnotoption: false, //true:不是选项
|
// code:"id",//是下拉选项时设置
|
// label:"product_name",//是下拉选项时设置
|
// filter: "",
|
// orderby: "product_name"
|
// },
|
{
|
name: "md_geo_province", // 省份下拉项
|
dataname: "md_geo_province",
|
isnotoption: false, //true:不是选项
|
code:"name",//是下拉选项时设置
|
label:"name",//是下拉选项时设置
|
filter: "",
|
orderby: "name"
|
},
|
|
{
|
name: "meta_account_position_list", // 业务负责人字段
|
dataname: "md_org_account_position",
|
url: "root/data/getEntitySet",
|
paramsobj: {dataname: "md_org_account_position", attachMeta: true, filter: "1<>1"},
|
isnotoption: true, //true:不是选项
|
filter: "1<>1",
|
},
|
],
|
options_md_org_master: [],
|
isExistsAccount: false,
|
exists_account: {}, //
|
md_bu_org_obj: {},
|
options_md_bu: [],
|
options_md_geo_province: [],
|
old_md_org_account_product_obj: {},
|
old_md_org_account_province_obj: {},
|
productobj_map: {},
|
md_bu_product_bu_obj: {},
|
options_tree_product: [],
|
options_province: [],
|
options_tree_province: [],
|
|
meta_account_position_list: [],
|
|
formData_change: {},
|
|
formAttr: {
|
istitle: false,
|
title: "表单名称",
|
columnnumber: 4,
|
labelwidth: "100px",
|
labelposition: "left",//"left",// right//top
|
size: "mini",
|
border: "10px solid #c6c6c600",
|
disabled: true
|
},
|
formAttr_change: {
|
istitle: false,
|
title: "表单名称",
|
columnnumber: 4,
|
labelwidth: "100px",
|
labelposition: "left",//"left",// right//top
|
size: "mini",
|
border: "10px solid #c6c6c600",
|
disabled: true
|
},
|
tableAttr: {
|
istitle: true,
|
title: "我方业务负责人",
|
isborder: true, // 显示表格的网格线
|
toolbarobj: {}
|
},
|
accountnccdata: {}, // NCC的数据(含经销商和公司信息)
|
orgdata: {},
|
formFields: [],
|
newformData: {
|
//id: uuid_short(),
|
// code: createCode("BA"),
|
// create_time: createDatetime(),
|
credit_amt: 0,
|
state_code: "Input",
|
state_name: "草稿",
|
},
|
newchangeformData: {
|
state_code: "Input",
|
state_name: "草稿",
|
},
|
formData: {},
|
|
isRefresh: true,
|
tableFields: [],
|
newTableData: {
|
md_position__name:"",
|
position_id:"",
|
is_editable: false,
|
is_share: false,
|
rate_share: "",
|
},
|
tableData: [],
|
tablebuttonclick: [],
|
|
//按键权限设置
|
table_isedit: false, // 表格可编辑
|
isedit: false,//提交前编辑,保存/提交
|
isrefuseedit: false,//拒绝后编辑,保存/再次提交
|
isapproval: false,//审批,同意/拒绝/转办/退回
|
isChange: false, // 是变更申请
|
iscommit: false,//提交标记
|
|
//弹窗参数
|
popupParames: {},
|
//字段设置
|
tablefieldClick: {},
|
formfieldClick: {},
|
|
dheight: null, // 主体高度
|
|
// 审批
|
reasonvisible: false, // 审批备注填写弹窗
|
approveremark: "", // 审批备注
|
passOrRefuse: false, // 通过或拒绝
|
loading_pass: false,
|
change_type: "",
|
isChangeEdit: false,
|
|
formFields_account: [],
|
formData_account: {},
|
|
account_entity: {},
|
account_metas: {},
|
|
},
|
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.formData.type_code == "close") {
|
this.dataname="md_org_account_close"
|
this.change_type = "close"
|
}
|
else {
|
this.dataname="md_org_account_change"
|
this.change_type = "change"
|
}
|
// this.formData_change = clone(this.popupParames.data);
|
}
|
// if (this.popupParames.delta && this.popupParames.delta.type) {
|
// this.change_type = this.popupParames.delta.type; // close change
|
// }
|
|
if (this.change_type == "close") { // 关户
|
var accountmetas = {
|
name: "accountmetas", // 业务负责人字段
|
dataname: "md_org_account",
|
url: "root/data/getEntity",
|
paramsobj: {dataname: "md_org_account", id: this.formData.host_id, attachMeta: true},
|
isnotoption: true, //true:不是选项
|
filter: "",
|
}
|
this.dataRequest.push(accountmetas);
|
|
if (this.popupParames.sceneCode) {
|
if (this.popupParames.sceneCode == "browse") {//只读
|
// this.isChangeEdit = false;
|
|
// this.formAttr_change.disabled = true;
|
// this.formAttr.disabled = true;
|
// this.table_isedit = false;
|
}
|
else if (this.popupParames.sceneCode == "edit") {//编辑
|
this.isChangeEdit = true;
|
this.formAttr_change.disabled = false;
|
// this.formAttr.disabled = true;
|
// this.table_isedit = false;
|
this.tablebuttonClick_ywlxr();
|
}
|
else if (this.popupParames.sceneCode == "approval") {//审批
|
this.isapproval = true;
|
// this.isChangeEdit = false;
|
// this.formAttr_change.disabled = true;
|
// this.formAttr.disabled = true;
|
// this.table_isedit = false;
|
}
|
}
|
}
|
else if (this.change_type == "change") { //
|
if (this.popupParames.sceneCode) {
|
if (this.popupParames.sceneCode == "browse") {//只读
|
// this.isChangeEdit = false;
|
|
// this.formAttr_change.disabled = true;
|
// this.formAttr.disabled = true;
|
// this.table_isedit = false;
|
}
|
else if (this.popupParames.sceneCode == "edit") {//编辑
|
this.isChangeEdit = true;
|
this.formAttr_change.disabled = false;
|
this.formAttr.disabled = false;
|
this.table_isedit = true;
|
this.tablebuttonClick_ywlxr();
|
}
|
else if (this.popupParames.sceneCode == "approval") {//审批
|
this.isapproval = true;
|
// this.isChangeEdit = false;
|
// this.formAttr_change.disabled = true;
|
// this.formAttr.disabled = true;
|
// this.table_isedit = false;
|
}
|
}
|
}
|
},
|
|
mounted() {
|
var me = this;
|
var title_h = 0;
|
if (me.popupParames.totab){
|
title_h = 42;
|
}
|
me.dheight = document.documentElement.clientHeight - 50 - title_h;
|
|
//预加载数据
|
if (this.dataRequest && this.dataRequest.length) {
|
var result = {};
|
this.loadRequestData(this.dataRequest, result, function(data) {
|
me.dataRequestObj = data;
|
|
// 获取变更的字段
|
// if (me.dataRequestObj.meta_account_change) {
|
// var meta_account_change_ = me.dataRequestObj.meta_account_change.meta.md_org_account_change.fields;
|
// meta_account_change_.map(f=>{
|
// f.isshow = "T";
|
// f.group_name = "变更信息"
|
// if (me.popupParames.sceneCode == "close" && f.field == "type_code") { //当为关户时,变更类型不可更改
|
// f.readonly = true
|
// f.optionsgroup = "account_type_close"
|
// }
|
// else if (f.field == "type_code") { //变更类型的下拉控制
|
// console.log(f.optionsgroup);
|
// f.optionsgroup = "account_type"
|
// }
|
// })
|
|
// me.formFields = meta_account_change_;
|
// }
|
|
// 原account数据
|
if (me.dataRequestObj.accountmetas) {
|
me.account_metas = me.dataRequestObj.accountmetas.meta;
|
me.account_entity = me.dataRequestObj.accountmetas.data;
|
|
}
|
// 业务负责人字段
|
if (me.dataRequestObj.meta_account_position_list) {
|
me.meta_account_position_list = me.dataRequestObj.meta_account_position_list.meta.md_org_account_position.fields;
|
}
|
|
// 公司
|
if (me.dataRequestObj.md_org_master) {
|
me.options_md_org_master = me.dataRequestObj.md_org_master;
|
}
|
|
// BU
|
if (me.dataRequestObj.md_bu) {
|
var md_bu_org_obj_ = {};
|
var options_md_bu = [];
|
var md_bu_list = clone(me.dataRequestObj.md_bu);
|
md_bu_list.map(bl=>{
|
if (!md_bu_org_obj_[bl.company_id]) {
|
md_bu_org_obj_[bl.company_id] = [];
|
}
|
md_bu_org_obj_[bl.company_id].push(bl);
|
})
|
me.md_bu_org_obj = clone(md_bu_org_obj_)
|
}
|
// 省份
|
if (me.dataRequestObj.md_geo_province) {
|
var options_tree_province_ = listTOListGroup(me.dataRequestObj.md_geo_province, "area", "value");
|
me.options_province = clone(me.dataRequestObj.md_geo_province);
|
}
|
me.initData();
|
|
// 以服务的方式调用的 Loading 需要异步关闭
|
me.$nextTick(() => {
|
hideLoading();
|
});
|
});
|
}
|
else {
|
this.initData();
|
// 以服务的方式调用的 Loading 需要异步关闭
|
me.$nextTick(() => {
|
hideLoading();
|
});
|
}
|
},
|
|
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();
|
}
|
},
|
|
// 事件
|
tablebuttonClick_ywlxr() {
|
var me = this;
|
var tablebuttonClick = [];
|
tablebuttonClick = [
|
{
|
// name: "新增", // type: "primary", // icon: "el-icon-edit",
|
isbuttonshow: this.table_isedit,
|
code: "add", isselected: false, classname: "",
|
onclick: function(obj) {
|
// popup_position
|
// 获取授权产品
|
if (!me.formData.bu_id) {
|
Root.message({
|
type: 'warning',
|
message: '请先选择BU'
|
});
|
return;
|
}
|
else {
|
me.openPositionTree("add", function(popupobj){
|
var table_row = clone(me.newTableData);
|
table_row.position_id = popupobj.row.id;
|
table_row.md_position_hierarchy__position_path = popupobj.row.md_position_hierarchy__position_path;
|
table_row.md_position_hierarchy__employee_name = popupobj.row.md_position_hierarchy__employee_name;
|
|
me.addTableData(table_row)
|
});
|
}
|
|
}
|
},
|
{
|
// name: "删除", , // icon: "el-icon-edit",
|
isbuttonshow: this.table_isedit, type: "danger",
|
code: "delete", isselected: true, classname: "",
|
onclick: function(obj) {
|
var row = obj.selectedList[0];
|
var txt = clone(row.md_position_hierarchy__position_path) + clone(row.md_position_hierarchy__employee_name);
|
me.deleteDataById(row.id, me.table_dataname, "【" + txt + "】", function(){
|
me.tableData.splice(obj.selectRowIndex, 1);
|
|
var tableData_ = clone(me.tableData);
|
if (row.is_main_approver) {
|
if (tableData_.length) {
|
tableData_[0].is_main_approver = true;
|
me.tableData = clone(tableData_);
|
}
|
}
|
})
|
// me.tableData.remove(obj.selectedList[0])
|
// obj.selectedList
|
// me.closeData('browse', obj.selectedList[0]);
|
// me.closeData();
|
|
|
}
|
},
|
]
|
|
this.tablebuttonclick = tablebuttonClick;
|
},
|
|
initData() {
|
let me = this
|
var id_ = null;
|
if (this.formData.id) {
|
id_ = this.formData.id;
|
}
|
this.getRowDataById(id_, function(result) {//查询后的回调,用于获取字段的
|
console.log(result);
|
var formData_ = {};
|
var formData_account_ = {};
|
var tableData_account_position_ = [];
|
|
if (me.change_type == "change") {
|
formData_ = clone(result.data["md_org_account_change"]);
|
formData_account_ = clone(result.host["md_org_account"] ? result.host["md_org_account"] : {});
|
tableData_account_position_ = clone(result.host["md_org_account_position"] ? result.host["md_org_account_position"] : []);
|
}
|
else if (me.change_type == "close"){ // 关户
|
formData_ = clone(result.data["md_org_account_close"]);
|
formData_account_ = clone(me.account_entity["md_org_account"] ? me.account_entity["md_org_account"] : {});
|
tableData_account_position_ = clone(me.account_entity["md_org_account_position"] ? me.account_entity["md_org_account_position"] : []);
|
}
|
|
if (result.meta) {
|
var metas_change = [];
|
var metas_account = [];
|
var metas_account_position = [];
|
|
if (me.change_type == "change") {
|
metas_change = clone(result.meta["md_org_account_change"].fields);
|
metas_account = clone(result.host_meta["md_org_account"].fields);
|
metas_account_position = clone(result.host_meta["md_org_account_position"].fields);
|
}
|
else if (me.change_type == "close"){ // 关户
|
metas_change = clone(result.meta["md_org_account_close"].fields);
|
metas_account = clone(me.account_metas["md_org_account"].fields);
|
metas_account_position = clone(me.account_metas["md_org_account_position"].fields);
|
}
|
|
var formFields_ = [];
|
var formFields_account_ = [];
|
var tableFields_ = [];
|
|
metas_change.map(f=>{
|
f.isshow = "T";
|
if (me.change_type == "close" && f.field == "type_code") { //当为关户时,变更类型不可更改
|
f.readonly = true
|
f.optionsgroup = "account_type_close"
|
}
|
else if (f.field == "type_code") { //变更类型的下拉控制
|
f.optionsgroup = "account_type"
|
}
|
|
if(f.field == "termination_date") {//终止日期范围设置
|
f.pickerOptions = {
|
disabledDate: function(time) {
|
var currentDate = new Date();
|
currentDate.setDate(currentDate.getDate() - 1);
|
return time < currentDate
|
},
|
cellClassName: function(date) {
|
return "aaaa";
|
}
|
}
|
}
|
|
formFields_.push(clone(f));
|
})
|
|
metas_account.map(f=>{
|
f.isshow = "T";
|
if (f.field == "company_id" || f.field == "bu_id") {
|
// f.options = me.options_md_org_master;
|
f.readonly = true
|
}
|
else if (f.field == "actor_code") {
|
f.readonly = true
|
if (formData_account_.md_org__source && formData_account_.md_org__source == "NCC") {
|
f.optionsgroup = "actor_ncc";
|
}
|
else if (formData_account_.md_org__source && formData_account_.md_org__source == "DMS") {
|
f.optionsgroup = "actor_dms";
|
}
|
}
|
|
else if (f.field == "authorize_province") {
|
f.options = me.options_province;
|
f.isfilterable = true
|
}
|
else if (f.field == "company_name" || f.field == "account_name" || f.field == "bu_name") {
|
f.inputtype = "span";
|
}
|
|
formFields_account_.push(clone(f));
|
})
|
|
metas_account_position.map(f=>{
|
f.isshow = "T";
|
if (f.field == "md_org_account__account_name"
|
|| f.field == "creator_name"
|
|| f.field == "create_time"
|
|| f.field == "update_time"
|
|| f.field == "md_org_account__company_name"
|
|| f.field == "md_org_account__bu_name") {
|
f.isshow = "F";
|
}
|
|
tableFields_.push(clone(f));
|
})
|
|
me.formFields = clone(formFields_);
|
me.formFields_account = clone(formFields_account_);
|
me.tableFields = clone(tableFields_);
|
|
//字段数组转字段obj,目的为了筛选时获取字段属性
|
me.fieldsToFieldsObj();
|
|
//设置字段事件
|
me.tableFieldClick();
|
}
|
|
// var formData_ = clone(result.data["md_org_account_change"]);
|
// var formData_account_ = clone(result.host["md_org_account"]);
|
// var tableData_account_position_ = clone(result.host["md_org_account_position"]);
|
|
// 如果选择了公司, 则bu的下拉项根据公司来
|
if (formData_account_.company_id) {
|
var formFields_account_ = clone(me.formFields_account);
|
formFields_account_.map(f=>{
|
if (f.field == "bu_id") {
|
if (me.md_bu_org_obj[formData_account_.company_id] && me.md_bu_org_obj[formData_account_.company_id].length) {
|
f.options = clone(me.md_bu_org_obj[formData_account_.company_id])
|
}
|
}
|
})
|
|
me.formFields_account = clone(formFields_account_);
|
}
|
|
me.formData = getDataByFields(formData_, me.formFields);
|
|
me.formData_account = formData_account_;
|
me.tableData = tableData_account_position_;
|
|
// 业务负责人
|
// me.getPositionDataByAccountId();
|
})
|
},
|
|
openPositionTree(sceneCode, callback) {
|
var me = this;
|
var data_ = {};
|
var text_ = "岗位负责人"
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "500px",
|
height: "80vh",
|
icon: "icon-product",
|
text: text_ + "选择",
|
id: "popup_position",//totab: true时需设置,用于判断是否已打开此页面
|
url: "module/md/page/popup/page/popup_position.html",
|
data: data_,
|
delta: {
|
company_id: me.formData.company_id,
|
bu_id: me.formData.bu_id,
|
select_position: this.tableData // position_id
|
},
|
// filter: "org_id='"+ me.selectedrow.org_id + "' and bu_id='" + me.selectedrow.bu_id + "'",
|
sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(popupobj, popupcallback) {
|
callback(popupobj)
|
|
if (popupcallback) {
|
popupcallback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
|
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: '已取消删除'
|
});
|
});
|
|
},
|
|
getPositionDataByAccountId() {
|
var me = this;
|
if (!this.formData.id) {
|
return
|
}
|
var params = {
|
dataname: "md_org_account_position",
|
filter: [
|
{"field": "parent_id", "value": this.formData_account.id},
|
]
|
}
|
Server.call("root/data/getEntitySet", params, function(result) {
|
if (result && result.data && result.data.entityset && result.data.entityset.length) {
|
var data_ = result.data.entityset;
|
me.tableData = data_;
|
}
|
|
me.$nextTick(() => {
|
me.isRefresh = true;
|
me.$forceUpdate();
|
});
|
})
|
},
|
|
tableFieldClick() {
|
var me = this;
|
//表单字段事件设置
|
this.formfieldClick = {
|
|
actor_code: {
|
select: {
|
onchange: function(obj) {
|
obj.data.actor_code = obj.selectoption.code || "";
|
obj.data.actor_name = obj.selectoption.value || "";
|
}
|
}
|
},
|
company_id: {
|
select: {
|
onchange: function(obj) {
|
obj.data.company_name = obj.selectoption.value || "";
|
|
//更改bu下拉项
|
var formFields_ = clone(me.formFields);
|
formFields_.map(f=>{
|
if (f.field == "bu_id") {
|
if (me.md_bu_org_obj[me.formData.company_id] && me.md_bu_org_obj[me.formData.company_id].length) {
|
f.options = clone(me.md_bu_org_obj[me.formData.company_id])
|
}
|
}
|
})
|
me.formFields = clone(formFields_);
|
}
|
}
|
},
|
bu_id: {
|
select: {
|
onchange: function(obj) {
|
obj.data.bu_name = obj.selectoption.value || "";
|
obj.data.product_id = [];
|
var formFields_ = clone(me.formFields);
|
|
formFields_.map(f=>{
|
if (f.field == "product_id") {
|
if (obj.selectoption.id) {
|
f.options = clone(me.md_bu_product_bu_obj[obj.selectoption.id]);
|
}
|
else {
|
f.options = [];
|
}
|
}
|
})
|
me.formFields = clone(formFields_);
|
}
|
}
|
},
|
business_need_code: {
|
select: {
|
onchange: function(obj) {
|
obj.data.business_need_name = obj.selectoption.value || "";
|
}
|
}
|
},
|
|
platform_account_name: {
|
popup: {
|
onclick: function(obj) {//弹窗点击事件
|
//打开开户平台弹窗
|
me.openAccount("add", obj, function(popupobj){
|
let row_ = clone(me.formData);
|
row_.platform_account_id = popupobj.row.id;
|
row_.platform_account_code = popupobj.row.code;
|
row_.platform_org_id = popupobj.row.org_id;
|
row_.platform_account_name = popupobj.row.account_name;
|
|
me.formData = clone(row_);
|
});
|
}
|
}
|
},
|
replace_account_name: {
|
popup: {
|
onclick: function(obj) {//弹窗点击事件
|
//打开开户平台弹窗
|
var filter_ = " md_org_account.id<>'"+ me.formData.host_id +"' and md_org_account.bu_name='" + me.formData.bu_name + "'"
|
|
//打开开户平台弹窗
|
me.openAccount(filter_, "add", obj, function(popupobj){
|
let row_ = clone(me.formData);
|
row_.replace_account_id = popupobj.row.id;
|
row_.replace_account_code = popupobj.row.code;
|
row_.replace_account_name = popupobj.row.account_name;
|
me.formData = clone(row_);
|
});
|
}
|
}
|
},
|
|
|
// 变更类型
|
type_code: {
|
select: {
|
onchange: function(obj) {
|
obj.data.type_name = obj.selectoption.value || "";
|
}
|
}
|
},
|
};
|
|
//表格字段事件设置
|
this.tablefieldClick = {
|
is_main_approver: {
|
input: {
|
onchange: function(obj) {
|
//
|
var tableData_ = clone(me.tableData);
|
var index_ = obj.$index;
|
if (obj.row.is_main_approver) { // 该行设置为主销售, 如果还有其他行,则其他行的主销售标识消失
|
tableData_
|
for (var i = 0; i < tableData_.length; i++) {
|
var row_ = tableData_[i];
|
if (i != index_) {
|
row_.is_main_approver = false;
|
}
|
}
|
}
|
else { // 该行取消主销售标识时,设置第一行的为主销售
|
tableData_[0].is_main_approver = true;
|
}
|
me.tableData = clone(tableData_);
|
}
|
},
|
},
|
};
|
},
|
openOrg(sceneCode, filter, callback) {
|
var me = this;
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "800px",
|
height: "520px",
|
icon: "icon-product",
|
text: "选择客商",
|
id: "popup_customer",//totab: true时需设置,用于判断是否已打开此页面
|
url: "module/md/page/popup/page/popup_customer.html",
|
data: {},
|
delta: "",
|
// filter: "category_code='"+ me.positiondata.org_id + "' and bu_id='" + me.positiondata.bu_id + "'",
|
filter: filter,
|
sceneCode: "add",//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(popupobj, popupcallback) {
|
callback(popupobj);
|
if (popupcallback) {
|
popupcallback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
openAccount(filter, sceneCode, obj, callback) {
|
var me = this;
|
var data_ = {};
|
var filter_ = "";
|
|
if (filter) {
|
filter_ = filter;
|
}
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "1100px",
|
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: filter_,
|
sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(popupobj, popupcallback) {
|
callback(popupobj);
|
if (popupcallback) {
|
popupcallback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
|
openPositionEmployee(sceneCode, obj, callback) {
|
var me = this;
|
var data_ = {};
|
// if (sceneCode == "edit") {
|
// data_ = obj.selectedList[0]
|
// }
|
var config = {
|
totab: false, //true: 以Tab导航的方式打开
|
width: "800px",
|
height: "520px",
|
icon: "icon-product",
|
text: "岗位选择",
|
id: "popup_position_employee_list",//totab: true时需设置,用于判断是否已打开此页面
|
url: "module/md/page/popup/page/popup_position_employee_list.html",
|
data: data_,
|
delta: {},
|
// filter: "org_id='"+ me.selectedrow.org_id + "' and bu_id='" + me.selectedrow.bu_id + "'",
|
filter: "md_position.bu_id='" + this.formData.bu_id + "'",
|
sceneCode: sceneCode,//"refuseedit",//"approval", //"add"//"browse",
|
callback: function(popupobj, popupcallback) {
|
callback(popupobj);
|
if (popupcallback) {
|
popupcallback();
|
}
|
}
|
};
|
me.doPopupByPublic(config);
|
},
|
|
addTableData(row) {
|
if (this.tableData.length == 0) {
|
row.is_main_approver = true;
|
}
|
else {
|
row.is_main_approver = false;
|
}
|
this.tableData.unshift(row);
|
// this.rowChange(table_row, "add", this.table_dataname);
|
},
|
|
delData(scope) {
|
let me = this;
|
let row = scope.row;
|
let index_ = scope.$index;
|
|
Root.confirm('确定删除数据【' + row.md_position__name + '】吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
me.rowChange(row, "del", me.table_dataname);
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
|
rowChange(row, type, tablename) {
|
var me = this;
|
if (type == "add") {
|
if (this.tableData.length == 0) {
|
row.is_main_approver = true;
|
}
|
this.tableData.unshift(row);
|
}
|
else if (type == "del") {
|
if (row.id) {
|
let param = {
|
dataname: tablename,
|
id: row.id
|
}
|
|
Server.call("root/data/deleteEntity", param, function(result) {
|
console.log(result);
|
if (result && result.data) {
|
me.tableData.remove(row);
|
Root.message({
|
type: 'success',
|
message: '删除成功!'
|
});
|
}
|
});
|
}
|
else {
|
this.tableData.remove(row);
|
}
|
}
|
else {
|
|
}
|
},
|
|
//提交
|
submitRowTable() {
|
var me = this;
|
var bo_change = this.$refs.change.checkForm();
|
if (!bo_change) {
|
bo_ = false;
|
Root.message({
|
type: 'error',
|
message: '请填写必填项'
|
});
|
return
|
}
|
this.iscommit = true;
|
this.saveChangeRowTable();
|
},
|
// 变更提交保存
|
saveChangeRowTable() {
|
var me = this;
|
var operator_ = "saveEntity";// 变更保存
|
if(me.iscommit) {
|
// operator_ = "commit";//变更提交
|
// operator_ = "toChange";//变更提交
|
|
if (this.formData.type_code == "close") {
|
operator_ = "toClose";//变更提交
|
}
|
else {
|
operator_ = "toChange";//变更提交
|
}
|
}
|
var change_entity = clone(this.formData);
|
var entity_ = clone(this.formData_account);
|
change_entity.host_id = entity_.id
|
change_entity.account_id = entity_.id
|
change_entity.account_code = entity_.code
|
change_entity.account_name = entity_.account_name
|
change_entity.bu_id = entity_.bu_id
|
change_entity.bu_name = entity_.bu_name
|
change_entity.company_id = entity_.company_id
|
change_entity.company_name = entity_.company_name
|
change_entity.org_id = entity_.org_id
|
|
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] || r[k] == false || r[k] == 0) {
|
row_[k] = r[k];
|
}
|
}
|
tableData_.push(row_);
|
})
|
|
if (tableData_.length == 0) {
|
Root.message({
|
type: 'warning',
|
message: '请先添加明细数据'
|
});
|
me.iscommit = false
|
return
|
}
|
|
let param = {
|
dataname: this.dataname,
|
data: {},
|
host: {},
|
}
|
if (change_entity.id) {
|
param.id = change_entity.id
|
}
|
|
param.data[this.dataname] = change_entity;
|
param.host[this.dataname_account] = entity;
|
param.host[this.table_dataname] = tableData_;
|
|
// 校验是否存在变更或关户中的数据
|
// var account_entity_id_filter = entity.company_id + entity.bu_id + entity.actor_code + entity.org_id
|
// if (me.exists_account[account_entity_id_filter] && me.exists_account[account_entity_id_filter] != entity.id) {
|
// Root.message({
|
// type: 'warning',
|
// message: "经销商" + entity.account_name + "已开过户,在" + entity.company_name + entity.bu + entity.actor_name + "中"
|
// });
|
// me.iscommit = false
|
// return
|
// }
|
|
console.log(param);
|
// return 0
|
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) {
|
if (errorresult.messages.list) {
|
me.iscommit = 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 {
|
me.iscommit = false;
|
Root.message({
|
type: 'error',
|
message: '提交失败'
|
});
|
}
|
});
|
},
|
|
// 开户保存
|
saveRowTable() {
|
var me = this;
|
var operator_ = "saveEntity";//保存
|
if(me.iscommit) {
|
operator_ = "commit";//提交
|
}
|
|
var entity_ = clone(this.formData);
|
var entity = {};
|
// var table_products_ = [];
|
// var table_provinces_ = [];
|
|
for (var r in entity_) {
|
// if (r == "product_id") {
|
// var products_ = entity_[r];
|
// products_.map(p=>{
|
// var p_ = {
|
// product_line_id: p[0],
|
// product_line_name: me.productobj_map[p[0]],
|
|
// };
|
// if (p.length == 2) {
|
// p_.product_id = p[1];
|
// p_.product_name = me.productobj_map[p[1]]
|
// }
|
|
// // 如果已经存过则id保持不变
|
// if (me.old_md_org_account_product_obj[p[0] + p[1]]) {
|
// p_.id = me.old_md_org_account_product_obj[p[0] + p[1]].id
|
// }
|
|
// // (缺功能)如果本次数据中没有了,则需要删除原数据。目前没有删除动作。
|
|
|
// table_products_.push(p_);
|
// })
|
// }
|
// else if (r == "province") {
|
// var provinces_ = entity_[r];
|
// provinces_.map(p=>{
|
// var p_ = {
|
// area: p[0],
|
// province: p[1]
|
// };
|
|
// // 如果已经存过则id保持不变
|
// if (me.old_md_org_account_province_obj[p[0] + p[1]]) {
|
// p_.id = me.old_md_org_account_province_obj[p[0] + p[1]].id
|
// }
|
|
// // (缺功能)如果本次数据中没有了,则需要删除原数据。目前没有删除动作。
|
|
|
// table_provinces_.push(p_);
|
// })
|
// }
|
// else
|
if (entity_[r] || entity_[r] == 0) {
|
entity[r] = entity_[r];
|
}
|
}
|
|
var tableData_ = [];
|
this.tableData.map(r=>{
|
var row_ = {};
|
for (var k in r) {
|
if (r[k] || r[k] == false || r[k] == 0) {
|
row_[k] = r[k];
|
}
|
}
|
tableData_.push(row_);
|
})
|
|
if (tableData_.length == 0) {
|
Root.message({
|
type: 'warning',
|
message: '请先添加明细数据'
|
});
|
me.iscommit = false
|
return
|
}
|
|
let param = {
|
dataname: this.dataname,
|
data: {},
|
}
|
if (me.formData.id) {
|
param.id = me.formData.id
|
}
|
if(me.iscommit) {
|
// param.to_state = "OpeningApproval";//提交
|
if (me.formData.org_ncc_id) {
|
param.refer = {
|
dataname: "md_org_account_ncc",
|
id: me.formData.org_ncc_id
|
}
|
}
|
|
}
|
|
param.data[this.dataname] = entity;
|
param.data[this.table_dataname] = tableData_;
|
|
// param.data["md_org_account_product"] = table_products_;
|
// param.data["md_org_account_province"] = table_provinces_;
|
|
// 校验唯一性
|
var account_entity_id_filter = entity.company_id + entity.bu_id + entity.actor_code + entity.org_id
|
if (me.exists_account[account_entity_id_filter] && me.exists_account[account_entity_id_filter] != entity.id) {
|
Root.message({
|
type: 'warning',
|
message: "经销商" + entity.account_name + "已开过户,在" + entity.company_name + entity.bu_name + entity.actor_name + "中"
|
});
|
me.iscommit = false
|
return
|
}
|
|
console.log(param);
|
// return
|
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) {
|
if (errorresult.messages.list) {
|
me.iscommit = 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 {
|
me.iscommit = false;
|
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() {
|
var me = this;
|
me.doRunApproval();
|
|
// this.getMachine(function(next_step, up_step) { //
|
// me.doRunApproval(next_step, up_step);
|
// });
|
},
|
|
getMachine(callback) {
|
var me = this;
|
let param = {
|
dataname: "md_org_account",
|
}
|
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;
|
if (!next_step) {
|
next_step = {}
|
}
|
if (!up_step) {
|
up_step = {}
|
}
|
|
// 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") {
|
// to_state_ = up_step[this.formData.state_code];
|
}
|
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,
|
remark: this.approveremark
|
}
|
if (to_state_) {
|
param.to_state = to_state_
|
}
|
//
|
// 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;
|
}
|
|
.h_change_body {
|
border: 1px solid #C0C4CC;
|
border-radius: 4px;
|
padding: 5px;
|
box-sizing: border-box;
|
}
|
</style>
|
|
</head>
|
|
<body style="margin: 0px;">
|
<div v-cloak id="vbody">
|
<div id="page_root">
|
<div ref="popup_body" style="padding: 0 20px;">
|
<div v-if="popupParames.totab" 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">
|
<div>
|
<h-form
|
ref="change"
|
:form-attr="formAttr_change"
|
:table-fields="formFields"
|
:form-data="formData"
|
:table-field-click="formfieldClick"
|
>
|
</h-form>
|
</div>
|
<div class="h_change_body">
|
<h-form
|
ref="JCXX"
|
:form-attr="formAttr"
|
:table-fields="formFields_account"
|
:form-data="formData_account"
|
:table-field-click="formfieldClick"
|
>
|
</h-form>
|
<div class="h_BU">
|
<div >
|
<!-- <div class="h_title">
|
<i class="iconfont icon-fuzhushuxian" style="color: #0270c1;"></i><span style="font-size: 14px;">我方业务负责人</span>
|
</div> -->
|
<div style="padding: 0px;">
|
<h-table v-if="tableFields.length"
|
ref="table1"
|
:table-attr="tableAttr"
|
:table-fields="tableFields"
|
:table-data="tableData"
|
:table-field-click="tablefieldClick"
|
:isfilterfield="false"
|
:isdraggableorder="false"
|
:table-buttons-click="tablebuttonclick"
|
:is-pagination="false"
|
:is-highlight-row="true"
|
:isbasicfilterfields="false"
|
|
:is-within-edit-table-data="table_isedit"
|
>
|
</h-table>
|
</div>
|
</div>
|
</div>
|
|
</div>
|
|
|
</div>
|
</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 size="small" type="default" @click="reasonvisible = false">取 消</el-button>
|
<el-button size="small" type="primary" :loading="loading_pass" @click="saveReason">确 定</el-button>
|
</div>
|
</el-dialog>
|
|
<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="isChangeEdit" type="primary" @click="saveChangeRowTable":icon="buttonsconfig.save.icon">{{buttonsconfig.save.name}}</el-button>
|
<el-button size="small" v-if="isChangeEdit" type="success" @click="submitRowTable":icon="buttonsconfig.submit.icon">{{buttonsconfig.submit.name}}</el-button>
|
|
<el-button size="small" v-if="isrefuseedit" type="success" @click="">再次提交</el-button>
|
|
<el-button size="small" v-if="isapproval" type="success" @click="onShowApproval('approve')">通 过</el-button>
|
<!-- <el-button size="small" v-if="isapproval" type="danger" @click="onShowApproval('goback')">拒 绝</el-button> -->
|
<!-- <el-button size="small" v-if="isapproval" type="primary" @click="">转 办</el-button> -->
|
<!-- <el-button size="small" v-if="isapproval" type="success" @click="onShowApproval('gohome')">退 回</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>
|
</body>
|
</html>
|