吉安感知网项目-前端
shuishen
2026-02-03 89380e6260a75d1d3b94de687ebcc2f50d50659d
applications/task-work-order/src/views/orderView/orderDataManage/supplyAdd/index.vue
@@ -3,7 +3,7 @@
      <el-form ref="queryParamsRef" :model="searchParams" class="gd-search-form">
         <el-form-item label="需求名称" prop="demandName">
            <el-input
               class="gd-input"
               class="gd-input gray"
               v-model="searchParams.demandName"
               placeholder="请输入"
               clearable
@@ -13,7 +13,7 @@
         <el-form-item label="需求状态" prop="demandStatus">
            <el-select
               class="gd-select"
               class="gd-select gray"
               popper-class="gd-select-popper"
               v-model="searchParams.demandStatus"
               placeholder="请选择"
@@ -35,15 +35,18 @@
         </el-form-item>
      </el-form>
      <div class="gd-table-toolbar">
      <div class="gd-table-toolbar" v-if="permissionList.addBtn">
         <el-button :icon="Plus" color="#4C34FF" type="primary" @click="openForm('add')">供需填报新增</el-button>
<!--         <el-button :icon="Delete" color="#4C34FF" :disabled="!selectedIds.length" @click="handleDelete()">删除</el-button>-->
      </div>
      <div class="gd-table-container" v-loading="loading">
         <div class="gd-table-content gd-table-content-bg">
            <el-table class="gd-table" :data="list" @selection-change="handleSelectionChange">
               <el-table-column type="selection" width="46" />
            <el-table class="gd-table" :data="list">
               <el-table-column label="序号" width="70" align="center">
                  <template #default="scope">
                     {{ scope.$index + 1 }}
                  </template>
               </el-table-column>
               <el-table-column prop="demandName" show-overflow-tooltip label="需求名称" />
               <el-table-column prop="demandType" show-overflow-tooltip label="需求类型">
                  <template v-slot="{ row }">
@@ -51,7 +54,7 @@
                  </template>
               </el-table-column>
               <el-table-column prop="contactPerson" show-overflow-tooltip label="需求联系人" />
               <el-table-column prop="contactPhone" show-overflow-tooltip label="需求联系人电话" />
               <el-table-column prop="contactPhone" show-overflow-tooltip width="180" label="需求联系人电话" />
               <el-table-column prop="contactEmail" show-overflow-tooltip label="需求邮箱" />
               <el-table-column prop="demandStatus" show-overflow-tooltip label="需求状态">
                  <template v-slot="{ row }">
@@ -73,13 +76,12 @@
               <el-table-column prop="responsibleDeptName" show-overflow-tooltip label="责任部门" />
               <el-table-column prop="dataSource" show-overflow-tooltip label="数据来源依据" />
               <el-table-column prop="demandInfo" show-overflow-tooltip label="需求信息项" />
               <el-table-column label="操作" class-name="operation-btns">
               <el-table-column label="操作" class-name="operation-btns" width="150">
                  <template v-slot="{ row }">
               <el-link @click="openForm('view', row)">查看</el-link>
               <!-- 只对非审批状态显示编辑和删除按钮 -->
               <el-link @click="openForm('edit', row)" v-if="!['1', '2', '3'].includes(row.demandStatus)">编辑</el-link>
               <el-link @click="handleDelete(row)" v-if="!['1', '2', '3'].includes(row.demandStatus)">删除</el-link>
            </template>
                     <el-link  type="primary"  @click="openForm('view', row)">查看</el-link>
                     <el-link  type="primary"  @click="openForm('edit', row)" v-if="!['1', '2', '3'].includes(row.demandStatus) && permissionList.addBtn">编辑</el-link>
                     <el-link  type="primary"  @click="handleDelete(row)" v-if="!['1', '2', '3'].includes(row.demandStatus) && permissionList.deleteBtn">删除</el-link>
                  </template>
               </el-table-column>
            </el-table>
         </div>
@@ -113,7 +115,9 @@
   gdSupplyDemandPageApi,
   gdSupplyDemandRemoveApi,
} from '@/views/orderView/orderDataManage/supplyAdd/supplyAddApi'
import { useStore } from 'vuex'
const store = useStore()
const permission = computed(() => store.state.user.permission);
// 初始化查询参数
const initSearchParams = () => ({
   demandName: '', // 需求名称
@@ -125,7 +129,6 @@
const total = ref(0) // 总条数
const loading = ref(true) // 列表加载中
const list = ref([]) // 列表数据
const selectedIds = ref([]) // 勾选的ID列表
const queryParamsRef = ref(null) // 查询表单实例
const dialogRef = ref(null) // 弹框实例
const dialogVisible = ref(false)
@@ -147,6 +150,19 @@
provide('treeProps', treeProps)
const detailDemandStatus = ref('')
provide('detailDemandStatus', detailDemandStatus)
const reasonForRejection = ref('') //拒绝原因
provide('reasonForRejection', reasonForRejection)
function validData(value, defaultValue) {
   return value !== undefined ? value : defaultValue
}
const permissionList = computed(() => {
   return {
      addBtn: validData(permission.value.orderData_addDemand, false),
      deleteBtn: validData(permission.value.orderData_delete, false),
   }
})
// 根据部门ID获取部门名称
function getDeptNameById(deptId, deptList) {
   if (!deptId || !Array.isArray(deptList)) return ''
@@ -171,7 +187,7 @@
      // 为每条记录添加部门名称
      list.value = records.map(item => ({
         ...item,
         responsibleDeptName: item.responsibleDeptName || getDeptNameById(item.responsibleDeptId, deptTree.value)
         responsibleDeptName: item.responsibleDeptName || getDeptNameById(item.responsibleDeptId, deptTree.value),
      }))
      total.value = res?.data?.data?.total ?? 0
   } finally {
@@ -220,23 +236,15 @@
// 删除
async function handleDelete(row) {
   const tips = row ? '该条' : '选中的项'
   await ElMessageBox.confirm(`确认删除${tips}吗?`, '提示', {
   await ElMessageBox.confirm('确认删除该条记录吗?', '提示', {
      type: 'warning',
      customClass: 'gd-confirm-custom',
      confirmButtonClass: 'gd-confirm-button',
      cancelButtonClass: 'gd-confirm-cancel-button',
   })
   const ids = row ? row.id : selectedIds.value.join(',')
   await gdSupplyDemandRemoveApi({ ids })
   await gdSupplyDemandRemoveApi({ ids: row.id })
   ElMessage.success('删除成功')
   selectedIds.value = []
   getList()
}
// 勾选值设置
function handleSelectionChange(rows) {
   selectedIds.value = rows.map(item => item.id)
}
// 获取字典