|
@@ -0,0 +1,314 @@
|
|
|
+const modal_template = `
|
|
|
+<div class="modal fade" id="modal_quota" 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="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>
|
|
|
+ <dl class="d-flex mb-1">
|
|
|
+ <dt class="" style="white-space: nowrap">源内容:</dt>
|
|
|
+ <dd id="ex_row" class="ms-3 mb-0"></dd>
|
|
|
+ </dl>
|
|
|
+ <div class="d-flex flex-wrap">
|
|
|
+ <dl class="d-flex mb-1 w-25">
|
|
|
+ <dt class="" style="white-space: nowrap">源数量:</dt>
|
|
|
+ <dd id="ex_amount" class="ms-3 mb-0"></dd>
|
|
|
+ </dl>
|
|
|
+ <dl class="d-flex mb-1 w-25">
|
|
|
+ <dt class="" style="white-space: nowrap">源数量位置:</dt>
|
|
|
+ <dd id="ex_cell" class="ms-3 mb-0"></dd>
|
|
|
+ </dl>
|
|
|
+ <dl class="d-flex mb-1 w-25">
|
|
|
+ <dt class="" style="white-space: nowrap">源数量单位:</dt>
|
|
|
+ <dd id="ex_unit" class="ms-3 mb-0"></dd>
|
|
|
+ </dl>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <span class="separator my-5"></span>
|
|
|
+ <div class="fv-row form-group mb-3">
|
|
|
+ <label for="entry_name" class="form-label required">工程或费用项目名称</label>
|
|
|
+ <input type="text" class="form-control" name="entry_name" id="entry_name" placeholder="请输入工程或费用项目名称" required />
|
|
|
+ </div>
|
|
|
+ <div class="fv-row form-group mb-3">
|
|
|
+ <label for="units" class="form-label required">单位</label>
|
|
|
+ <input type="text" class="form-control" name="units" id="units" placeholder="请输入单位" required />
|
|
|
+ </div>
|
|
|
+ <div class="fv-row form-group mb-3">
|
|
|
+ <label for="amount" class="form-label required">工程数量</label>
|
|
|
+ <input type="text" class="form-control" name="amount" id="amount" placeholder="请输入工程数量" required />
|
|
|
+ </div>
|
|
|
+ <div class="fv-row form-group mb-3">
|
|
|
+ <label for="quota_code" class="form-label">定额编号</label>
|
|
|
+ <input type="text" class="form-control" name="quota_code" id="quota_code" placeholder="请输入定额编号" />
|
|
|
+ </div>
|
|
|
+ <div class="d-flex pt-3 justify-content-center">
|
|
|
+ <div class="form-check form-check-custom form-check-solid form-check-danger mb-3" id="is_edit_box">
|
|
|
+ <input class="form-check-input" type="radio" checked value="0" name="is_edit" id="is_edit_1"/>
|
|
|
+ <label class="form-check-label ms-3 text-danger" for="is_edit_1">覆盖(新增)源数据</label>
|
|
|
+ </div>
|
|
|
+ <div class="form-check form-check-solid ms-5 mb-3" id="is_edit_box">
|
|
|
+ <input class="form-check-input" type="radio" value="1" name="is_edit" id="is_edit_2"/>
|
|
|
+ <label class="form-check-label ms-3 text-primary" for="is_edit_2">修改(新增)源数据</label>
|
|
|
+ </div>
|
|
|
+ </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-primary" onclick="SaveQuota(true)">提交</button>
|
|
|
+ <button type="button" class="btn btn-primary" onclick="SaveQuota()">保存草稿</button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>`
|
|
|
+ $('.app-main .app-container').append(modal_template)
|
|
|
+const $modalQuota = $('#modal_quota')
|
|
|
+console.log(`加载项目:${project_id}`)
|
|
|
+function LoadQuotaTable(table,url){
|
|
|
+ IwbTable(table,{
|
|
|
+ url,
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ title: '序号',
|
|
|
+ data: 'id',
|
|
|
+ width: '80px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '工程或费用项目名称',
|
|
|
+ data: 'entry_name',
|
|
|
+ width: '210px',
|
|
|
+ render: (row) => {
|
|
|
+ return `<span class="one-line mw-200px" data-bs-toggle="tooltip" data-bs-placement="top" title="${row.entry_name}" >${row.entry_name}</span>`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '工程数量',
|
|
|
+ data: 'amount',
|
|
|
+ width: '100px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '单位',
|
|
|
+ data: 'units',
|
|
|
+ width: '80px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '定额编号',
|
|
|
+ data: 'quota_code',
|
|
|
+ width: '100px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: 'Excel文件',
|
|
|
+ data: 'ex_file',
|
|
|
+ width: '150px',
|
|
|
+ render: (row) => {
|
|
|
+ const path = row.ex_file
|
|
|
+ if (!path) {
|
|
|
+ return '-'
|
|
|
+ }
|
|
|
+ const names = path.split('/')
|
|
|
+ const file_name = names[names.length - 1]
|
|
|
+ return `<span class="one-line mw-150px"><a href="#" onclick="DownloadFile('/api/task/download?filename=${encodeURIComponent(path)}','${file_name}')" class="link link-info px-2">${file_name}</a></span>`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: 'Excel整行内容',
|
|
|
+ data: 'ex_row',
|
|
|
+ width: 'auto',
|
|
|
+ render: (row) => {
|
|
|
+ return `<span class="one-line w-300px" data-bs-toggle="tooltip" data-bs-placement="top" title="${row.ex_row}" >${row.ex_row}</span>`
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: 'Excel数量',
|
|
|
+ data: 'ex_amount',
|
|
|
+ width: '100px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '数量位置',
|
|
|
+ data: 'ex_cell',
|
|
|
+ width: '80px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '数量单位',
|
|
|
+ data: 'ex_unit',
|
|
|
+ width: '80px',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '状态',
|
|
|
+ data: 'status',
|
|
|
+ width: '100px',
|
|
|
+ render: (row) => {
|
|
|
+ let str=''
|
|
|
+ // if(row.process_status === 0){
|
|
|
+ // str+= `<span class="badge badge-primary">未处理</span>`
|
|
|
+ // }else if (row.process_status === 1){
|
|
|
+ // str+= `<span class="badge badge-warning">处理中</span>`
|
|
|
+ // }else if (row.process_status === 2){
|
|
|
+ // str+= `<span class="badge badge-success">已处理</span>`
|
|
|
+ // }else if (row.process_status === 3){
|
|
|
+ // str+= `<span class="badge badge-danger">处理失败</span>`
|
|
|
+ // }else if (row.process_status === 4){
|
|
|
+ // str+= `<span class="badge badge-danger">数据变更</span>`
|
|
|
+ // }
|
|
|
+ if(row.send_status === 0){
|
|
|
+ str+= `<span class="badge badge-primary ms-3">未发送</span>`
|
|
|
+ }else if (row.send_status === 1){
|
|
|
+ str+= `<span class="badge badge-warning ms-3">发送中</span>`
|
|
|
+ }else if (row.send_status === 200){
|
|
|
+ str+= `<span class="badge badge-success ms-3">发送成功</span>`
|
|
|
+ }else if (row.send_status === 2){
|
|
|
+ str+= `<span class="badge badge-danger ms-3">发送失败</span>`
|
|
|
+ }else if (row.send_status === 3){
|
|
|
+ str+= `<span class="badge badge-danger ms-3">数据变更</span>`
|
|
|
+ }
|
|
|
+
|
|
|
+ return str
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ data: 'id',
|
|
|
+ width: '120px',
|
|
|
+ render: (row) => {
|
|
|
+ let str=''
|
|
|
+ // if (row.process_status === 0) {
|
|
|
+ // str += `<button type="button" class="btn btn-icon btn-sm btn-light-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="开始处理" onclick="StartProcessQuota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-book-square fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span></i></button>`
|
|
|
+ // } else if (row.process_status === 2) {
|
|
|
+ // str += `<button type="button" class="btn btn-icon btn-sm btn-light-warning" data-bs-toggle="tooltip" data-bs-placement="top" title="重新处理" onclick="ReStartProcessQuota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-book-square fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span></i></button>`
|
|
|
+ //
|
|
|
+ // } else if (row.process_status === 3) {
|
|
|
+ // str += `<button type="button" class="btn btn-icon btn-sm btn-light-danger" data-bs-toggle="tooltip" data-bs-placement="top" title="重新处理" onclick="ReStartProcessQuota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-book-square fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span></i></button>`
|
|
|
+ // } else if (row.process_status === 4) {
|
|
|
+ // str += `<button type="button" class="btn btn-icon btn-sm btn-light-info" data-bs-toggle="tooltip" data-bs-placement="top" title="重新处理" onclick="ReStartProcessQuota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-book-square fs-1"><span class="path1"></span><span class="path2"></span><span class="path3"></span></i></button>`
|
|
|
+ // }
|
|
|
+ if (row.send_status === 0) {
|
|
|
+ str += `<button type="button" class="btn btn-icon btn-sm btn-light-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="开始发送" onclick="StartSendQuota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-send fs-1"><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 btn-light-warning" data-bs-toggle="tooltip" data-bs-placement="top" title="重新发送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-send fs-1"><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 btn-light-danger" data-bs-toggle="tooltip" data-bs-placement="top" title="重新发送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-send fs-1"><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 btn-light-info" data-bs-toggle="tooltip" data-bs-placement="top" title="重新发送" onclick="ReStartSendQuota(${row.id}, ${row.budget_id})"><i class="ki-duotone ki-send 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_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>`
|
|
|
+ return str
|
|
|
+ }
|
|
|
+ },
|
|
|
+ ]
|
|
|
+ }, true)
|
|
|
+}
|
|
|
+
|
|
|
+function SetBudgetData($el){
|
|
|
+ const $tableBox = $(`.table-box`)
|
|
|
+ $el.find('[name="project_id"]').val($tableBox.find('input[name="project_id"]').val());
|
|
|
+ $el.find('[name="item_id"]').val($tableBox.find('input[name="item_id"]').val());
|
|
|
+ $el.find('[name="item_code"]').val($tableBox.find('input[name="item_code"]').val());
|
|
|
+}
|
|
|
+function Add_Quota(budget_id,) {
|
|
|
+ AddModal($modalQuota, () => {
|
|
|
+ SetBudgetData($modalQuota)
|
|
|
+ $modalQuota.find('[name="quota_id"]').val('0');
|
|
|
+ $modalQuota.find('[name="quota_id"]').val('0');
|
|
|
+ $modalQuota.find('[name="task_id"]').val('0');
|
|
|
+ $modalQuota.find('[name="budget_id"]').val(budget_id);
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function Edit_Quota(id) {
|
|
|
+ EditModal($modalQuota,()=>{
|
|
|
+ IwbAjax_1({
|
|
|
+ url:`/api/quota/get/${id}`,
|
|
|
+ success:res=>{
|
|
|
+ if(!res.success){
|
|
|
+ console.error(res.message)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const data = res.data
|
|
|
+ // SetBudgetData(budget_id)
|
|
|
+ $modalQuota.find('[name="quota_id"]').val(data.id);
|
|
|
+ $modalQuota.find('[name="task_id"]').val(data.task_id);
|
|
|
+ $modalQuota.find('[name="budget_id"]').val(data.budget_id);
|
|
|
+ $modalQuota.find('[name="project_id"]').val(data.project_id);
|
|
|
+ $modalQuota.find('[name="item_id"]').val(data.item_id);
|
|
|
+ $modalQuota.find('[name="item_code"]').val(data.item_code);
|
|
|
+ $modalQuota.find('[name="entry_name"]').val(data.entry_name);
|
|
|
+ $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('#ex_row').html(data.ex_row);
|
|
|
+ $modalQuota.find('#ex_amount').html(data.ex_amount);
|
|
|
+ $modalQuota.find('#ex_cell').html(data.ex_cell);
|
|
|
+ $modalQuota.find('#ex_unit').html(data.ex_unit);
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function SaveQuota(isSubmit){
|
|
|
+ const quota_id = $modalQuota.find('[name="quota_id"]').val(),
|
|
|
+ task_id = $modalQuota.find('[name="task_id"]').val(),
|
|
|
+ budget_id = $modalQuota.find('[name="budget_id"]').val(),
|
|
|
+ project_id = $modalQuota.find('[name="project_id"]').val(),
|
|
|
+ item_id = $modalQuota.find('[name="item_id"]').val(),
|
|
|
+ item_code = $modalQuota.find('[name="item_code"]').val(),
|
|
|
+ entry_name = $modalQuota.find('[name="entry_name"]').val(),
|
|
|
+ amount = $modalQuota.find('[name="amount"]').val(),
|
|
|
+ units = $modalQuota.find('[name="units"]').val(),
|
|
|
+ quota_code = $modalQuota.find('[name="quota_code"]').val()
|
|
|
+ IwbAjax({
|
|
|
+ url:`/api/quota/save`,
|
|
|
+ data:{
|
|
|
+ id: quota_id,
|
|
|
+ task_id,
|
|
|
+ budget_id,
|
|
|
+ project_id,
|
|
|
+ item_id,
|
|
|
+ item_code,
|
|
|
+ entry_name,
|
|
|
+ amount,
|
|
|
+ units,
|
|
|
+ quota_code,
|
|
|
+ run_now: isSubmit?'true':'false'
|
|
|
+ },
|
|
|
+ modal:$modalQuota,
|
|
|
+ table:`#table_${budget_id}`
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function Delete_Quota(id,budget_id){
|
|
|
+ ConfirmUrl('确定删除吗?',`/api/quota/delete/${id}`,`#table_${budget_id}`)
|
|
|
+}
|
|
|
+
|
|
|
+// function StartProcessQuota(id,budget_id){
|
|
|
+// ConfirmUrl('确定开始处理吗?',`/api/quota/start_process/${id}`,`#table_${budget_id}`)
|
|
|
+// }
|
|
|
+// function ReStartProcessQuota(id,budget_id){
|
|
|
+// ConfirmUrl('确定重新开始处理吗?',`/api/quota/start_process/${id}`,`#table_${budget_id}`)
|
|
|
+// }
|
|
|
+function StartSendQuota(id,budget_id){
|
|
|
+ ConfirmUrl('确定开始发送吗?',`/api/quota/start_send/${id}`,`#table_${budget_id}`)
|
|
|
+}
|
|
|
+function ReStartSendQuota(id,budget_id){
|
|
|
+ ConfirmUrl('确定重新开始发送吗?',`/api/quota/start_send/${id}`,`#table_${budget_id}`)
|
|
|
+}
|