修改进度管理bug
This commit is contained in:
		| @ -4,112 +4,117 @@ | ||||
|       <div v-show="showSearch" class="mb-[10px]"> | ||||
|         <el-card shadow="hover"> | ||||
|           <el-form ref="queryFormRef" :model="queryParams" :inline="true"> | ||||
|             <el-form-item label="请选择方阵:" prop="pid" label-width="100"> | ||||
|               <!-- <el-input v-model="queryParams.pid" placeholder="请选择" clearable /> --> | ||||
|               <el-cascader | ||||
|                 :options="matrixOptions" | ||||
|                 ref="treeRef" | ||||
|                 placeholder="请选择" | ||||
|                 @change="handleChange" | ||||
|                 :props="{ value: 'matrixId', label: 'name' }" | ||||
|                 v-model="queryParams.matrixId" | ||||
|                 clearable | ||||
|               /> | ||||
|               <!-- <el-select v-model="matrixValue" placeholder="请选择" @change="handleChange" clearable> | ||||
|                 <el-option v-for="item in matrixOptions" :key="item.id" :label="item.matrixName" :value="item.id" /> | ||||
|               </el-select> --> | ||||
|             <el-form-item label="请选择项目:" prop="pid" label-width="100"> | ||||
|               <el-select v-model="queryParams.projectId" placeholder="请选择" @change="handleChange" clearable> | ||||
|                 <el-option v-for="item in matrixOptions" :key="item.projectId" :label="item.name" :value="item.projectId" /> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|             <el-form-item label="请选择方阵:" prop="pid" label-width="100" v-if="relevancyStructure == '2'"> | ||||
|               <el-select v-model="matrixValue" placeholder="请选择" @change="handleChange" clearable> | ||||
|                 <el-option v-for="item in matrixList" :key="item.id" :label="item.matrixName" :value="item.id" /> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|           </el-form> | ||||
|         </el-card> | ||||
|       </div> | ||||
|     </transition> | ||||
|     <el-tabs type="border-card" v-model="activeTab" @tab-click="handleTabClick"> | ||||
|       <el-tab-pane :label="item.name" v-for="item in tabList" :key="item.id" :name="item.id"></el-tab-pane> | ||||
|       <el-card shadow="never"> | ||||
|         <template #header> | ||||
|           <el-row :gutter="10" class="mb8"> | ||||
|             <el-col :span="1.5"> | ||||
|               <el-button type="primary" plain icon="Plus" @click="handleAdd()">新增</el-button> | ||||
|             </el-col> | ||||
|             <el-col :span="1.5"> | ||||
|               <file-upload | ||||
|                 upload-url="/progress/progressCategory/import" | ||||
|                 v-model="file" | ||||
|                 :limit="1" | ||||
|                 :file-type="['xls', 'xlsx']" | ||||
|                 :on-upload-success="handleSuccess" | ||||
|               > | ||||
|                 <el-button type="primary" plain icon="Compass">导入</el-button> | ||||
|               </file-upload> | ||||
|             </el-col> | ||||
|             <el-col :span="1.5"> | ||||
|               <el-button type="primary" plain icon="Filter" @click="handleExport">导出</el-button> | ||||
|             </el-col> | ||||
|             <el-col :span="1.5"> | ||||
|               <el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button> | ||||
|             </el-col> | ||||
|             <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> | ||||
|           </el-row> | ||||
|         </template> | ||||
|         <el-table | ||||
|           ref="progressCategoryTableRef" | ||||
|           v-loading="loading" | ||||
|           :data="progressCategoryList" | ||||
|           row-key="id" | ||||
|           :default-expand-all="isExpandAll" | ||||
|           :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" | ||||
|         > | ||||
|           <!-- <el-table-column label="父类别id" prop="parentId" /> --> | ||||
|           <el-table-column label="类别名称" prop="name" width="230" /> | ||||
|           <el-table-column label="计量方式" align="center" prop="unitType"> | ||||
|             <template #default="{ row }"> | ||||
|               <dict-tag :options="progress_unit_type" :value="row.unitType" v-if="row.parentId != 0" /> | ||||
|               <span v-else></span> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="计量单位" align="center" prop="unit"> | ||||
|             <template #default="{ row }"> | ||||
|               {{ row.parentId == 0 ? '' : row.unit }} | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="综合单价(业主)" align="center" prop="ownerPrice"> | ||||
|             <template #default="{ row }"> | ||||
|               {{ row.parentId == 0 ? '' : row.ownerPrice }} | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="综合单价(分包)" align="center" prop="constructionPrice"> | ||||
|             <template #default="{ row }"> | ||||
|               {{ row.parentId == 0 ? '' : row.constructionPrice }} | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="产值金额(业主)" align="center" prop="ownerOutputValue"> | ||||
|             <template #default="{ row }"> | ||||
|               {{ row.parentId == 0 ? '' : row.ownerOutputValue }} | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="产值金额(分包)" align="center" prop="constructionOutputValue"> | ||||
|             <template #default="{ row }"> | ||||
|               {{ row.parentId == 0 ? '' : row.constructionOutputValue }} | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="总数量" align="center" prop="total"> | ||||
|             <template #default="{ row }"> | ||||
|               {{ row.parentId == 0 ? '' : row.total }} | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="关联结构" align="center" prop="relevancyStructure" width="100"> | ||||
|             <template #default="{ row }"> | ||||
|               <el-tag :type="row.relevancyStructure == '1' ? 'primary' : 'success'"> | ||||
|                 {{ row.relevancyStructure == '1' ? '子项目' : '方阵' }} | ||||
|               </el-tag> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||||
|             <template #default="scope"> | ||||
|               <div> | ||||
|                 <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['progress:progressCategory:edit']"> | ||||
|                   修改 | ||||
|                 </el-button> | ||||
|                 <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['progress:progressCategory:remove']"> | ||||
|                   删除 | ||||
|                 </el-button> | ||||
|               </div> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|         </el-table> | ||||
|       </el-card> | ||||
|     </el-tabs> | ||||
|  | ||||
|     <el-card shadow="never"> | ||||
|       <template #header> | ||||
|         <el-row :gutter="10" class="mb8"> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="primary" plain icon="Plus" @click="handleAdd">新增</el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <file-upload | ||||
|               upload-url="/progress/progressCategory/import" | ||||
|               v-model="file" | ||||
|               :limit="1" | ||||
|               :file-type="['xls', 'xlsx']" | ||||
|               :on-upload-success="handleSuccess" | ||||
|             > | ||||
|               <el-button type="primary" plain icon="Compass">导入</el-button> | ||||
|             </file-upload> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="primary" plain icon="Filter" @click="handleExport">导出</el-button> | ||||
|           </el-col> | ||||
|           <el-col :span="1.5"> | ||||
|             <el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button> | ||||
|           </el-col> | ||||
|           <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar> | ||||
|         </el-row> | ||||
|       </template> | ||||
|       <el-table | ||||
|         ref="progressCategoryTableRef" | ||||
|         v-loading="loading" | ||||
|         :data="progressCategoryList" | ||||
|         row-key="id" | ||||
|         :default-expand-all="isExpandAll" | ||||
|         :tree-props="{ children: 'children', hasChildren: 'hasChildren' }" | ||||
|       > | ||||
|         <!-- <el-table-column label="父类别id" prop="parentId" /> --> | ||||
|         <el-table-column label="类别名称" prop="name" width="230" /> | ||||
|         <el-table-column label="计量方式" align="center" prop="unitType"> | ||||
|           <template #default="{ row }"> | ||||
|             <dict-tag :options="progress_unit_type" :value="row.unitType" v-if="row.parentId != 0" /> | ||||
|             <span v-else></span> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="计量单位" align="center" prop="unit"> | ||||
|           <template #default="{ row }"> | ||||
|             {{ row.parentId == 0 ? '' : row.unit }} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="综合单价(业主)" align="center" prop="ownerPrice"> | ||||
|           <template #default="{ row }"> | ||||
|             {{ row.parentId == 0 ? '' : row.ownerPrice }} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="综合单价(分包)" align="center" prop="constructionPrice"> | ||||
|           <template #default="{ row }"> | ||||
|             {{ row.parentId == 0 ? '' : row.constructionPrice }} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="产值金额(业主)" align="center" prop="ownerOutputValue"> | ||||
|           <template #default="{ row }"> | ||||
|             {{ row.parentId == 0 ? '' : row.ownerOutputValue }} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="产值金额(分包)" align="center" prop="constructionOutputValue"> | ||||
|           <template #default="{ row }"> | ||||
|             {{ row.parentId == 0 ? '' : row.constructionOutputValue }} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="总数量" align="center" prop="total"> | ||||
|           <template #default="{ row }"> | ||||
|             {{ row.parentId == 0 ? '' : row.total }} | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|         <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||||
|           <template #default="scope"> | ||||
|             <div> | ||||
|               <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['progress:progressCategory:edit']"> | ||||
|                 修改 | ||||
|               </el-button> | ||||
|               <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['progress:progressCategory:remove']"> | ||||
|                 删除 | ||||
|               </el-button> | ||||
|             </div> | ||||
|           </template> | ||||
|         </el-table-column> | ||||
|       </el-table> | ||||
|     </el-card> | ||||
|     <!-- 添加或修改分项工程单价对话框 --> | ||||
|     <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body> | ||||
|       <el-form ref="progressCategoryFormRef" :model="form" :rules="rules" label-width="120px"> | ||||
| @ -148,6 +153,12 @@ | ||||
|             <el-option v-for="dict in progress_work_type" :key="dict.value" :label="dict.label" :value="dict.value" /> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="关联结构" prop="relevancyStructure"> | ||||
|           <el-select v-model="form.relevancyStructure" value-key="" placeholder="请选择关联结构" clearable filterable @change=""> | ||||
|             <el-option label="子项目" value="1"></el-option> | ||||
|             <el-option label="方阵" value="2"></el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|         <el-form-item label="备注" prop="remark" v-if="!form.id"> | ||||
|           <el-input v-model="form.remark" placeholder="请输入备注" /> | ||||
|         </el-form-item> | ||||
| @ -173,14 +184,20 @@ import { | ||||
|   delProgressCategory, | ||||
|   addProgressCategory, | ||||
|   updateProgressCategory, | ||||
|   downloadProgressCategory | ||||
|   downloadProgressCategory, | ||||
|   getCategoryTabList, | ||||
|   getCategoryList | ||||
| } from '@/api/progress/progressCategory'; | ||||
| import { ProgressCategoryVO, ProgressCategoryQuery, ProgressCategoryForm } from '@/api/progress/progressCategory/types'; | ||||
| import { getTabList } from '@/api/progress/progressCategoryTemplate'; | ||||
| import { useUserStoreHook } from '@/store/modules/user'; | ||||
|  | ||||
| const { proxy } = getCurrentInstance() as ComponentInternalInstance; | ||||
| const { progress_unit_type, progress_work_type } = toRefs<any>(proxy?.useDict('progress_unit_type', 'progress_work_type')); | ||||
|  | ||||
| const activeTab = ref('0'); | ||||
| const relevancyStructure = ref('1'); | ||||
| const matrixList = ref([]); | ||||
| const tabList = ref<any[]>([]); | ||||
| // 获取用户 store | ||||
| const userStore = useUserStoreHook(); | ||||
| // 从 store 中获取项目列表和当前选中的项目 | ||||
| @ -219,6 +236,8 @@ const initFormData: ProgressCategoryForm = { | ||||
|   unitType: undefined, | ||||
|   unit: undefined, | ||||
|   constructionPrice: undefined, | ||||
|   relevancyStructure: undefined, | ||||
|  | ||||
|   ownerPrice: undefined, | ||||
|   unitPrice: undefined, | ||||
|   outputValue: undefined, | ||||
| @ -235,7 +254,7 @@ const data = reactive<PageData<ProgressCategoryForm, ProgressCategoryQuery>>({ | ||||
|   form: { ...initFormData }, | ||||
|   queryParams: { | ||||
|     parentId: undefined, | ||||
|     projectId: currentProject.value?.id, | ||||
|     projectId: undefined, | ||||
|  | ||||
|     matrixId: undefined, | ||||
|     matrixName: undefined, | ||||
| @ -264,7 +283,8 @@ const data = reactive<PageData<ProgressCategoryForm, ProgressCategoryQuery>>({ | ||||
|     isDelay: [{ required: true, message: '是否超期不能为空', trigger: 'blur' }], | ||||
|     status: [{ required: true, message: '完成状态不能为空', trigger: 'change' }], | ||||
|     constructionPrice: [{ required: true, message: '综合单价(分包)不能为空', trigger: 'change' }], | ||||
|     ownerPrice: [{ required: true, message: '综合单价(业主)不能为空', trigger: 'change' }] | ||||
|     ownerPrice: [{ required: true, message: '综合单价(业主)不能为空', trigger: 'change' }], | ||||
|     relevancyStructure: [{ required: true, message: '关联结构不能为空', trigger: 'change' }] | ||||
|   } | ||||
| }); | ||||
|  | ||||
| @ -273,7 +293,7 @@ const matrixIdList = ref([]); | ||||
|  | ||||
| /** 查询分项工程单价列表 */ | ||||
| const getList = async () => { | ||||
|   if (!queryParams.value.matrixId) { | ||||
|   if (!queryParams.value.projectId) { | ||||
|     const res = await getProjectSquare(currentProject.value?.id); | ||||
|     if (res.data.length === 0) { | ||||
|       proxy?.$modal.msgWarning('当前项目下没有方阵,请先创建方阵'); | ||||
| @ -286,17 +306,26 @@ const getList = async () => { | ||||
|       }); | ||||
|       if (!matrixValue.value) matrixValue.value = matrixList[0].id; | ||||
|       matrixOptions.value = matrixList; | ||||
|       queryParams.value.matrixId = matrixList[0].children[0].matrixId; | ||||
|       queryParams.value.projectId = matrixList[0].projectId; | ||||
|       form.value.projectId = matrixList[0].projectId; | ||||
|       form.value.matrixId = matrixList[0].children[0].matrixId; | ||||
|       // form.value.matrixId = matrixList[0].projectId; | ||||
|       await getCategoryTabList(queryParams.value.projectId as string).then((res) => { | ||||
|         tabList.value = res.data; | ||||
|         activeTab.value = res.data[0]?.id; | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
|   loading.value = true; | ||||
|   try { | ||||
|     const res = await listProgressCategory(queryParams.value); | ||||
|     const id = relevancyStructure.value == '2' ? matrixValue.value : activeTab.value; | ||||
|     const res = await listProgressCategory(id); | ||||
|     const data = proxy?.handleTree<ProgressCategoryVO>(res.data, 'id', 'parentId'); | ||||
|     if (data) { | ||||
|       progressCategoryList.value = data; | ||||
|       progressCategoryOptions.value = []; | ||||
|       const datas: ProgressCategoryOption = { id: 0, name: '顶级节点', children: [...data] }; | ||||
|       progressCategoryOptions.value.push(datas); | ||||
|       console.log('🚀 ~ getList ~ progressCategoryOptions.value:', progressCategoryOptions.value); | ||||
|       loading.value = false; | ||||
|     } | ||||
|   } finally { | ||||
| @ -311,11 +340,12 @@ const handleSuccess = () => { | ||||
|  | ||||
| /** 查询分项工程单价下拉树结构 */ | ||||
| const getTreeselect = async () => { | ||||
|   const res = await listProgressCategory(queryParams.value); | ||||
|   progressCategoryOptions.value = []; | ||||
|   const data: ProgressCategoryOption = { id: 0, name: '顶级节点', children: [] }; | ||||
|   data.children = proxy?.handleTree<ProgressCategoryOption>(res.data, 'id', 'parentId'); | ||||
|   progressCategoryOptions.value.push(data); | ||||
|   // const id = relevancyStructure.value == '2' ? matrixValue.value : activeTab.value; | ||||
|   // const res = await getCategoryList(id); | ||||
|   // progressCategoryOptions.value = []; | ||||
|   // const data: ProgressCategoryOption = { id: 0, name: '顶级节点', children: [] }; | ||||
|   // data.children = proxy?.handleTree<ProgressCategoryOption>(res.data, 'id', 'parentId'); | ||||
|   // progressCategoryOptions.value.push(data); | ||||
| }; | ||||
|  | ||||
| // 取消按钮 | ||||
| @ -324,6 +354,21 @@ const cancel = () => { | ||||
|   dialog.visible = false; | ||||
| }; | ||||
|  | ||||
| const handleTabClick = (tab: any) => { | ||||
|   const id = tab.props.name; // 实际上就是 item.id | ||||
|   const current = tabList.value.find((item) => item.id === id); | ||||
|   if (current.matrixStructureList && current.matrixStructureList.length > 0) { | ||||
|     matrixList.value = current.matrixStructureList; | ||||
|     activeTab.value = current.matrixStructureList[0].id; | ||||
|     matrixValue.value = current.matrixStructureList[0].id; | ||||
|   } else { | ||||
|     activeTab.value = current.id; | ||||
|   } | ||||
|  | ||||
|   relevancyStructure.value = current.relevancyStructure; | ||||
|   getList(); | ||||
| }; | ||||
|  | ||||
| // 表单重置 | ||||
| const reset = () => { | ||||
|   const projectId = form.value.projectId; | ||||
| @ -332,10 +377,7 @@ const reset = () => { | ||||
|   progressCategoryFormRef.value?.resetFields(); | ||||
| }; | ||||
| /** 级联选择器改变事件 */ | ||||
| const handleChange = (value: number) => { | ||||
|   form.value.matrixId = value[1]; | ||||
|   form.value.projectId = value[0]; | ||||
|   queryParams.value.matrixId = value[1]; | ||||
| const handleChange = (value: string) => { | ||||
|   getList(); | ||||
| }; | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user