|
@@ -78,16 +78,54 @@ const quota_modal_template = `
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
-</div>`
|
|
|
+</div>`,
|
|
|
+ chapter_modal_template = `
|
|
|
+<div class="modal fade" id="modal_chapter" tabindex="-1" aria-hidden="true">
|
|
|
+ <div class="modal-dialog modal-lg modal-dialog-centered">
|
|
|
+ <div class="modal-content rounded">
|
|
|
+ <div class="modal-header">
|
|
|
+ <h3 class="modal-title"><span class="prefix"></span>章节条目</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">
|
|
|
+ <form>
|
|
|
+ <div class="form-group">
|
|
|
+ <input type="hidden" name="id" value="">
|
|
|
+ <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="quota_id" value="">
|
|
|
+ <input type="hidden" name="task_id" value="">
|
|
|
+ <div class="fv-row form-group mb-3">
|
|
|
+ <label for="quota_code" class="form-label">章节条目</label>
|
|
|
+ <select type="text" class="form-select" name="chapter" onchange="OnChapterChange()"></select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+ </div>
|
|
|
+ <div class="modal-footer">
|
|
|
+ <button type="button" class="btn btn-light" data-bs-dismiss="modal">取消</button>
|
|
|
+ <button type="button" class="btn btn-light-success" onclick="SaveChapterChange()">保存</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+`
|
|
|
$('.app-main .app-container').append(quota_modal_template)
|
|
|
+$('.app-main .app-container').append(chapter_modal_template)
|
|
|
const nav_template = `<ul id="nav_tab" class="nav nav-tabs nav-line-tabs nav-line-tabs-2x fs-6"></ul><div class="tab-content" id="tab_content" style="height: calc(100% - 80px);"></div>`,
|
|
|
nav_tab_template = `
|
|
|
<li class="nav-item" data-id="{0}">
|
|
|
<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 h-100" id="iwb_tab_{0}" role="tabpanel">{1}</div>`,
|
|
|
- table_add_quota_btn_template = `<button type="button" class="quota_add_btn btn btn-primary btn-sm" onclick="Send_Quota_Batch('{0}')">批量推送</button>` //`<button type="button" class="quota_add_btn btn btn-primary btn-sm" onclick="Add_Quota('{0}')">添加定额</button>`,
|
|
|
-table_run_select_template = `<select class="form-select form-select-sm me-5" name="process_status">
|
|
|
+ table_run_select_template = `<select class="form-select form-select-sm me-5" name="process_status" data-placeholder="请选择运行状态">
|
|
|
<option value="">全部运行状态</option>
|
|
|
<option value="0">草稿</option>
|
|
|
<option value="1">等待运行</option>
|
|
@@ -97,13 +135,13 @@ table_run_select_template = `<select class="form-select form-select-sm me-5" nam
|
|
|
<option value="5">运行失败</option>
|
|
|
<!--<option value="4">已修改</option>-->
|
|
|
</select>`,
|
|
|
- table_send_select_template = `<select class="form-select form-select-sm me-5" name="send_status">
|
|
|
+ table_send_select_template = `<select class="form-select form-select-sm me-5" name="send_status" data-placeholder="请选择推送状态">
|
|
|
<option value="">全部推送状态</option>
|
|
|
<option value="0">未推送</option>
|
|
|
- <option value="1">推送中</option>
|
|
|
+<!-- <option value="1">推送中</option>-->
|
|
|
<option value="200">推送成功</option>
|
|
|
<option value="2">推送失败</option>
|
|
|
- <option value="3">数据变更</option>
|
|
|
+<!-- <option value="3">数据变更</option>-->
|
|
|
</select>`,
|
|
|
table_template = `<div class="table-box table-responsive" data-id="{0}" id="table_box_{0}">
|
|
|
<div class="d-flex justify-content-between my-5">
|
|
@@ -123,8 +161,11 @@ table_run_select_template = `<select class="form-select form-select-sm me-5" nam
|
|
|
</table>
|
|
|
<div class="pagination-row"></div>
|
|
|
</div>`
|
|
|
+let table_add_quota_btn_template = `<button type="button" class="quota_add_btn btn btn-primary btn-sm" onclick="Send_Quota_Batch('{0}')">批量推送</button>`;
|
|
|
+// table_add_quota_btn_template += `<button type="button" class="ms-5 btn btn-warning btn-sm" onclick="Edit_QuotaChapter(null,'{0}')">批量修改章节</button>`
|
|
|
+//`<button type="button" class="quota_add_btn btn btn-primary btn-sm" onclick="Add_Quota('{0}')">添加定额</button>`
|
|
|
|
|
|
-const $modalQuota = $('#modal_quota')
|
|
|
+const $modalQuota = $('#modal_quota'), $modalChapter = $('#modal_chapter')
|
|
|
let $rightBox, $rightBoxHeader, $rightBoxBody, $taskBox, $quotaBox, budget_id, item_code
|
|
|
|
|
|
console.log(`加载项目:${project_id}`)
|
|
@@ -132,6 +173,7 @@ InitBody()
|
|
|
$(function () {
|
|
|
BuildChapterInfo()
|
|
|
$(window).on('resize', AdjustBoxHeight)
|
|
|
+ RenderChapterSelect()
|
|
|
})
|
|
|
|
|
|
function InitBody() {
|
|
@@ -183,8 +225,9 @@ function AdjustBoxHeight() {
|
|
|
$('#body_box .project-box').height(h)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function BuildChapterInfo() {
|
|
|
- const $tree = $(`#js-tree`)
|
|
|
+ const $tree = $(`#js-tree`), taskId = task_id || ""
|
|
|
const opt = {
|
|
|
core: {
|
|
|
themes: {
|
|
@@ -197,7 +240,7 @@ function BuildChapterInfo() {
|
|
|
data: function (node, callback) {
|
|
|
// console.log('TREE_NODE', node)
|
|
|
IwbAjax_1({
|
|
|
- url: `/api/project/chapter/${project_id}?c=${node?.data?.item_code || ''}`,
|
|
|
+ url: `/api/project/chapter/${project_id}?c=${node?.data?.item_code || ''}&&t=${taskId}`,
|
|
|
success: res => {
|
|
|
if (res.success) {
|
|
|
console.log('TREE', res.data)
|
|
@@ -233,6 +276,7 @@ function BuildChapterInfo() {
|
|
|
$tree.jstree(opt)
|
|
|
}
|
|
|
|
|
|
+
|
|
|
function RenderRightBox(data) {
|
|
|
console.log('RenderRightBox', arguments)
|
|
|
$rightBoxBody.data('data', data)
|
|
@@ -320,6 +364,9 @@ function LoadQuotaTable(table) {
|
|
|
IwbTable(table, {
|
|
|
url,
|
|
|
checkBox: true,
|
|
|
+ checkBoxDisable: (row) => {
|
|
|
+ return row.send_status === 200
|
|
|
+ },
|
|
|
columns: [
|
|
|
{
|
|
|
title: '序号',
|
|
@@ -428,7 +475,7 @@ function LoadQuotaTable(table) {
|
|
|
{
|
|
|
title: '操作',
|
|
|
data: 'id',
|
|
|
- width: '120px',
|
|
|
+ width: '160px',
|
|
|
render: (row) => {
|
|
|
let str = ''
|
|
|
// if (row.process_status === 0) {
|
|
@@ -444,14 +491,18 @@ function LoadQuotaTable(table) {
|
|
|
if (row.send_status === 0) {
|
|
|
str += `<button type="button" class="btn btn-icon btn-sm ${row.quota_id ? 'btn-primary' : 'btn-light-primary'}" data-bs-toggle="tooltip" data-bs-placement="top" title="开始推送" onclick="StartSendQuota(${row.id}, ${row.budget_id}, ${row.quota_id})"><i class="ki-duotone ki-send fs-3"><span class="path1"></span><span class="path2"></span></i></button>`
|
|
|
} else if (row.send_status === 200) {
|
|
|
- str += `<button type="button" class="btn btn-icon btn-sm ${row.quota_id ? 'btn-warning' : 'btn-light-warning'}" data-bs-toggle="tooltip" data-bs-placement="top" title="重新推送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id}, ${row.quota_id})"><i class="ki-duotone ki-send fs-3"><span class="path1"></span><span class="path2"></span></i></button>`
|
|
|
+ str = `<span class="text-gray-500">暂无操作</span>`
|
|
|
+ // str += `<button type="button" class="btn btn-icon btn-sm ${row.quota_id ? 'btn-warning' : 'btn-light-warning'}" data-bs-toggle="tooltip" data-bs-placement="top" title="重新推送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id}, ${row.quota_id})"><i class="ki-duotone ki-send fs-3"><span class="path1"></span><span class="path2"></span></i></button>`
|
|
|
} else if (row.send_status === 2) {
|
|
|
str += `<button type="button" class="btn btn-icon btn-sm ${row.quota_id ? 'btn-danger' : 'btn-light-danger'}" data-bs-toggle="tooltip" data-bs-placement="top" title="重新推送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id}, ${row.quota_id})"><i class="ki-duotone ki-send fs-3"><span class="path1"></span><span class="path2"></span></i></button>`
|
|
|
} else if (row.send_status === 3) {
|
|
|
str += `<button type="button" class="btn btn-icon btn-sm ${row.quota_id ? 'btn-info' : 'btn-light-info'}" data-bs-toggle="tooltip" data-bs-placement="top" title="重新推送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id}, ${row.quota_id})"><i class="ki-duotone ki-send fs-3"><span class="path1"></span><span class="path2"></span></i></button>`
|
|
|
}
|
|
|
- str += `<button type="button" class="btn btn-icon btn-sm btn-light-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="编辑" onclick="Edit_Quota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-message-edit fs-1"><span class="path1"></span><span class="path2"></span></i></button>`
|
|
|
- str += `<button type="button" class="btn btn-icon btn-sm btn-light-danger" data-bs-toggle="tooltip" data-bs-placement="top" title="删除" onclick="Delete_Quota(${row.id}, ${row.budget_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>`
|
|
|
+ if (row.send_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="Edit_Quota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-message-edit fs-1"><span class="path1"></span><span class="path2"></span></i></button>`
|
|
|
+ str += `<button type="button" class="btn btn-icon btn-sm btn-light-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="修改条目" onclick="Edit_QuotaChapter(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-burger-menu-1 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-danger" data-bs-toggle="tooltip" data-bs-placement="top" title="删除" onclick="Delete_Quota(${row.id}, ${row.budget_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
|
|
|
}
|
|
|
},
|
|
@@ -474,6 +525,7 @@ function Add_Quota(budget_id,) {
|
|
|
$modalQuota.find('[name="task_id"]').val('0');
|
|
|
$modalQuota.find('[name="budget_id"]').val(budget_id);
|
|
|
$modalQuota.find('[name="is_cover"]').val('0')
|
|
|
+ $modalQuota.find('[name="chapter"]').val('').data('id', "").data('code', "").select2tree();
|
|
|
$modalQuota.find('.is_cover_box').hide()
|
|
|
})
|
|
|
}
|
|
@@ -502,6 +554,7 @@ function Edit_Quota(id) {
|
|
|
$modalQuota.find('[name="amount"]').val(data.amount);
|
|
|
$modalQuota.find('[name="units"]').val(data.units);
|
|
|
$modalQuota.find('[name="quota_code"]').val(data.quota_code);
|
|
|
+ $modalQuota.find('[name="chapter"]').data('id', data.item_id).data('code', data.item_code).val(data.item_code).select2tree();
|
|
|
$modalQuota.find('#ex_row').html(data.ex_row);
|
|
|
$modalQuota.find('#ex_amount').html(data.ex_amount);
|
|
|
$modalQuota.find('#ex_cell').html(data.ex_cell);
|
|
@@ -527,7 +580,8 @@ function SaveQuota(isSubmit) {
|
|
|
amount = $modalQuota.find('[name="amount"]').val(),
|
|
|
units = $modalQuota.find('[name="units"]').val(),
|
|
|
quota_code = $modalQuota.find('[name="quota_code"]').val(),
|
|
|
- is_cover = $modalQuota.find('[name="is_cover"]:checked').val()
|
|
|
+ is_cover = $modalQuota.find('[name="is_cover"]:checked').val(),
|
|
|
+ chapter = $modalQuota.find('[name="chapter"]').val()
|
|
|
IwbAjax({
|
|
|
url: `/api/quota/save`,
|
|
|
data: {
|
|
@@ -542,6 +596,7 @@ function SaveQuota(isSubmit) {
|
|
|
amount,
|
|
|
units,
|
|
|
quota_code,
|
|
|
+ chapter,
|
|
|
run_now: isSubmit ? 'true' : 'false',
|
|
|
is_cover: is_cover === '1' || is_cover === 1 ? 'true' : 'false',
|
|
|
},
|
|
@@ -634,4 +689,74 @@ function SendQuota(title, ids, budget_id, is_cover, is_html) {
|
|
|
table: `#table_${budget_id}`
|
|
|
})
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+function Edit_QuotaChapter(id, budget_id) {
|
|
|
+ let ids = id
|
|
|
+ if (!ids) {
|
|
|
+ ids = IwbTableGetSelectedIds('#table_' + budget_id).join(",")
|
|
|
+ }
|
|
|
+ console.log("Edit_QuotaChapter", ids)
|
|
|
+ EditModal($modalChapter, () => {
|
|
|
+ $modalChapter.find('[name="budget_id"]').val(budget_id);
|
|
|
+ $modalChapter.find('[name="id"]').val(ids);
|
|
|
+ RenderChapterSelect()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function RenderChapterSelect() {
|
|
|
+ const $chapter = $modalChapter.find('[name="chapter"]')
|
|
|
+ if ($chapter.data('init')) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ IwbAjax_1({
|
|
|
+ url: `/api/project/task_chapters/${task_id}`,
|
|
|
+ success: function (res) {
|
|
|
+ if (res.success) {
|
|
|
+ let str = FormatChapterOption(res.data)
|
|
|
+ $chapter.html(str).data('init', true).select2tree()
|
|
|
+ } else {
|
|
|
+ console.error('加载章节出错:', res.message)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function FormatChapterOption(data) {
|
|
|
+ console.log('FormatChapterOption', data)
|
|
|
+ let str = ''
|
|
|
+ if (data && data.length) {
|
|
|
+ data.forEach(item => {
|
|
|
+ // let parent_code = get_parent_code(item.item_code)
|
|
|
+ // console.log('item_code', item.id, item.parent, item.text)
|
|
|
+ if (item.parent) {
|
|
|
+ str += `<option data-id="${item.data.item_id}" value="${item.id}" parent="${item.parent}">${item.text}</option>`
|
|
|
+ } else {
|
|
|
+ str += `<option data-id="${item.data.item_id}" value="${item.id}">${item.text}</option>`
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ return str
|
|
|
+}
|
|
|
+
|
|
|
+function OnChapterChange() {
|
|
|
+ // const $this = $modalChapter.find('[name="chapter"]')
|
|
|
+ // let code = $this.val(), id = $this.find('option[value="' + code + '"]').data('id')
|
|
|
+ // console.log('OnChapterChange', code, id)
|
|
|
+}
|
|
|
+
|
|
|
+function SaveChapterChange() {
|
|
|
+ const $this = $modalChapter.find('[name="chapter"]'), budget_id = $modalChapter.find('[name="budget_id"]').val()
|
|
|
+ let code = $this.val(), newId = $this.find('option[value="' + code + '"]').data('id')
|
|
|
+ if (!newId) {
|
|
|
+ MsgWarning('请选择章节编号!')
|
|
|
+ }
|
|
|
+ IwbAjax_2({
|
|
|
+ url: `/api/quota/save_change_chapter/${project_id}`,
|
|
|
+ data: {
|
|
|
+ ids: $modalChapter.find('[name="id"]').val(),
|
|
|
+ new_id: newId
|
|
|
+ }
|
|
|
+ }, $modalChapter, $('#table_' + budget_id))
|
|
|
+
|
|
|
}
|