|
|
@@ -85,6 +85,20 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="项目部" prop="projectDeptId">
|
|
|
+ <el-select
|
|
|
+ v-model="formData.projectDeptId"
|
|
|
+ :options="deptOptions"
|
|
|
+ filterable
|
|
|
+ placeholder="请选择项目部"
|
|
|
+ clearable
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-row>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="责任人" prop="responsiblePerson">
|
|
|
<el-tooltip
|
|
|
@@ -101,7 +115,7 @@
|
|
|
type="primary"
|
|
|
size="small"
|
|
|
@click="openUserDialog"
|
|
|
- style="margin-left: 10px;"
|
|
|
+ style="margin-left: 10px"
|
|
|
:disabled="!formData.deptId"
|
|
|
>
|
|
|
选择责任人
|
|
|
@@ -109,9 +123,6 @@
|
|
|
<div v-if="!formData.deptId" class="el-form-item__error">请先选择所属公司</div>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- </el-row>
|
|
|
-
|
|
|
- <el-row>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item :label="t('project.overseaFlag')" prop="overseas">
|
|
|
<el-select v-model="formData.overseas" placeholder="请选择" clearable>
|
|
|
@@ -124,6 +135,9 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-row>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item :label="t('project.overseaArea')" prop="overseasArea">
|
|
|
<el-select v-model="formData.overseasArea" placeholder="请选择" clearable>
|
|
|
@@ -136,9 +150,6 @@
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- </el-row>
|
|
|
-
|
|
|
- <el-row>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item :label="t('project.workArea')" prop="location">
|
|
|
<el-autocomplete
|
|
|
@@ -163,7 +174,8 @@
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
-
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="虚拟项目" prop="contractSubject">
|
|
|
<el-switch
|
|
|
@@ -175,10 +187,7 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- </el-row>
|
|
|
-
|
|
|
- <el-row>
|
|
|
- <el-col :span="24">
|
|
|
+ <el-col :span="12">
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
<el-input v-model="formData.remark" placeholder="请输入备注" type="textarea" />
|
|
|
</el-form-item>
|
|
|
@@ -235,18 +244,17 @@
|
|
|
</ContentWrap>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
-
|
|
|
import { IotProjectInfoApi, IotProjectInfoVO } from '@/api/pms/iotprojectinfo'
|
|
|
-import {defaultProps,handleTree} from "@/utils/tree";
|
|
|
-import * as DeptApi from "@/api/system/dept";
|
|
|
+import { defaultProps } from '@/utils/tree'
|
|
|
+import * as DeptApi from '@/api/system/dept'
|
|
|
import CustomerList from '@/views/pms/device/CustomerList.vue'
|
|
|
-import {ref} from "vue";
|
|
|
-import {useUserStore} from "@/store/modules/user";
|
|
|
-import {IotProjectTaskApi, IotProjectTaskVO} from "@/api/pms/iotprojecttask";
|
|
|
-import {useTagsViewStore} from "@/store/modules/tagsView";
|
|
|
-import * as UserApi from "@/api/system/user";
|
|
|
-import {UserVO} from "@/api/system/user";
|
|
|
-import {DICT_TYPE, getIntDictOptions, getStrDictOptions, getDictLabel} from "@/utils/dict";
|
|
|
+import { ref } from 'vue'
|
|
|
+import { useUserStore } from '@/store/modules/user'
|
|
|
+import { IotProjectTaskVO } from '@/api/pms/iotprojecttask'
|
|
|
+import { useTagsViewStore } from '@/store/modules/tagsView'
|
|
|
+import * as UserApi from '@/api/system/user'
|
|
|
+import { UserVO } from '@/api/system/user'
|
|
|
+import { DICT_TYPE, getIntDictOptions, getStrDictOptions, getDictLabel } from '@/utils/dict'
|
|
|
import { Loading } from '@element-plus/icons-vue'
|
|
|
|
|
|
/** 项目信息 表单 */
|
|
|
@@ -265,21 +273,49 @@ const formLoading = ref(false) // 表单的加载中:1)修改时的数据加
|
|
|
const taskList = ref<IotProjectTaskVO[]>([]) // 列表的数据
|
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
const loading = ref(true) // 列表的加载中
|
|
|
-const simpleUsers = ref<UserVO[]>([]) // 责任人列表
|
|
|
+const simpleUsers = ref<UserVO[]>([]) // 责任人列表
|
|
|
+
|
|
|
+const deptLoading = ref(false)
|
|
|
+const deptOptions = ref<any[]>([])
|
|
|
+
|
|
|
+const user = useUserStore().getUser
|
|
|
+
|
|
|
+const userdeptId = user.deptId
|
|
|
+
|
|
|
+async function loadDept(deptId?: number) {
|
|
|
+ deptLoading.value = true
|
|
|
+ try {
|
|
|
+ const res = await DeptApi.specifiedSimpleDepts(deptId ?? userdeptId)
|
|
|
+ deptOptions.value = res
|
|
|
+ .map((item: any) => ({
|
|
|
+ label: item.name,
|
|
|
+ value: item.id,
|
|
|
+ raw: item
|
|
|
+ }))
|
|
|
+ .filter((item) => item.raw.type === '2')
|
|
|
+ } catch (error) {
|
|
|
+ } finally {
|
|
|
+ deptLoading.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ loadDept()
|
|
|
+})
|
|
|
|
|
|
// 添加责任人相关变量
|
|
|
-const userDialogVisible = ref(false);
|
|
|
-const userList = ref([]); // 所有用户列表
|
|
|
-const selectedUserIds = ref([]); // 选中的用户ID
|
|
|
-const selectedUserNames = ref(''); // 选中的用户名称显示
|
|
|
-const selectedUserList = ref([]); // 存储选中的用户对象列表
|
|
|
+const userDialogVisible = ref(false)
|
|
|
+const userList = ref([]) // 所有用户列表
|
|
|
+const selectedUserIds = ref([]) // 选中的用户ID
|
|
|
+const selectedUserNames = ref('') // 选中的用户名称显示
|
|
|
+const selectedUserList = ref([]) // 存储选中的用户对象列表
|
|
|
|
|
|
// 添加 workAreaOptions 引用和加载状态
|
|
|
const workAreaOptions = ref<any[]>([])
|
|
|
const loadingWorkAreaOptions = ref(false)
|
|
|
const workAreaAutocomplete = ref() // 添加对el-autocomplete的引用
|
|
|
// currentDictLabel 响应式变量
|
|
|
-const currentDictLabel = ref(''); // 存储当前项目对应的施工区域字典类型
|
|
|
+const currentDictLabel = ref('') // 存储当前项目对应的施工区域字典类型
|
|
|
|
|
|
const formData = ref({
|
|
|
id: undefined,
|
|
|
@@ -299,16 +335,25 @@ const formData = ref({
|
|
|
overseasArea: undefined,
|
|
|
remark: undefined,
|
|
|
dictType: undefined,
|
|
|
+ projectDeptId: undefined,
|
|
|
userName: useUserStore().getUser.name,
|
|
|
- userId: useUserStore().getUser.userId,
|
|
|
+ userId: useUserStore().getUser.userId
|
|
|
})
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => formData.value.deptId,
|
|
|
+ (newVal) => {
|
|
|
+ loadDept(newVal)
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
const close = () => {
|
|
|
delView(unref(currentRoute))
|
|
|
- push({ name: 'iotProjectInfo', params:{}})
|
|
|
+ push({ name: 'iotProjectInfo', params: {} })
|
|
|
}
|
|
|
|
|
|
const queryParams = reactive({
|
|
|
- projectId:undefined
|
|
|
+ projectId: undefined
|
|
|
})
|
|
|
const formRules = reactive({
|
|
|
manufacturerId: [{ required: true, message: '客户不能为空', trigger: 'blur' }],
|
|
|
@@ -317,13 +362,13 @@ const formRules = reactive({
|
|
|
contractCode: [{ required: true, message: '合同编码不能为空', trigger: 'blur' }],
|
|
|
workloadTotal: [{ required: true, message: '工作量总数不能为空', trigger: 'blur' }],
|
|
|
startTime: [{ required: true, message: '开始时间不能为空', trigger: 'blur' }],
|
|
|
- endTime: [{ required: true, message: '结束时间不能为空', trigger: 'blur' }],
|
|
|
+ endTime: [{ required: true, message: '结束时间不能为空', trigger: 'blur' }]
|
|
|
})
|
|
|
const formRef1 = ref() // 表单 Ref
|
|
|
const openForm = (type: string, id?: number) => {
|
|
|
formRef1.value.open(type, id)
|
|
|
}
|
|
|
-const zzClear = () =>{
|
|
|
+const zzClear = () => {
|
|
|
formData.value.manufacturerId = undefined
|
|
|
formData.value.manufactureName = undefined
|
|
|
}
|
|
|
@@ -340,37 +385,37 @@ const openCustomerZz = () => {
|
|
|
|
|
|
// 格式化用户名称显示
|
|
|
const formatUserNames = (users) => {
|
|
|
- if (!users || users.length === 0) return '';
|
|
|
+ if (!users || users.length === 0) return ''
|
|
|
|
|
|
- const names = users.map(user => user.nickname);
|
|
|
+ const names = users.map((user) => user.nickname)
|
|
|
|
|
|
if (names.length <= 2) {
|
|
|
- return names.join(', ');
|
|
|
+ return names.join(', ')
|
|
|
} else {
|
|
|
- return `${names[0]}, ${names[1]}...`;
|
|
|
+ return `${names[0]}, ${names[1]}...`
|
|
|
}
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
// 根据用户ID获取用户信息
|
|
|
const fetchUserInfoByIds = async (userIds) => {
|
|
|
if (!userIds || userIds.length === 0) {
|
|
|
- selectedUserList.value = [];
|
|
|
- selectedUserNames.value = '';
|
|
|
- return;
|
|
|
+ selectedUserList.value = []
|
|
|
+ selectedUserNames.value = ''
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
const params = {
|
|
|
userIds: userIds
|
|
|
- };
|
|
|
- const response = await UserApi.companyDeptsEmployee(params); // 假设有这个API
|
|
|
- selectedUserList.value = response;
|
|
|
- selectedUserNames.value = formatUserNames(response);
|
|
|
+ }
|
|
|
+ const response = await UserApi.companyDeptsEmployee(params) // 假设有这个API
|
|
|
+ selectedUserList.value = response
|
|
|
+ selectedUserNames.value = formatUserNames(response)
|
|
|
} catch (error) {
|
|
|
- console.error('获取用户信息失败:', error);
|
|
|
- ElMessage.error('获取用户信息失败');
|
|
|
+ console.error('获取用户信息失败:', error)
|
|
|
+ ElMessage.error('获取用户信息失败')
|
|
|
}
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
// 添加处理施工区域获取焦点的方法
|
|
|
const handleWorkAreaFocus = async () => {
|
|
|
@@ -380,7 +425,7 @@ const handleWorkAreaFocus = async () => {
|
|
|
try {
|
|
|
// 直接调用el-autocomplete的focus方法
|
|
|
if (workAreaAutocomplete.value && typeof workAreaAutocomplete.value.focus === 'function') {
|
|
|
- workAreaAutocomplete.value.focus();
|
|
|
+ workAreaAutocomplete.value.focus()
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('触发下拉框显示失败:', error)
|
|
|
@@ -395,7 +440,7 @@ const handleWorkAreaFocus = async () => {
|
|
|
if (workAreaOptions.value.length > 0) {
|
|
|
try {
|
|
|
if (workAreaAutocomplete.value && typeof workAreaAutocomplete.value.focus === 'function') {
|
|
|
- workAreaAutocomplete.value.focus();
|
|
|
+ workAreaAutocomplete.value.focus()
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.error('触发下拉框显示失败:', error)
|
|
|
@@ -406,30 +451,30 @@ const handleWorkAreaFocus = async () => {
|
|
|
|
|
|
// 根据部门ID获取部门名称
|
|
|
const getDeptNames = (deptIds) => {
|
|
|
- if (!deptIds || deptIds.length === 0) return '';
|
|
|
+ if (!deptIds || deptIds.length === 0) return ''
|
|
|
|
|
|
- const names = [];
|
|
|
+ const names = []
|
|
|
const findDept = (list, id) => {
|
|
|
for (const item of list) {
|
|
|
if (item.id === id) {
|
|
|
- names.push(item.name);
|
|
|
- return true;
|
|
|
+ names.push(item.name)
|
|
|
+ return true
|
|
|
}
|
|
|
if (item.children && findDept(item.children, id)) {
|
|
|
- return true;
|
|
|
+ return true
|
|
|
}
|
|
|
}
|
|
|
- return false;
|
|
|
- };
|
|
|
+ return false
|
|
|
+ }
|
|
|
|
|
|
- deptIds.forEach(id => findDept(deptList.value, id));
|
|
|
- return names.join(', ');
|
|
|
-};
|
|
|
+ deptIds.forEach((id) => findDept(deptList.value, id))
|
|
|
+ return names.join(', ')
|
|
|
+}
|
|
|
|
|
|
// 计算属性:判断部门选择框是否应该禁用
|
|
|
const isDeptDisabled = computed(() => {
|
|
|
- return formType.value === 'update' || deptList.value.length === 1;
|
|
|
-});
|
|
|
+ return formType.value === 'update' || deptList.value.length === 1
|
|
|
+})
|
|
|
|
|
|
// 打开用户选择对话框
|
|
|
const openUserDialog = async () => {
|
|
|
@@ -437,64 +482,61 @@ const openUserDialog = async () => {
|
|
|
// 获取用户列表,传递部门ID参数
|
|
|
const params = {
|
|
|
deptIds: [formData.value.deptId] // 将部门ID转换为数组格式
|
|
|
- };
|
|
|
+ }
|
|
|
// 获取用户列表
|
|
|
- const response = await UserApi.companyDeptsEmployee(params);
|
|
|
- userList.value = response;
|
|
|
+ const response = await UserApi.companyDeptsEmployee(params)
|
|
|
+ userList.value = response
|
|
|
|
|
|
// 设置当前已选中的用户
|
|
|
- selectedUserIds.value = formData.value.responsiblePerson || [];
|
|
|
-
|
|
|
- userDialogVisible.value = true;
|
|
|
+ selectedUserIds.value = formData.value.responsiblePerson || []
|
|
|
|
|
|
+ userDialogVisible.value = true
|
|
|
} catch (error) {
|
|
|
- console.error('获取用户列表失败:', error);
|
|
|
- ElMessage.error('获取用户列表失败');
|
|
|
+ console.error('获取用户列表失败:', error)
|
|
|
+ ElMessage.error('获取用户列表失败')
|
|
|
}
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
// 确认用户选择
|
|
|
const confirmUserSelection = () => {
|
|
|
// 更新表单数据
|
|
|
- formData.value.responsiblePerson = [...selectedUserIds.value];
|
|
|
+ formData.value.responsiblePerson = [...selectedUserIds.value]
|
|
|
|
|
|
// 更新显示的用户名称
|
|
|
// updateSelectedUserNames();
|
|
|
|
|
|
- selectedUserList.value = userList.value.filter(user =>
|
|
|
- selectedUserIds.value.includes(user.id)
|
|
|
- );
|
|
|
+ selectedUserList.value = userList.value.filter((user) => selectedUserIds.value.includes(user.id))
|
|
|
// 更新显示的用户名称
|
|
|
- selectedUserNames.value = formatUserNames(selectedUserList.value);
|
|
|
+ selectedUserNames.value = formatUserNames(selectedUserList.value)
|
|
|
|
|
|
- userDialogVisible.value = false;
|
|
|
-};
|
|
|
+ userDialogVisible.value = false
|
|
|
+}
|
|
|
|
|
|
// 更新显示的用户名称
|
|
|
const updateSelectedUserNames = () => {
|
|
|
console.log('已经保存的责任人:' + formData.value.responsiblePerson)
|
|
|
if (!formData.value.responsiblePerson || formData.value.responsiblePerson.length === 0) {
|
|
|
- selectedUserNames.value = '';
|
|
|
- return;
|
|
|
+ selectedUserNames.value = ''
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
- const selectedUsers = userList.value.filter(user =>
|
|
|
+ const selectedUsers = userList.value.filter((user) =>
|
|
|
formData.value.responsiblePerson.includes(user.id)
|
|
|
- );
|
|
|
+ )
|
|
|
|
|
|
- const names = selectedUsers.map(user => user.nickname);
|
|
|
+ const names = selectedUsers.map((user) => user.nickname)
|
|
|
|
|
|
if (names.length <= 2) {
|
|
|
- selectedUserNames.value = names.join(', ');
|
|
|
+ selectedUserNames.value = names.join(', ')
|
|
|
} else {
|
|
|
- selectedUserNames.value = `${names[0]}, ${names[1]}...`;
|
|
|
+ selectedUserNames.value = `${names[0]}, ${names[1]}...`
|
|
|
}
|
|
|
-};
|
|
|
+}
|
|
|
|
|
|
// 关闭用户选择对话框
|
|
|
const handleUserDialogClose = () => {
|
|
|
- userDialogVisible.value = false;
|
|
|
-};
|
|
|
+ userDialogVisible.value = false
|
|
|
+}
|
|
|
|
|
|
const tableData = ref([
|
|
|
{
|
|
|
@@ -505,42 +547,42 @@ const tableData = ref([
|
|
|
technique: '',
|
|
|
workloadDesign: '',
|
|
|
deptIds: [],
|
|
|
- remark:'',
|
|
|
+ remark: '',
|
|
|
editData: {},
|
|
|
- editing:true,
|
|
|
+ editing: true,
|
|
|
originalData: {},
|
|
|
errors: {}
|
|
|
- },
|
|
|
-]);
|
|
|
-let deptInfo: any[] = "";
|
|
|
+ }
|
|
|
+])
|
|
|
+let deptInfo: any[] = ''
|
|
|
/** 打开弹窗 */
|
|
|
const open = async () => {
|
|
|
resetForm()
|
|
|
// 修改时,设置数据
|
|
|
if (id) {
|
|
|
- formType.value = 'update';
|
|
|
+ formType.value = 'update'
|
|
|
formLoading.value = true
|
|
|
try {
|
|
|
formData.value = await IotProjectInfoApi.getIotProjectInfo(id)
|
|
|
|
|
|
// 如果已有责任人数据,获取用户信息并显示
|
|
|
if (formData.value.responsiblePerson && formData.value.responsiblePerson.length > 0) {
|
|
|
- await fetchUserInfoByIds(formData.value.responsiblePerson);
|
|
|
- selectedUserIds.value = [...formData.value.responsiblePerson];
|
|
|
+ await fetchUserInfoByIds(formData.value.responsiblePerson)
|
|
|
+ selectedUserIds.value = [...formData.value.responsiblePerson]
|
|
|
}
|
|
|
|
|
|
// 编辑页面:根据项目所属公司加载施工区域选项
|
|
|
if (formData.value.deptId) {
|
|
|
- await loadWorkAreaOptions(formData.value.deptId);
|
|
|
+ await loadWorkAreaOptions(formData.value.deptId)
|
|
|
}
|
|
|
} finally {
|
|
|
formLoading.value = false
|
|
|
}
|
|
|
} else {
|
|
|
- formType.value = 'create';
|
|
|
+ formType.value = 'create'
|
|
|
// 如果只有一个部门,则自动选中
|
|
|
if (deptList.value.length === 1) {
|
|
|
- formData.value.deptId = deptList.value[0].id;
|
|
|
+ formData.value.deptId = deptList.value[0].id
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -555,14 +597,14 @@ const submitForm = async () => {
|
|
|
await formRef.value.validate()
|
|
|
|
|
|
// 将当前字典类型赋值给formData
|
|
|
- formData.value.dictType = currentDictLabel.value;
|
|
|
+ formData.value.dictType = currentDictLabel.value
|
|
|
|
|
|
// 提交请求
|
|
|
formLoading.value = true
|
|
|
try {
|
|
|
// formData.value.deptId = useUserStore().getUser.deptId;
|
|
|
const data = {
|
|
|
- projectData: formData.value as unknown as IotProjectInfoVO,
|
|
|
+ projectData: formData.value as unknown as IotProjectInfoVO
|
|
|
//taskList:tableData.value
|
|
|
}
|
|
|
if (formType.value === 'create') {
|
|
|
@@ -599,9 +641,9 @@ const resetForm = () => {
|
|
|
payment: undefined,
|
|
|
userName: undefined,
|
|
|
userId: undefined,
|
|
|
- responsiblePerson: [], // 重置责任人字段
|
|
|
+ responsiblePerson: [] // 重置责任人字段
|
|
|
}
|
|
|
- selectedUserNames.value = '';
|
|
|
+ selectedUserNames.value = ''
|
|
|
formRef.value?.resetFields()
|
|
|
}
|
|
|
onMounted(async () => {
|
|
|
@@ -611,35 +653,34 @@ onMounted(async () => {
|
|
|
|
|
|
// 如果只有一个部门,则自动选中
|
|
|
if (deptList.value.length === 1) {
|
|
|
- formData.value.deptId = deptList.value[0].id;
|
|
|
+ formData.value.deptId = deptList.value[0].id
|
|
|
}
|
|
|
- open();
|
|
|
+ open()
|
|
|
})
|
|
|
|
|
|
-const showCloumn = false;
|
|
|
+const showCloumn = false
|
|
|
// 表格数据
|
|
|
|
|
|
// 计算正在编辑的行数
|
|
|
const editingRowsCount = computed(() => {
|
|
|
- return tableData.value.filter(row => row.editing).length;
|
|
|
-});
|
|
|
+ return tableData.value.filter((row) => row.editing).length
|
|
|
+})
|
|
|
|
|
|
// 格式化日期
|
|
|
const formatDate = (timestamp) => {
|
|
|
- const date = new Date(timestamp);
|
|
|
- return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
|
|
|
-};
|
|
|
+ const date = new Date(timestamp)
|
|
|
+ return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`
|
|
|
+}
|
|
|
|
|
|
// 为编辑中的行添加特殊样式
|
|
|
const rowClassName = ({ row }) => {
|
|
|
- return row.editing ? 'editable-row' : '';
|
|
|
-};
|
|
|
+ return row.editing ? 'editable-row' : ''
|
|
|
+}
|
|
|
|
|
|
// 添加新行
|
|
|
const addNewRow = () => {
|
|
|
- const newId = tableData.value.length > 0
|
|
|
- ? Math.max(...tableData.value.map(item => item.id)) + 1
|
|
|
- : 1;
|
|
|
+ const newId =
|
|
|
+ tableData.value.length > 0 ? Math.max(...tableData.value.map((item) => item.id)) + 1 : 1
|
|
|
|
|
|
const newRow = {
|
|
|
id: newId,
|
|
|
@@ -649,7 +690,7 @@ const addNewRow = () => {
|
|
|
technique: '',
|
|
|
workloadDesign: '',
|
|
|
deptIds: [],
|
|
|
- remark:'',
|
|
|
+ remark: '',
|
|
|
editing: true,
|
|
|
editData: {
|
|
|
wellName: '',
|
|
|
@@ -657,20 +698,20 @@ const addNewRow = () => {
|
|
|
location: '',
|
|
|
technique: '',
|
|
|
workloadDesign: '',
|
|
|
- deptIds:[],
|
|
|
- remark:'',
|
|
|
+ deptIds: [],
|
|
|
+ remark: ''
|
|
|
},
|
|
|
originalData: {},
|
|
|
errors: {}
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
- tableData.value.unshift(newRow);
|
|
|
-};
|
|
|
+ tableData.value.unshift(newRow)
|
|
|
+}
|
|
|
|
|
|
// 编辑行
|
|
|
const editRow = (row) => {
|
|
|
// 保存原始数据用于取消编辑时恢复
|
|
|
- row.originalData = {...row};
|
|
|
+ row.originalData = { ...row }
|
|
|
// 设置编辑数据
|
|
|
row.editData = {
|
|
|
id: row.id,
|
|
|
@@ -680,166 +721,173 @@ const editRow = (row) => {
|
|
|
technique: row.technique,
|
|
|
workloadDesign: row.workloadDesign,
|
|
|
deptIds: row.deptIds,
|
|
|
- remark:row.remark,
|
|
|
- };
|
|
|
+ remark: row.remark
|
|
|
+ }
|
|
|
// 进入编辑状态
|
|
|
- row.editing = true;
|
|
|
+ row.editing = true
|
|
|
// 清空错误信息
|
|
|
- row.errors = {};
|
|
|
-};
|
|
|
+ row.errors = {}
|
|
|
+}
|
|
|
|
|
|
// 验证行数据
|
|
|
const validateRow = (row) => {
|
|
|
- row.errors = {};
|
|
|
- let valid = true;
|
|
|
+ row.errors = {}
|
|
|
+ let valid = true
|
|
|
|
|
|
if (!row.editData.wellName || row.editData.wellName.trim() === '') {
|
|
|
- row.errors.name = '井号不能为空';
|
|
|
- valid = false;
|
|
|
+ row.errors.name = '井号不能为空'
|
|
|
+ valid = false
|
|
|
}
|
|
|
|
|
|
if (!row.editData.wellType || row.editData.wellType.trim() === '') {
|
|
|
- row.errors.email = '井型不能为空';
|
|
|
- valid = false;
|
|
|
+ row.errors.email = '井型不能为空'
|
|
|
+ valid = false
|
|
|
}
|
|
|
|
|
|
- return valid;
|
|
|
-};
|
|
|
+ return valid
|
|
|
+}
|
|
|
|
|
|
// 保存行
|
|
|
const saveRow = (row) => {
|
|
|
- if (!validateRow(row)) return;
|
|
|
+ if (!validateRow(row)) return
|
|
|
|
|
|
// 将编辑数据应用到行
|
|
|
- row.id = row.editData.id;
|
|
|
- row.wellName = row.editData.wellName;
|
|
|
- row.wellType = row.editData.wellType;
|
|
|
- row.location = row.editData.location;
|
|
|
- row.technique = row.editData.technique;
|
|
|
- row.workloadDesign = row.editData.workloadDesign;
|
|
|
- row.deptIds = row.editData.deptIds;
|
|
|
- row.remark = row.editData.remark;
|
|
|
+ row.id = row.editData.id
|
|
|
+ row.wellName = row.editData.wellName
|
|
|
+ row.wellType = row.editData.wellType
|
|
|
+ row.location = row.editData.location
|
|
|
+ row.technique = row.editData.technique
|
|
|
+ row.workloadDesign = row.editData.workloadDesign
|
|
|
+ row.deptIds = row.editData.deptIds
|
|
|
+ row.remark = row.editData.remark
|
|
|
// 退出编辑状态
|
|
|
- row.editing = false;
|
|
|
-};
|
|
|
+ row.editing = false
|
|
|
+}
|
|
|
|
|
|
// 生成Tooltip要显示的完整责任人名称字符串
|
|
|
const getFullSelectedUserNames = () => {
|
|
|
if (!selectedUserList.value || selectedUserList.value.length === 0) {
|
|
|
- return '';
|
|
|
+ return ''
|
|
|
}
|
|
|
- return selectedUserList.value.map(user => user.nickname).join(', ');
|
|
|
-};
|
|
|
+ return selectedUserList.value.map((user) => user.nickname).join(', ')
|
|
|
+}
|
|
|
|
|
|
// 保存所有更改
|
|
|
const saveAll = () => {
|
|
|
- let allValid = true;
|
|
|
+ let allValid = true
|
|
|
|
|
|
// 验证所有编辑中的行
|
|
|
- tableData.value.forEach(row => {
|
|
|
+ tableData.value.forEach((row) => {
|
|
|
if (row.editing && !validateRow(row)) {
|
|
|
- allValid = false;
|
|
|
+ allValid = false
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
|
|
|
if (!allValid) {
|
|
|
- ElMessage.error('部分数据验证失败,请检查输入');
|
|
|
- return;
|
|
|
+ ElMessage.error('部分数据验证失败,请检查输入')
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
// 保存所有编辑中的行
|
|
|
- tableData.value.forEach(row => {
|
|
|
+ tableData.value.forEach((row) => {
|
|
|
if (row.editing) {
|
|
|
- row.id = row.editData.id;
|
|
|
- row.wellName = row.editData.wellName;
|
|
|
- row.wellType = row.editData.wellType;
|
|
|
- row.location = row.editData.location;
|
|
|
- row.technique = row.editData.technique;
|
|
|
- row.workloadDesign = row.editData.workloadDesign;
|
|
|
- row.deptIds = row.editData.deptIds;
|
|
|
- row.remark = row.editData.remark;
|
|
|
+ row.id = row.editData.id
|
|
|
+ row.wellName = row.editData.wellName
|
|
|
+ row.wellType = row.editData.wellType
|
|
|
+ row.location = row.editData.location
|
|
|
+ row.technique = row.editData.technique
|
|
|
+ row.workloadDesign = row.editData.workloadDesign
|
|
|
+ row.deptIds = row.editData.deptIds
|
|
|
+ row.remark = row.editData.remark
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
|
|
|
- ElMessage.success('所有更改已保存');
|
|
|
-};
|
|
|
+ ElMessage.success('所有更改已保存')
|
|
|
+}
|
|
|
|
|
|
// 取消编辑
|
|
|
const cancelEdit = (row) => {
|
|
|
// 恢复原始数据
|
|
|
if (row.originalData.id) {
|
|
|
- row.id = row.originalData.id;
|
|
|
- row.wellName = row.originalData.wellName;
|
|
|
- row.wellType = row.originalData.wellType;
|
|
|
- row.location = row.originalData.location;
|
|
|
- row.technique = row.originalData.technique;
|
|
|
- row.workloadDesign = row.originalData.workloadDesign;
|
|
|
- row.deptIds = row.originalData.deptIds;
|
|
|
- row.remark = row.originalData.remark;
|
|
|
+ row.id = row.originalData.id
|
|
|
+ row.wellName = row.originalData.wellName
|
|
|
+ row.wellType = row.originalData.wellType
|
|
|
+ row.location = row.originalData.location
|
|
|
+ row.technique = row.originalData.technique
|
|
|
+ row.workloadDesign = row.originalData.workloadDesign
|
|
|
+ row.deptIds = row.originalData.deptIds
|
|
|
+ row.remark = row.originalData.remark
|
|
|
} else {
|
|
|
// 如果是新增行,则删除
|
|
|
- const index = tableData.value.indexOf(row);
|
|
|
+ const index = tableData.value.indexOf(row)
|
|
|
if (index !== -1) {
|
|
|
- tableData.value.splice(index, 1);
|
|
|
+ tableData.value.splice(index, 1)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- row.editing = false;
|
|
|
-};
|
|
|
+ row.editing = false
|
|
|
+}
|
|
|
|
|
|
// 删除行
|
|
|
const deleteRow = (index) => {
|
|
|
- tableData.value.splice(index, 1);
|
|
|
- ElMessage.success('行已删除');
|
|
|
-};
|
|
|
+ tableData.value.splice(index, 1)
|
|
|
+ ElMessage.success('行已删除')
|
|
|
+}
|
|
|
|
|
|
// 添加监听部门ID变化的方法
|
|
|
-watch(() => formData.value.deptId, async (newDeptId, oldDeptId) => {
|
|
|
- // 只有当部门ID确实发生变化时才加载选项
|
|
|
- if (newDeptId && newDeptId !== oldDeptId) {
|
|
|
- await loadWorkAreaOptions(newDeptId);
|
|
|
+watch(
|
|
|
+ () => formData.value.deptId,
|
|
|
+ async (newDeptId, oldDeptId) => {
|
|
|
+ // 只有当部门ID确实发生变化时才加载选项
|
|
|
+ if (newDeptId && newDeptId !== oldDeptId) {
|
|
|
+ await loadWorkAreaOptions(newDeptId)
|
|
|
+ }
|
|
|
}
|
|
|
-});
|
|
|
+)
|
|
|
|
|
|
// 添加立即执行的监听器,用于处理编辑页面
|
|
|
-watch(() => formData.value.deptId, async (newDeptId) => {
|
|
|
- if (newDeptId) {
|
|
|
- await loadWorkAreaOptions(newDeptId);
|
|
|
- } else {
|
|
|
- workAreaOptions.value = [];
|
|
|
- }
|
|
|
-}, { immediate: true });
|
|
|
+watch(
|
|
|
+ () => formData.value.deptId,
|
|
|
+ async (newDeptId) => {
|
|
|
+ if (newDeptId) {
|
|
|
+ await loadWorkAreaOptions(newDeptId)
|
|
|
+ } else {
|
|
|
+ workAreaOptions.value = []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { immediate: true }
|
|
|
+)
|
|
|
|
|
|
// 加载工作区域选项的方法
|
|
|
const loadWorkAreaOptions = async (deptId: number) => {
|
|
|
// 如果正在加载,直接返回
|
|
|
- if (loadingWorkAreaOptions.value) return;
|
|
|
+ if (loadingWorkAreaOptions.value) return
|
|
|
|
|
|
- loadingWorkAreaOptions.value = true;
|
|
|
+ loadingWorkAreaOptions.value = true
|
|
|
try {
|
|
|
// 先尝试通过 getDictLabel 获取字典标签
|
|
|
- const dictLabel = await getDictLabel(DICT_TYPE.PMS_PROJECT_WORK_AREA, deptId);
|
|
|
+ const dictLabel = await getDictLabel(DICT_TYPE.PMS_PROJECT_WORK_AREA, deptId)
|
|
|
console.log('当前专业公司的施工区域数据字典类型:' + dictLabel)
|
|
|
// 将 dictLabel 存储到 currentDictLabel
|
|
|
- currentDictLabel.value = dictLabel || ''; // 如果没有获取到,设为空字符串
|
|
|
+ currentDictLabel.value = dictLabel || '' // 如果没有获取到,设为空字符串
|
|
|
|
|
|
if (dictLabel) {
|
|
|
// 如果获取到标签,再获取完整的字典选项
|
|
|
- const dictOptions = getStrDictOptions(dictLabel);
|
|
|
+ const dictOptions = getStrDictOptions(dictLabel)
|
|
|
console.log('当前专业公司的施工区域数据字典集合长度:' + dictOptions.length)
|
|
|
- workAreaOptions.value = dictOptions.map(option => ({
|
|
|
+ workAreaOptions.value = dictOptions.map((option) => ({
|
|
|
value: option.label, // 使用标签作为显示值
|
|
|
- id: option.value // 保留原始值
|
|
|
- }));
|
|
|
+ id: option.value // 保留原始值
|
|
|
+ }))
|
|
|
} else {
|
|
|
// 如果获取不到标签,清空选项
|
|
|
- workAreaOptions.value = [];
|
|
|
+ workAreaOptions.value = []
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.error('获取工作区域选项失败:', error);
|
|
|
- workAreaOptions.value = [];
|
|
|
+ console.error('获取工作区域选项失败:', error)
|
|
|
+ workAreaOptions.value = []
|
|
|
} finally {
|
|
|
- loadingWorkAreaOptions.value = false;
|
|
|
+ loadingWorkAreaOptions.value = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -847,41 +895,40 @@ const loadWorkAreaOptions = async (deptId: number) => {
|
|
|
const querySearch = (queryString: string, cb: any) => {
|
|
|
// 如果没有查询字符串,返回所有选项
|
|
|
if (!queryString) {
|
|
|
- cb(workAreaOptions.value);
|
|
|
- return;
|
|
|
+ cb(workAreaOptions.value)
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
// 有查询字符串时进行筛选
|
|
|
- const results = workAreaOptions.value.filter(option =>
|
|
|
+ const results = workAreaOptions.value.filter((option) =>
|
|
|
option.value.toLowerCase().includes(queryString.toLowerCase())
|
|
|
- );
|
|
|
+ )
|
|
|
|
|
|
// 调用 callback 返回建议列表的数据
|
|
|
- cb(results);
|
|
|
+ cb(results)
|
|
|
}
|
|
|
|
|
|
// 添加选择处理方法
|
|
|
const handleSelect = (item: any) => {
|
|
|
// 这里可以根据需要处理选择后的逻辑
|
|
|
- console.log('选择了:', item.value);
|
|
|
+ console.log('选择了:', item.value)
|
|
|
}
|
|
|
-
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
.user-names {
|
|
|
- padding: 0px 10px;
|
|
|
- border: 1px solid #dcdfe6;
|
|
|
- border-radius: 4px;
|
|
|
- background-color: #f5f7fa;
|
|
|
display: inline-block;
|
|
|
- min-width: 200px;
|
|
|
max-height: 32px;
|
|
|
+ min-width: 200px;
|
|
|
+ padding: 0 10px;
|
|
|
+ background-color: #f5f7fa;
|
|
|
+ border: 1px solid #dcdfe6;
|
|
|
+ border-radius: 4px;
|
|
|
}
|
|
|
|
|
|
.transfer-container {
|
|
|
+ padding: 0;
|
|
|
text-align: center;
|
|
|
- padding: 0px 0;
|
|
|
}
|
|
|
|
|
|
/* 3. 直接调整 el-transfer 左右窗口的宽度 */
|
|
|
@@ -896,14 +943,14 @@ const handleSelect = (item: any) => {
|
|
|
|
|
|
:deep(.el-transfer-panel__item) {
|
|
|
display: flex !important;
|
|
|
- align-items: center !important;
|
|
|
height: 32px !important;
|
|
|
- line-height: 32px !important;
|
|
|
padding: 0 8px !important;
|
|
|
margin: 0 !important;
|
|
|
- white-space: nowrap;
|
|
|
overflow: hidden;
|
|
|
+ line-height: 32px !important;
|
|
|
text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ align-items: center !important;
|
|
|
}
|
|
|
|
|
|
.transfer-option-text {
|