|
|
@@ -3,20 +3,43 @@ const table = '#table',
|
|
|
console.log(project_id)
|
|
|
const nav_tab_template = `
|
|
|
<li class="nav-item" data-id="{0}">
|
|
|
- <a class="nav-link btn btn-active-light btn-color-gray-600 btn-active-color-primary {2} rounded-bottom-0" data-bs-toggle="tab" href="#iwb_tab_{0}">{1}</a>
|
|
|
+ <button type="button" class="nav-link {2} btn-light-primary btn-active-color-primary" data-id="{0}" data-bs-toggle="tab" data-bs-target="#iwb_tab_{0}">{1}</button>
|
|
|
</li>`,
|
|
|
- tab_content_template = `<div class="tab-pane fade show active" id="iwb_tab_{0}" role="tabpanel">{1}</div>`,
|
|
|
+ tab_content_template = `<div class="tab-pane h-100 fade" id="iwb_tab_{0}" role="tabpanel">{1}</div>`,
|
|
|
table_template = `
|
|
|
-<div class="d-flex flex-row h-100">
|
|
|
- <div class="w-200px flex-row-auto left-box border-left-1 border-gray-500">
|
|
|
- <div class="tree-dom"></div>
|
|
|
+<div class="d-flex flex-row h-100 project-box">
|
|
|
+ <div class="flex-row-auto h-100 left-box">
|
|
|
+ <div class="tree-dom h-100 overflow-auto" id="js-tree_{0}"></div>
|
|
|
</div>
|
|
|
<div class="flex-row-fluid right-box">
|
|
|
- <div class="table-box table-responsive" id="table_{0}">
|
|
|
- <div class="d-flex justify-content-between mb-5 mx-10">
|
|
|
- <div></div>
|
|
|
+ <div class="table-box table-responsive" id="table_box_{0}" style="display: none">
|
|
|
+ <section class="d-none">
|
|
|
+ <input type="hidden" name="budget_id" value="{0}">
|
|
|
+ <input type="hidden" name="project_id" value="">
|
|
|
+ <input type="hidden" name="item_id" value="">
|
|
|
+ <input type="hidden" name="item_code" value="">
|
|
|
+ </section>
|
|
|
+ <span class="my-3 fs-3 table-title mt-5"><span class="fw-bolder me-5 title"></span><span class="badge badge-primary">定额任务列表</span></span>
|
|
|
+ <div class="d-flex justify-content-between my-5">
|
|
|
+ <div>
|
|
|
+ <button type="button" class="btn btn-primary btn-sm" onclick="Add('{0}')">添加任务</button>
|
|
|
+ </div>
|
|
|
<form class="search-box d-flex">
|
|
|
<div class="d-flex">
|
|
|
+ <select class="form-select form-select-sm me-5" name="process_status">
|
|
|
+ <option value="">全部处理状态</option>
|
|
|
+ <option value="0">未处理</option>
|
|
|
+ <option value="1">处理中</option>
|
|
|
+ <option value="2">已处理</option>
|
|
|
+ <option value="3">处理失败</option>
|
|
|
+ </select>
|
|
|
+ <select class="form-select form-select-sm me-5" name="send_status">
|
|
|
+ <option value="">全部发送状态</option>
|
|
|
+ <option value="0">未发送</option>
|
|
|
+ <option value="1">发送中</option>
|
|
|
+ <option value="2">已发送</option>
|
|
|
+ <option value="3">发送失败</option>
|
|
|
+ </select>
|
|
|
<input type="text" class="form-control form-control-sm w-200px" placeholder="请输入关键字" name="keyword" />
|
|
|
</div>
|
|
|
<div class="btn-group ms-5">
|
|
|
@@ -25,47 +48,58 @@ const nav_tab_template = `
|
|
|
</div>
|
|
|
</form>
|
|
|
</div>
|
|
|
- <table class="table table-striped table-bordered table-hover table-rounded" id="table">
|
|
|
+ <table class="table table-striped table-bordered table-hover table-rounded" id="table_{0}">
|
|
|
</table>
|
|
|
<div class="pagination-row"></div>
|
|
|
- </div>
|
|
|
+ </section>
|
|
|
</div>
|
|
|
</div>`
|
|
|
|
|
|
$(function () {
|
|
|
GetBudgetInfo()
|
|
|
+ // setTimeout(function () {GetBudgetItems(1)},1000)
|
|
|
})
|
|
|
|
|
|
function GetBudgetInfo() {
|
|
|
IwbAjax_1({
|
|
|
url: `/api/project/budget/${project_id}`,
|
|
|
success: function (res) {
|
|
|
- console.log(res)
|
|
|
if (res.success) {
|
|
|
- let str1 = '',
|
|
|
- str2 = '',
|
|
|
- first_id = ''
|
|
|
- for (let i = 0; i < res.data.length; i++) {
|
|
|
- const item = res.data[i]
|
|
|
- let active = ''
|
|
|
- if (i === 0) {
|
|
|
- first_id = item.budget_id
|
|
|
- active = 'active'
|
|
|
- }
|
|
|
- str1 += nav_tab_template.format(item.budget_id, item.budget_code, active)
|
|
|
- str2 += tab_content_template.format(item.budget_id, table_template.format(item.budget_id))
|
|
|
- }
|
|
|
- $('#nav_tab').html(str1)
|
|
|
- $('#tab_content').html(str2)
|
|
|
- GetBudgetItems(first_id)
|
|
|
+ RenderTabs(res.data)
|
|
|
+ }else{
|
|
|
+ console.error(res.message)
|
|
|
}
|
|
|
},
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+function RenderTabs(data){
|
|
|
+ console.log('RenderTabs', data)
|
|
|
+ let str1 = '',
|
|
|
+ str2 = ''
|
|
|
+ if(data && data.length){
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ const item = data[i]
|
|
|
+ str1 += nav_tab_template.format(item.budget_id, item.budget_code)
|
|
|
+ str2 += tab_content_template.format(item.budget_id, table_template.format(item.budget_id))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#nav_tab').html(str1)
|
|
|
+ const h= $('.app-main .app-container').height() - $('#nav_tab').height() - $('#breadcrumb_header').height()
|
|
|
+ $('#tab_content').html(str2).height(h)
|
|
|
+ const $tab = $('#nav_tab li button[data-bs-toggle="tab"]')
|
|
|
+ $tab.on('shown.bs.tab',(e)=>{
|
|
|
+ console.log('TAB', e)
|
|
|
+ const tab_id = $(e.target).data('id')
|
|
|
+ GetBudgetItems(tab_id)
|
|
|
+ })
|
|
|
+ const firstTab = new bootstrap.Tab($tab.eq(0))
|
|
|
+ firstTab.show()
|
|
|
+}
|
|
|
+
|
|
|
function GetBudgetItems(id) {
|
|
|
- console.log('GetBudgetItems', id)
|
|
|
- const $tree = $(`#iwb_tab_${id} .tree-dom`)
|
|
|
+ const $tree = $(`#js-tree_${id}`)
|
|
|
+ // console.log('GetBudgetItems', id,$tree)
|
|
|
const opt = {
|
|
|
core: {
|
|
|
themes: {
|
|
|
@@ -73,7 +107,7 @@ function GetBudgetItems(id) {
|
|
|
},
|
|
|
check_callback: true,
|
|
|
data: function (node, callback) {
|
|
|
- console.log('TREE_NODE', node)
|
|
|
+ // console.log('TREE_NODE', node)
|
|
|
IwbAjax_1({
|
|
|
url: `/api/project/budget-item/${id}/${project_id}?c=${node?.data?.item_code || ''}`,
|
|
|
success: res => {
|
|
|
@@ -97,6 +131,270 @@ function GetBudgetItems(id) {
|
|
|
},
|
|
|
plugins: ['dnd', 'types'],
|
|
|
}
|
|
|
- $tree.jstree('destroy')
|
|
|
+ // $tree.jstree('destroy')
|
|
|
+ $tree.on('loaded.jstree', function(e, data){
|
|
|
+ // console.log('TREE_LOADED', e, data)
|
|
|
+ const inst = data.instance;
|
|
|
+ const obj = inst.get_node(e.target.firstChild.firstChild.firstChild);
|
|
|
+ inst.select_node(obj);
|
|
|
+ })
|
|
|
+ $tree.on('select_node.jstree', function (e, data) {
|
|
|
+ console.log('TREE_SELECTED', e, data)
|
|
|
+ RenderTabCondent(data.node?.data)
|
|
|
+ })
|
|
|
$tree.jstree(opt)
|
|
|
}
|
|
|
+
|
|
|
+function RenderTabCondent(data) {
|
|
|
+ // console.log('RenderTabCondent', data)
|
|
|
+ if(data.chapter){
|
|
|
+ const $tableBox = $(`#table_box_${data.budget_id}`),
|
|
|
+ $table = $(`#table_${data.budget_id}`)
|
|
|
+ $tableBox.find('.table-title .title').text(`${data.chapter}、${data.project_name}`)
|
|
|
+ $tableBox.show()
|
|
|
+ $tableBox.find('input[name="budget_id"]').val(data.budget_id);
|
|
|
+ $tableBox.find('input[name="project_id"]').val(project_id);
|
|
|
+ $tableBox.find('input[name="item_id"]').val(data.item_id);
|
|
|
+ $tableBox.find('input[name="item_code"]').val(data.item_code);
|
|
|
+
|
|
|
+ IwbTable($table, {
|
|
|
+ url: `/api/task/list/${data.budget_id}/${project_id}/${data.item_id}`,
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ title: '任务编号',
|
|
|
+ data: 'id',
|
|
|
+ width: '100px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '任务名称',
|
|
|
+ data: 'task_name',
|
|
|
+ width: '240px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '文件数据',
|
|
|
+ data: 'file_data',
|
|
|
+ width: 'auto',
|
|
|
+ render: (row) => {
|
|
|
+ let str = ``
|
|
|
+ const file_paths = row.file_path ? row.file_path.split(',') : []
|
|
|
+ if(file_paths.length){
|
|
|
+ for (let i = 0; i < file_paths.length; i++) {
|
|
|
+ const path = file_paths[i]
|
|
|
+ const names = path.split('/')
|
|
|
+ const file_name = names[names.length - 1]
|
|
|
+ str += `<a href="#" onclick="DownloadFile('/api/task/download?filename=${encodeURIComponent(path)}','${file_name}')" class="link link-info px-2">${file_name}</a>`
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ str ="-"
|
|
|
+ }
|
|
|
+ return str
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '任务状态',
|
|
|
+ data: 'task_status',
|
|
|
+ width: '220px',
|
|
|
+ render: (row) => {
|
|
|
+ let str = ``
|
|
|
+ if (row.collect_status === 0) {
|
|
|
+ str += `<span class="badge badge-light-primary">未采集</span>`
|
|
|
+ } else if (row.collect_status === 1){
|
|
|
+ str += `<span class="badge badge-light-warning">采集中</span>`
|
|
|
+ } else if (row.collect_status === 2){
|
|
|
+ str += `<span class="badge badge-light-success">采集完成</span>`
|
|
|
+ if (row.process_status === 0) {
|
|
|
+ str += `<span class="badge badge-light-primary">未处理</span>`
|
|
|
+ } else if (row.process_status === 1){
|
|
|
+ str += `<span class="badge badge-light-warning">处理中</span>`
|
|
|
+ } else if (row.process_status === 2){
|
|
|
+ str += `<span class="badge badge-light-success">已处理</span>`
|
|
|
+ if (row.send_status === 0) {
|
|
|
+ str += `<span class="badge badge-light-primary">未发送</span>`
|
|
|
+ } else if (row.send_status === 1){
|
|
|
+ str += `<span class="badge badge-light-warning">发送中</span>`
|
|
|
+ } else if (row.send_status === 2){
|
|
|
+ str += `<span class="badge badge-light-success">已发送</span>`
|
|
|
+ } else if (row.send_status === 3){
|
|
|
+ str += `<span class="badge badge-light-danger">发送失败</span>`
|
|
|
+ }
|
|
|
+ } else if (row.process_status === 3){
|
|
|
+ str += `<span class="badge badge-light-danger">处理失败</span>`
|
|
|
+ }
|
|
|
+ } else if (row.collect_status === 3){
|
|
|
+ str += `<span class="badge badge-light-danger">采集失败</span>`
|
|
|
+ }
|
|
|
+
|
|
|
+ return str
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ data: 'id',
|
|
|
+ width: '160px',
|
|
|
+ render: (row) => {
|
|
|
+ let str = ``
|
|
|
+ str += `<button type="button" class="btn btn-primary btn-sm" data-kt-menu="true" data-kt-menu-trigger="click" data-kt-menu-placement="bottom-end" data-kt-menu-flip="top-end">
|
|
|
+ 操作
|
|
|
+ <span class="svg-icon fs-5 m-0">
|
|
|
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="24px" height="24px" viewBox="0 0 24 24" version="1.1">
|
|
|
+ <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
|
+ <polygon points="0 0 24 0 24 24 0 24"></polygon>
|
|
|
+ <path d="M6.70710678,15.7071068 C6.31658249,16.0976311 5.68341751,16.0976311 5.29289322,15.7071068 C4.90236893,15.3165825 4.90236893,14.6834175 5.29289322,14.2928932 L11.2928932,8.29289322 C11.6714722,7.91431428 12.2810586,7.90106866 12.6757246,8.26284586 L18.6757246,13.7628459 C19.0828436,14.1360383 19.1103465,14.7686056 18.7371541,15.1757246 C18.3639617,15.5828436 17.7313944,15.6103465 17.3242754,15.2371541 L12.0300757,10.3841378 L6.70710678,15.7071068 Z" fill="currentColor" fill-rule="nonzero" transform="translate(12.000003, 11.999999) rotate(-180.000000) translate(-12.000003, -11.999999)"></path>
|
|
|
+ </g>
|
|
|
+ </svg>
|
|
|
+ </span>
|
|
|
+ </button>
|
|
|
+ <div class="menu menu-sub menu-sub-dropdown menu-column menu-rounded menu-gray-600 menu-state-bg-light-primary fw-bold fs-7 w-125px px-3 py-1" data-kt-menu="true">
|
|
|
+ `
|
|
|
+ const template = `<div class="menu-item py-1 px-1"><button type="button" class="btn btn-sm btn-light-{0} w-100" onclick="{1}(${row.id},${data.budget_id})">{2}</button></div>`
|
|
|
+ if (row.collect_status === 0) {
|
|
|
+ str += template.format('primary', 'StartCollect', '开始采集')
|
|
|
+ } else if (row.collect_status === 2) {
|
|
|
+ str += template.format('warning', 'ReStartCollect', '重新采集')
|
|
|
+ if (row.process_status === 0) {
|
|
|
+ str += template.format('primary', 'StartProcess', '开始处理')
|
|
|
+ } else if (row.process_status === 2) {
|
|
|
+ str += template.format('warning', 'ReStartProcess', '重新处理')
|
|
|
+ if (row.send_status === 0) {
|
|
|
+ str += template.format('primary', 'StartSend', '开始发送')
|
|
|
+ } else if (row.send_status === 2) {
|
|
|
+ str += template.format('warning', 'ReStartSend', '重新发送')
|
|
|
+ } else if (row.send_status === 3) {
|
|
|
+ str += template.format('danger', 'ReStartSend', '重新发送')
|
|
|
+ }
|
|
|
+ } else if (row.process_status === 3) {
|
|
|
+ str += template.format('danger', 'ReStartProcess', '重新处理')
|
|
|
+ }
|
|
|
+ } else if (row.collect_status === 3) {
|
|
|
+ str += template.format('danger', 'ReStartCollect', '重新采集')
|
|
|
+ }
|
|
|
+ str += template.format('primary', 'Edit', '编辑')
|
|
|
+ str += template.format('danger', 'Delete', '删除')
|
|
|
+ // if (row.collect_status === 0) {
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-primary" onclick="StartCollect(${row.id}, ${data.budget_id})">开始任务</button>`
|
|
|
+ // } else if (row.collect_status === 2) {
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-warning" onclick="ReStartCollect(${row.id}, ${data.budget_id})">重新采集</button>`
|
|
|
+ // if (row.process_status === 0) {
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-primary" onclick="StartProcess(${row.id}, ${data.budget_id})">开始处理</button>`
|
|
|
+ // } else if (row.process_status === 2) {
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-warning" onclick="ReStartProcess(${row.id}, ${data.budget_id})">重新处理</button>`
|
|
|
+ // if (row.send_status === 0) {
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-primary" onclick="StartSend(${row.id}, ${data.budget_id})">开始发送</button>`
|
|
|
+ // } else if (row.send_status === 2) {
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-warning" onclick="ReStartSend(${row.id}, ${data.budget_id})">重新发送</button>`
|
|
|
+ // } else if (row.send_status === 3) {
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-danger" onclick="ReStartSend(${row.id}, ${data.budget_id})">重新发送</button>`
|
|
|
+ // }
|
|
|
+ // } else if (row.process_status === 3) {
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-danger" onclick="ReStartProcess(${row.id}, ${data.budget_id})">重新处理</button>`
|
|
|
+ // }
|
|
|
+ // } else if (row.collect_status === 3) {
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-danger" onclick="ReStartCollect(${row.id}, ${data.budget_id})">重新采集</button>`
|
|
|
+ // }
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-info" onclick="GoTo('')">详情</button>`
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-primary" onclick="Edit(${row.id}, ${data.budget_id})">编辑</button>`
|
|
|
+ // str += `<button type="button" class="btn btn-sm btn-light-danger" onclick="Delete(${row.id}, ${data.budget_id})">删除</button>`
|
|
|
+ str+= `</div>`
|
|
|
+ str += `<button type="button" class="btn btn-sm btn-light-primary ms-5" onclick="GoTo('')">详情</button></div>`
|
|
|
+
|
|
|
+ return str
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ callAfterRender:()=>{
|
|
|
+ KTMenu.createInstances(`#table_${data.budget_id} [data-kt-menu="true"]`)
|
|
|
+ }
|
|
|
+ }, true)
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function Add(budget_id) {
|
|
|
+ AddModal($modal, () => {
|
|
|
+ $modal.find('#task_id').val('0');
|
|
|
+ SetBudgetData(budget_id)
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function Edit(id) {
|
|
|
+ EditModal($modal,()=>{
|
|
|
+ IwbAjax_1({
|
|
|
+ url:`/api/task/get/${id}`,
|
|
|
+ success:res=>{
|
|
|
+ if(!res.success){
|
|
|
+ console.error(res.message)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const data = res.data
|
|
|
+ // SetBudgetData(budget_id)
|
|
|
+ $modal.find('#task_id').val(data.id);
|
|
|
+ $modal.find('#budget_id').val(data.budget_id);
|
|
|
+ $modal.find('#project_id').val(data.project_id);
|
|
|
+ $modal.find('#item_id').val(data.item_id);
|
|
|
+ $modal.find('#item_code').val(data.item_code);
|
|
|
+ $modal.find('#task_name').val(data.task_name);
|
|
|
+ $modal.find('#task_desc').val(data.task_desc);
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function SetBudgetData(budget_id){
|
|
|
+ const $tableBox = $(`#table_box_${budget_id}`)
|
|
|
+ $modal.find('#budget_id').val(budget_id);
|
|
|
+ $modal.find('#project_id').val($tableBox.find('input[name="project_id"]').val());
|
|
|
+ $modal.find('#item_id').val($tableBox.find('input[name="item_id"]').val());
|
|
|
+ $modal.find('#item_code').val($tableBox.find('input[name="item_code"]').val());
|
|
|
+}
|
|
|
+function SaveProject() {
|
|
|
+ const
|
|
|
+ budget_id = $modal.find('#budget_id').val(),
|
|
|
+ item_id = $modal.find('#item_id').val(),
|
|
|
+ item_code = $modal.find('#item_code').val(),
|
|
|
+ project_id = $modal.find('#project_id').val(),
|
|
|
+ task_id= $modal.find('#task_id').val(),
|
|
|
+ task_name = $modal.find('#task_name').val(),
|
|
|
+ task_desc = $modal.find('#task_desc').val()
|
|
|
+ IwbAjax({
|
|
|
+ url:`/api/task/save/${task_id}`,
|
|
|
+ data:{
|
|
|
+ budget_id,
|
|
|
+ project_id,
|
|
|
+ item_id,
|
|
|
+ item_code,
|
|
|
+ task_name,
|
|
|
+ task_desc,
|
|
|
+ },
|
|
|
+ modal:"#modal",
|
|
|
+ table:`#table_${budget_id}`
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function Delete(id,budget_id){
|
|
|
+ ConfirmUrl('确定删除吗?',`/api/task/delete/${id}`,`#table_${budget_id}`)
|
|
|
+}
|
|
|
+
|
|
|
+function StartCollect(id,budget_id){
|
|
|
+ ConfirmUrl('确定开始采集吗?',`/api/task/start_collect/${id}`,`#table_${budget_id}`)
|
|
|
+}
|
|
|
+function ReStartCollect(id,budget_id){
|
|
|
+ ConfirmUrl('确定重新开始采集吗?',`/api/task/start_collect/${id}`,`#table_${budget_id}`)
|
|
|
+}
|
|
|
+
|
|
|
+function StartProcess(id,budget_id){
|
|
|
+ ConfirmUrl('确定开始处理吗?',`/api/task/start_process/${id}`,`#table_${budget_id}`)
|
|
|
+}
|
|
|
+
|
|
|
+function ReStartProcess(id,budget_id){
|
|
|
+ ConfirmUrl('确定重新开始处理吗?',`/api/task/start_process/${id}`,`#table_${budget_id}`)
|
|
|
+}
|
|
|
+
|
|
|
+function StartSend(id,budget_id){
|
|
|
+ ConfirmUrl('确定开始发送吗?',`/api/task/start_send/${id}`,`#table_${budget_id}`)
|
|
|
+}
|
|
|
+function ReStartSend(id,budget_id){
|
|
|
+ ConfirmUrl('确定重新开始发送吗?',`/api/task/start_send/${id}`,`#table_${budget_id}`)
|
|
|
+}
|