<!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: "",
|
table_dataname: "",
|
title: "字典编辑",
|
formAttr: {
|
istitle: false,
|
title: "表单名称",
|
columnnumber: 3,
|
labelwidth: "140px",
|
labelposition: "left",//"left",// right//top
|
size: "mini",
|
border: "3px solid #c6c6c600"
|
},
|
|
default_formFields: [
|
{isshow: "T", field: "biz_date", name: "订单日期", type: "date", formatter: "date", notvalunit: true},
|
{isshow: "T", field: "customer_name", name: "客户名称", type: "popup", required: true, notvalunit: true},
|
{isshow: "T", field: "customer_consignee_address", name: "收货地址", required: true, type: "select",isfilterable:true, isrefresh:true, options: [], props:{value: "id", label: "address", checkStrictly: true}, notvalunit: true},
|
{isshow: "T", field: "customer_consignee_user_name", name: "联系人", required: true, notvalunit: true},
|
{isshow: "T", field: "customer_consignee_phone", name: "联系电话", required: true, notvalunit: true},
|
{isshow: "T", field: "operate_emp_name", name: "业务员名称", disabled: true, notvalunit: true},
|
{isshow: "T", field: "business_depart_name", name: "业务部门", type: "popup", required: true, notvalunit: true},
|
{isshow: "T", field: "province_name", name: "区域", width: "120", type: "popup", required: true, notvalunit: true},
|
{isshow: "T", field: "settle_type", name: "结算方式", type: "select", options: [{label: "现金",value: "cash"}, {label: "信用付款",value: "credit"}], required: true, notvalunit: true},
|
{isshow: "T", field: "emp_depart_name", name: "销售部门", disabled: true, defaultval: "", notvalunit: true},
|
{isshow: "T", field: "contract_no", name: "合同号", notvalunit: true},
|
{isshow: "T", field: "amt_credit", name: "授信额度", disabled: true, formatter: "money", notvalunit: true},
|
{isshow: "F", field: "iscreditsuccess", name: "资信检查结果", formatter: "TF3", notvalunit: true},
|
{isshow: "T", field: "amt", name: "订单总金额", disabled: true, formatter: "money", align: "right", notvalunit: true},
|
{isshow: "T", field: "amt_receipts", name: "折扣后金额", disabled: true, formatter: "money", align: "right", notvalunit: true},
|
{isshow: "T", field: "amt_discount", name: "折扣总金额", disabled: true, formatter: "money", align: "right", notvalunit: true},
|
],
|
formFields: [],
|
|
newformData: {
|
//id: uuid_short(),
|
// code: createCode("BA"),
|
create_time: createDatetime(),
|
state_code: "Draft",
|
state_name: "草稿",
|
creator_name: window.top.vue.userinfo.name,
|
type_code: "",
|
type_name: "",
|
},
|
formData: {},
|
|
isRefresh: true,
|
default_tableFields: [
|
{isshow: "T",field: "create_time", name: "创建日期", width: "130",formatter: "formatter_date"},
|
{isshow: "T", field: "delivery_part_name", name: "工厂名称", width: "180"},
|
{isshow: "T", field: "product_code", name: "产品编号", width: "120"},
|
{isshow: "T", field: "product_name", name: "产品名称", width: "400", type: "popup", align: "left"},
|
{isshow: "T", field: "cnt", name: "数量", width: "80", type: "input", istablesum: true},
|
{isshow: "T", field: "rebate_amt_sku", name: "折扣金额(专项)", defaultval: 0, align: "right", width: "120", istablesum: true},
|
{isshow: "T", field: "rebate_amt_ty", name: "折扣金额(通用)", defaultval: 0, align: "right", width: "120", type: "popup"},
|
{isshow: "T", field: "price_type", name: "价格类型", width: "120", type: "popup"},
|
{isshow: "T", field: "product_price", name: "单价", width: "80", formatter: "formatter_money", align: "right"},
|
{isshow: "T", field: "tax_rate", name: "税率", width: "110", type: "select", options: dataRoot.database.taxrate},
|
{isshow: "T", field: "product_conversion_rate", name: "换算率", width: "80"},
|
{isshow: "T", field: "standrad_cnt", name: "件数", width: "80", istablesum: true},
|
{isshow: "T", field: "stock", name: "库存", width: "80", istablesum: true},
|
{isshow: "T", field: "amt", name: "金额", align: "right", width: "120", formatter: "formatter_money", istablesum: true},
|
{isshow: "T", field: "rebate_amt", name: "返利金额", align: "right", width: "100", formatter: "formatter_money", istablesum: true},
|
{isshow: "T", field: "sales_type", name: "销售类型", width: "120", type: "select", options: dataRoot.database.saletype},
|
{isshow: "T", field: "qty_return", name: "退货数量", width: "160", align: "right"},
|
{isshow: "T", field: "remark", name: "备注", type: "input", width: "180"},
|
],
|
tableFields: [],
|
newTableData: {
|
//create_time: createDatetime(),
|
//creator_name: window.top.vue.userinfo.name,
|
},
|
tableData: [],
|
|
//按键权限设置
|
isedit: false,//提交前编辑,保存/提交
|
isrefuseedit: false,//拒绝后编辑,保存/再次提交
|
isapproval: false,//审批,同意/拒绝/转办/退回
|
|
iscommit: false,//提交标记
|
|
//弹窗参数
|
popupParames: {},
|
//字段设置
|
tablefieldClick: {},
|
formfieldClick: {},
|
},
|
created() {
|
this.popupParames = clone(Root.popupParames);
|
this.title = this.popupParames.title || this.popupParames.text;
|
this.dataname = this.popupParames.delta.pageobj.dataname;
|
|
if (this.popupParames.data) {
|
this.formData = clone(this.popupParames.data);
|
}
|
|
if (this.popupParames.sceneCode) {
|
if (this.popupParames.sceneCode == "add") {//新增
|
if (this.newformData) {
|
let formData_ = clone(this.formData);
|
|
for (var k in this.newformData) {
|
formData_[k] = this.newformData[k];
|
}
|
this.formData = formData_;
|
}
|
|
if (this.newTableData) {
|
this.tableData.push(clone(this.newTableData));
|
}
|
|
this.isedit = true;
|
}
|
else if (this.popupParames.sceneCode == "browse") {//只读
|
this.formAttr.disabled = 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;
|
//预加载数据
|
if (this.dataRequest && this.dataRequest.length) {
|
var result = {};
|
this.loadRequestData(this.dataRequest, result, function(data) {
|
me.dataRequestObj = data;
|
//预加载数据后给哪些字段设置options或formatterjson
|
|
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;
|
}
|
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 (!f.inputtype) {
|
f.type = "input";
|
}
|
else {
|
f.type = f.inputtype;
|
}
|
formFields_.push(clone(f));
|
})
|
|
var boolFieldobj = {
|
is_required: true,
|
is_readonly: true,
|
is_filter: true,
|
is_fixed: true,
|
list_is_visible: true,
|
form_is_visible: true,
|
is_list: true,
|
is_form: true,
|
}
|
table_metas.map(f=>{
|
f.isshow = "T";
|
if (!f.inputtype) {
|
f.type = "input";
|
}
|
else {
|
f.type = f.inputtype;
|
}
|
|
tableFields_.push(clone(f));
|
})
|
|
if (!me.formFields || (me.formFields && me.formFields.length == 0)) {
|
me.formFields = clone(formFields_);
|
me.tableFields = clone(tableFields_);
|
|
//字段数组转字段obj,目的为了筛选时获取字段属性
|
me.fieldsToFieldsObj();
|
|
//设置字段事件
|
me.tableFieldClick();
|
}
|
}
|
|
if (me.rowData[me.dataname]) {
|
me.formData = me.rowData[me.dataname];
|
}
|
if (me.rowData[me.table_dataname]) {
|
me.tableData = me.rowData[me.table_dataname];
|
}
|
})
|
},
|
|
tableFieldClick() {
|
var me = this;
|
//表单字段事件设置
|
//表格字段事件设置
|
},
|
|
addTableData() {
|
var table_row = clone(this.newTableData);
|
this.rowChange(table_row, "add", this.table_dataname);
|
},
|
|
delData(scope) {
|
let me = this;
|
let row = scope.row;
|
let index_ = scope.$index;
|
|
Root.confirm('确定删除数据【' + JSON.stringify(row) + '】吗?', '删除提示', {
|
confirmButtonText: '删除',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
var tablename_ = me.dataname + "." + me.table_dataname;
|
me.rowChange(row, "del", tablename_);
|
}).catch(() => {
|
Root.message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
|
rowChange(row, type, tablename) {
|
var me = this;
|
if (type == "add") {
|
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() {
|
this.iscommit = true;
|
this.saveRowTable();
|
},
|
|
//保存
|
saveRowTable() {
|
var me = this;
|
var operator_ = "save";//保存
|
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] || r[k] == false || r[k] == 0 || r[k] == "") {
|
row_[k] = r[k];
|
}
|
}
|
tableData_.push(row_);
|
})
|
|
if (tableData_.length == 0) {
|
Root.message({
|
type: 'warning',
|
message: '请先添加明细数据'
|
});
|
return
|
}
|
|
let param = {
|
dataname: this.dataname,
|
// operator: operator_,
|
data: {},
|
}
|
param.data[this.dataname] = entity;
|
param.data[this.table_dataname] = tableData_;
|
|
Server.call("root/data/saveEntity", 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();
|
}
|
}
|
});
|
},
|
|
}
|
});
|
};
|
|
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: 550px; 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">
|
<div v-if="(isedit || isrefuseedit) && tableFields.length" style=" text-align: right; ">
|
<!-- 工具栏 -->
|
<div style=" display: inline-block; width: 90px;">
|
<el-button-group>
|
<el-button @click="addTableData">新增明细</el-button>
|
</el-button-group>
|
</div>
|
</div>
|
<h-table
|
v-if="isRefresh && tableFields.length"
|
ref="table1"
|
:table-fields="tableFields"
|
:table-data="tableData"
|
:is-edit-table-data="isedit || isrefuseedit"
|
:is-within-edit-table-data="isedit || isrefuseedit"
|
:is-pagination="false"
|
:table-field-click="tablefieldClick"
|
:edit-table-button="editTableButton"
|
:table-height="400"
|
|
v-on:get-data="getData"
|
v-on:del-data="delData"
|
>
|
</h-table>
|
</div>
|
|
|
</div>
|
</div>
|
<div class="el-dialog__footer">
|
<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>
|
</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>
|