diff --git a/public/config/config.json b/public/config/config.json index a00a459..4f4b6e2 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,6 +1,6 @@ { "title":"计量业务系统", - "versionByEqpt":"1.3.0.1", + "versionByEqpt":"1.3.0.2", "baseUrl": "http://111.198.10.15:21611", "baseUrlBusiness": "http://111.198.10.15:21606", "baseUrlLaboratory": "http://111.198.10.15:21610", @@ -23,6 +23,5 @@ "设备到期":"/info/detail", "计量计划":"/plan/detail", "合同通知":"/breviewpage/detail" - } } diff --git a/public/config/config.json b/public/config/config.json index a00a459..4f4b6e2 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,6 +1,6 @@ { "title":"计量业务系统", - "versionByEqpt":"1.3.0.1", + "versionByEqpt":"1.3.0.2", "baseUrl": "http://111.198.10.15:21611", "baseUrlBusiness": "http://111.198.10.15:21606", "baseUrlLaboratory": "http://111.198.10.15:21610", @@ -23,6 +23,5 @@ "设备到期":"/info/detail", "计量计划":"/plan/detail", "合同通知":"/breviewpage/detail" - } } diff --git a/src/views/tested/MeasurementPlan/early/components/edit.vue b/src/views/tested/MeasurementPlan/early/components/edit.vue index 4f1629b..7296946 100644 --- a/src/views/tested/MeasurementPlan/early/components/edit.vue +++ b/src/views/tested/MeasurementPlan/early/components/edit.vue @@ -120,13 +120,13 @@ } } watch(() => ruleForm.value.customerId, (newVal) => { - if ($route.path.includes('detail') || !isAdmin.value || flag.value) { return } - ruleForm.value.createDeptId = '' if (newVal) { getDeptTreeList({ pid: newVal }).then((res) => { deptList.value = toTreeList(res.data.map((item: any) => ({ ...item, label: item.name, value: item.id }))) }) } + if ($route.path.includes('detail') || !isAdmin.value || flag.value) { return } + ruleForm.value.createDeptId = '' }) onMounted(() => { initDialog() @@ -162,6 +162,9 @@ if (submitId.value) { ruleForm.value.id = submitId.value } + if (isAdmin.value) { + ruleForm.value.customerName = companyList.value.filter(item => item.id === ruleForm.value.customerId)[0]?.name + } editApply(ruleForm.value).then((res) => { const submit = (id: string) => { submitApply({ id, formId: $route.query.approvalType === '0' ? SCHEDULE.METERING_PLAN_EARLY : SCHEDULE.METERING_PLAN_DEALY }).then((res) => { diff --git a/public/config/config.json b/public/config/config.json index a00a459..4f4b6e2 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,6 +1,6 @@ { "title":"计量业务系统", - "versionByEqpt":"1.3.0.1", + "versionByEqpt":"1.3.0.2", "baseUrl": "http://111.198.10.15:21611", "baseUrlBusiness": "http://111.198.10.15:21606", "baseUrlLaboratory": "http://111.198.10.15:21610", @@ -23,6 +23,5 @@ "设备到期":"/info/detail", "计量计划":"/plan/detail", "合同通知":"/breviewpage/detail" - } } diff --git a/src/views/tested/MeasurementPlan/early/components/edit.vue b/src/views/tested/MeasurementPlan/early/components/edit.vue index 4f1629b..7296946 100644 --- a/src/views/tested/MeasurementPlan/early/components/edit.vue +++ b/src/views/tested/MeasurementPlan/early/components/edit.vue @@ -120,13 +120,13 @@ } } watch(() => ruleForm.value.customerId, (newVal) => { - if ($route.path.includes('detail') || !isAdmin.value || flag.value) { return } - ruleForm.value.createDeptId = '' if (newVal) { getDeptTreeList({ pid: newVal }).then((res) => { deptList.value = toTreeList(res.data.map((item: any) => ({ ...item, label: item.name, value: item.id }))) }) } + if ($route.path.includes('detail') || !isAdmin.value || flag.value) { return } + ruleForm.value.createDeptId = '' }) onMounted(() => { initDialog() @@ -162,6 +162,9 @@ if (submitId.value) { ruleForm.value.id = submitId.value } + if (isAdmin.value) { + ruleForm.value.customerName = companyList.value.filter(item => item.id === ruleForm.value.customerId)[0]?.name + } editApply(ruleForm.value).then((res) => { const submit = (id: string) => { submitApply({ id, formId: $route.query.approvalType === '0' ? SCHEDULE.METERING_PLAN_EARLY : SCHEDULE.METERING_PLAN_DEALY }).then((res) => { diff --git a/src/views/tested/MeasurementPlan/plan/components/summary.vue b/src/views/tested/MeasurementPlan/plan/components/summary.vue index 1854304..aca79c1 100644 --- a/src/views/tested/MeasurementPlan/plan/components/summary.vue +++ b/src/views/tested/MeasurementPlan/plan/components/summary.vue @@ -23,14 +23,14 @@ summaryName: '', year: '', }) -const isAdmin = ref(false) +const isDeptAdmin = ref(false) // 获取初始数据 const fetchData = () => { const data = JSON.parse($route.query.data as string) - isAdmin.value = data.isAdmin ? data.deptId : null + isDeptAdmin.value = data.isDeptAdmin ? data.deptId : null getSummary({ companyId: data.commpanyId, - deptId: data.isAdmin ? null : data.deptId, + deptId: data.isDeptAdmin ? null : data.deptId, year: data.year, }).then((res) => { ruleForm.value = res.data @@ -61,7 +61,7 @@ }) exportSummary({ companyId: data.commpanyId, - deptId: data.isAdmin ? null : data.deptId, + deptId: data.isDeptAdmin ? null : data.deptId, year: data.year, }).then((res) => { exportFile(res.data, ruleForm.value.summaryName) @@ -100,7 +100,7 @@ - + diff --git a/public/config/config.json b/public/config/config.json index a00a459..4f4b6e2 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,6 +1,6 @@ { "title":"计量业务系统", - "versionByEqpt":"1.3.0.1", + "versionByEqpt":"1.3.0.2", "baseUrl": "http://111.198.10.15:21611", "baseUrlBusiness": "http://111.198.10.15:21606", "baseUrlLaboratory": "http://111.198.10.15:21610", @@ -23,6 +23,5 @@ "设备到期":"/info/detail", "计量计划":"/plan/detail", "合同通知":"/breviewpage/detail" - } } diff --git a/src/views/tested/MeasurementPlan/early/components/edit.vue b/src/views/tested/MeasurementPlan/early/components/edit.vue index 4f1629b..7296946 100644 --- a/src/views/tested/MeasurementPlan/early/components/edit.vue +++ b/src/views/tested/MeasurementPlan/early/components/edit.vue @@ -120,13 +120,13 @@ } } watch(() => ruleForm.value.customerId, (newVal) => { - if ($route.path.includes('detail') || !isAdmin.value || flag.value) { return } - ruleForm.value.createDeptId = '' if (newVal) { getDeptTreeList({ pid: newVal }).then((res) => { deptList.value = toTreeList(res.data.map((item: any) => ({ ...item, label: item.name, value: item.id }))) }) } + if ($route.path.includes('detail') || !isAdmin.value || flag.value) { return } + ruleForm.value.createDeptId = '' }) onMounted(() => { initDialog() @@ -162,6 +162,9 @@ if (submitId.value) { ruleForm.value.id = submitId.value } + if (isAdmin.value) { + ruleForm.value.customerName = companyList.value.filter(item => item.id === ruleForm.value.customerId)[0]?.name + } editApply(ruleForm.value).then((res) => { const submit = (id: string) => { submitApply({ id, formId: $route.query.approvalType === '0' ? SCHEDULE.METERING_PLAN_EARLY : SCHEDULE.METERING_PLAN_DEALY }).then((res) => { diff --git a/src/views/tested/MeasurementPlan/plan/components/summary.vue b/src/views/tested/MeasurementPlan/plan/components/summary.vue index 1854304..aca79c1 100644 --- a/src/views/tested/MeasurementPlan/plan/components/summary.vue +++ b/src/views/tested/MeasurementPlan/plan/components/summary.vue @@ -23,14 +23,14 @@ summaryName: '', year: '', }) -const isAdmin = ref(false) +const isDeptAdmin = ref(false) // 获取初始数据 const fetchData = () => { const data = JSON.parse($route.query.data as string) - isAdmin.value = data.isAdmin ? data.deptId : null + isDeptAdmin.value = data.isDeptAdmin ? data.deptId : null getSummary({ companyId: data.commpanyId, - deptId: data.isAdmin ? null : data.deptId, + deptId: data.isDeptAdmin ? null : data.deptId, year: data.year, }).then((res) => { ruleForm.value = res.data @@ -61,7 +61,7 @@ }) exportSummary({ companyId: data.commpanyId, - deptId: data.isAdmin ? null : data.deptId, + deptId: data.isDeptAdmin ? null : data.deptId, year: data.year, }).then((res) => { exportFile(res.data, ruleForm.value.summaryName) @@ -100,7 +100,7 @@ - + diff --git a/src/views/tested/MeasurementPlan/plan/components/summaryDialog.vue b/src/views/tested/MeasurementPlan/plan/components/summaryDialog.vue index 2ecb05b..c90483d 100644 --- a/src/views/tested/MeasurementPlan/plan/components/summaryDialog.vue +++ b/src/views/tested/MeasurementPlan/plan/components/summaryDialog.vue @@ -5,6 +5,8 @@ import { ElMessage, ElMessageBox } from 'element-plus' import useUserStore from '@/store/modules/user' import { getAdminDept, getUserDept } from '@/api/system/user' +import { getDeptTreeList } from '@/api/system/dept' +import { toTreeList } from '@/utils/structure' const emits = defineEmits(['confirm']) const $router = useRouter() const userStore = useUserStore() @@ -15,7 +17,7 @@ commpanyId: '', deptId: '', deptName: '', - year: '', + year: `${new Date().getFullYear()}`, }) // 表单 const rules = ref({ year: [{ required: true, message: '年度必选', trigger: ['blur', 'change'] }], @@ -33,40 +35,64 @@ } const commpanyList = ref([]) const isAdmin = ref(false) +const isDeptAdmin = ref(false) const fetchCommany = () => { - if (userStore.roleNames.some((item: string) => item.includes('管理员'))) { - isAdmin.value = true + if (userStore.roleNames.length === 1 && userStore.roleNames[0].includes('单位管理员')) { + isDeptAdmin.value = true } else { - isAdmin.value = false + isDeptAdmin.value = false } getUserDept().then((res) => { + const fun = () => { + if (commpanyList.value.length) { + dataForm.value.deptId = '' + dataForm.value.deptName = '' + } + else { + dataForm.value.deptId = userStore.deptId + dataForm.value.deptName = userStore.deptName + } + if (isAdmin.value) { + rules.value.commpanyId = [{ required: true, message: '单位必选', trigger: ['blur', 'change'] }] + } + else { + rules.value.commpanyId = undefined + } + } if (res.data.fullName === '顶级' || res.data.version === '1' || res.data.version === 1) { getAdminDept({}).then((res) => { commpanyList.value = res.data.map((item: any) => ({ id: item.id, value: item.id, name: item.fullName })) + isAdmin.value = true + fun() }) - isAdmin.value = true } else { dataForm.value.commpany = res.data.fullName dataForm.value.commpanyId = res.data.id + fun() } }) - dataForm.value.deptId = userStore.deptId - dataForm.value.deptName = userStore.deptName - if (isAdmin.value) { - rules.value.commpanyId = [{ required: true, message: '单位必选', trigger: ['blur', 'change'] }] - } - else { - rules.value.commpanyId = undefined - } } // 初始化对话框 const initDialog = () => { resetForm() fetchCommany() dialogFormVisible.value = true + dataForm.value.year = `${new Date().getFullYear()}` } +const deptList = ref([]) // 部门列表 +watch(() => dataForm.value.commpanyId, (newVal) => { + dataForm.value.deptId = '' + if (newVal) { + getDeptTreeList({ pid: newVal }).then((res) => { + deptList.value = toTreeList(res.data.map((item: any) => ({ ...item, label: item.name, value: item.id }))) + }) + } + else { + deptList.value = [] + } +}) // 确认 const saveData = () => { if (dataFormRef.value) { @@ -75,7 +101,7 @@ $router.push({ path: '/plan/summary', query: { - data: JSON.stringify({ ...dataForm.value, isAdmin: isAdmin.value }), + data: JSON.stringify({ ...dataForm.value, isDeptAdmin: isDeptAdmin.value }), statusName: '', row: JSON.stringify({ id: '' }), }, @@ -97,8 +123,8 @@ const currentYear = new Date().getFullYear() for (let index = 0; index < 6; index++) { yearList.value.push({ - name: currentYear - index, - value: currentYear - index, + name: String(currentYear - index), + value: String(currentYear - index), }) } } @@ -118,10 +144,19 @@ - + - - + + + diff --git a/public/config/config.json b/public/config/config.json index a00a459..4f4b6e2 100644 --- a/public/config/config.json +++ b/public/config/config.json @@ -1,6 +1,6 @@ { "title":"计量业务系统", - "versionByEqpt":"1.3.0.1", + "versionByEqpt":"1.3.0.2", "baseUrl": "http://111.198.10.15:21611", "baseUrlBusiness": "http://111.198.10.15:21606", "baseUrlLaboratory": "http://111.198.10.15:21610", @@ -23,6 +23,5 @@ "设备到期":"/info/detail", "计量计划":"/plan/detail", "合同通知":"/breviewpage/detail" - } } diff --git a/src/views/tested/MeasurementPlan/early/components/edit.vue b/src/views/tested/MeasurementPlan/early/components/edit.vue index 4f1629b..7296946 100644 --- a/src/views/tested/MeasurementPlan/early/components/edit.vue +++ b/src/views/tested/MeasurementPlan/early/components/edit.vue @@ -120,13 +120,13 @@ } } watch(() => ruleForm.value.customerId, (newVal) => { - if ($route.path.includes('detail') || !isAdmin.value || flag.value) { return } - ruleForm.value.createDeptId = '' if (newVal) { getDeptTreeList({ pid: newVal }).then((res) => { deptList.value = toTreeList(res.data.map((item: any) => ({ ...item, label: item.name, value: item.id }))) }) } + if ($route.path.includes('detail') || !isAdmin.value || flag.value) { return } + ruleForm.value.createDeptId = '' }) onMounted(() => { initDialog() @@ -162,6 +162,9 @@ if (submitId.value) { ruleForm.value.id = submitId.value } + if (isAdmin.value) { + ruleForm.value.customerName = companyList.value.filter(item => item.id === ruleForm.value.customerId)[0]?.name + } editApply(ruleForm.value).then((res) => { const submit = (id: string) => { submitApply({ id, formId: $route.query.approvalType === '0' ? SCHEDULE.METERING_PLAN_EARLY : SCHEDULE.METERING_PLAN_DEALY }).then((res) => { diff --git a/src/views/tested/MeasurementPlan/plan/components/summary.vue b/src/views/tested/MeasurementPlan/plan/components/summary.vue index 1854304..aca79c1 100644 --- a/src/views/tested/MeasurementPlan/plan/components/summary.vue +++ b/src/views/tested/MeasurementPlan/plan/components/summary.vue @@ -23,14 +23,14 @@ summaryName: '', year: '', }) -const isAdmin = ref(false) +const isDeptAdmin = ref(false) // 获取初始数据 const fetchData = () => { const data = JSON.parse($route.query.data as string) - isAdmin.value = data.isAdmin ? data.deptId : null + isDeptAdmin.value = data.isDeptAdmin ? data.deptId : null getSummary({ companyId: data.commpanyId, - deptId: data.isAdmin ? null : data.deptId, + deptId: data.isDeptAdmin ? null : data.deptId, year: data.year, }).then((res) => { ruleForm.value = res.data @@ -61,7 +61,7 @@ }) exportSummary({ companyId: data.commpanyId, - deptId: data.isAdmin ? null : data.deptId, + deptId: data.isDeptAdmin ? null : data.deptId, year: data.year, }).then((res) => { exportFile(res.data, ruleForm.value.summaryName) @@ -100,7 +100,7 @@ - + diff --git a/src/views/tested/MeasurementPlan/plan/components/summaryDialog.vue b/src/views/tested/MeasurementPlan/plan/components/summaryDialog.vue index 2ecb05b..c90483d 100644 --- a/src/views/tested/MeasurementPlan/plan/components/summaryDialog.vue +++ b/src/views/tested/MeasurementPlan/plan/components/summaryDialog.vue @@ -5,6 +5,8 @@ import { ElMessage, ElMessageBox } from 'element-plus' import useUserStore from '@/store/modules/user' import { getAdminDept, getUserDept } from '@/api/system/user' +import { getDeptTreeList } from '@/api/system/dept' +import { toTreeList } from '@/utils/structure' const emits = defineEmits(['confirm']) const $router = useRouter() const userStore = useUserStore() @@ -15,7 +17,7 @@ commpanyId: '', deptId: '', deptName: '', - year: '', + year: `${new Date().getFullYear()}`, }) // 表单 const rules = ref({ year: [{ required: true, message: '年度必选', trigger: ['blur', 'change'] }], @@ -33,40 +35,64 @@ } const commpanyList = ref([]) const isAdmin = ref(false) +const isDeptAdmin = ref(false) const fetchCommany = () => { - if (userStore.roleNames.some((item: string) => item.includes('管理员'))) { - isAdmin.value = true + if (userStore.roleNames.length === 1 && userStore.roleNames[0].includes('单位管理员')) { + isDeptAdmin.value = true } else { - isAdmin.value = false + isDeptAdmin.value = false } getUserDept().then((res) => { + const fun = () => { + if (commpanyList.value.length) { + dataForm.value.deptId = '' + dataForm.value.deptName = '' + } + else { + dataForm.value.deptId = userStore.deptId + dataForm.value.deptName = userStore.deptName + } + if (isAdmin.value) { + rules.value.commpanyId = [{ required: true, message: '单位必选', trigger: ['blur', 'change'] }] + } + else { + rules.value.commpanyId = undefined + } + } if (res.data.fullName === '顶级' || res.data.version === '1' || res.data.version === 1) { getAdminDept({}).then((res) => { commpanyList.value = res.data.map((item: any) => ({ id: item.id, value: item.id, name: item.fullName })) + isAdmin.value = true + fun() }) - isAdmin.value = true } else { dataForm.value.commpany = res.data.fullName dataForm.value.commpanyId = res.data.id + fun() } }) - dataForm.value.deptId = userStore.deptId - dataForm.value.deptName = userStore.deptName - if (isAdmin.value) { - rules.value.commpanyId = [{ required: true, message: '单位必选', trigger: ['blur', 'change'] }] - } - else { - rules.value.commpanyId = undefined - } } // 初始化对话框 const initDialog = () => { resetForm() fetchCommany() dialogFormVisible.value = true + dataForm.value.year = `${new Date().getFullYear()}` } +const deptList = ref([]) // 部门列表 +watch(() => dataForm.value.commpanyId, (newVal) => { + dataForm.value.deptId = '' + if (newVal) { + getDeptTreeList({ pid: newVal }).then((res) => { + deptList.value = toTreeList(res.data.map((item: any) => ({ ...item, label: item.name, value: item.id }))) + }) + } + else { + deptList.value = [] + } +}) // 确认 const saveData = () => { if (dataFormRef.value) { @@ -75,7 +101,7 @@ $router.push({ path: '/plan/summary', query: { - data: JSON.stringify({ ...dataForm.value, isAdmin: isAdmin.value }), + data: JSON.stringify({ ...dataForm.value, isDeptAdmin: isDeptAdmin.value }), statusName: '', row: JSON.stringify({ id: '' }), }, @@ -97,8 +123,8 @@ const currentYear = new Date().getFullYear() for (let index = 0; index < 6; index++) { yearList.value.push({ - name: currentYear - index, - value: currentYear - index, + name: String(currentYear - index), + value: String(currentYear - index), }) } } @@ -118,10 +144,19 @@ - + - - + + + diff --git a/src/views/tested/device/group/components/selectDevice.vue b/src/views/tested/device/group/components/selectDevice.vue index b5e5941..c99ad13 100644 --- a/src/views/tested/device/group/components/selectDevice.vue +++ b/src/views/tested/device/group/components/selectDevice.vue @@ -365,7 +365,7 @@ - companyList +