diff --git a/src/views/contract/components/printPaymentForm.vue b/src/views/contract/components/printPaymentForm.vue index f2fd410..c46e8c2 100644 --- a/src/views/contract/components/printPaymentForm.vue +++ b/src/views/contract/components/printPaymentForm.vue @@ -14,7 +14,7 @@
-
暂无事前支付表格内容
+
暂无事前审批表格内容
@@ -65,16 +65,98 @@ export default { this.$Message.error('获取付款详情失败') } }, + replaceControls(element) { + // 替换所有输入框(文本、数字、日期)为纯文本 + const inputs = element.getElementsByTagName('input') + Array.from(inputs).forEach(input => { + const span = document.createElement('span') + let displayText = input.value || '' + + // 处理不同类型的输入框 + if (input.type === 'checkbox' || input.type === 'radio') { + // 获取当前选中的值 + const checkedInput = element.querySelector(`input[name="${input.name}"]:checked`) + if (checkedInput) { + // 获取显示文本(如果有label,使用label的文本) + const label = element.querySelector(`label[for="${checkedInput.id}"]`) + displayText = label ? label.textContent : checkedInput.value || '' + } else { + displayText = '' + } + } else if (input.type === 'date') { + displayText = input.value ? new Date(input.value).toLocaleDateString() : '' + } + + span.textContent = displayText + // 复制原始输入框的样式 + span.style.cssText = window.getComputedStyle(input).cssText + span.style.display = 'inline-block' + span.style.width = input.offsetWidth + 'px' + span.style.height = input.offsetHeight + 'px' + span.style.border = 'none' + span.style.backgroundColor = 'transparent' + input.parentNode.replaceChild(span, input) + }) + + // 替换所有下拉框为纯文本 + const selects = element.getElementsByTagName('select') + Array.from(selects).forEach(select => { + const span = document.createElement('span') + span.textContent = select.options[select.selectedIndex]?.text || '' + // 复制原始下拉框的样式 + span.style.cssText = window.getComputedStyle(select).cssText + span.style.display = 'inline-block' + span.style.width = select.offsetWidth + 'px' + span.style.height = select.offsetHeight + 'px' + span.style.border = 'none' + span.style.backgroundColor = 'transparent' + select.parentNode.replaceChild(span, select) + }) + + // 替换所有文本域为纯文本 + const textareas = element.getElementsByTagName('textarea') + Array.from(textareas).forEach(textarea => { + const span = document.createElement('span') + span.textContent = textarea.value || '' + // 复制原始文本域的样式 + span.style.cssText = window.getComputedStyle(textarea).cssText + span.style.display = 'inline-block' + span.style.width = textarea.offsetWidth + 'px' + span.style.height = textarea.offsetHeight + 'px' + span.style.border = 'none' + span.style.backgroundColor = 'transparent' + textarea.parentNode.replaceChild(span, textarea) + }) + }, async print() { try { - const canvas = await html2canvas(this.$refs['printtable'], { + // 创建临时打印容器 + const tempContainer = document.createElement('div') + tempContainer.style.position = 'absolute' + tempContainer.style.left = '-9999px' + tempContainer.style.top = '-9999px' + document.body.appendChild(tempContainer) + + // 复制原始内容到临时容器 + const originalContent = this.$refs['printtable'].cloneNode(true) + tempContainer.appendChild(originalContent) + + // 在临时容器中替换控件 + this.replaceControls(tempContainer) + + // 使用临时容器进行打印 + const canvas = await html2canvas(tempContainer, { backgroundColor: null, useCORS: true, }) + + // 打印完成后移除临时容器 + document.body.removeChild(tempContainer) + printJS({ printable: canvas.toDataURL(), type: 'image', - documentTitle: `苏州市河道管理处${this.currentForm === 'pre' ? '事前' : '事后'}支付表格`, + documentTitle: `苏州市河道管理处${this.currentForm === 'pre' ? '事前审批表格' : '事后支付表格'}`, style: '@page{margin:auto;}' }) } catch (error) { diff --git a/src/views/contract/contractList.vue b/src/views/contract/contractList.vue index c0f2846..70d05c7 100644 --- a/src/views/contract/contractList.vue +++ b/src/views/contract/contractList.vue @@ -3,6 +3,34 @@
+ +
+ + + +
+
关键字 @@ -140,7 +168,6 @@
- + @@ -81,7 +90,8 @@ import { listdept, save, - del + del, + updateStatus } from "../../api/system/department.js"; import { listuser @@ -110,7 +120,8 @@ leader: "", sortnumber: 0, icon: "", - pname: "上级部门" + pname: "上级部门", + status: 1 // 添加状态字段,1-启用,0-禁用 }, rules: { name: [{ @@ -239,6 +250,31 @@ }); } }, + // 切换部门状态 + toggleStatus(row) { + const newStatus = row.status === 1 ? 0 : 1; + const actionText = newStatus === 1 ? '启用' : '禁用'; + + this.$confirm(`确认要${actionText}该部门?`, '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: newStatus === 1 ? 'success' : 'warning', + center: true + }).then(() => { + const params = { + id: row.id, + status: newStatus + }; + save(params).then(response => { + this.$message.success('操作成功'); + this.load(); + }).catch(error => { + this.$message.error('操作失败'); + }); + }).catch(() => { + // 取消 + }); + }, } }; - +