+
-
-
+
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ {{ scope.row.pro_name }}
+
+
+
+
+ {{ scope.row.org_name }}
+
+
+
+
+
+
+
+ {{ scope.row.project_address }}
+
+
+
+
+
+
+
+ {{ scope.row.project_status || '-' }}
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 编辑
-
-
-
-
-
- 删除
-
-
-
+
+
+
+ 编辑
+ 删除
-
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ handleNumberInput(e, this, 'addOrEditForm.substation_capacity')"
+ />
+
+
+ handleNumberInput(e, this, 'addOrEditForm.line_length')"
+ />
+
+
+
+
+
+
+
+
+
+
+
+
+
+ handleNumberInput(e, this, 'addOrEditForm.project_amount')"
+ />
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
@@ -444,240 +300,62 @@ import {
getProjectTypeList,
delProjectBatch // 新增:导入批量删除API
} from '@/api/system/project'
-import { Message } from 'element-ui'
-import { getProvinces, getCities, getCounties } from '@/api/system/region'
-import {debounce} from "@/utils";
export default {
name: 'ProjectManagement',
+ dicts: ['voltage_type', 'project_status', 'project_type', 'project_source'],
data() {
return {
- total: 0,
- projectList: [],
- selectedRows: [], // 存储选中的表格行
- provinceOptions: [], // 省份下拉选项
- cityOptions: [], // 城市下拉选项
- districtOptions: [], // 区县下拉选项
- dialogTitle: '新增项目',
- addOrEditDialogVisible: false,
- submitLoading: false,
- isAdd: true,
- isView: false,
- voltageList: [
- { value: '35kv及以下', label: '35kv及以下' },
- { value: '110kv', label: '110kv' },
- { value: '220kv', label: '220kv' },
- { value: '500kv', label: '500kv' },
- { value: '500kv以上', label: '500kv以上' }
- ],
-
- // 搜索参数
+ // 搜索参数 - 精简版
searchParams: {
- pro_name: '',
- pro_code: '',
- project_type: '',
- org_name: '',
- dict_value:'',
+ pageNum: 1,
pageSize: 10,
- pageNum: 1
- },
-
- // 表单数据
- addOrEditForm: {
- id: '',
pro_name: '',
- pro_code: '',
project_type: '',
- org_name: '',
- contractUnit: '',
- mechanize_rate: '',
- remark: '',
- voltage: '',
- scale: '',
- province: '',
- city: '',
- county: '',
- start_time: '',
- put_time: '',
+ project_status: '',
+ voltage: ''
},
-
- projectTypeList: [],
-
- // 表单验证规则
+ // 列表数据
+ projectList: [],
+ total: 0,
+ // 选中行
+ selectedRows: [],
+ // 弹窗相关
+ addOrEditDialogVisible: false,
+ dialogTitle: '',
+ isAdd: true,
+ submitLoading: false,
+ // 表单数据 - 精简字段
+ addOrEditForm: {
+ pro_code: '',
+ pro_name: '',
+ construction_unit: '',
+ project_source: '',
+ project_type: '',
+ project_amount: 0,
+ project_address: '',
+ actual_start_date: '',
+ actual_end_date: '',
+ project_status: '',
+ voltage: '',
+ substation_capacity: 0,
+ line_length: 0,
+ remark: ''
+ },
+ // 简化校验规则
addOrEditFormRules: {
- // 以下字段保持必填
- pro_name: [
- { required: true, message: '请输入项目名称', trigger: 'blur' }
- ],
- pro_code: [
- { required: true, message: '请输入项目编号', trigger: 'blur' }
- ],
- voltage: [
- { required: true, message: '请输入电压等级', trigger: 'blur' }
- ],
- scale: [
- { required: true, message: '请输入规模', trigger: 'blur' }
- ],
- project_type: [
- { required: true, message: '请选择项目类型', trigger: 'change' }
- ],
- province: [
- { required: true, message: '请选择所在省', trigger: 'blur' }
- ],
- city: [
- { required: true, message: '请选择所在市', trigger: 'blur' }
- ],
- county: [
- { required: true, message: '请选择所在区/县', trigger: 'blur' }
- ],
-
- start_time: [
-
- { message: '请选择开工时间', trigger: 'change' }
- ],
- put_time: [
- { message: '请选择投产时间', trigger: 'change' },
- { validator: this.validateTimeDifference, trigger: 'change' }
- ],
- mechanize_rate: [
-
- {
- pattern: /^(100(\.0{1,2})?|0(\.\d{1,2})?|[1-9]\d{0,1}(\.\d{1,2})?)$/,
- message: '请输入 0 ~ 100 之间的有效数字,且不能以 0 开头(如 01、010)',
- trigger: 'blur'
- }
- ],
- org_name: [
- // 非必填,仅保留长度限制(可选)
- { max: 50, message: '单位名称不能超过50个字符', trigger: 'blur' }
- ],
- remark: [
- { max: 100, message: '备注不能超过100个字符', trigger: 'blur' }
- ],
- contractUnit: [] // 完全非必填,留空数组
+ pro_name: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
+ pro_code: [{ required: true, message: '请输入项目编号', trigger: 'blur' }],
+ construction_unit: [{ required: true, message: '请输入施工单位', trigger: 'blur' }],
+ project_type: [{ required: true, message: '请选择项目类型', trigger: 'change' }]
}
}
},
-
created() {
- this.handleSubmit=debounce(this.handleSubmit, 500);
- },
-
- mounted() {
- this.loadProvinces() // 页面加载时加载省份
this.getProjectListData()
- this.loadProjectTypes()
},
-
methods: {
-
- // 自定义校验:投产时间必须晚于开工时间
- validateTimeDifference(rule, value, callback) {
- const startTime = this.addOrEditForm.start_time; // 开工时间
- const endTime = value; // 投产时间(当前校验字段的值)
-
- // 若未选择投产时间,直接通过(非必填)
- if (!endTime) return callback();
-
- // 若已选择开工时间,校验时间差
- if (startTime) {
- const startDate = new Date(startTime);
- const endDate = new Date(endTime);
- // 若投产时间早于或等于开工时间,提示错误
- if (endDate <= startDate) {
- return callback(new Error('投产时间必须晚于开工时间'));
- }
- }
-
- // 校验通过
- callback();
- },
-
- async loadProvinces() {
- try {
- const res = await getProvinces()
- if (res.code === 200) {
- // 关键转换:将 areaCode → value,name → label
- this.provinceOptions = res.data.map(item => ({
- value: item.areaCode, // 下拉框的选项值(存储用)
- label: item.short_name // 下拉框的显示文本(用户看)
- }))
- } else {
- Message.error('加载省份失败:' + (res.message || '未知错误'))
- }
- } catch (error) {
- console.error('省份加载异常:', error)
- Message.error('网络异常,无法加载省份数据')
- }
- },
-
- // 加载城市
- async loadCities(provinceAreaCode) {
- console.log('loadCities param:', provinceAreaCode)
-
- // 关键改动:当省份改变时,清空城市和区县的选项及表单值
- // 即使 provinceAreaCode 为空(例如用户清空了省份选择),也执行清空操作
- this.cityOptions = [];
- this.districtOptions = [];
- this.addOrEditForm.city = '';
- this.addOrEditForm.county = '';
-
- // 如果没有传入有效的省份编码,则直接返回
- if (!provinceAreaCode || !/^\d{6,12}$/.test(provinceAreaCode)) {
- console.error('❌ 传入了无效的 provinceAreaCode:', provinceAreaCode);
- return;
- }
-
- try {
- const res = await getCities(provinceAreaCode)
- if (res.code === 200) {
- this.cityOptions = res.data.map(item => ({
- value: item.areaCode,
- label: item.short_name
- }))
- } else {
- Message.error('加载城市失败')
- }
- } catch (error) {
- console.error('城市加载异常:', error)
- Message.error('无法加载城市数据')
- }
- },
-
-// 加载区县
- async loadDistricts(cityAreaCode) {
- console.log('loadDistricts param:', cityAreaCode)
-
- // 关键改动:当城市改变时,清空区县的选项及表单值
- // 即使 cityAreaCode 为空,也执行清空操作
- this.districtOptions = [];
- this.addOrEditForm.county = '';
-
- // 如果没有传入有效的城市编码,则直接返回
- if (!cityAreaCode || !/^\d{6,12}$/.test(cityAreaCode)) {
- console.error('❌ 传入了无效的 cityAreaCode:', cityAreaCode);
- return;
- }
-
- try {
- const res = await getCounties(cityAreaCode)
- if (res.code === 200) {
- this.districtOptions = res.data.map(item => ({
- value: item.areaCode,
- label: item.name
- }))
- } else {
- Message.error('加载区县失败')
- }
- } catch (error) {
- console.error('区县加载异常:', error)
- Message.error('无法加载区县数据')
- }
- },
-
-
-
- // 获取工程列表
+ // 获取列表数据
async getProjectListData() {
try {
const res = await listProject(this.searchParams)
@@ -685,625 +363,409 @@ export default {
this.projectList = res.data.rows || []
this.total = res.data.total || 0
} else {
- Message.error(res.message || '获取项目列表失败')
+ this.$modal.msgError(res.message || '获取项目列表失败')
}
} catch (error) {
- Message.error('获取项目列表失败')
+ this.$modal.msgError('获取项目列表失败')
}
},
-
- // 加载工程类型
- async loadProjectTypes() {
- try {
- const res = await getProjectTypeList()
- if (res.code === 200) {
- this.projectTypeList = res.data.map(item => ({
- label: item.dict_label,
- value: item.dict_value
- }))
- } else {
- Message.error('获取项目类型失败:' + (res.message || ''))
- }
- } catch (error) {
- Message.error('加载项目类型时发生网络错误')
- }
- },
-
- handleExport() {
- this.download('/material-mall/project/export', {
- ...this.queryParams
- }, `项目管理_${new Date().getTime()}.xlsx`)
- },
-
- // 重置搜索
- onReset() {
- this.searchParams = {
- pro_name: '',
- pro_code: '',
- project_type: '',
- org_name: '',
- pageSize: this.searchParams.pageSize,
- pageNum: 1
- }
- this.$refs.searchFormRef?.clearValidate()
- this.getProjectListData()
- },
-
- // 表格选择变化
- handleSelectionChange(selection) {
- this.selectedRows = selection
- },
-
- // 详情页跳转
- handleToDetails(id) {
- this.$router.push({name: 'demand-details', query: {id}})
- },
-
- // 新增工程
- handleAdd() {
- this.isAdd = true
- this.isView = false
- this.dialogTitle = '新增项目'
- this.addOrEditForm = {
- id: '',
- pro_name: '',
- pro_code: '',
- project_type: '',
- org_name: '',
- contractUnit: '',
- remark: '',
- voltage: '',
- scale: '',
- province: '',
- city: '',
- county: '',
- start_time: '',
- put_time: ''
- }
- this.$refs.addOrEditFormRef?.clearValidate()
- this.addOrEditDialogVisible = true
- },
-
- // 查看详情
- async handleViewDetails(row) {
- this.isView = true
- this.dialogTitle = '查看项目详情'
- try {
- const res = await getProject(row.id)
- if (res.code === 200) {
- this.addOrEditForm = {...res.data}
- this.addOrEditDialogVisible = true
- } else {
- Message.error(res.message || '获取项目详情失败')
- }
- } catch (error) {
- Message.error('获取项目详情失败')
- }
- },
-
- async handleEdit(row) {
- this.isAdd = false;
- this.isView = false;
- this.dialogTitle = '编辑项目';
-
- try {
- // 1. 获取工程详情
- const res = await getProject(row.id);
- if (res.code !== 200) return this.$message.error('获取详情失败');
-
- // 拿到原始数据
- const projectData = res.data;
-
- // ================== 核心修改开始 ==================
- // 2. 处理机械化率的格式:去除百分号,并转换为数字
- if (projectData.mechanize_rate && typeof projectData.mechanize_rate === 'string') {
- // 使用 replace('%', '') 去掉百分号
- // 使用 parseFloat() 将字符串转换为数字
- projectData.mechanize_rate = parseFloat(projectData.mechanize_rate.replace('%', ''));
- }
- // ================== 核心修改结束 ==================
-
- // 3. 确保省份列表已加载(含 areaCode 映射)
- await this.loadProvinces();
-
- // 4. 省份名称 -> 编码
- const targetProvince = this.provinceOptions.find(item => item.label === projectData.province);
- const provinceCode = targetProvince ? targetProvince.value : '';
- if (!provinceCode) {
- Message.warning(`未找到“${projectData.province}”对应的编码,请手动选择`);
- this.addOrEditForm = { ...projectData }; // 这里也会使用处理后的数据
- this.addOrEditDialogVisible = true;
- return;
- }
-
- // 5. 用编码加载城市列表
- await this.loadCities(provinceCode);
- // 城市名称 -> 编码
- const targetCity = this.cityOptions.find(item => item.label === projectData.city);
- const cityCode = targetCity ? targetCity.value : '';
-
- // 6. 用编码加载区县列表
- await this.loadDistricts(cityCode);
- // 区县名称 -> 编码
- const targetCounty = this.districtOptions.find(item => item.label === projectData.county);
- const countyCode = targetCounty ? targetCounty.value : '';
-
- // 7. 表单赋值(此时 projectData.mechanize_rate 已经是数字 80 了)
- this.addOrEditForm = {
- ...projectData,
- province: provinceCode,
- city: cityCode,
- county: countyCode
- };
-
- this.addOrEditDialogVisible = true;
- this.$nextTick(() => this.$refs.addOrEditFormRef?.clearValidate());
- } catch (error) {
- console.error('编辑失败:', error);
- Message.error('编辑失败');
- }
- },
-
-
- // 提交表单
- async handleSubmit() {
-
- const valid = await this.$refs.addOrEditFormRef?.validate()
- if (!valid) return
-
-
- // 处理机械化率:添加%符号
- if (this.addOrEditForm.mechanize_rate) {
- this.addOrEditForm.mechanize_rate = `${this.addOrEditForm.mechanize_rate}%`
- }
-
- this.submitLoading = true
- try {
- let res = this.isAdd ? await addProject(this.addOrEditForm) : await updateProject(this.addOrEditForm)
- if (res.code === 200) {
- Message.success(this.isAdd ? '新增项目成功' : '编辑项目成功')
- this.addOrEditDialogVisible = false
- this.getProjectListData()
- } else {
- Message.error(res.message || (this.isAdd ? '新增项目失败' : '编辑项目失败'))
- }
- } catch (error) {
- //Message.error('网络错误,操作失败')
- } finally {
- this.submitLoading = false
- }
- },
-
- // 删除工程
- async handleDelete(id) {
- try {
- const res = await delProject(id)
- if (res.code === 200) {
- Message.success('删除项目成功')
- this.getProjectListData()
- } else {
- Message.error(res.message || '删除项目失败')
- }
- } catch (error) {
- Message.error('删除项目失败')
- }
- },
-
- // 批量删除 - 修复后的方法
- async handleBatchDelete() {
- if (this.selectedRows.length === 0) {
- Message.warning('请选择要删除的项目')
+ handleNumberInput(val, vm, field, options = {}) {
+ // 核心修复1:校验vm有效性,避免调用内部方法时报错
+ if (!vm || typeof vm.$nextTick !== 'function' || typeof vm.$set !== 'function') {
+ console.warn('handleNumberInput: 无效的Vue实例', vm)
return
}
- try {
- await this.$confirm(
- `确定删除选中的 ${this.selectedRows.length} 个项目吗?`,
- '提示',
- {
- type: 'warning',
- confirmButtonText: '确定',
- cancelButtonText: '取消'
- }
- )
+ // 默认配置
+ const { decimalLimit = 2, allowZero = true } = options
+ // 特殊处理:单独输入e/E直接重置为0(核心拦截点1)
+ if (val === 'e' || val === 'E' || val === 'e' || val === 'E') {
+ this.setNestedField(vm, field, '0')
+ return
+ }
+ // 核心修复2:过滤非法字段名(避开$/_开头的内部属性)
+ if (!field || typeof field !== 'string' || field.includes('__ob__') || field.startsWith('$') || field.startsWith('_')) {
+ console.warn('handleNumberInput: 非法字段名', field)
+ return
+ }
- const ids = this.selectedRows.map(row => row.id)
- const res = await delProjectBatch(ids)
-
- if (res.code === 200) {
- Message.success(`成功删除 ${this.selectedRows.length} 个项目`)
- this.getProjectListData()
- this.selectedRows = [] // 清空选中状态
- } else {
- Message.error(res.message || '批量删除失败')
- }
- } catch (error) {
- if (error !== 'cancel') {
- Message.error('批量删除失败')
+ // 步骤0:禁止数字常量(科学计数法、十六进制、Infinity、NaN等)
+ let valStr = ''
+ if (val !== '' && val !== null && val !== undefined) {
+ valStr = val.toString().toLowerCase()
+ console.log(valStr)
+ const invalidPattern = /(e|0x|infinity|nan)/
+ if (invalidPattern.test(valStr)) {
+ const emptyValue = allowZero ? '0' : ''
+ this.setNestedField(vm, field, emptyValue)
+ return
}
}
+
+ // 空值处理
+ if (val === '' || val === null || val === undefined) {
+ const emptyValue = allowZero ? '0' : ''
+ this.setNestedField(vm, field, emptyValue)
+ return
+ }
+
+ // 步骤1:移除所有非数字和非小数点的字符
+ let newValue = valStr.replace(/[^0-9.]/g, '')
+
+ // 步骤2:禁止负数(若有负号直接重置)
+ if (newValue.includes('-')) {
+ newValue = allowZero ? '0' : ''
+ }
+
+ // 步骤3:处理前置0
+ if (newValue.indexOf('.') === -1) {
+ // 无小数点:纯数字去前置0
+ newValue = Number(newValue).toString()
+ // 处理 Number(0000) → '0' 的情况
+ if (newValue === '0' && !allowZero) {
+ newValue = ''
+ }
+ } else {
+ // 有小数点:仅清理整数部分前置0
+ const [integerPart, decimalPart] = newValue.split('.')
+ const cleanInteger = integerPart ? Number(integerPart).toString() : '0'
+ // 拼接小数部分(保留不超过限制位数)
+ const limitedDecimal = decimalPart.slice(0, decimalLimit)
+ newValue = `${cleanInteger}.${limitedDecimal}`
+ // 处理特殊情况:0. → 0 或 空
+ if (newValue.endsWith('.')) {
+ newValue = allowZero ? cleanInteger : (cleanInteger === '0' ? '' : cleanInteger)
+ }
+ }
+
+ // 步骤4:限制小数位数(兜底处理)
+ if (newValue.indexOf('.') !== -1) {
+ const [intPart, decPart] = newValue.split('.')
+ if (decPart.length > decimalLimit) {
+ newValue = `${intPart}.${decPart.slice(0, decimalLimit)}`
+ }
+ }
+
+ // 步骤5:不允许0的情况,清空0值
+ if (!allowZero && newValue === '0') {
+ newValue = ''
+ }
+
+ // 核心修复3:安全设置嵌套字段(从$data开始,避开内部属性)
+ this.setNestedField(vm, field, newValue)
},
- // 关闭对话框
- handleDialogClose() {
- this.isView = false
- this.$refs.addOrEditFormRef?.clearValidate()
- },
+ // 新增:安全设置嵌套字段的辅助方法(核心解决__ob__警告)
+ setNestedField(vm, field, value) {
+ const fieldArr = field.split('.')
+ // 从$data开始解析(仅访问用户定义的data属性,避开Vue内部属性)
+ let target = vm.$data
+ // 逐层初始化嵌套字段(避免访问到__ob__)
+ for (let i = 0; i < fieldArr.length - 1; i++) {
+ const key = fieldArr[i]
+ // 跳过内部属性
+ if (key.startsWith('$') || key.startsWith('_') || key === '__ob__') continue
+ // 若层级不存在,初始化空对象(保证响应式)
+ if (!target[key] || typeof target[key] !== 'object') {
+ vm.$set(target, key, {})
+ }
+ target = target[key]
+ }
+
+ // 最终赋值(保证响应式)
+ const finalKey = fieldArr[fieldArr.length - 1]
+ if (finalKey && !finalKey.startsWith('$') && !finalKey.startsWith('_') && finalKey !== '__ob__') {
+ vm.$nextTick(() => {
+ vm.$set(target, finalKey, value)
+ })
+ }
+ },
+ // 重置搜索
+ onReset() {
+ this.$refs.searchFormRef.resetFields()
+ this.searchParams = {
+ pageNum: 1,
+ pageSize: 10,
+ pro_name: '',
+ project_type: '',
+ project_status: '',
+ voltage: ''
+ }
+ this.getProjectListData()
+ },
// 分页大小改变
handleSizeChange(val) {
this.searchParams.pageSize = val
this.getProjectListData()
},
-
- // 当前页码改变
+ // 页码改变
handleCurrentChange(val) {
this.searchParams.pageNum = val
this.getProjectListData()
+ },
+ // 选择行改变
+ handleSelectionChange(val) {
+ this.selectedRows = val
+ },
+ // 新增
+ handleAdd() {
+ this.isAdd = true
+ this.dialogTitle = '新增项目'
+ this.resetForm()
+ this.addOrEditDialogVisible = true
+ },
+ // 编辑
+ handleEdit(row) {
+ this.isAdd = false
+ this.dialogTitle = '编辑项目'
+ this.addOrEditForm = { ...row }
+ this.addOrEditDialogVisible = true
+ },
+ // 删除确认
+ handleDeleteConfirm(id) {
+ this.$confirm('确定删除该项目吗?', '提示', {
+ type: 'warning',
+ confirmButtonText: '确定',
+ cancelButtonText: '取消'
+ }).then(() => {
+ try {
+ delProject(id)
+ this.getProjectListData()
+ // 实际替换为批量删除接口
+ this.$message.success('删除成功')
+
+ } catch (e) {
+ this.$message.error('删除失败')
+ }
+ })
+ },
+ // 批量删除
+ handleBatchDelete() {
+ this.$confirm('确定删除选中的项目吗?', '提示', { type: 'warning' }).then(async() => {
+ try {
+ const ids = this.selectedRows.map(item => item.id)
+ delProjectBatch(ids)
+ // 实际替换为批量删除接口
+ this.$message.success('批量删除成功')
+ this.getProjectListData()
+ } catch (e) {
+ this.$message.error('批量删除失败')
+ }
+ })
+ },
+ // 导出
+ handleExport() {
+ this.$message.success('导出成功')
+ },
+ // 提交表单
+ async handleSubmit() {
+ try {
+ // 1. 先禁用提交按钮,防止重复点击
+ this.submitLoading = true
+
+ // 2. 表单校验(转为Promise,适配async/await)
+ const valid = await new Promise((resolve) => {
+ this.$refs.addOrEditFormRef.validate((isValid) => {
+ resolve(isValid)
+ })
+ })
+
+ // 3. 校验失败直接返回
+ if (!valid) {
+ this.$message.error('表单校验失败,请检查必填项')
+ return // 终止后续逻辑
+ }
+
+ // 4. 调用接口(await等待返回结果)
+ let res
+ if (this.isAdd) {
+ res = await addProject(this.addOrEditForm) // 新增接口
+ } else {
+ res = await updateProject(this.addOrEditForm) // 编辑接口
+ }
+
+ // 5. 接口返回结果判断(根据实际后端返回格式调整)
+ if (res && (res.code === 200 || res.success)) {
+ this.$message.success(this.isAdd ? '新增成功' : '编辑成功')
+ this.addOrEditDialogVisible = false
+ await this.getProjectListData() // 刷新列表
+ } else {
+ // 接口返回失败(如业务校验不通过)
+ this.$message.error(res?.msg || (this.isAdd ? '新增失败' : '编辑失败'))
+ }
+ } catch (e) {
+ // 捕获所有异常:接口报错、网络错误、代码异常等
+ console.error('提交表单异常:', e)
+ this.$message.error(e?.response?.data?.msg || '操作失败,请稍后重试')
+ } finally {
+ // 无论成功/失败,最终恢复加载状态
+ this.submitLoading = false
+ }
+ },
+ // 关闭弹窗
+ handleDialogClose() {
+ this.resetForm()
+ },
+ // 重置表单
+ resetForm() {
+ this.addOrEditForm = {
+ pro_code: '',
+ pro_name: '',
+ construction_unit: '',
+ project_source: '',
+ project_type: '',
+ project_amount: '',
+ project_address: '',
+ actual_start_date: '',
+ actual_end_date: '',
+ project_status: '',
+ voltage: '',
+ substation_capacity: '',
+ line_length: '',
+ remark: ''
+ }
+ this.$nextTick(() => {
+ this.$refs.addOrEditFormRef?.clearValidate()
+ })
+ },
+ // 获取状态标签类型
+ getStatusTagType(status) {
+ const typeMap = {
+ '1': 'info',
+ '2': 'primary',
+ '3': 'success',
+ '4': 'warning'
+ }
+ return typeMap[status] || 'default'
}
}
}
-