Browse Source

[feat]基础信息: 新增报销单,添加报销类别表中的列字段的成本类型字段的值,来决定本列的成本小类的字段的下拉列表的选项,更换查询语句,修改查询对象。 新增一个类型为成本类型字段code值为'costType',创建一个根据此code在sys_actegory表中的子项分类的接口。

dev
zhangsiqi 6 months ago
parent
commit
cbed4629ca
  1. 25
      ruoyi-admin/src/main/java/com/ruoyi/system/CategoryController.java
  2. 10
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExpenseAccountController.java
  3. 26
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java
  4. 18
      ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesOrderController.java
  5. 12
      ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExpenseAccount.java
  6. 12
      ruoyi-admin/src/main/resources/mapper/system/BaseExpenseAccountMapper.xml
  7. 114
      ruoyi-admin/src/main/resources/templates/system/baseExpense/add.html
  8. 8
      ruoyi-admin/src/main/resources/templates/system/baseExpense/baseExpense.html
  9. 114
      ruoyi-admin/src/main/resources/templates/system/baseExpense/edit.html
  10. 71
      ruoyi-admin/src/main/resources/templates/system/baseExpenseChild/baseExpenseChild.html

25
ruoyi-admin/src/main/java/com/ruoyi/system/CategoryController.java

@ -0,0 +1,25 @@
package com.ruoyi.system;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.framework.web.service.CategoryService;
import com.ruoyi.system.domain.SysCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
@Controller
@RequestMapping("/system/category")
public class CategoryController extends BaseController {
@Autowired
private CategoryService categoryService;
@RequestMapping("getChildCode")
@ResponseBody
public List<SysCategory> getChildCode(String code) {
return categoryService.getChildByCode(code);
}
}

10
ruoyi-admin/src/main/java/com/ruoyi/system/controller/BaseExpenseAccountController.java

@ -5,11 +5,7 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap; import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BaseExpenseAccount; import com.ruoyi.system.domain.BaseExpenseAccount;
@ -84,7 +80,7 @@ public class BaseExpenseAccountController extends BaseController
@Log(title = "报销单", businessType = BusinessType.INSERT) @Log(title = "报销单", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
@ResponseBody @ResponseBody
public AjaxResult addSave(BaseExpenseAccount baseExpenseAccount) public AjaxResult addSave(@RequestBody BaseExpenseAccount baseExpenseAccount)
{ {
return toAjax(baseExpenseAccountService.insertBaseExpenseAccount(baseExpenseAccount)); return toAjax(baseExpenseAccountService.insertBaseExpenseAccount(baseExpenseAccount));
} }
@ -107,7 +103,7 @@ public class BaseExpenseAccountController extends BaseController
@Log(title = "报销单", businessType = BusinessType.UPDATE) @Log(title = "报销单", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
@ResponseBody @ResponseBody
public AjaxResult editSave(BaseExpenseAccount baseExpenseAccount) public AjaxResult editSave(@RequestBody BaseExpenseAccount baseExpenseAccount)
{ {
return toAjax(baseExpenseAccountService.updateBaseExpenseAccount(baseExpenseAccount)); return toAjax(baseExpenseAccountService.updateBaseExpenseAccount(baseExpenseAccount));
} }

26
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysCustomerQuoteController.java

@ -38,6 +38,7 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
* 客户报价信息Controller * 客户报价信息Controller
@ -68,6 +69,8 @@ public class SysCustomerQuoteController extends BaseController
@Autowired @Autowired
private RuntimeService runtimeService; private RuntimeService runtimeService;
@Autowired
private ISysUserService sysUserService;
@Autowired @Autowired
private IProcessService processService; private IProcessService processService;
@ -90,16 +93,33 @@ public class SysCustomerQuoteController extends BaseController
@ResponseBody @ResponseBody
public TableDataInfo list(SysCustomerQuoteVo sysCustomerQuoteVo) public TableDataInfo list(SysCustomerQuoteVo sysCustomerQuoteVo)
{ {
try {
SysUser curUser = ShiroUtils.getSysUser(); SysUser curUser = ShiroUtils.getSysUser();
Long userId = curUser.getUserId(); Long userId = curUser.getUserId();
Set<String> roleKeys = roleService.selectRoleKeys(userId); Set<String> roleKeys = roleService.selectRoleKeys(userId);
startPage();
List<SysCustomerQuoteVo> list = sysCustomerQuoteService.selectSysCustomerQuoteList(sysCustomerQuoteVo);
String loginName = ShiroUtils.getLoginName();
List<SysUser> sysUserlist = sysUserService.selectRoleToUserList("ywyRole");
sysUserlist.add(curUser);
if (roleKeys.contains("ywjlRole")) {
List<SysUser> findUser = sysUserlist.stream().filter(item -> (item.getDeptId().equals(curUser.getDeptId()))).collect(Collectors.toList());
Set<String> user = findUser.stream().map(SysUser::getLoginName).collect(Collectors.toSet());
startPage();
List<SysCustomerQuoteVo> list2 = list.stream().filter(item -> user.contains(item.getApplyUser())).collect(Collectors.toList());
return getDataTable(list2);
}
// 业务员角色只能看到自己创建的数据 // 业务员角色只能看到自己创建的数据
if (roleKeys.contains("ywyRole")) { if (roleKeys.contains("ywyRole")) {
sysCustomerQuoteVo.setCreateBy(curUser.getLoginName()); sysCustomerQuoteVo.setApplyUser(curUser.getLoginName());
}
startPage(); startPage();
List<SysCustomerQuoteVo> list = sysCustomerQuoteService.selectSysCustomerQuoteList(sysCustomerQuoteVo); List<SysCustomerQuoteVo> list2 = sysCustomerQuoteService.selectSysCustomerQuoteList(sysCustomerQuoteVo);
return getDataTable(list2);
}
return getDataTable(list); return getDataTable(list);
}catch(NullPointerException e){
throw new NullPointerException("当前用户没有申请客户报价信息");
}
} }
/** /**

18
ruoyi-admin/src/main/java/com/ruoyi/system/controller/SysSalesOrderController.java

@ -25,6 +25,7 @@ import com.ruoyi.process.general.service.IProcessService;
import com.ruoyi.system.domain.*; import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.exportDto.SysSalesFinishDto; import com.ruoyi.system.domain.exportDto.SysSalesFinishDto;
import com.ruoyi.system.domain.exportDto.SysSalesOrderDto; import com.ruoyi.system.domain.exportDto.SysSalesOrderDto;
import com.ruoyi.system.mapper.SysSalesOrderMapper;
import com.ruoyi.system.service.*; import com.ruoyi.system.service.*;
import org.activiti.engine.RuntimeService; import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService; import org.activiti.engine.TaskService;
@ -85,6 +86,9 @@ public class SysSalesOrderController extends BaseController
@Autowired @Autowired
private ISysMakeOrderService sysMakeOrderService; private ISysMakeOrderService sysMakeOrderService;
@Autowired
private SysSalesOrderMapper sysSalesOrderMapper;
@RequiresPermissions("system:salesOrder:view") @RequiresPermissions("system:salesOrder:view")
@GetMapping() @GetMapping()
public String salesOrder(ModelMap mmap) public String salesOrder(ModelMap mmap)
@ -110,6 +114,14 @@ public class SysSalesOrderController extends BaseController
Set<String> roleKeys = roleService.selectRoleKeys(userId); Set<String> roleKeys = roleService.selectRoleKeys(userId);
List<SysUser> sysUserlist = sysUserService.selectRoleToUserList("ywyRole"); List<SysUser> sysUserlist = sysUserService.selectRoleToUserList("ywyRole");
sysUserlist.add(curUser); sysUserlist.add(curUser);
if (curUser.getUserName().contains("admin")) {
SysSalesOrderVo sysSalesOrderVo2 = new SysSalesOrderVo();
startPage();
List<SysSalesOrderVo> list2 = sysSalesOrderService.selectSysSalesOrderList(sysSalesOrderVo2);
return getDataTable(list2);
}
//如果主管审批,查看当前自己部门的审核
//如果经理审计需要查询自己部门下所有业务员的提交的订单,以及自身的提交的订单
if (roleKeys.contains("ywjlRole")) { if (roleKeys.contains("ywjlRole")) {
List<SysUser> findUser = sysUserlist.stream().filter(item -> (item.getDeptId().equals(curUser.getDeptId()))).collect(Collectors.toList()); List<SysUser> findUser = sysUserlist.stream().filter(item -> (item.getDeptId().equals(curUser.getDeptId()))).collect(Collectors.toList());
Set<String> user = findUser.stream().map(SysUser::getLoginName).collect(Collectors.toSet()); Set<String> user = findUser.stream().map(SysUser::getLoginName).collect(Collectors.toSet());
@ -119,10 +131,10 @@ public class SysSalesOrderController extends BaseController
} }
// 业务员角色只能看到自己创建的数据 // 业务员角色只能看到自己创建的数据
if (roleKeys.contains("ywyRole")) { if (roleKeys.contains("ywyRole")) {
sysSalesOrderVo.setApplyUser(curUser.getUserName()); sysSalesOrderVo.setApplyUser(curUser.getLoginName());
startPage(); startPage();
list = sysSalesOrderService.selectSysSalesOrderList(sysSalesOrderVo); List<SysSalesOrderVo> list2 = sysSalesOrderService.selectSysSalesOrderList(sysSalesOrderVo);
return getDataTable(list); return getDataTable(list2);
} }
return getDataTable(list); return getDataTable(list);
}catch(NullPointerException e){ }catch(NullPointerException e){

12
ruoyi-admin/src/main/java/com/ruoyi/system/domain/BaseExpenseAccount.java

@ -5,6 +5,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import java.util.List;
/** /**
* 报销单对象 base_emp_expense_account * 报销单对象 base_emp_expense_account
* *
@ -80,6 +82,16 @@ public class BaseExpenseAccount extends BaseEntity
private String del_flag; private String del_flag;
private List<BaseExpenseAccountChild> expenseAccountChildList;
public List<BaseExpenseAccountChild> getExpenseAccountChildList() {
return expenseAccountChildList;
}
public void setExpenseAccountChildList(List<BaseExpenseAccountChild> expenseAccountChildList) {
this.expenseAccountChildList = expenseAccountChildList;
}
public String getDel_flag() { public String getDel_flag() {
return del_flag; return del_flag;
} }

12
ruoyi-admin/src/main/resources/mapper/system/BaseExpenseAccountMapper.xml

@ -55,7 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<insert id="insertBaseExpenseAccount" parameterType="BaseExpenseAccount" useGeneratedKeys="true" keyProperty="expenseId"> <insert id="insertBaseExpenseAccount" parameterType="BaseExpenseAccount" useGeneratedKeys="true" keyProperty="expenseId">
insert into base_emp_expense_account insert into base_expense_account
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="auditStatus != null">audit_status,</if> <if test="auditStatus != null">audit_status,</if>
<if test="managerAuditStatus != null">manager_audit_status,</if> <if test="managerAuditStatus != null">manager_audit_status,</if>
@ -103,7 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</insert> </insert>
<update id="updateBaseExpenseAccount" parameterType="BaseExpenseAccount"> <update id="updateBaseExpenseAccount" parameterType="BaseExpenseAccount">
update base_emp_expense_account update base_expense_account
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="auditStatus != null">audit_status = #{auditStatus},</if> <if test="auditStatus != null">audit_status = #{auditStatus},</if>
<if test="managerAuditStatus != null">manager_audit_status = #{managerAuditStatus},</if> <if test="managerAuditStatus != null">manager_audit_status = #{managerAuditStatus},</if>
@ -130,22 +130,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<delete id="deleteBaseExpenseAccountById" parameterType="Long"> <delete id="deleteBaseExpenseAccountById" parameterType="Long">
delete from base_emp_expense_account where expense_id = #{expenseId} delete from base_expense_account where expense_id = #{expenseId}
</delete> </delete>
<delete id="deleteBaseExpenseAccountByIds" parameterType="String"> <delete id="deleteBaseExpenseAccountByIds" parameterType="String">
delete from base_emp_expense_account where expense_id in delete from base_expense_account where expense_id in
<foreach item="expenseId" collection="array" open="(" separator="," close=")"> <foreach item="expenseId" collection="array" open="(" separator="," close=")">
#{expenseId} #{expenseId}
</foreach> </foreach>
</delete> </delete>
<update id="cancelBaseExpenseAccountById" parameterType="Long"> <update id="cancelBaseExpenseAccountById" parameterType="Long">
update base_emp_expense_account set del_flag = '1' where expense_id = #{expenseId} update base_expense_account set del_flag = '1' where expense_id = #{expenseId}
</update> </update>
<update id="restoreBaseExpenseAccountById" parameterType="Long"> <update id="restoreBaseExpenseAccountById" parameterType="Long">
update base_emp_expense_account set del_flag = '0' where expense_id = #{expenseId} update base_expense_account set del_flag = '0' where expense_id = #{expenseId}
</update> </update>
</mapper> </mapper>

114
ruoyi-admin/src/main/resources/templates/system/baseExpense/add.html

@ -90,6 +90,9 @@
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "system/baseExpense" var prefix = ctx + "system/baseExpense"
$("#form-baseExpense-add").validate({focusCleanup: true}); $("#form-baseExpense-add").validate({focusCleanup: true});
var costTypeDatas = [[${@category.getChildByCode('costType')}]];
var $table = $("#bootstrap-sub-table-expense");
var costTypes;
$(function() { $(function() {
$.ajax({ $.ajax({
url: prefix + "/getId", url: prefix + "/getId",
@ -103,8 +106,9 @@
} }
} }
}); });
}) // 假设此函数返回供应商列表
var $table = $("#bootstrap-sub-table-expense");
});
//获取子表信息 //获取子表信息
$(function() { $(function() {
var options = { var options = {
@ -114,15 +118,23 @@
model: "报销单数据", model: "报销单数据",
columns: [ columns: [
{checkbox: true}, {checkbox: true},
{title: '主键',field: '',visible: false, {title: '主键',field: 'index',align: 'center',visible: false,
formatter: function (value, row, index) { formatter: function (value, row, index) {
return index; return index;
} }
}, },
{title: '报销单分项子表',field: 'expenseChildId',visible: false}, {title: '报销单分项子表',field: 'expenseChildId',visible: false},
{title: '关联报销单号',field: 'quoteId',visible: false}, {title: '关联报销单号',field: 'quoteId',visible: false},
{title: '成本类型',field: 'costType',}, {title: '成本类型',field: 'costType',
{title: '成本小类',field: 'costSmallType',}, formatter:function (value, row, index) {
return costTypeFormatter(value,row,index);
}
},
{title: '成本小类',field:'costSmallType',
formatter:function(value, row, index){
return getCostSmallType(value,row,index)
}
},
{title: '用途',field: 'purpose',editable:{type:'text',options:{maxlength:100}}}, {title: '用途',field: 'purpose',editable:{type:'text',options:{maxlength:100}}},
{title: '金额',field: 'amounts',editable: {type:'text',options:{maxlength:100}}}, {title: '金额',field: 'amounts',editable: {type:'text',options:{maxlength:100}}},
{title: '报销时间',field: 'expenseTime',editable:{type:'date'}}, {title: '报销时间',field: 'expenseTime',editable:{type:'date'}},
@ -132,7 +144,7 @@
{title: '操作', align: 'center', {title: '操作', align: 'center',
formatter: function (value, row, index) { formatter: function (value, row, index) {
var actions = []; var actions = [];
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.index + '\')"><i class="fa fa-remove"></i>删除</a> '); actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + index + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join(''); return actions.join('');
} }
} }
@ -145,31 +157,87 @@
index:1, index:1,
row: { row: {
expenseChildId:'', expenseChildId:'',
costType: "<select name='costType' class='form-control'>"+ "<option value=''>所有</option>" + "</select>", costType: "",
costSmallType:"<select name='costSmallType' class='form-control'>"+ "\"<option value=''>所有</option>\"" +"</select>", costSmallType:"",
purpose:'<input name="purpose" class="form-control" type="text">' , purpose:'' ,
amounts: '<input name="amounts" class="form-control" type="text">', amounts: '',
expenseTime: '<div class="input-group date">\n' + expenseTime: '',
'<input name="expenseTime" class="form-control" placeholder="yyyy-MM-dd" type="date"></div>', evectionCode:'' ,
evectionCode:'<input name="evectionCode" class="form-control" type="text">' , purcahseCode:'',
purcahseCode:'<input name="purcahseCode" class="form-control" type="text">', outsourceCode: '',
outsourceCode: '<input name="outsourceCode" class="form-control" type="text">',
} }
}) })
layer.close(index);
} }
/* 删除指定表格行 */ /* 删除指定表格行 */
function removeRow(id){ function removeRow(index){$table.bootstrapTable('remove', {field: 'index',values: index})};
$table.bootstrapTable('remove', {
field: 'id',
values: id
})
}
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
$.operate.save(prefix + "/add", $('#form-baseExpense-add').serialize()); var formData = $('#form-baseExpense-add').serializeArray();
var tableData = $table.bootstrapTable('getData');
var rows = tableData.length;
if(rows==0){
$.modal.alertWarning("子表数据不能为空!");
}else{
formData.push({"name": "expenseAccountChildList", "value": tableData});
var jsonData = $.common.formDataToJson(formData);
$.operate.saveJson(prefix + "/add", jsonData);
}
} }
} }
// 列中获取成本类型的下拉改变数据
function onCostTypeChange(selectElement, rowIndex) {
var newSupplierId = $(selectElement).val();
var tableData = $table.bootstrapTable('getData');
var newRow = tableData[rowIndex]; // 获取当前行数据
newRow.costType = newSupplierId; // 更新供应商ID
// 重新渲染成本小类的设备名称列
// 更新行数据
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow});
}
// 自定义供应商名称列的格式化函数
function costTypeFormatter(value, row, index) {
var selectHtml = '<select class="form-control" onchange="onCostTypeChange(this, ' + index + ')">';
costTypeDatas.forEach(function (child) {
selectHtml += '<option value="' + child.code + '"' + (value === child.code ? ' selected' : '') + '>' + child.name + '</option>';
});
selectHtml += '</select>';
return selectHtml;
}
// 自定义设备名称列的格式化函数,依赖于供应商列的选择
function getCostSmallType(value, row, index) {
var selectHtml = '<select class="form-control" onchange="onCostSmallTypeChange(this, ' + index + ')">';
// 假设此函数根据供应商ID返回设备列表
var costSamllTypes = [];
$.ajax({
url: ctx + 'system/category/getChildCode',
type: 'post',
data: {code: row.costType},
async: false,
success: function (result) {
console.log(result);
costSamllTypes = result;
}
});
if (costSamllTypes) {
costSamllTypes.forEach(function (child) {
selectHtml += '<option value="' + child.code + '"' + (value === child.code ? ' selected' : '') + '>' + child.name + '</option>';
});
selectHtml += '</select>';
return selectHtml;
}
}
function onCostSmallTypeChange(selectElement, rowIndex) {
var newCostSmallType = $(selectElement).val();
var tableData = $table.bootstrapTable('getData');
var newRow = tableData[rowIndex]; // 获取当前行数据
newRow.costSmallType = newCostSmallType;
// 重新渲染当前行的设备名称列
// 更新行数据
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow});
}
</script> </script>
</body> </body>
</html> </html>

8
ruoyi-admin/src/main/resources/templates/system/baseExpense/baseExpense.html

@ -54,13 +54,14 @@
</li> </li>
<li> <li>
<label>成本类型:</label> <label>成本类型:</label>
<select name="financeAuditStatus"> <select name="costType" th:with="childList=${@category.getChildByCode('costType')}">
<option value="">所有</option> <option value="">所有</option>
<option th:each="chilld: ${childList}" th:value="${chilld.code}" th:text="${chilld.name}"></option>
</select> </select>
</li> </li>
<li> <li>
<label>成本小类:</label> <label>成本小类:</label>
<select name="financeAuditStatus"> <select name="costSamllType">
<option value="">所有</option> <option value="">所有</option>
</select> </select>
</li> </li>
@ -99,13 +100,14 @@
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<script th:inline="javascript"> <script th:inline="javascript">
var costTypeDatas = [[${@category.getChildByCode('costType')}]];
var editFlag = [[${@permission.hasPermi('system:baseExpense:edit')}]]; var editFlag = [[${@permission.hasPermi('system:baseExpense:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:baseExpense:remove')}]]; var removeFlag = [[${@permission.hasPermi('system:baseExpense:remove')}]];
var cancelFlag = [[${@permission.hasPermi('system:baseExpense:cancel')}]]; var cancelFlag = [[${@permission.hasPermi('system:baseExpense:cancel')}]];
var restoreFlag = [[${@permission.hasPermi('system:baseExpense:restore')}]]; var restoreFlag = [[${@permission.hasPermi('system:baseExpense:restore')}]];
var prefix = ctx + "system/baseExpense"; var prefix = ctx + "system/baseExpense";
$(function() { $(function() {
var costTypeDatas = [[${@category.getChildByCode('costType')}]];
var options = { var options = {
url: prefix + "/list", url: prefix + "/list",
createUrl: prefix + "/add", createUrl: prefix + "/add",

114
ruoyi-admin/src/main/resources/templates/system/baseExpense/edit.html

@ -37,7 +37,6 @@
<input name="expenseMethod" th:field="*{expenseMethod}" class="form-control" type="text"> <input name="expenseMethod" th:field="*{expenseMethod}" class="form-control" type="text">
</div> </div>
</div> </div>
<div class="form-row" id="expanseType">
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">供应商ID:</label> <label class="col-sm-3 control-label">供应商ID:</label>
<div class="col-sm-8"> <div class="col-sm-8">
@ -69,9 +68,6 @@
<input name="publicAccountBanks" th:field="*{publicAccountBanks}" class="form-control" type="text"> <input name="publicAccountBanks" th:field="*{publicAccountBanks}" class="form-control" type="text">
</div> </div>
</div> </div>
</div>
</form> </form>
<div class="container"> <div class="container">
<div class="form-row"> <div class="form-row">
@ -90,6 +86,7 @@
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "system/baseExpense" var prefix = ctx + "system/baseExpense"
var costTypeDatas = [[${@category.getChildByCode('costType')}]];
$("#form-baseExpense-add").validate({focusCleanup: true}); $("#form-baseExpense-add").validate({focusCleanup: true});
$(function(){ $(function(){
$.ajax({ $.ajax({
@ -128,8 +125,16 @@
}, },
{title: '报销单分项子表',field: 'expenseChildId',visible: false}, {title: '报销单分项子表',field: 'expenseChildId',visible: false},
{title: '关联报销单号',field: 'quoteId',visible: false}, {title: '关联报销单号',field: 'quoteId',visible: false},
{title: '成本类型',field: 'costType',}, {title: '成本类型',field: 'costType',
{title: '成本小类',field: 'costSmallType',}, formatter:function (value, row, index) {
return costTypeFormatter(value,row,index);
}
},
{title: '成本小类',field: 'costSmallType',
formatter:function(value, row, index){
return getCostSmallType(value,row,index)
}
},
{title: '用途',field: 'purpose',editable:{type:'text',options:{maxlength:100}}}, {title: '用途',field: 'purpose',editable:{type:'text',options:{maxlength:100}}},
{title: '金额',field: 'amounts',editable: {type:'text',options:{maxlength:100}}}, {title: '金额',field: 'amounts',editable: {type:'text',options:{maxlength:100}}},
{title: '报销时间',field: 'expenseTime',editable:{type:'date'}}, {title: '报销时间',field: 'expenseTime',editable:{type:'date'}},
@ -152,15 +157,14 @@
index:1, index:1,
row: { row: {
expenseChildId:'', expenseChildId:'',
costType: "<select name='costType' class='form-control'>"+ "<option value=''>所有</option>" + "</select>", costType: "",
costSmallType:"<select name='costSmallType' class='form-control'>"+ "\"<option value=''>所有</option>\"" +"</select>", costSmallType:"",
purpose:'<input name="purpose" class="form-control" type="text">' , purpose:'' ,
amounts: '<input name="amounts" class="form-control" type="text">', amounts: '',
expenseTime: '<div class="input-group date">\n' + expenseTime: '',
'<input name="expenseTime" class="form-control" placeholder="yyyy-MM-dd" type="date"></div>', evectionCode:'' ,
evectionCode:'<input name="evectionCode" class="form-control" type="text">' , purcahseCode:'',
purcahseCode:'<input name="purcahseCode" class="form-control" type="text">', outsourceCode: '',
outsourceCode: '<input name="outsourceCode" class="form-control" type="text">',
} }
}) })
layer.close(index); layer.close(index);
@ -175,9 +179,87 @@
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-baseExpense-edit').serialize()); var formData = $('#form-baseExpense-edit').serializeArray();
var tableData = $table.bootstrapTable('getData');
var rows = tableData.length;
if(rows==0){
$.modal.alertWarning("子表数据不能为空!");
}else{
formData.push({"name": "expenseAccountChildList", "value": tableData});
var jsonData = $.common.formDataToJson(formData);
$.operate.saveJson(prefix + "/edit", jsonData);
}
}
}
function submitHandler() {
if ($.validate.form()) {
var formData = $('#form-baseExpense-add').serializeArray();
var tableData = $table.bootstrapTable('getData');
var rows = tableData.length;
if(rows==0){
$.modal.alertWarning("子表数据不能为空!");
}else{
formData.push({"name": "expenseAccountChildList", "value": tableData});
var jsonData = $.common.formDataToJson(formData);
$.operate.saveJson(prefix + "/add", jsonData);
}
}
}
// 列中获取成本类型的下拉改变数据
function onCostTypeChange(selectElement, rowIndex) {
var newSupplierId = $(selectElement).val();
var tableData = $table.bootstrapTable('getData');
var newRow = tableData[rowIndex]; // 获取当前行数据
newRow.costType = newSupplierId; // 更新供应商ID
// 重新渲染成本小类的设备名称列
// 更新行数据
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow});
}
// 自定义供应商名称列的格式化函数
function costTypeFormatter(value, row, index) {
var selectHtml = '<select class="form-control" onchange="onCostTypeChange(this, ' + index + ')">';
costTypeDatas.forEach(function (child) {
selectHtml += '<option value="' + child.code + '"' + (value === child.code ? ' selected' : '') + '>' + child.name + '</option>' ;
});
selectHtml += '</select>';
return selectHtml;
}
// 自定义设备名称列的格式化函数,依赖于供应商列的选择
function getCostSmallType(value, row, index) {
var selectHtml = '<select class="form-control" onchange="onCostSmallTypeChange(this, ' + index + ')">';
// 假设此函数根据供应商ID返回设备列表
var costSamllTypes = [];
$.ajax({
url: ctx + 'system/category/getChildCode',
type: 'post',
data: {code: row.costType},
async: false,
success: function (result) {
console.log(result);
costSamllTypes = result;
}
});
if (costSamllTypes) {
costSamllTypes.forEach(function (child) {
selectHtml += '<option value="' + child.code + '"' + (value === child.code ? ' selected' : '') + '>' + child.name + '</option>';
});
selectHtml += '</select>';
return selectHtml;
} }
} }
function onCostSmallTypeChange(selectElement, rowIndex) {
var newCostSmallType = $(selectElement).val();
var tableData = $table.bootstrapTable('getData');
var newRow = tableData[rowIndex]; // 获取当前行数据
newRow.costSmallType = newCostSmallType;
// 重新渲染当前行的设备名称列
// 更新行数据
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow});
}
</script> </script>
</body> </body>
</html> </html>

71
ruoyi-admin/src/main/resources/templates/system/baseExpenseChild/baseExpenseChild.html

@ -17,8 +17,7 @@
<li> <li>
<label>成本类型:</label> <label>成本类型:</label>
<select name="cost type"> <select name="cost type">
<option value="">所有</option> <option value="" th:with="">所有</option>
<option value="-1">代码生成请选择字典属性</option>
</select> </select>
</li> </li>
<li> <li>
@ -92,57 +91,20 @@
restoreUrl: prefix + "/restore/{id}", restoreUrl: prefix + "/restore/{id}",
exportUrl: prefix + "/export", exportUrl: prefix + "/export",
modalName: "报销单分类子", modalName: "报销单分类子",
columns: [{ columns: [
checkbox: true {checkbox: true},
}, {title: '报销单分项子表',field: 'expenseChildId',visible: false},
{ {title: '关联报销单号',field: 'quoteId',},
title: '报销单分项子表', {title: '成本类型',field: 'cosType',},
field: 'expenseChildId', {title: '成本小类',field: 'costSmallType',},
visible: false {title: '用途',field: 'purpose',},
}, {title: '金额',field: 'amounts',},
{ {title: '报销时间',field: 'expenseTime',},
title: '关联报销单号', {title: '出差单号',field: 'evectionCode',},
field: 'quoteId', {title: '采购单号',field: 'purcahseCode',},
}, {title: '委外单号',field: 'outsourceCode',},
{ {title: '备注',field: 'remark',},
title: '成本类型', {title: '操作',align: 'center',
field: 'cost type',
},
{
title: '成本小类',
field: 'costSmallType',
},
{
title: '用途',
field: 'purpose',
},
{
title: '金额',
field: 'amounts',
},
{
title: '报销时间',
field: 'expenseTime',
},
{
title: '出差单号',
field: 'evectionCode',
},
{
title: '采购单号',
field: 'purcahseCode',
},
{
title: '委外单号',
field: 'outsourceCode',
},
{
title: '备注',
field: 'remark',
},
{
title: '操作',
align: 'center',
formatter: function(value, row, index) { formatter: function(value, row, index) {
var actions = []; var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.expenseChildId + '\')"><i class="fa fa-edit"></i>编辑</a> '); actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.expenseChildId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
@ -154,7 +116,8 @@
} }
return actions.join(''); return actions.join('');
} }
}] }
]
}; };
$.table.init(options); $.table.init(options);
}); });

Loading…
Cancel
Save