提交 4e78f927 编写于 作者: L LAPTOP-UV1MNL38\18023

feat:采购申请转合同

上级 8c21df8f
......@@ -160,6 +160,7 @@ function calculatedTotalPrice() {
taxLastMoneyPrice.toFixed(2);
// 返回最终金额
$(".totalPrice").html((taxLastMoneyPrice - discountMoney).toFixed(2));
return (taxLastMoneyPrice - discountMoney).toFixed(2);
}
layui.define(["jquery"], function(exports) {
......@@ -168,6 +169,7 @@ layui.define(["jquery"], function(exports) {
// 数量变化,税率变化
$("body").on("input", ".rkNum, .unitPrice, .amountOfMoney, .taxRate, .taxMoney, .taxUnitPrice, .taxLastMoney", function () {
var clazz = $(this).attr("class").replace("layui-input", "").replace("change-input", "").replace("layui-form-danger", "").replace(/\s+/g, "");
tableId = $(this).parents("table").parent().attr("id");
if (clazz != showTdByEdit) {
showTdByEdit = clazz;
$(".change-input").parent().removeAttr("style");
......@@ -177,6 +179,7 @@ layui.define(["jquery"], function(exports) {
});
$("body").on("change", ".rkNum, .unitPrice, .amountOfMoney, .taxRate, .taxMoney, .taxUnitPrice, .taxLastMoney", function () {
var clazz = $(this).attr("class").replace("layui-input", "").replace("change-input", "").replace("layui-form-danger", "").replace(/\s+/g, "");
tableId = $(this).parents("table").parent().attr("id");
if (clazz != showTdByEdit) {
showTdByEdit = clazz;
$(".change-input").parent().removeAttr("style");
......
// 根据那一列的值进行变化,默认根据数量
var showTdByEdit = 'operNumber';
var tableId = '';
// 已经选择的商品集合key:表格的行trId,value:商品信息
var allChooseProduct = {};
layui.config({
base: basePath,
version: skyeyeVersion
}).extend({
window: 'js/winui.window'
}).define(['window', 'table', 'jquery', 'winui', 'form'], function (exports) {
}).define(['window', 'table', 'jquery', 'winui', 'form', 'tagEditor', 'laydate'], function (exports) {
winui.renderColor();
var index = parent.layer.getFrameIndex(window.name);
var $ = layui.$,
form = layui.form,
tagEditor = layui.tagEditor,
laydate = layui.laydate,
table = layui.table;
var selOption = getFileContent('tpl/template/select-option.tpl');
var serviceClassName = sysServiceMation["purchaseRequest"]["key"];
// 表单模板信息
let beanTemplate = $("#beanTemplate").html();
var id = GetUrlParam("id");
let tabList = [{
name: "tab1",
content: '内容1'
}, {
name: "tab2",
content: '内容2'
}]
AjaxPostUtil.request({url: sysMainMation.erpBasePath + "queryPurchaseRequestTransferContract", params: {id: id}, type: 'json', method: "GET", callback: function(json) {
if (!isNull(json.bean)) {
let tabList = [];
let tabIndex = 1;
let supplierIds = [];
$.each(json.bean, function (key, value) {
console.log(value)
if (!isNull(key)) {
supplierIds.push(key)
}
let tab = {
supplierId: key,
name: '合同-' + tabIndex,
class: tabIndex == 1 ? 'layui-this' : '',
contentClass: tabIndex == 1 ? 'layui-show' : '',
tabIndex: tabIndex,
bean: value
};
$.each(value, function(i, item) {
if (i == 0) {
tab.supplierMation = item.lastSupplierMation
}
item.normsId = {
"html": getDataUseHandlebars(selOption, {rows: item.materialMation.materialNorms}),
"value": item.normsId
};
});
tabList.push(tab);
tabIndex++;
})
$("#titleUl").html(getDataUseHandlebars('{{#rows}}<li class="{{class}}">{{name}}</li>{{/rows}}', {rows: tabList}));
$("#contentDiv").html(getDataUseHandlebars(beanTemplate, {rows: tabList}));
if (supplierIds.length > 0){
// 获取联系人
var objectIds = JSON.stringify(supplierIds)
AjaxPostUtil.request({url: sysMainMation.reqBasePath + "queryContactsListByObjectIds", params: {objectIds:objectIds}, type: 'json', method: "POST", callback: function(json) {
let contactsMap = json.bean;
initRender(tabIndex, tabList, contactsMap);
}});
} else {
initRender(tabIndex, tabList, {});
}
}
}});
function initRender(tabIndex, tabList, contactsMap) {
for (let i = 1; i < tabIndex; i++) {
// 加载联系人
$("#contacts" + i).html(getDataUseHandlebars(selOption,
{rows: contactsMap[tabList[i - 1].supplierId]}));
// 加载附件组件
skyeyeEnclosure.init('enclosureUpload' + i);
// 加载所属部门
systemCommonUtil.queryDepartmentListByCurrentUserBelong(function(data) {
$("#departmentId" + i).html(getDataUseHandlebars(selOption, data));
form.render('select');
});
// 签约日期
laydate.render({elem: '#signingTime' + i, type: 'date', value: getYMDFormatDate(), trigger: 'click'});
// 生效日期
laydate.render({elem: '#effectTime' + i, type: 'date',value: getYMDFormatDate(), trigger: 'click'});
// 服务结束日期
laydate.render({elem: '#serviceEndTime' + i, type: 'date',value: getYMDFormatDate(), trigger: 'click'});
initTableChooseUtil.initTable({
id: "supplierContractChildList" + i,
cols: [
{id: 'materialId', title: '产品', formType: 'chooseInput', width: '150', className: 'materialId', verify: 'required'},
{id: 'normsId', title: '规格', formType: 'select', width: '50', className: 'normsId', verify: 'required', layFilter: 'selectUnitProperty'},
{id: 'operNumber', title: '数量', formType: 'input', width: '80', className: 'change-input rkNum', verify: 'required|number', value: '1'},
{id: 'unitPrice', title: '单价', formType: 'input', width: '80', className: 'change-input readOnly unitPrice', verify: 'required|money'},
{id: 'allPrice', title: '总金额', formType: 'input', width: '80', className: 'change-input readOnly allPrice', verify: 'required|money'},
{id: 'taxRate', title: '税率(%)', formType: 'input', width: '80', className: 'change-input readOnly taxRate', verify: 'required|double', value: '0.00'},
{id: 'taxMoney', title: '税额', formType: 'input', width: '80', className: 'change-input readOnly taxMoney', verify: 'required|money'},
{id: 'taxUnitPrice', title: '含税单价', formType: 'input', width: '80', className: 'change-input readOnly taxUnitPrice', verify: 'required|money'},
{id: 'taxLastMoney', title: '合计价税', formType: 'input', width: '80', className: 'change-input readOnly taxLastMoney', verify: 'required|money'},
{id: 'remark', title: '备注', formType: 'input', width: '100'}
],
deleteRowCallback: function (trcusid) {
tableId = "supplierContractChildList" + i;
delete allChooseProduct[trcusid];
// 计算价格
calculatedTotalPrice();
},
addRowCallback: function (trcusid) {
// 设置根据某列变化的颜色
$("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'});
},
form: form,
minData: 1
});
initTableChooseUtil.deleteAllRow("supplierContractChildList" + i);
$.each(tabList[i - 1].bean, function(j, item) {
var trId = initTableChooseUtil.resetData("supplierContractChildList" + i, item);
item.tableTrId = trId;
// 将规格所属的商品信息加入到对象中存储
allChooseProduct[trId] = item;
$("#addRowsupplierContractChildList" + i).remove();
});
// 计算价格
let totlePrice = calculatedTotalPrice();
$("#materialTotalPrice" + i).html(totlePrice);
$(".readOnly").attr("readonly", true);
$(".materialId").parent().find("i").remove();
$(".normsId").attr("disabled", true);
// 商品规格加载变化事件
mUnitChangeEvent(form, allChooseProduct, "estimatePurchasePrice");
if (!isNull(tabList[i - 1].supplierMation)) {
$("#supplierName" + i).val(tabList[i - 1].supplierMation.name);
$("#supplierName" + i).attr("objectId", tabList[i - 1].supplierMation.id);
$("#supplierName" + i).attr("objectKey", tabList[i - 1].supplierMation.serviceClassName);
$("#supplierName" + i).parent().find("i").remove();
}
// 关联人员
$('#relationUser' + i).tagEditor({
initialTags: [],
placeholder: '请选择关联人员',
editorTag: false,
beforeTagDelete: function(field, editor, tags, val) {
var listVal = $("#relationUser" + i).attr('list');
var list = isNull(listVal) ? [] : JSON.parse(listVal);
list = [].concat(arrayUtil.removeArrayPointName(list, val));
$("#relationUser" + i).attr('list', JSON.stringify(list));
}
});
// 保存为草稿
form.on('submit(formAddBean' + i + ')', function(data) {
if (winui.verifyForm(data.elem)) {
saveData("1", "", $(this).attr("tabIndex"));
}
return false;
});
// 走工作流的提交审批
form.on('submit(formSubOneBean' + i + ')', function(data) {
if (winui.verifyForm(data.elem)) {
var tabIndex=$(this).attr("tabIndex")
activitiUtil.startProcess(serviceClassName, null, function (approvalId) {
console.log(approvalId)
saveData("2", approvalId, tabIndex);
});
}
return false;
});
// 不走工作流的提交
form.on('submit(formSubTwoBean' + i + ')', function(data) {
if(winui.verifyForm(data.elem)) {
saveData("3", "", $(this).attr("tabIndex"));
}
return false;
});
initChooseProductBtnEnent(form, function(trId, chooseProductMation) {
// 商品赋值
allChooseProduct[trId] = chooseProductMation;
});
}
matchingLanguage();
form.render();
}
function saveData(formSubType, approvalId, i) {
var result = initTableChooseUtil.getDataList('supplierContractChildList' + i);
if (!result.checkResult) {
return false;
}
var noError = false;
var tableData = [];
$.each(result.dataList, function(i, item) {
//获取行编号
var thisRowKey = item["trcusid"].replace("tr", "");
if (parseInt(item.operNumber) == 0) {
$("#operNumber" + thisRowKey).addClass("layui-form-danger");
$("#operNumber" + thisRowKey).focus();
winui.window.msg('数量不能为0', {icon: 2, time: 2000});
noError = true;
return false;
}
//商品对象
var material = allChooseProduct["tr" + thisRowKey];
if (inTableDataArrayByAssetarId(material.materialId, item.normsId, tableData)) {
winui.window.msg('一张单中不允许出现相同单位的商品信息.', {icon: 2, time: 2000});
noError = true;
return false;
}
item["materialId"] = material.materialId;
tableData.push(item);
});
if (noError) {
return false;
}
var listVal = $("#relationUser" + i).attr('list');
var list = isNull(listVal) ? [] : JSON.parse(listVal);
var params = {
id: id,
objectId: $("#supplierName" + i).attr("objectId"),
objectKey: $("#supplierName" + i).attr("objectKey"),
title: $("#title" + i).val(),
price: $("#price" + i).val(),
signingTime: $("#signingTime" + i).val(),
effectTime: $("#effectTime" + i).val(),
serviceEndTime: $("#serviceEndTime" + i).val(),
contacts: $("#contacts" + i).val(),
technicalTerms: $("#technicalTerms" + i).val(),
departmentId: $("#departmentId" + i).val(),
relationUserId: JSON.stringify(systemCommonUtil.tagEditorGetAllData('relationUser' + i, list)),
supplierContractChildList: JSON.stringify(tableData),
enclosureInfo: JSON.stringify({enclosureInfo: skyeyeEnclosure.getEnclosureIdsByBoxId('enclosureUpload' + i)}),
formSubType: formSubType,
approvalId: approvalId
};
AjaxPostUtil.request({url: sysMainMation.erpBasePath + "purchaseRequestToContract", params: params, type: 'json', method: "POST", callback: function(json) {
parent.layer.close(index);
parent.refreshCode = '0';
}});
}
// 供应商选择
$("body").on("click", ".supplierNameSel", function (e) {
var inputId = "supplierName" + $(this).attr("tabIndex");
var contactsId="contacts" + $(this).attr("tabIndex");
sysSupplierUtil.openSysSupplierChoosePage(function (supplierMation) {
$("#" + inputId).val(supplierMation.name);
$("#" + inputId).attr("objectId", supplierMation.id);
// 获取所选供应商的联系人
AjaxPostUtil.request({url: sysMainMation.reqBasePath + "queryContactsListByObject", params: {objectId:supplierMation.id}, type: 'json', method: "GET", callback: function(json) {
let contactsList = json.rows;
console.log(contactsId);
$("#" + contactsId).html(getDataUseHandlebars(selOption, {rows: contactsList}));
form.render();
}});
});
});
$("#titleUl").html(getDataUseHandlebars('{{#rows}}<li>{{name}}</li>{{/rows}}', {rows: tabList}));
$("#contentDiv").html(getDataUseHandlebars('{{#rows}}<div class="layui-tab-item">{{content}}</div>{{/rows}}', {rows: tabList}));
// 关联人员
$("body").on("click", ".relationUserIdSel", function() {
// 获取值 systemCommonUtil.tagEditorGetItemData('supplierName', list);
var inputId = "relationUser" + $(this).attr("tabIndex");
systemCommonUtil.userReturnList = [];
systemCommonUtil.chooseOrNotMy = "1"; // 人员列表中是否包含自己--1.包含;其他参数不包含
systemCommonUtil.chooseOrNotEmail = "2"; // 人员列表中是否必须绑定邮箱--1.必须;其他参数没必要
systemCommonUtil.checkType = "1"; // 人员选择类型,1.多选;其他。单选
systemCommonUtil.openSysUserStaffChoosePage(function (userReturnList){
let list = [].concat(systemCommonUtil.tagEditorResetData(inputId, userReturnList));
$("#" + inputId).attr('list', JSON.stringify(list));
});
});
});
\ No newline at end of file
......@@ -43,8 +43,19 @@
<a class="layui-btn layui-btn-xs" lay-event="fixedPrice">定价</a>
{{# } }}
{{# } }}
{{# if(d.inquiryState == 1 || d.inquiryState == 4) { }}
{{# if(auth('1717078688711')){ }}
<a class="layui-btn layui-btn-xs" lay-event="toContract">转采购合同</a>
{{# } }}
{{# } }}
{{# } }}
{{# if(d.state == 'partialProcurement') { }}
{{# if(d.inquiryState == 1 || d.inquiryState == 4) { }}
{{# if(auth('1717078688711')){ }}
<a class="layui-btn layui-btn-xs" lay-event="toContract">转采购合同</a>
{{# } }}
{{# } }}
{{# } }}
<a class="layui-btn layui-btn-xs" lay-event="toContract">转采购合同</a>
</script>
</div>
<script src="../../assets/lib/layui/layui.js"></script>
......
......@@ -15,14 +15,110 @@
</div>
</div>
<script type="text/x-handlebars-template" id="fileMationTemplate">
{{#bean}}
<script type="text/x-handlebars-template" id="beanTemplate">
{{#rows}}
<div class="layui-tab-item {{contentClass}}">
<form class="layui-form" action="" autocomplete="off" id="form{{tabIndex}}">
<div class="layui-form-item layui-col-xs12">
<span class="hr-title">基本信息</span><hr>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">合同名称<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="title{{tabIndex}}" name="title{{tabIndex}}" win-verify="required" placeholder="请输入合同名称" class="layui-input" maxlength="100"/>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">合同金额</label>
<div class="layui-input-block">
<input type="text" id="price{{tabIndex}}" name="price{{tabIndex}}" placeholder="请输入合同金额" class="layui-input" maxlength="100"/>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">所属部门<i class="red">*</i></label>
<div class="layui-input-block">
<select id="departmentId{{tabIndex}}" lay-search win-verify="required"></select>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">签约日期<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="signingTime{{tabIndex}}" name="signingTime{{tabIndex}}" placeholder="请选择签约日期" win-verify="required" class="layui-input"/>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">生效日期</label>
<div class="layui-input-block">
<input type="text" id="effectTime{{tabIndex}}" name="effectTime{{tabIndex}}" placeholder="请选择生效日期" class="layui-input"/>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">服务结束日期</label>
<div class="layui-input-block">
<input type="text" id="serviceEndTime{{tabIndex}}" name="serviceEndTime{{tabIndex}}" placeholder="请选择服务结束日期" class="layui-input"/>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">供应商<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="supplierName{{tabIndex}}" name="supplierName{{tabIndex}}" win-verify="required" placeholder="请选择供应商" class="layui-input" readonly="readonly"/>
<i class="fa fa-plus-circle input-icon supplierNameSel" tabIndex="{{tabIndex}}"></i>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">联系人<i class="red">*</i></label>
<div class="layui-input-block">
<select id="contacts{{tabIndex}}" lay-search win-verify="required"></select>
</div>
</div>
<div class="layui-form-item layui-col-xs6">
<label class="layui-form-label">关联人员<i class="red">*</i></label>
<div class="layui-input-block">
<input type="text" id="relationUser{{tabIndex}}" name="relationUser{{tabIndex}}" win-verify="required" placeholder="请选择关联人员" class="layui-input" readonly="readonly"/>
<i class="fa fa-plus-circle input-icon relationUserIdSel" tabIndex="{{tabIndex}}"></i>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">采购申请明细</label>
<div class="layui-input-block" id="supplierContractChildList{{tabIndex}}">
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">主要技术条款</label>
<div class="layui-input-block">
<textarea id="technicalTerms{{tabIndex}}" name="technicalTerms{{tabIndex}}" placeholder="请输入主要技术条款" class="layui-textarea" style="height: 100px;" maxlength="200"></textarea>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">主要商务条款</label>
<div class="layui-input-block">
<textarea id="businessTerms{{tabIndex}}" name="businessTerms{{tabIndex}}" placeholder="请输入主要商务条款" class="layui-textarea" style="height: 100px;" maxlength="200"></textarea>
</div>
</div>
<div class="layui-form-item layui-col-xs12">
<label class="layui-form-label">附件资料</label>
<div class="layui-input-block ver-center" id="enclosureUpload{{tabIndex}}">
</div>
</div>
{{/bean}}
<div class="layui-form-item layui-col-xs12">
<div class="layui-input-block">
<button class="winui-btn" tabIndex="{{tabIndex}}" lay-submit lay-filter="formAddBean{{tabIndex}}">保存为草稿</button>
<button class="winui-btn submitTypeIsOne" tabIndex="{{tabIndex}}" lay-submit lay-filter="formSubOneBean{{tabIndex}}">提交审批</button>
<button class="winui-btn submitTypeIsTwo" tabIndex="{{tabIndex}}" lay-submit lay-filter="formSubTwoBean{{tabIndex}}">提交</button>
</div>
</div>
</form>
</div>
{{/rows}}
</script>
<script src="../../assets/lib/layui/layui.js"></script>
<script src="../../assets/lib/layui/custom.js"></script>
<script src="../../js/erpcommon/calculatePrice.js"></script>
<script src="../../js/erpcommon/loadStock.js"></script>
<script type="text/javascript">
layui.config({base : '../../js/purchaseRequest/'}).use('requestToContract');
</script>
......
......@@ -118,7 +118,7 @@ var initTableChooseUtil = {
'<i class="fa fa-plus-circle input-icon ' + item.iconClassName + '" style="top: 12px;"></i></td>';
} else if (item.formType == 'select') {
var modelHtml = isNull(item.modelHtml) ? "" : item.modelHtml;
tbodyStr += '<td><select id="' + tdId + '" lay-filter="' + item.layFilter + '" lay-search win-verify="' + verify + '">' + modelHtml + '</select></td>';
tbodyStr += '<td><select id="' + tdId + '" lay-filter="' + item.layFilter + '" lay-search win-verify="' + verify + '" class="' + className + '">' + modelHtml + '</select></td>';
} else if (item.formType == 'detail') {
tbodyStr += '<td id="' + tdId + '" class="' + className + '">' + value + '</td>';
}
......
......@@ -8200,3 +8200,13 @@ select[multiple]+.layui-form-select .layui-form-checkbox[lay-skin=primary] i{ po
overflow: hidden;
white-space: nowrap;
}
/*设置只读状态的样式*/
input:-moz-read-only { /* For Firefox */
color: #d2d2d2 !important;
cursor: not-allowed !important;
}
input:read-only {
color: #d2d2d2 !important;
cursor: not-allowed !important;
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册