新增报销关联项目功能,优化任务选择关联项目的操作。
This commit is contained in:
parent
408f3384fe
commit
2dd16db21c
@ -63,6 +63,12 @@ class Expense extends Model
|
||||
}
|
||||
else{
|
||||
$expense['pay_time'] = '-';
|
||||
}
|
||||
if ($expense['ptid'] > 0) {
|
||||
$expense['ptname'] = Db::name('Project')->where(['id' => $expense['ptid']])->value('name');
|
||||
}
|
||||
else{
|
||||
$expense['ptname'] = '';
|
||||
}
|
||||
$expense['list'] = Db::name('ExpenseInterfix')
|
||||
->field('a.*,c.title as cate_title')
|
||||
|
@ -41,6 +41,13 @@
|
||||
<input type="text" class="layui-input" id="income_month" name="income_month" lay-verify="required" placeholder="请选择入账月份" lay-reqText="请选择入账月份" readonly value="">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">关联的项目</td>
|
||||
<td colspan="5">
|
||||
<input type="text" class="layui-input project-picker" name="ptname" placeholder="请选择需要关联的项目" readonly value="">
|
||||
<input type="hidden" class="layui-input" name="ptid" value="0">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">报销选项<font>*</font></td>
|
||||
<td colspan="5">
|
||||
@ -124,6 +131,13 @@
|
||||
<input type="text" class="layui-input" id="income_month" name="income_month" lay-verify="required" placeholder="请选择入账月份" lay-reqText="请选择入账月份" readonly value="{$expense.income_month}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">关联的项目</td>
|
||||
<td colspan="5">
|
||||
<input type="text" class="layui-input project-picker" name="ptname" placeholder="请选择需要关联的项目" readonly value="{$expense.ptname}">
|
||||
<input type="hidden" class="layui-input" name="ptid" value="{$expense.ptid}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="layui-td-gray">报销选项<font>*</font></td>
|
||||
<td colspan="5">
|
||||
@ -242,11 +256,7 @@ Array.prototype.remove = function (val) {
|
||||
|
||||
const moduleInit = ['tool','employeepicker'];
|
||||
function gouguInit() {
|
||||
var form = layui.form,
|
||||
upload = layui.upload,
|
||||
tool=layui.tool,
|
||||
employeepicker = layui.employeepicker,
|
||||
laydate = layui.laydate;
|
||||
var form = layui.form,upload = layui.upload,tool=layui.tool,table=layui.table,employeepicker = layui.employeepicker,laydate = layui.laydate;
|
||||
|
||||
laydate.render({
|
||||
elem: '#income_month',
|
||||
@ -305,6 +315,58 @@ const moduleInit = ['tool','employeepicker'];
|
||||
}
|
||||
});
|
||||
|
||||
//选择关联项目
|
||||
$('.project-picker').on('click', function () {
|
||||
selectProject();
|
||||
});
|
||||
var projectTable;
|
||||
function selectProject() {
|
||||
layer.open({
|
||||
title: '选择项目',
|
||||
area: ['600px', '580px'],
|
||||
type: 1,
|
||||
content: '<div class="picker-table">\
|
||||
<form class="layui-form pb-2">\
|
||||
<div class="layui-input-inline" style="width:480px;">\
|
||||
<input type="text" name="keywords" placeholder="项目名称" class="layui-input" autocomplete="off" />\
|
||||
</div>\
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_form">提交搜索</button>\
|
||||
</form>\
|
||||
<div id="projectTable"></div></div>',
|
||||
success: function () {
|
||||
projectTable = table.render({
|
||||
elem: '#projectTable'
|
||||
, url: '/project/api/get_project'
|
||||
, page: true //开启分页
|
||||
, limit: 10
|
||||
, cols: [[
|
||||
{ type: 'radio', title: '选择' }
|
||||
, { field: 'id', width: 100, title: '编号', align: 'center' }
|
||||
, { field: 'title', title: '项目名称' }
|
||||
]]
|
||||
});
|
||||
},
|
||||
btn: ['确定'],
|
||||
yes: function () {
|
||||
var checkStatus = table.checkStatus(projectTable.config.id);
|
||||
var data = checkStatus.data;
|
||||
if (data.length > 0) {
|
||||
$('[name="ptname"]').val(data[0].title);
|
||||
$('[name="ptid"]').val(data[0].id);
|
||||
layer.closeAll();
|
||||
}
|
||||
else {
|
||||
layer.msg('请先选择项目');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//项目搜索提交
|
||||
form.on('submit(search_form)', function (data) {
|
||||
projectTable.reload({ where: { keywords: data.field.keywords }, page: { curr: 1 } });
|
||||
return false;
|
||||
});
|
||||
|
||||
//监听提交
|
||||
form.on('submit(webform)', function(data){
|
||||
|
@ -66,6 +66,12 @@
|
||||
<td class="layui-td-gray-2">原始单据日期</td>
|
||||
<td>{$detail.expense_time}</td>
|
||||
</tr>
|
||||
{if condition="$detail.ptid > 0"}
|
||||
<tr>
|
||||
<td class="layui-td-gray">关联的项目</td>
|
||||
<td colspan="5">{$detail.ptname}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td class="layui-td-gray">报销人</td>
|
||||
<td>{$detail.create_user}</td>
|
||||
|
@ -522,10 +522,24 @@ class Api extends BaseController
|
||||
//获取项目列表
|
||||
public function get_project()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['delete_time', '=', 0];
|
||||
$project = Db::name('Project')->field('id,name as title')->where($where)->select();
|
||||
return to_assign(0, '', $project);
|
||||
$param = get_params();
|
||||
$project_ids = Db::name('ProjectUser')->where(['uid' => $this->uid, 'delete_time' => 0])->column('project_id');
|
||||
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
|
||||
|
||||
$auth = isAuth($this->uid,'contract_admin');
|
||||
$where = [];
|
||||
$where[] = ['delete_time', '=', 0];
|
||||
if(isset($param['keywords'])){
|
||||
$where[] = ['name', 'like', '%'.$param['keywords'].'%'];
|
||||
}
|
||||
if($auth == 0){
|
||||
$where[] = ['id', 'in', $project_ids];
|
||||
}
|
||||
$list = ProjectList::field('id,name as title')
|
||||
->where($where)
|
||||
->order('id desc')
|
||||
->paginate($rows, false, ['query' => $param]);
|
||||
return table_assign(0, '', $list);
|
||||
}
|
||||
|
||||
//编辑阶段
|
||||
|
@ -370,12 +370,7 @@
|
||||
}
|
||||
if (name == "project_id") {
|
||||
if (admin_id == login_user) {
|
||||
loading = true;
|
||||
tool.get("/project/api/get_project", {}, function (res) {
|
||||
let data = res.data;
|
||||
loading = false;
|
||||
edit.dropdown(id, name, real_txt, data, editPost, 1);
|
||||
});
|
||||
edit.select_table(id, name, real_txt, "/project/api/get_project", editPost, 1);
|
||||
} else {
|
||||
layer.msg('您没权限修改,请联系创建人或负责人修改');
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
layui.define(['tool','employeepicker','tinymce'], function (exports) {
|
||||
const table = layui.table;
|
||||
const laydate = layui.laydate;
|
||||
const dropdown = layui.dropdown;
|
||||
const employeepicker = layui.employeepicker;
|
||||
const tinymce = layui.tinymce;
|
||||
const obj = {
|
||||
let form = layui.form;
|
||||
let table = layui.table;
|
||||
let laydate = layui.laydate;
|
||||
let dropdown = layui.dropdown;
|
||||
let employeepicker = layui.employeepicker;
|
||||
let tinymce = layui.tinymce;
|
||||
let obj = {
|
||||
//文本
|
||||
text: function (id, name, real_txt, editPost) {
|
||||
let that = this;
|
||||
@ -79,6 +80,54 @@ layui.define(['tool','employeepicker','tinymce'], function (exports) {
|
||||
}
|
||||
});
|
||||
},
|
||||
//ajax表格单选
|
||||
select_table: function (id, name, real_val, url, editPost) {
|
||||
let that = this;
|
||||
let selectTable;
|
||||
layer.open({
|
||||
title: '请选择',
|
||||
area: ['600px', '580px'],
|
||||
type: 1,
|
||||
content: '<div class="picker-table">\
|
||||
<form class="layui-form pb-2">\
|
||||
<div class="layui-input-inline" style="width:480px;">\
|
||||
<input type="text" name="keywords" placeholder="项目名称" class="layui-input" autocomplete="off" />\
|
||||
</div>\
|
||||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="search_form">提交搜索</button>\
|
||||
</form>\
|
||||
<div id="selectTable"></div></div>',
|
||||
success: function () {
|
||||
selectTable = table.render({
|
||||
elem: '#selectTable'
|
||||
, url: url
|
||||
, page: true //开启分页
|
||||
, limit: 10
|
||||
, cols: [[
|
||||
{ type: 'radio', title: '选择' }
|
||||
, { field: 'id', width: 100, title: '编号', align: 'center' }
|
||||
, { field: 'title', title: '项目名称' }
|
||||
]]
|
||||
});
|
||||
//项目搜索提交
|
||||
form.on('submit(search_form)', function (data) {
|
||||
selectTable.reload({ where: { keywords: data.field.keywords }, page: { curr: 1 } });
|
||||
return false;
|
||||
});
|
||||
},
|
||||
btn: ['确定'],
|
||||
yes: function () {
|
||||
var checkStatus = table.checkStatus(selectTable.config.id);
|
||||
var data = checkStatus.data;
|
||||
if (data.length > 0) {
|
||||
editPost(id, name, data[0].title, data[0].id);
|
||||
}
|
||||
else {
|
||||
layer.msg('请选择');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//表格单选
|
||||
select_type: function (id, name, real_val, data, editPost) {
|
||||
let that = this;
|
||||
|
Loading…
x
Reference in New Issue
Block a user