|
@@ -25,6 +25,7 @@ const task_modal_template = `
|
|
|
<select class="form-select " name="task_type" id="task_type" data-placeholder="请选择任务类型">
|
|
|
<option value="0" selected>普通任务</option>
|
|
|
<option value="1">匹配任务</option>
|
|
|
+ <option value="2">模板任务</option>
|
|
|
</select>
|
|
|
</div>
|
|
|
<div class="fv-row form-group mb-3">
|
|
@@ -89,18 +90,65 @@ const task_modal_template = `
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
+</div>`,
|
|
|
+ template_modal_template2 = `<div class="modal fade" id="modal_template" tabindex="-1" aria-hidden="true">
|
|
|
+ <div class="modal-dialog modal-lg modal-dialog-centered" style="max-width:1200px;">
|
|
|
+ <div class="modal-content rounded">
|
|
|
+ <div class="modal-header">
|
|
|
+ <h3 class="modal-title">模板管理</h3>
|
|
|
+ <div class="btn btn-sm btn-icon btn-active-color-primary" data-bs-dismiss="modal">
|
|
|
+ <i class="ki-duotone ki-cross fs-1">
|
|
|
+ <span class="path1"></span>
|
|
|
+ <span class="path2"></span>
|
|
|
+ </i>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="modal-body py-0">
|
|
|
+ <section>
|
|
|
+ <input type="hidden" name="budget_id" value="">
|
|
|
+ <input type="hidden" name="project_id" value="">
|
|
|
+ <input type="hidden" name="item_id" value="">
|
|
|
+ <input type="hidden" name="item_code" value="">
|
|
|
+ <input type="hidden" name="task_id" value="">
|
|
|
+ <input type="hidden" name="parent_id" value="">
|
|
|
+ </section>
|
|
|
+ <div class="table-box table-responsive" data-id="" id="table_box_task_template">
|
|
|
+ <div class="d-flex justify-content-between my-5">
|
|
|
+ <div class=""></div>
|
|
|
+ <form class="search-box d-flex">
|
|
|
+ <div class="d-flex">
|
|
|
+ <input type="text" class="form-control form-control-sm w-200px" placeholder="请输入项目名称" name="projectName" />
|
|
|
+ <input type="text" class="form-control form-control-sm w-200px ms-5" placeholder="请输入关键字" name="keyword" />
|
|
|
+ </div>
|
|
|
+ <div class="btn-group ms-5">
|
|
|
+ <button type="button" class="btn btn-primary btn-sm" onclick="IwbTableSearch(this);clear()">查询</button>
|
|
|
+ <button type="button" class="btn btn-danger btn-sm" onclick="IwbTableResetSearch(this);clear()">重置</button>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ <table class="table table-striped table-bordered table-hover table-rounded" id="table_task_template">
|
|
|
+ </table>
|
|
|
+ <div class="pagination-row"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="modal-footer">
|
|
|
+ <button type="button" class="btn btn-light" data-bs-dismiss="modal">取消</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>`
|
|
|
$('.app-main .app-container').append(task_modal_template)
|
|
|
-const table_add_task_btn_template = `<button type="button" class="task_add_btn btn btn-primary btn-sm" onclick="Add('{0}')">添加任务</button>`
|
|
|
+$('.app-main .app-container').append(template_modal_template2)
|
|
|
+let table_add_task_btn_template = `<button type="button" class="task_add_btn btn btn-primary btn-sm" onclick="Add('{0}')">添加任务</button>`
|
|
|
+table_add_task_btn_template += `<button type="button" class="task_add_btn btn btn-warning btn-sm ms-5" onclick="AddFromTemplate('{0}')">模板管理</button>`
|
|
|
|
|
|
const table = '#table',
|
|
|
- $modal = $('#modal')
|
|
|
+ $modal = $('#modal'), $modal_template = $('#modal_template')
|
|
|
$modal.find('#budget_id').html($('#budget_id_options').html())
|
|
|
$(function () {
|
|
|
InitFileUpload()
|
|
|
})
|
|
|
|
|
|
-
|
|
|
let _fileUploadDropzone = null;
|
|
|
|
|
|
function InitFileUpload() {
|
|
@@ -163,13 +211,15 @@ function RenderRightBox_Custom(data) {
|
|
|
_taskTable(data)
|
|
|
}
|
|
|
})
|
|
|
+ _renderTask(data)
|
|
|
+
|
|
|
if (data.children_count > 0 || data.chapter) {
|
|
|
- _renderTask(data)
|
|
|
+ // _renderTask(data)
|
|
|
} else {
|
|
|
- $rightBoxHeader.find('.badge').text('定额输入明细').removeClass('badge-primary').addClass('badge-success')
|
|
|
- $rightBoxHeader.find('#task_radio').prop("disabled", true)
|
|
|
- $rightBoxHeader.find('#quota_radio').prop("checked", true)
|
|
|
- QuotaNavTab(data)
|
|
|
+ // $rightBoxHeader.find('.badge').text('定额输入明细').removeClass('badge-primary').addClass('badge-success')
|
|
|
+ // $rightBoxHeader.find('#task_radio').prop("disabled", true)
|
|
|
+ // $rightBoxHeader.find('#quota_radio').prop("checked", true)
|
|
|
+ // QuotaNavTab(data)
|
|
|
}
|
|
|
|
|
|
function _renderTask(data) {
|
|
@@ -187,6 +237,9 @@ function RenderRightBox_Custom(data) {
|
|
|
url: `/api/task/list/${project_id}/${data.item_code}`,
|
|
|
trClass: (row) => {
|
|
|
if (row.parent_id && row.parent_id !== 0) {
|
|
|
+ if (row.task_type === 2) {
|
|
|
+ return 'tr-warning'
|
|
|
+ }
|
|
|
return 'tr-primary'
|
|
|
}
|
|
|
},
|
|
@@ -206,7 +259,7 @@ function RenderRightBox_Custom(data) {
|
|
|
data: 'task_type',
|
|
|
width: '120px',
|
|
|
render: (row) => {
|
|
|
- return row.task_type === 0 ? '<span class="badge badge-light-primary">普通任务</span>' : '<span class="badge badge-light-success">匹配任务</span>'
|
|
|
+ return row.task_type === 0 ? '<span class="badge badge-light-primary">普通任务</span>' : row.task_type === 1 ? '<span class="badge badge-light-success">匹配任务</span>' : '<span class="badge badge-light-info">模板任务</span>'
|
|
|
}
|
|
|
},
|
|
|
{
|
|
@@ -327,9 +380,11 @@ function RenderRightBox_Custom(data) {
|
|
|
str += `<!--<button type="button" class="btn btn-icon btn-sm btn-light-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="编辑" onclick="Edit(${row.id})"><i class="ki-duotone ki-message-edit fs-1"><span class="path1"></span><span class="path2"></span></i></button>-->`
|
|
|
if (row.process_status === 2 || row.process_status === 200) {
|
|
|
str += `<button type="button" class="btn btn-icon btn-sm btn-light-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="定额输入列表" onclick="GoTo('/${row.task_type === 0 ? 'quota_info' : 'quota_match_info'}/${project_id}/${row.id}',0)"><i class="ki-duotone ki-eye fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span></i></button>`
|
|
|
- if (row.task_type === 0) {
|
|
|
- str += `<button type="button" class="btn btn-icon btn-sm btn-light-info" data-bs-toggle="tooltip" data-bs-placement="top" title="再次提交任务" onclick="ReCreate(${row.id})"><i class="ki-duotone ki-add-notepad fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span></i></button>`
|
|
|
- }
|
|
|
+ // if (row.task_type === 0) {
|
|
|
+ // }else {
|
|
|
+ // }
|
|
|
+ str += `<button type="button" class="btn btn-icon btn-sm btn-light-info" data-bs-toggle="tooltip" data-bs-placement="top" title="再次提交任务" onclick="ReCreate(${row.id})"><i class="ki-duotone ki-add-notepad fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span></i></button>`
|
|
|
+ str += `<button type="button" class="btn btn-icon btn-sm btn-light-success" data-bs-toggle="tooltip" data-bs-placement="top" title="保存为模板" onclick="SaveToTemplate(${row.id})"><i class="ki-duotone ki-archive-tick fs-1"><span class="path1"></span><span class="path2"></span></i></button>`
|
|
|
}
|
|
|
if (row.process_status !== 2 && row.process_status !== 1) {
|
|
|
str += `<button type="button" class="btn btn-icon btn-sm btn-light-danger" data-bs-toggle="tooltip" data-bs-placement="top" title="删除" onclick="Delete(${row.id})"><i class="ki-duotone ki-trash-square fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span></i></button>`
|
|
@@ -440,7 +495,7 @@ function SaveProject(is_submit) {
|
|
|
files.forEach((file) => {
|
|
|
formData.append('files', file)
|
|
|
})
|
|
|
- } else {
|
|
|
+ } else if (task_id === '0') {
|
|
|
MsgWarning('文件不能为空,请选择文件')
|
|
|
return
|
|
|
}
|
|
@@ -472,6 +527,10 @@ function Delete(id) {
|
|
|
ConfirmUrl('确定删除吗?', `/api/task/delete/${id}`, `#table_0`)
|
|
|
}
|
|
|
|
|
|
+function SaveToTemplate(id) {
|
|
|
+ ConfirmUrl('确定保存为模板吗?', `/api/task/template/add/${id}`, `#table_0`)
|
|
|
+}
|
|
|
+
|
|
|
function StarTask(id) {
|
|
|
clear()
|
|
|
ConfirmUrl('确定开始运行任务吗?', `/api/task/start_task/${id}`, `#table_0`, function () {
|
|
@@ -506,18 +565,84 @@ function auto_refresh_table(id) {
|
|
|
}, 10 * 1000)
|
|
|
}
|
|
|
|
|
|
-// function StartProcessTask(id){
|
|
|
-// ConfirmUrl('确定开始处理吗?',`/api/task/start_process/${id}`,`#table_0`)
|
|
|
-// }
|
|
|
-//
|
|
|
-// function ReStartProcessTask(id){
|
|
|
-// ConfirmUrl('确定重新开始处理吗?',`/api/task/start_process/${id}`,`#table_0`)
|
|
|
-// }
|
|
|
+function AddFromTemplate(budget_id) {
|
|
|
+ $modal_template.find('[name="budget_id"]').val(budget_id);
|
|
|
+ SetBudgetData($modal_template)
|
|
|
+ IwbTable('#table_task_template', {
|
|
|
+ url: '/api/task/template/list',
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ title: '模板任务名称',
|
|
|
+ data: 'task_name',
|
|
|
+ width: `250px`,
|
|
|
+ render: (row) => {
|
|
|
+ return `<span class="one-line " data-bs-toggle="tooltip" data-bs-placement="top" title="${row.task_name}" >${row.task_name}</span>`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '项目名称',
|
|
|
+ data: 'project_name',
|
|
|
+ render: (row) => {
|
|
|
+ return `<span class="one-line " data-bs-toggle="tooltip" data-bs-placement="top" title="${row.project_name}" >${row.project_name}</span>`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '项目编号',
|
|
|
+ data: 'project_id',
|
|
|
+ width: '200px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '创建人',
|
|
|
+ data: 'created_by',
|
|
|
+ width: '100px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '创建时间',
|
|
|
+ data: 'created_at',
|
|
|
+ width: '160px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ data: 'id',
|
|
|
+ width: '90px',
|
|
|
+ render: (row) => {
|
|
|
+ let str = `<button type="button" class="btn btn-icon btn-sm btn-light-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="创建任务" onclick="SaveCreateTemplate(${row.id})"><i class="ki-duotone ki-plus-square fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span></i></button>`
|
|
|
+ if (row.can_operate) {
|
|
|
+ str += `<button type="button" class="btn btn-icon btn-sm btn-light-danger" data-bs-toggle="tooltip" data-bs-placement="top" title="删除" onclick="DeleteTemplate(${row.id})"><i class="ki-duotone ki-trash-square fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span><span class="path4"></span></i></button>`
|
|
|
+ }
|
|
|
+ return str
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ ]
|
|
|
+ })
|
|
|
+ $modal_template.modal('show')
|
|
|
+}
|
|
|
|
|
|
-// function StartSendTask(id){
|
|
|
-// ConfirmUrl('确定开始发送吗?',`/api/task/start_send/${id}`,`#table_0`)
|
|
|
-// }
|
|
|
-// function ReStartSendTask(id){
|
|
|
-// ConfirmUrl('确定重新开始发送吗?',`/api/task/start_send/${id}`,`#table_0`)
|
|
|
-// }
|
|
|
+function DeleteTemplate(id) {
|
|
|
+ ConfirmUrl('确定删除模板吗?', `/api/task/template/delete/${id}`, `#table_task_template`)
|
|
|
+}
|
|
|
|
|
|
+function SaveCreateTemplate(id) {
|
|
|
+ Confirm('确定使用模板创建任务吗?', function () {
|
|
|
+ const budget_id = $modal_template.find('[name="budget_id"]').val(),
|
|
|
+ item_id = $modal_template.find('[name="item_id"]').val(),
|
|
|
+ item_code = $modal_template.find('[name="item_code"]').val(),
|
|
|
+ project_id = $modal_template.find('[name="project_id"]').val()
|
|
|
+ IwbAjax({
|
|
|
+ url: `/api/task/template/copy/${id}`,
|
|
|
+ data: {
|
|
|
+ budget_id,
|
|
|
+ item_id,
|
|
|
+ item_code,
|
|
|
+ project_id
|
|
|
+ },
|
|
|
+ success: res => {
|
|
|
+ if (res.success) {
|
|
|
+ $modal_template.modal('hide')
|
|
|
+ IwbTableReload(`#table_0`)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|