| | |
| | | v-hasPermi="['needIdentify:list:add']" |
| | | >新增</el-button> |
| | | </el-form-item> |
| | | <el-form-item label="企业名称:" v-if="data.isAdmin" style="margin-left: 20px"> |
| | | <el-form-item label="单位名称:" v-if="data.isAdmin" style="margin-left: 20px"> |
| | | <el-select v-model="data.queryParams.companyId" placeholder="请选择" filterable clearable> |
| | | <el-option |
| | | v-for="item in data.companyList" |
| | |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="年份:" style="margin-left: 20px"> |
| | | <el-select |
| | | <el-date-picker |
| | | v-model="data.queryParams.year" |
| | | type="year" |
| | | value-format="YYYY" |
| | | placeholder="请选择年份" |
| | | style="width: 240px" |
| | | filterable |
| | | allow-create |
| | | default-first-option |
| | | :reserve-keyword="false" |
| | | @change="handleChangeNum" |
| | | > |
| | | <el-option |
| | | v-for="item in data.yearList" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.label" |
| | | /> |
| | | </el-select> |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" style="margin-left: 30px" @click="searchClick">查询</el-button> |
| | | <el-button plain @click="reset">重置</el-button> |
| | | <el-button type="primary" plain @click="copyMenu">复制</el-button> |
| | | </el-form-item> |
| | | <el-form-item style="margin-left: 15px"> |
| | | <el-button |
| | |
| | | /> |
| | | </div> |
| | | <editDialog ref="noticeRef" @getList = "getList"></editDialog> |
| | | <el-dialog |
| | | v-model="copyVisible" |
| | | width="500px" |
| | | :before-close="handleClose" |
| | | :close-on-press-escape="false" |
| | | :close-on-click-modal="false" |
| | | > |
| | | <span v-if="isAdmin" style="display: block; margin-bottom: 8px">单位名称:</span> |
| | | <el-select |
| | | v-model="chooseCompanyId" |
| | | v-if="isAdmin" |
| | | placeholder="请选择单位" |
| | | filterable |
| | | clearable |
| | | style="width: 100%; margin-bottom: 15px" |
| | | > |
| | | <el-option |
| | | v-for="item in companyList" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | > |
| | | </el-option> |
| | | </el-select> |
| | | <span style="display: block; margin-bottom: 8px">将以下年份数据</span> |
| | | <el-date-picker |
| | | v-model="queryParams.year" |
| | | type="year" |
| | | value-format="YYYY" |
| | | placeholder="请选择年份" |
| | | style="width: 100%; margin-bottom: 15px" |
| | | disabled |
| | | /> |
| | | <span style="display: block; margin-bottom: 8px">复制到:</span> |
| | | <el-date-picker |
| | | v-model="chooseYear" |
| | | type="year" |
| | | value-format="YYYY" |
| | | placeholder="请选择年份" |
| | | style="width: 100%; margin-bottom: 15px" |
| | | /> |
| | | |
| | | <div class="dialog-footer" style="display: flex; justify-content: right"> |
| | | <el-button @click="handleClose" size="default">取 消</el-button> |
| | | <el-button |
| | | type="primary" |
| | | @click="onSubmitCopy" |
| | | size="default" |
| | | v-preReClick |
| | | >确认</el-button |
| | | > |
| | | </div> |
| | | </el-dialog> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | import Cookies from "js-cookie"; |
| | | import {generateWordDocument} from "@/utils/exportWord"; |
| | | import {delTable, getTable} from "@/api/qualityObjectives/table"; |
| | | import {delNeedDiscren, getNeedDiscren} from "@/api/need/need"; |
| | | import {delNeedDiscren, getNeedDiscren, copyNeed} from "@/api/need/need"; |
| | | const { proxy } = getCurrentInstance(); |
| | | const loading = ref(false); |
| | | const noticeRef = ref(); |
| | |
| | | }, |
| | | companyList: [], |
| | | isAdmin: false, |
| | | dialogVisible: false, |
| | | yearList: [ |
| | | { |
| | | value: 1, |
| | | label: '2025' |
| | | }, |
| | | { |
| | | value: 2, |
| | | label: '2024' |
| | | }, |
| | | { |
| | | value: 3, |
| | | label: '2023' |
| | | }, |
| | | { |
| | | value: 4, |
| | | label: '2022' |
| | | }, |
| | | { |
| | | value: 5, |
| | | label: '2021' |
| | | }, |
| | | ], |
| | | copyVisible: false, |
| | | chooseCompanyId: null, |
| | | chooseYear: null |
| | | }); |
| | | const dataList = ref([]); |
| | | const total = ref(0); |
| | | |
| | | const { queryParams } = toRefs(data); |
| | | const { queryParams, isAdmin, copyVisible, chooseCompanyId, chooseYear, companyList } = toRefs(data); |
| | | |
| | | onMounted(() => { |
| | | const userInfo = JSON.parse(Cookies.get('userInfo')) |
| | | console.log("userInfo",userInfo) |
| | | data.isAdmin = userInfo.userType === 0; |
| | | if(data.isAdmin){ |
| | | data.queryParams.companyId = null |
| | | }else { |
| | | data.queryParams.companyId = userInfo.companyId |
| | | data.chooseCompanyId = userInfo.companyId |
| | | } |
| | | getList(); |
| | | if(data.isAdmin){ |
| | | getCompanyList() |
| | | } |
| | | }); |
| | | |
| | | const copyMenu = () => { |
| | | if (!data.queryParams.year) { |
| | | ElMessage.warning("请先选择要复制的年份"); |
| | | return; |
| | | } |
| | | data.copyVisible = true; |
| | | }; |
| | | |
| | | const handleClose = () => { |
| | | data.chooseCompanyId = null |
| | | data.chooseYear = null |
| | | data.copyVisible = false |
| | | }; |
| | | |
| | | const onSubmitCopy = async () => { |
| | | if (data.isAdmin && !data.chooseCompanyId) { |
| | | ElMessage.warning("请先选择单位"); |
| | | return; |
| | | } |
| | | if (!data.chooseYear) { |
| | | ElMessage.warning("请选择目标年份"); |
| | | return; |
| | | } |
| | | ElMessageBox.confirm("该操作将覆盖目标年份的数据,是否继续?", "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(async () => { |
| | | const p = { |
| | | companyId: data.chooseCompanyId, |
| | | sourceYear: data.queryParams.year, |
| | | targetYear: data.chooseYear |
| | | }; |
| | | const r = await copyNeed(p); |
| | | if (r.code === 200) { |
| | | ElMessage.success(r.message); |
| | | await handleClose(); |
| | | await getList(); |
| | | } else { |
| | | ElMessage.warning(r.message); |
| | | } |
| | | }) |
| | | .catch((err) => {}); |
| | | }; |
| | | |
| | | const getList = async () => { |
| | | loading.value = true; |
| | | const res = await getNeedDiscren(data.queryParams); |
| | |
| | | const handleCurrentChange = (val) => { |
| | | data.queryParams.pageNum = val |
| | | getList() |
| | | } |
| | | const handleClose = () => { |
| | | data.dialogVisible = false |
| | | } |
| | | |
| | | /** 重置新增的表单以及其他数据 */ |
| | |
| | | ElMessage.warning(res.message) |
| | | } |
| | | }) |
| | | } |
| | | const handleChangeNum = (value) => { |
| | | if (!/^\d+$/.test(value)) { // 验证是否为数字 |
| | | ElMessage.warning('只能输入数字') |
| | | data.queryParams.year = '' // 重置选择,避免非法值被添加到options中 |
| | | } else if (!data.yearList.some(option => option.label === value)) { // 确保不是已存在的选项 |
| | | data.yearList.push({ value, label: value }); // 添加新选项(这里简单地将值和标签设为相同) |
| | | } |
| | | } |
| | | |
| | | </script> |