|
|
|
|
@ -4,6 +4,33 @@
|
|
|
|
|
<div slot="content"></div>
|
|
|
|
|
<slot>
|
|
|
|
|
<div class="selects">
|
|
|
|
|
<div>
|
|
|
|
|
<span style="padding: 0 6px;word-break: keep-all;">
|
|
|
|
|
合同分类
|
|
|
|
|
</span>
|
|
|
|
|
<Select v-model="select.contract_category" @on-change="handleCategoryChange" disabled placeholder="请选择合同分类" style="width:140px;">
|
|
|
|
|
<Option v-for="item in categoryOptions" :key="item.id" :value="item.id">{{ item.value || item.name }}</Option>
|
|
|
|
|
</Select>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<span style="padding: 0 6px;word-break: keep-all;">
|
|
|
|
|
事务类型
|
|
|
|
|
</span>
|
|
|
|
|
<Select v-model="select.work_type" @on-change="handleTransactionTypeChange" multiple clearable placeholder="请选择事务类型" style="width:140px;">
|
|
|
|
|
<Option v-for="item in transactionTypes" :key="item.id" :value="item.id">{{ item.value || item.name }}</Option>
|
|
|
|
|
</Select>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<span style="padding: 0 6px;word-break: keep-all;">
|
|
|
|
|
合同类型
|
|
|
|
|
</span>
|
|
|
|
|
<Select v-model="select.contract_type" @on-change="handleContractTypeChange" multiple clearable placeholder="请选择合同类型" style="width:140px;">
|
|
|
|
|
<Option v-for="item in contractTypes" :key="item.id" :value="item.id">{{ item.value || item.name }}</Option>
|
|
|
|
|
</Select>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<span style="padding: 0 6px;word-break: keep-all;">关键字</span>
|
|
|
|
|
<span>
|
|
|
|
|
@ -411,6 +438,7 @@
|
|
|
|
|
import {
|
|
|
|
|
getInfo
|
|
|
|
|
} from '@/api/user.js'
|
|
|
|
|
import { getContractCategoryTemplateBaseConfig } from "@/api/businessConfig/businessConfig"
|
|
|
|
|
|
|
|
|
|
import editor from "./components/editorContract"
|
|
|
|
|
import detail from "./components/detailContract"
|
|
|
|
|
@ -489,7 +517,10 @@
|
|
|
|
|
showDatePickerBao: "",
|
|
|
|
|
start_assurance_expire: "",
|
|
|
|
|
end_assurance_expire: "",
|
|
|
|
|
is_contract: ''
|
|
|
|
|
is_contract: '',
|
|
|
|
|
contract_category: '',
|
|
|
|
|
work_type: '',
|
|
|
|
|
contract_type: ''
|
|
|
|
|
},
|
|
|
|
|
types: [{
|
|
|
|
|
label: '服务',
|
|
|
|
|
@ -982,6 +1013,11 @@
|
|
|
|
|
plansPageIndex: 1,
|
|
|
|
|
|
|
|
|
|
isShowEditor: false,
|
|
|
|
|
contractCategories: [], // 合同分类
|
|
|
|
|
transactionTypes: [], // 事务类型
|
|
|
|
|
contractTypes: [], // 合同类型
|
|
|
|
|
categoryOptions: [], // 分类选项
|
|
|
|
|
purchaseMethodsMap: {}, // 采购方式映射
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
@ -1509,33 +1545,136 @@
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 获取分类选项
|
|
|
|
|
async getCategoryOptions() {
|
|
|
|
|
try {
|
|
|
|
|
// 获取分类配置
|
|
|
|
|
const res = await getContractCategoryTemplateBaseConfig()
|
|
|
|
|
if (res.errcode !== undefined) {
|
|
|
|
|
this.$message.error(res.errmsg || '获取分类配置失败')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保存采购方式映射
|
|
|
|
|
this.purchaseMethodsMap = res.purchase_methods || {}
|
|
|
|
|
|
|
|
|
|
// 设置分类选项 - 从第二级开始(合同类、报销类、其他支出类)
|
|
|
|
|
this.categoryOptions = res.map?.[0]?.children || []
|
|
|
|
|
|
|
|
|
|
// 递归处理每一层的 children,确保所有层级都被正确解析
|
|
|
|
|
const processChildren = (items) => {
|
|
|
|
|
if (!items) return
|
|
|
|
|
items.forEach(item => {
|
|
|
|
|
if (item.children) {
|
|
|
|
|
// 确保每个子项都有正确的 id 和 name/value
|
|
|
|
|
item.children = item.children.map(child => ({
|
|
|
|
|
id: child.id,
|
|
|
|
|
name: child.name || child.value, // 添加对 value 字段的支持
|
|
|
|
|
value: child.value || child.name, // 保留原始的 value 字段
|
|
|
|
|
children: child.children || []
|
|
|
|
|
}))
|
|
|
|
|
processChildren(item.children)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 处理所有层级的 children
|
|
|
|
|
processChildren(this.categoryOptions)
|
|
|
|
|
|
|
|
|
|
// 更新下拉框数据
|
|
|
|
|
this.updateDropdownOptions()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取分类配置失败:', error)
|
|
|
|
|
this.$message.error('获取分类配置失败')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 更新下拉框选项
|
|
|
|
|
updateDropdownOptions() {
|
|
|
|
|
// 重置所有选项
|
|
|
|
|
this.transactionTypes = []
|
|
|
|
|
this.contractTypes = []
|
|
|
|
|
|
|
|
|
|
// 获取当前选中的分类
|
|
|
|
|
const selectedCategory = this.categoryOptions.find(item => item.id === this.select.contract_category)
|
|
|
|
|
if (!selectedCategory) return
|
|
|
|
|
|
|
|
|
|
// 更新事务类型选项
|
|
|
|
|
this.transactionTypes = selectedCategory.children || []
|
|
|
|
|
|
|
|
|
|
// 如果是初始化,默认全选事务类型
|
|
|
|
|
if (!this.select.work_type || this.select.work_type.length === 0) {
|
|
|
|
|
this.select.work_type = this.transactionTypes.map(item => item.id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取所有选中事务类型的合同类型
|
|
|
|
|
const selectedTransactionTypes = this.transactionTypes.filter(item =>
|
|
|
|
|
this.select.work_type.includes(item.id)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 合并所有选中事务类型的合同类型
|
|
|
|
|
this.contractTypes = selectedTransactionTypes.reduce((acc, curr) => {
|
|
|
|
|
return [...acc, ...(curr.children || [])]
|
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
|
|
// 如果是初始化,选择除了"无合同"(id=140)之外的所有合同类型
|
|
|
|
|
if (!this.select.contract_type || this.select.contract_type.length === 0) {
|
|
|
|
|
this.select.contract_type = this.contractTypes
|
|
|
|
|
.filter(item => item.id !== 140) // 排除"无合同"选项
|
|
|
|
|
.map(item => item.id)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 处理分类变更
|
|
|
|
|
handleCategoryChange() {
|
|
|
|
|
// 清空选择,让 updateDropdownOptions 重新初始化
|
|
|
|
|
this.select.work_type = []
|
|
|
|
|
this.select.contract_type = []
|
|
|
|
|
this.updateDropdownOptions()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 处理事务类型变更
|
|
|
|
|
handleTransactionTypeChange() {
|
|
|
|
|
// 清空合同类型选择,让 updateDropdownOptions 重新初始化
|
|
|
|
|
this.select.contract_type = []
|
|
|
|
|
this.updateDropdownOptions()
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 处理合同类型变更
|
|
|
|
|
handleContractTypeChange() {
|
|
|
|
|
this.updateDropdownOptions()
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.window.width = screen.availWidth * 0.95
|
|
|
|
|
this.window.height = screen.availHeight * 0.95
|
|
|
|
|
this.window.top = (window.screen.height - 30 - this.window.height) / 2
|
|
|
|
|
this.window.left = (window.screen.width - 10 - this.window.width) / 2
|
|
|
|
|
this.window.width = screen.availWidth * 0.95;
|
|
|
|
|
this.window.height = screen.availHeight * 0.95;
|
|
|
|
|
this.window.top = (window.screen.height - 30 - this.window.height) / 2;
|
|
|
|
|
this.window.left = (window.screen.width - 10 - this.window.width) / 2;
|
|
|
|
|
let that = this;
|
|
|
|
|
getInfo().then(response => {
|
|
|
|
|
console.log(response)
|
|
|
|
|
console.log(response);
|
|
|
|
|
this.user = response;
|
|
|
|
|
|
|
|
|
|
if (that.userList.indexOf(response.username) != -1) {
|
|
|
|
|
|
|
|
|
|
that.hasEdit = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).catch(error => {})
|
|
|
|
|
this.getPurchaseType()
|
|
|
|
|
this.getContracts()
|
|
|
|
|
this.getDepartment()
|
|
|
|
|
this.getPurchaseWay()
|
|
|
|
|
this.getMoneyWay()
|
|
|
|
|
}).catch(error => {});
|
|
|
|
|
this.getPurchaseType();
|
|
|
|
|
this.getContracts();
|
|
|
|
|
this.getDepartment();
|
|
|
|
|
this.getPurchaseWay();
|
|
|
|
|
this.getMoneyWay();
|
|
|
|
|
// 获取分类数据
|
|
|
|
|
this.getCategoryOptions().then(() => {
|
|
|
|
|
// 设置默认选择第一个分类
|
|
|
|
|
if (this.categoryOptions && this.categoryOptions.length > 0) {
|
|
|
|
|
this.select.contract_category = this.categoryOptions[0].id;
|
|
|
|
|
this.handleCategoryChange();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
//页面激活后刷新合同列表
|
|
|
|
|
window.onfocus = () => {
|
|
|
|
|
this.getContracts()
|
|
|
|
|
}
|
|
|
|
|
this.getContracts();
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
destroyed() {
|
|
|
|
|
window.onfocus = null
|
|
|
|
|
@ -1601,4 +1740,4 @@
|
|
|
|
|
content: '(元)'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
</style>
|
|
|
|
|
|