-
@@ -817,6 +844,7 @@ export default {
}
return {
+ selectedCategory: 'contract', // 添加选中的分类
userList: ["liuxiangyu", "zhushulan", "admin", "jiangjiao"],
window: {
width: 0,
@@ -3240,6 +3268,53 @@ export default {
}
this.showPaymentFormPreview = false;
},
+ // 添加分类选择处理方法
+ handleCategorySelect(category) {
+ this.selectedCategory = category;
+ // 根据分类筛选数据
+ this.select.category = category;
+ this.getContracts();
+ },
+ // 添加按分类新增合同的方法
+ async handleAddContractByCategory(category) {
+ // 先设置 loading 状态
+ this.loading = true;
+
+ try {
+ // 显示弹窗
+ this.isShowAdd = true;
+ this.isEditMode = false;
+ this.isFromPayment = false;
+
+ // 等待获取分类配置
+ await this.getCategoryOptions();
+
+ // 重置表单
+ this.resetForm();
+
+ // 根据分类自动选择对应的选项
+ if (this.categoryOptions && this.categoryOptions.length > 0) {
+ // 找到对应分类的选项
+ const categoryOption = this.categoryOptions.find(item => {
+ const name = item.name || item.value || '';
+ return name.includes(category === 'contract' ? '合同' :
+ category === 'reimbursement' ? '报销' : '其他支出');
+ });
+
+ if (categoryOption) {
+ this.form.category = categoryOption.id;
+ // 触发分类变更,自动选择后续选项
+ this.handleCategoryChange();
+ }
+ }
+ } catch (error) {
+ console.error('加载数据失败:', error);
+ this.$message.error('加载数据失败');
+ } finally {
+ // 无论成功失败都关闭 loading
+ this.loading = false;
+ }
+ },
},
mounted() {
this.window.width = screen.availWidth * 0.95
@@ -3689,6 +3764,38 @@ export default {
}
}
}
+
+// 添加分类按钮样式
+.category-buttons {
+ display: flex;
+ justify-content: center;
+ gap: 20px;
+ margin-bottom: 20px;
+ padding: 10px 0;
+
+ .category-button {
+ min-width: 180px;
+ height: 48px;
+ font-size: 16px;
+ font-weight: 500;
+ border-radius: 8px;
+ transition: all 0.3s ease;
+ background: #2d8cf0;
+ border-color: #2d8cf0;
+
+ &:hover {
+ transform: translateY(-2px);
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
+ background: #2b85e4;
+ border-color: #2b85e4;
+ }
+
+ &:active {
+ transform: translateY(0);
+ box-shadow: none;
+ }
+ }
+}
+
diff --git a/src/views/system/department.vue b/src/views/system/department.vue
index cddeddd..ab5d5f1 100644
--- a/src/views/system/department.vue
+++ b/src/views/system/department.vue
@@ -40,6 +40,15 @@
ghost>下级部门
+
@@ -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(() => {
+ // 取消
+ });
+ },
}
};
-
+