代码优化
This commit is contained in:
parent
478b20ef44
commit
6e54c974a4
|
|
@ -120,7 +120,7 @@ const handleCloseInner = () => {
|
||||||
|
|
||||||
.com-dialog__outer .el-dialog__headerbtn,
|
.com-dialog__outer .el-dialog__headerbtn,
|
||||||
.com-dialog__inner .el-dialog__headerbtn {
|
.com-dialog__inner .el-dialog__headerbtn {
|
||||||
top: 14px;
|
top: 4px;
|
||||||
right: 16px;
|
right: 16px;
|
||||||
|
|
||||||
.el-dialog__close {
|
.el-dialog__close {
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="Position">
|
<script setup name="Position">
|
||||||
import { ref } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import {
|
import {
|
||||||
listBusinessTypeAPI,
|
listBusinessTypeAPI,
|
||||||
addBusinessTypeAPI,
|
addBusinessTypeAPI,
|
||||||
|
|
@ -68,12 +68,16 @@ const { proxy } = getCurrentInstance()
|
||||||
const addAndEditFormRef = ref(null)
|
const addAndEditFormRef = ref(null)
|
||||||
const comTableRef = ref(null)
|
const comTableRef = ref(null)
|
||||||
const editId = ref(null)
|
const editId = ref(null)
|
||||||
const addAndEditForm = ref({
|
|
||||||
|
// 定义初始表单数据函数
|
||||||
|
const getInitFormData = () => ({
|
||||||
planMajorName: '',
|
planMajorName: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
category: 1,
|
category: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const addAndEditForm = ref(getInitFormData())
|
||||||
|
|
||||||
const addAndEditRules = ref({
|
const addAndEditRules = ref({
|
||||||
planMajorName: [{ required: true, message: '请输入业务类型名称', trigger: 'blur' }],
|
planMajorName: [{ required: true, message: '请输入业务类型名称', trigger: 'blur' }],
|
||||||
})
|
})
|
||||||
|
|
@ -85,14 +89,14 @@ const actionColumns = [
|
||||||
link: true,
|
link: true,
|
||||||
handler: (row) => {
|
handler: (row) => {
|
||||||
const { planMajorId, planMajorName, remark } = row
|
const { planMajorId, planMajorName, remark } = row
|
||||||
addAndEditForm.value = {
|
editId.value = planMajorId
|
||||||
planMajorId,
|
|
||||||
planMajorName,
|
|
||||||
remark,
|
|
||||||
}
|
|
||||||
editId.value = row.planMajorId
|
|
||||||
dialogConfig.outerTitle = '编辑业务类型'
|
dialogConfig.outerTitle = '编辑业务类型'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 使用 nextTick 确保在弹框渲染、表单组件挂载后再赋值
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditForm.value.planMajorName = planMajorName
|
||||||
|
addAndEditForm.value.remark = remark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -116,41 +120,47 @@ const actionColumns = [
|
||||||
// 新增
|
// 新增
|
||||||
const onHandleAdd = () => {
|
const onHandleAdd = () => {
|
||||||
editId.value = null
|
editId.value = null
|
||||||
|
dialogConfig.outerTitle = '新增业务类型'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 重置表单数据
|
||||||
|
addAndEditForm.value = getInitFormData()
|
||||||
|
// 清除之前的校验信息
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditFormRef.value?.clearValidate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消
|
// 取消
|
||||||
const onHandleCancel = () => {
|
const onHandleCancel = () => {
|
||||||
|
addAndEditFormRef?.value?.resetFields() // 重置表单
|
||||||
dialogConfig.outerVisible = false
|
dialogConfig.outerVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
const onHandleSave = async () => {
|
const onHandleSave = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
try {
|
await addAndEditFormRef.value.validate()
|
||||||
addAndEditFormRef.value.validate(async (valid) => {
|
const API = editId.value ? updateBusinessTypeAPI : addBusinessTypeAPI
|
||||||
if (valid) {
|
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
||||||
const API = editId.value ? updateBusinessTypeAPI : addBusinessTypeAPI
|
editId.value ? (params.planMajorId = editId.value) : null
|
||||||
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
|
||||||
editId.value ? (params.planMajorId = editId.value) : null
|
|
||||||
|
|
||||||
const result = await API(params)
|
const result = await API(params)
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
||||||
addAndEditFormRef.value.resetFields() // 重置表单
|
addAndEditFormRef.value.resetFields() // 重置表单
|
||||||
dialogConfig.outerVisible = false
|
dialogConfig.outerVisible = false
|
||||||
comTableRef.value?.refresh() // 刷新表格
|
comTableRef.value?.refresh() // 刷新表格
|
||||||
}
|
|
||||||
resolve(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
|
console.error('表单校验失败或请求错误:', error)
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseDialogOuter = (visible) => {
|
const onCloseDialogOuter = (visible) => {
|
||||||
dialogConfig.outerVisible = visible
|
dialogConfig.outerVisible = visible
|
||||||
|
if (!visible) {
|
||||||
|
addAndEditFormRef.value?.resetFields()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="inspectionStation">
|
<script setup name="inspectionStation">
|
||||||
import { ref } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import {
|
import {
|
||||||
listInspectionStationAPI,
|
listInspectionStationAPI,
|
||||||
addInspectionStationAPI,
|
addInspectionStationAPI,
|
||||||
|
|
@ -77,12 +77,16 @@ const { proxy } = getCurrentInstance()
|
||||||
const addAndEditFormRef = ref(null)
|
const addAndEditFormRef = ref(null)
|
||||||
const comTableRef = ref(null)
|
const comTableRef = ref(null)
|
||||||
const editId = ref(null)
|
const editId = ref(null)
|
||||||
const addAndEditForm = ref({
|
|
||||||
|
// 定义初始表单数据函数
|
||||||
|
const getInitFormData = () => ({
|
||||||
inspectionStationName: '',
|
inspectionStationName: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
category: 0,
|
category: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const addAndEditForm = ref(getInitFormData())
|
||||||
|
|
||||||
const addAndEditRules = ref({
|
const addAndEditRules = ref({
|
||||||
inspectionStationName: [{ required: true, message: '请输入运检站名称', trigger: 'blur' }],
|
inspectionStationName: [{ required: true, message: '请输入运检站名称', trigger: 'blur' }],
|
||||||
})
|
})
|
||||||
|
|
@ -94,14 +98,15 @@ const actionColumns = [
|
||||||
link: true,
|
link: true,
|
||||||
handler: (row) => {
|
handler: (row) => {
|
||||||
const { inspectionStationId, inspectionStationName, remark } = row
|
const { inspectionStationId, inspectionStationName, remark } = row
|
||||||
addAndEditForm.value = {
|
editId.value = inspectionStationId
|
||||||
inspectionStationId,
|
|
||||||
inspectionStationName,
|
|
||||||
remark,
|
|
||||||
}
|
|
||||||
editId.value = row.inspectionStationId
|
|
||||||
dialogConfig.outerTitle = '编辑运检站'
|
dialogConfig.outerTitle = '编辑运检站'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 使用 nextTick 确保在弹框渲染、表单组件挂载后再赋值
|
||||||
|
// 这样 el-form 记录的 "initial value" 才是空值,resetFields 才能生效
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditForm.value.inspectionStationName = inspectionStationName
|
||||||
|
addAndEditForm.value.remark = remark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -125,7 +130,14 @@ const actionColumns = [
|
||||||
// 新增
|
// 新增
|
||||||
const onHandleAdd = () => {
|
const onHandleAdd = () => {
|
||||||
editId.value = null
|
editId.value = null
|
||||||
|
dialogConfig.outerTitle = '新增运检站'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 重置表单数据
|
||||||
|
addAndEditForm.value = getInitFormData()
|
||||||
|
// 清除之前的校验信息
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditFormRef.value?.clearValidate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消
|
// 取消
|
||||||
|
|
@ -136,31 +148,30 @@ const onHandleCancel = () => {
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
const onHandleSave = async () => {
|
const onHandleSave = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
try {
|
await addAndEditFormRef.value.validate()
|
||||||
addAndEditFormRef.value.validate(async (valid) => {
|
const API = editId.value ? updateInspectionStationAPI : addInspectionStationAPI
|
||||||
if (valid) {
|
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
||||||
const API = editId.value ? updateInspectionStationAPI : addInspectionStationAPI
|
editId.value ? (params.inspectionStationId = editId.value) : null
|
||||||
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
|
||||||
editId.value ? (params.inspectionStationId = editId.value) : null
|
|
||||||
|
|
||||||
const result = await API(params)
|
const result = await API(params)
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
||||||
addAndEditFormRef.value.resetFields() // 重置表单
|
addAndEditFormRef.value.resetFields() // 重置表单
|
||||||
dialogConfig.outerVisible = false
|
dialogConfig.outerVisible = false
|
||||||
comTableRef.value?.refresh() // 刷新表格
|
comTableRef.value?.refresh() // 刷新表格
|
||||||
}
|
|
||||||
resolve(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
|
console.error('表单校验失败或请求错误:', error)
|
||||||
|
// 必须抛出错误或返回 Promise.reject(),ComButton 才能捕获并结束 loading 状态
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseDialogOuter = (visible) => {
|
const onCloseDialogOuter = (visible) => {
|
||||||
dialogConfig.outerVisible = visible
|
dialogConfig.outerVisible = visible
|
||||||
|
if (!visible) {
|
||||||
|
addAndEditFormRef.value?.resetFields()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="PersonNature">
|
<script setup name="PersonNature">
|
||||||
import { ref } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import {
|
import {
|
||||||
listPersonCategoryAPI,
|
listPersonCategoryAPI,
|
||||||
addPersonCategoryAPI,
|
addPersonCategoryAPI,
|
||||||
|
|
@ -77,12 +77,16 @@ const { proxy } = getCurrentInstance()
|
||||||
const addAndEditFormRef = ref(null)
|
const addAndEditFormRef = ref(null)
|
||||||
const comTableRef = ref(null)
|
const comTableRef = ref(null)
|
||||||
const editId = ref(null)
|
const editId = ref(null)
|
||||||
const addAndEditForm = ref({
|
|
||||||
|
// 定义初始表单数据函数
|
||||||
|
const getInitFormData = () => ({
|
||||||
personnelClassificationName: '',
|
personnelClassificationName: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
category: 1,
|
category: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const addAndEditForm = ref(getInitFormData())
|
||||||
|
|
||||||
const addAndEditRules = ref({
|
const addAndEditRules = ref({
|
||||||
personnelClassificationName: [
|
personnelClassificationName: [
|
||||||
{ required: true, message: '请输入人员分类名称', trigger: 'blur' },
|
{ required: true, message: '请输入人员分类名称', trigger: 'blur' },
|
||||||
|
|
@ -96,14 +100,14 @@ const actionColumns = [
|
||||||
link: true,
|
link: true,
|
||||||
handler: (row) => {
|
handler: (row) => {
|
||||||
const { personnelClassificationId, personnelClassificationName, remark } = row
|
const { personnelClassificationId, personnelClassificationName, remark } = row
|
||||||
addAndEditForm.value = {
|
editId.value = personnelClassificationId
|
||||||
personnelClassificationId,
|
|
||||||
personnelClassificationName,
|
|
||||||
remark,
|
|
||||||
}
|
|
||||||
editId.value = row.personnelClassificationId
|
|
||||||
dialogConfig.outerTitle = '编辑人员分类'
|
dialogConfig.outerTitle = '编辑人员分类'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 使用 nextTick 确保在弹框渲染、表单组件挂载后再赋值
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditForm.value.personnelClassificationName = personnelClassificationName
|
||||||
|
addAndEditForm.value.remark = remark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -127,7 +131,14 @@ const actionColumns = [
|
||||||
// 新增
|
// 新增
|
||||||
const onHandleAdd = () => {
|
const onHandleAdd = () => {
|
||||||
editId.value = null
|
editId.value = null
|
||||||
|
dialogConfig.outerTitle = '新建人员分类'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 重置表单数据
|
||||||
|
addAndEditForm.value = getInitFormData()
|
||||||
|
// 清除之前的校验信息
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditFormRef.value?.clearValidate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消
|
// 取消
|
||||||
|
|
@ -138,31 +149,29 @@ const onHandleCancel = () => {
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
const onHandleSave = async () => {
|
const onHandleSave = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
try {
|
await addAndEditFormRef.value.validate()
|
||||||
addAndEditFormRef.value.validate(async (valid) => {
|
const API = editId.value ? updatePersonCategoryAPI : addPersonCategoryAPI
|
||||||
if (valid) {
|
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
||||||
const API = editId.value ? updatePersonCategoryAPI : addPersonCategoryAPI
|
editId.value ? (params.personnelClassificationId = editId.value) : null
|
||||||
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
|
||||||
editId.value ? (params.personnelClassificationId = editId.value) : null
|
|
||||||
|
|
||||||
const result = await API(params)
|
const result = await API(params)
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
||||||
addAndEditFormRef.value.resetFields() // 重置表单
|
addAndEditFormRef.value.resetFields() // 重置表单
|
||||||
dialogConfig.outerVisible = false
|
dialogConfig.outerVisible = false
|
||||||
comTableRef.value?.refresh() // 刷新表格
|
comTableRef.value?.refresh() // 刷新表格
|
||||||
}
|
|
||||||
resolve(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
|
console.error('表单校验失败或请求错误:', error)
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseDialogOuter = (visible) => {
|
const onCloseDialogOuter = (visible) => {
|
||||||
dialogConfig.outerVisible = visible
|
dialogConfig.outerVisible = visible
|
||||||
|
if (!visible) {
|
||||||
|
addAndEditFormRef.value?.resetFields()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="PersonNature">
|
<script setup name="PersonNature">
|
||||||
import { ref } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import {
|
import {
|
||||||
listPersonNatureAPI,
|
listPersonNatureAPI,
|
||||||
addPersonNatureAPI,
|
addPersonNatureAPI,
|
||||||
|
|
@ -77,12 +77,16 @@ const { proxy } = getCurrentInstance()
|
||||||
const addAndEditFormRef = ref(null)
|
const addAndEditFormRef = ref(null)
|
||||||
const comTableRef = ref(null)
|
const comTableRef = ref(null)
|
||||||
const editId = ref(null)
|
const editId = ref(null)
|
||||||
const addAndEditForm = ref({
|
|
||||||
|
// 定义初始表单数据函数
|
||||||
|
const getInitFormData = () => ({
|
||||||
personnelClassificationName: '',
|
personnelClassificationName: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
category: 1,
|
category: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const addAndEditForm = ref(getInitFormData())
|
||||||
|
|
||||||
const addAndEditRules = ref({
|
const addAndEditRules = ref({
|
||||||
personnelClassificationName: [
|
personnelClassificationName: [
|
||||||
{ required: true, message: '请输入人员性质名称', trigger: 'blur' },
|
{ required: true, message: '请输入人员性质名称', trigger: 'blur' },
|
||||||
|
|
@ -96,14 +100,14 @@ const actionColumns = [
|
||||||
link: true,
|
link: true,
|
||||||
handler: (row) => {
|
handler: (row) => {
|
||||||
const { personnelClassificationId, personnelClassificationName, remark } = row
|
const { personnelClassificationId, personnelClassificationName, remark } = row
|
||||||
addAndEditForm.value = {
|
editId.value = personnelClassificationId
|
||||||
personnelClassificationId,
|
|
||||||
personnelClassificationName,
|
|
||||||
remark,
|
|
||||||
}
|
|
||||||
editId.value = row.personnelClassificationId
|
|
||||||
dialogConfig.outerTitle = '编辑人员性质'
|
dialogConfig.outerTitle = '编辑人员性质'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 使用 nextTick 确保在弹框渲染、表单组件挂载后再赋值
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditForm.value.personnelClassificationName = personnelClassificationName
|
||||||
|
addAndEditForm.value.remark = remark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -127,7 +131,14 @@ const actionColumns = [
|
||||||
// 新增
|
// 新增
|
||||||
const onHandleAdd = () => {
|
const onHandleAdd = () => {
|
||||||
editId.value = null
|
editId.value = null
|
||||||
|
dialogConfig.outerTitle = '新建人员性质'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 重置表单数据
|
||||||
|
addAndEditForm.value = getInitFormData()
|
||||||
|
// 清除之前的校验信息
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditFormRef.value?.clearValidate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消
|
// 取消
|
||||||
|
|
@ -138,31 +149,29 @@ const onHandleCancel = () => {
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
const onHandleSave = async () => {
|
const onHandleSave = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
try {
|
await addAndEditFormRef.value.validate()
|
||||||
addAndEditFormRef.value.validate(async (valid) => {
|
const API = editId.value ? updatePersonNatureAPI : addPersonNatureAPI
|
||||||
if (valid) {
|
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
||||||
const API = editId.value ? updatePersonNatureAPI : addPersonNatureAPI
|
editId.value ? (params.personnelClassificationId = editId.value) : null
|
||||||
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
|
||||||
editId.value ? (params.personnelClassificationId = editId.value) : null
|
|
||||||
|
|
||||||
const result = await API(params)
|
const result = await API(params)
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
||||||
addAndEditFormRef.value.resetFields() // 重置表单
|
addAndEditFormRef.value.resetFields() // 重置表单
|
||||||
dialogConfig.outerVisible = false
|
dialogConfig.outerVisible = false
|
||||||
comTableRef.value?.refresh() // 刷新表格
|
comTableRef.value?.refresh() // 刷新表格
|
||||||
}
|
|
||||||
resolve(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
|
console.error('表单校验失败或请求错误:', error)
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseDialogOuter = (visible) => {
|
const onCloseDialogOuter = (visible) => {
|
||||||
dialogConfig.outerVisible = visible
|
dialogConfig.outerVisible = visible
|
||||||
|
if (!visible) {
|
||||||
|
addAndEditFormRef.value?.resetFields()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="Position">
|
<script setup name="Position">
|
||||||
import { ref } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import {
|
import {
|
||||||
listPlanCategoryAPI,
|
listPlanCategoryAPI,
|
||||||
addPlanCategoryAPI,
|
addPlanCategoryAPI,
|
||||||
|
|
@ -77,12 +77,16 @@ const { proxy } = getCurrentInstance()
|
||||||
const addAndEditFormRef = ref(null)
|
const addAndEditFormRef = ref(null)
|
||||||
const comTableRef = ref(null)
|
const comTableRef = ref(null)
|
||||||
const editId = ref(null)
|
const editId = ref(null)
|
||||||
const addAndEditForm = ref({
|
|
||||||
|
// 定义初始表单数据函数
|
||||||
|
const getInitFormData = () => ({
|
||||||
planMajorName: '',
|
planMajorName: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
category: 2,
|
category: 2,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const addAndEditForm = ref(getInitFormData())
|
||||||
|
|
||||||
const addAndEditRules = ref({
|
const addAndEditRules = ref({
|
||||||
planMajorName: [{ required: true, message: '请输入计划类别名称', trigger: 'blur' }],
|
planMajorName: [{ required: true, message: '请输入计划类别名称', trigger: 'blur' }],
|
||||||
})
|
})
|
||||||
|
|
@ -94,14 +98,14 @@ const actionColumns = [
|
||||||
link: true,
|
link: true,
|
||||||
handler: (row) => {
|
handler: (row) => {
|
||||||
const { planMajorId, planMajorName, remark } = row
|
const { planMajorId, planMajorName, remark } = row
|
||||||
addAndEditForm.value = {
|
editId.value = planMajorId
|
||||||
planMajorId,
|
|
||||||
planMajorName,
|
|
||||||
remark,
|
|
||||||
}
|
|
||||||
editId.value = row.planMajorId
|
|
||||||
dialogConfig.outerTitle = '编辑计划类别'
|
dialogConfig.outerTitle = '编辑计划类别'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 使用 nextTick 确保在弹框渲染、表单组件挂载后再赋值
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditForm.value.planMajorName = planMajorName
|
||||||
|
addAndEditForm.value.remark = remark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -125,7 +129,14 @@ const actionColumns = [
|
||||||
// 新增
|
// 新增
|
||||||
const onHandleAdd = () => {
|
const onHandleAdd = () => {
|
||||||
editId.value = null
|
editId.value = null
|
||||||
|
dialogConfig.outerTitle = '新建计划类别'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 重置表单数据
|
||||||
|
addAndEditForm.value = getInitFormData()
|
||||||
|
// 清除之前的校验信息
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditFormRef.value?.clearValidate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消
|
// 取消
|
||||||
|
|
@ -136,31 +147,29 @@ const onHandleCancel = () => {
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
const onHandleSave = async () => {
|
const onHandleSave = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
try {
|
await addAndEditFormRef.value.validate()
|
||||||
addAndEditFormRef.value.validate(async (valid) => {
|
const API = editId.value ? updatePlanCategoryAPI : addPlanCategoryAPI
|
||||||
if (valid) {
|
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
||||||
const API = editId.value ? updatePlanCategoryAPI : addPlanCategoryAPI
|
editId.value ? (params.planMajorId = editId.value) : null
|
||||||
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
|
||||||
editId.value ? (params.planMajorId = editId.value) : null
|
|
||||||
|
|
||||||
const result = await API(params)
|
const result = await API(params)
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
||||||
addAndEditFormRef.value.resetFields() // 重置表单
|
addAndEditFormRef.value.resetFields() // 重置表单
|
||||||
dialogConfig.outerVisible = false
|
dialogConfig.outerVisible = false
|
||||||
comTableRef.value?.refresh() // 刷新表格
|
comTableRef.value?.refresh() // 刷新表格
|
||||||
}
|
|
||||||
resolve(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
|
console.error('表单校验失败或请求错误:', error)
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseDialogOuter = (visible) => {
|
const onCloseDialogOuter = (visible) => {
|
||||||
dialogConfig.outerVisible = visible
|
dialogConfig.outerVisible = visible
|
||||||
|
if (!visible) {
|
||||||
|
addAndEditFormRef.value?.resetFields()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="Position">
|
<script setup name="Position">
|
||||||
import { ref } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import {
|
import {
|
||||||
listPlanProfessionalAPI,
|
listPlanProfessionalAPI,
|
||||||
addPlanProfessionalAPI,
|
addPlanProfessionalAPI,
|
||||||
|
|
@ -77,12 +77,16 @@ const { proxy } = getCurrentInstance()
|
||||||
const addAndEditFormRef = ref(null)
|
const addAndEditFormRef = ref(null)
|
||||||
const comTableRef = ref(null)
|
const comTableRef = ref(null)
|
||||||
const editId = ref(null)
|
const editId = ref(null)
|
||||||
const addAndEditForm = ref({
|
|
||||||
|
// 定义初始表单数据函数
|
||||||
|
const getInitFormData = () => ({
|
||||||
planMajorName: '',
|
planMajorName: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
category: 0,
|
category: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const addAndEditForm = ref(getInitFormData())
|
||||||
|
|
||||||
const addAndEditRules = ref({
|
const addAndEditRules = ref({
|
||||||
planMajorName: [{ required: true, message: '请输入计划专业名称', trigger: 'blur' }],
|
planMajorName: [{ required: true, message: '请输入计划专业名称', trigger: 'blur' }],
|
||||||
})
|
})
|
||||||
|
|
@ -94,14 +98,14 @@ const actionColumns = [
|
||||||
link: true,
|
link: true,
|
||||||
handler: (row) => {
|
handler: (row) => {
|
||||||
const { planMajorId, planMajorName, remark } = row
|
const { planMajorId, planMajorName, remark } = row
|
||||||
addAndEditForm.value = {
|
editId.value = planMajorId
|
||||||
planMajorId,
|
|
||||||
planMajorName,
|
|
||||||
remark,
|
|
||||||
}
|
|
||||||
editId.value = row.planMajorId
|
|
||||||
dialogConfig.outerTitle = '编辑计划专业'
|
dialogConfig.outerTitle = '编辑计划专业'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 使用 nextTick 确保在弹框渲染、表单组件挂载后再赋值
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditForm.value.planMajorName = planMajorName
|
||||||
|
addAndEditForm.value.remark = remark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -125,7 +129,14 @@ const actionColumns = [
|
||||||
// 新增
|
// 新增
|
||||||
const onHandleAdd = () => {
|
const onHandleAdd = () => {
|
||||||
editId.value = null
|
editId.value = null
|
||||||
|
dialogConfig.outerTitle = '新建计划专业'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 重置表单数据
|
||||||
|
addAndEditForm.value = getInitFormData()
|
||||||
|
// 清除之前的校验信息
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditFormRef.value?.clearValidate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消
|
// 取消
|
||||||
|
|
@ -136,31 +147,29 @@ const onHandleCancel = () => {
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
const onHandleSave = async () => {
|
const onHandleSave = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
try {
|
await addAndEditFormRef.value.validate()
|
||||||
addAndEditFormRef.value.validate(async (valid) => {
|
const API = editId.value ? updatePlanProfessionalAPI : addPlanProfessionalAPI
|
||||||
if (valid) {
|
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
||||||
const API = editId.value ? updatePlanProfessionalAPI : addPlanProfessionalAPI
|
editId.value ? (params.planMajorId = editId.value) : null
|
||||||
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
|
||||||
editId.value ? (params.planMajorId = editId.value) : null
|
|
||||||
|
|
||||||
const result = await API(params)
|
const result = await API(params)
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
||||||
addAndEditFormRef.value.resetFields() // 重置表单
|
addAndEditFormRef.value.resetFields() // 重置表单
|
||||||
dialogConfig.outerVisible = false
|
dialogConfig.outerVisible = false
|
||||||
comTableRef.value?.refresh() // 刷新表格
|
comTableRef.value?.refresh() // 刷新表格
|
||||||
}
|
|
||||||
resolve(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
|
console.error('表单校验失败或请求错误:', error)
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseDialogOuter = (visible) => {
|
const onCloseDialogOuter = (visible) => {
|
||||||
dialogConfig.outerVisible = visible
|
dialogConfig.outerVisible = visible
|
||||||
|
if (!visible) {
|
||||||
|
addAndEditFormRef.value?.resetFields()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="Position">
|
<script setup name="Position">
|
||||||
import { ref } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import {
|
import {
|
||||||
listPositionAPI,
|
listPositionAPI,
|
||||||
addPositionAPI,
|
addPositionAPI,
|
||||||
|
|
@ -77,12 +77,16 @@ const { proxy } = getCurrentInstance()
|
||||||
const addAndEditFormRef = ref(null)
|
const addAndEditFormRef = ref(null)
|
||||||
const comTableRef = ref(null)
|
const comTableRef = ref(null)
|
||||||
const editId = ref(null)
|
const editId = ref(null)
|
||||||
const addAndEditForm = ref({
|
|
||||||
|
// 定义初始表单数据函数
|
||||||
|
const getInitFormData = () => ({
|
||||||
personnelClassificationName: '',
|
personnelClassificationName: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
category: 2,
|
category: 2,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const addAndEditForm = ref(getInitFormData())
|
||||||
|
|
||||||
const addAndEditRules = ref({
|
const addAndEditRules = ref({
|
||||||
personnelClassificationName: [{ required: true, message: '请输入岗位名称', trigger: 'blur' }],
|
personnelClassificationName: [{ required: true, message: '请输入岗位名称', trigger: 'blur' }],
|
||||||
})
|
})
|
||||||
|
|
@ -94,14 +98,14 @@ const actionColumns = [
|
||||||
link: true,
|
link: true,
|
||||||
handler: (row) => {
|
handler: (row) => {
|
||||||
const { personnelClassificationId, personnelClassificationName, remark } = row
|
const { personnelClassificationId, personnelClassificationName, remark } = row
|
||||||
addAndEditForm.value = {
|
editId.value = personnelClassificationId
|
||||||
personnelClassificationId,
|
|
||||||
personnelClassificationName,
|
|
||||||
remark,
|
|
||||||
}
|
|
||||||
editId.value = row.personnelClassificationId
|
|
||||||
dialogConfig.outerTitle = '编辑岗位'
|
dialogConfig.outerTitle = '编辑岗位'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 使用 nextTick 确保在弹框渲染、表单组件挂载后再赋值
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditForm.value.personnelClassificationName = personnelClassificationName
|
||||||
|
addAndEditForm.value.remark = remark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -125,7 +129,14 @@ const actionColumns = [
|
||||||
// 新增
|
// 新增
|
||||||
const onHandleAdd = () => {
|
const onHandleAdd = () => {
|
||||||
editId.value = null
|
editId.value = null
|
||||||
|
dialogConfig.outerTitle = '新建岗位'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 重置表单数据
|
||||||
|
addAndEditForm.value = getInitFormData()
|
||||||
|
// 清除之前的校验信息
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditFormRef.value?.clearValidate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消
|
// 取消
|
||||||
|
|
@ -136,31 +147,29 @@ const onHandleCancel = () => {
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
const onHandleSave = async () => {
|
const onHandleSave = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
try {
|
await addAndEditFormRef.value.validate()
|
||||||
addAndEditFormRef.value.validate(async (valid) => {
|
const API = editId.value ? updatePositionAPI : addPositionAPI
|
||||||
if (valid) {
|
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
||||||
const API = editId.value ? updatePositionAPI : addPositionAPI
|
editId.value ? (params.personnelClassificationId = editId.value) : null
|
||||||
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
|
||||||
editId.value ? (params.personnelClassificationId = editId.value) : null
|
|
||||||
|
|
||||||
const result = await API(params)
|
const result = await API(params)
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
||||||
addAndEditFormRef.value.resetFields() // 重置表单
|
addAndEditFormRef.value.resetFields() // 重置表单
|
||||||
dialogConfig.outerVisible = false
|
dialogConfig.outerVisible = false
|
||||||
comTableRef.value?.refresh() // 刷新表格
|
comTableRef.value?.refresh() // 刷新表格
|
||||||
}
|
|
||||||
resolve(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
|
console.error('表单校验失败或请求错误:', error)
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseDialogOuter = (visible) => {
|
const onCloseDialogOuter = (visible) => {
|
||||||
dialogConfig.outerVisible = visible
|
dialogConfig.outerVisible = visible
|
||||||
|
if (!visible) {
|
||||||
|
addAndEditFormRef.value?.resetFields()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="projectDept">
|
<script setup name="projectDept">
|
||||||
import { ref } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import {
|
import {
|
||||||
listProjectDeptAPI,
|
listProjectDeptAPI,
|
||||||
addProjectDeptAPI,
|
addProjectDeptAPI,
|
||||||
|
|
@ -77,12 +77,16 @@ const { proxy } = getCurrentInstance()
|
||||||
const addAndEditFormRef = ref(null)
|
const addAndEditFormRef = ref(null)
|
||||||
const comTableRef = ref(null)
|
const comTableRef = ref(null)
|
||||||
const editId = ref(null)
|
const editId = ref(null)
|
||||||
const addAndEditForm = ref({
|
|
||||||
|
// 定义初始表单数据函数
|
||||||
|
const getInitFormData = () => ({
|
||||||
inspectionStationName: '',
|
inspectionStationName: '',
|
||||||
remark: '',
|
remark: '',
|
||||||
category: 1,
|
category: 1,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const addAndEditForm = ref(getInitFormData())
|
||||||
|
|
||||||
const addAndEditRules = ref({
|
const addAndEditRules = ref({
|
||||||
inspectionStationName: [{ required: true, message: '请输入项目部名称', trigger: 'blur' }],
|
inspectionStationName: [{ required: true, message: '请输入项目部名称', trigger: 'blur' }],
|
||||||
})
|
})
|
||||||
|
|
@ -94,14 +98,14 @@ const actionColumns = [
|
||||||
link: true,
|
link: true,
|
||||||
handler: (row) => {
|
handler: (row) => {
|
||||||
const { inspectionStationId, inspectionStationName, remark } = row
|
const { inspectionStationId, inspectionStationName, remark } = row
|
||||||
addAndEditForm.value = {
|
editId.value = inspectionStationId
|
||||||
inspectionStationId,
|
|
||||||
inspectionStationName,
|
|
||||||
remark,
|
|
||||||
}
|
|
||||||
editId.value = row.inspectionStationId
|
|
||||||
dialogConfig.outerTitle = '编辑项目部'
|
dialogConfig.outerTitle = '编辑项目部'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 使用 nextTick 确保在弹框渲染、表单组件挂载后再赋值
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditForm.value.inspectionStationName = inspectionStationName
|
||||||
|
addAndEditForm.value.remark = remark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -125,7 +129,14 @@ const actionColumns = [
|
||||||
// 新增
|
// 新增
|
||||||
const onHandleAdd = () => {
|
const onHandleAdd = () => {
|
||||||
editId.value = null
|
editId.value = null
|
||||||
|
dialogConfig.outerTitle = '新建项目部'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 重置表单数据
|
||||||
|
addAndEditForm.value = getInitFormData()
|
||||||
|
// 清除之前的校验信息
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditFormRef.value?.clearValidate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消
|
// 取消
|
||||||
|
|
@ -136,31 +147,29 @@ const onHandleCancel = () => {
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
const onHandleSave = async () => {
|
const onHandleSave = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
try {
|
await addAndEditFormRef.value.validate()
|
||||||
addAndEditFormRef.value.validate(async (valid) => {
|
const API = editId.value ? updateProjectDeptAPI : addProjectDeptAPI
|
||||||
if (valid) {
|
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
||||||
const API = editId.value ? updateProjectDeptAPI : addProjectDeptAPI
|
editId.value ? (params.inspectionStationId = editId.value) : null
|
||||||
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
|
||||||
editId.value ? (params.inspectionStationId = editId.value) : null
|
|
||||||
|
|
||||||
const result = await API(params)
|
const result = await API(params)
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
||||||
addAndEditFormRef.value.resetFields() // 重置表单
|
addAndEditFormRef.value.resetFields() // 重置表单
|
||||||
dialogConfig.outerVisible = false
|
dialogConfig.outerVisible = false
|
||||||
comTableRef.value?.refresh() // 刷新表格
|
comTableRef.value?.refresh() // 刷新表格
|
||||||
}
|
|
||||||
resolve(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
|
console.error('表单校验失败或请求错误:', error)
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseDialogOuter = (visible) => {
|
const onCloseDialogOuter = (visible) => {
|
||||||
dialogConfig.outerVisible = visible
|
dialogConfig.outerVisible = visible
|
||||||
|
if (!visible) {
|
||||||
|
addAndEditFormRef.value?.resetFields()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup name="Position">
|
<script setup name="Position">
|
||||||
import { ref } from 'vue'
|
import { ref, nextTick } from 'vue'
|
||||||
import {
|
import {
|
||||||
listWorkloadCategoryAPI,
|
listWorkloadCategoryAPI,
|
||||||
addWorkloadCategoryAPI,
|
addWorkloadCategoryAPI,
|
||||||
|
|
@ -95,12 +95,16 @@ const { proxy } = getCurrentInstance()
|
||||||
const addAndEditFormRef = ref(null)
|
const addAndEditFormRef = ref(null)
|
||||||
const comTableRef = ref(null)
|
const comTableRef = ref(null)
|
||||||
const editId = ref(null)
|
const editId = ref(null)
|
||||||
const addAndEditForm = ref({
|
|
||||||
|
// 定义初始表单数据函数
|
||||||
|
const getInitFormData = () => ({
|
||||||
workloadCategoryName: '',
|
workloadCategoryName: '',
|
||||||
unitPrice: 0.1,
|
unitPrice: 0.1,
|
||||||
remark: '',
|
remark: '',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const addAndEditForm = ref(getInitFormData())
|
||||||
|
|
||||||
const addAndEditRules = ref({
|
const addAndEditRules = ref({
|
||||||
workloadCategoryName: [{ required: true, message: '请输入工作量类别名称', trigger: 'blur' }],
|
workloadCategoryName: [{ required: true, message: '请输入工作量类别名称', trigger: 'blur' }],
|
||||||
unitPrice: [{ required: true, message: '请输入单价', trigger: 'blur' }],
|
unitPrice: [{ required: true, message: '请输入单价', trigger: 'blur' }],
|
||||||
|
|
@ -113,15 +117,15 @@ const actionColumns = [
|
||||||
link: true,
|
link: true,
|
||||||
handler: (row) => {
|
handler: (row) => {
|
||||||
const { workloadCategoryId, workloadCategoryName, remark, unitPrice } = row
|
const { workloadCategoryId, workloadCategoryName, remark, unitPrice } = row
|
||||||
addAndEditForm.value = {
|
editId.value = workloadCategoryId
|
||||||
workloadCategoryId,
|
|
||||||
workloadCategoryName,
|
|
||||||
unitPrice: fenToYuan(unitPrice), // 分转元回显
|
|
||||||
remark,
|
|
||||||
}
|
|
||||||
editId.value = row.workloadCategoryId
|
|
||||||
dialogConfig.outerTitle = '编辑工作量类别'
|
dialogConfig.outerTitle = '编辑工作量类别'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 使用 nextTick 确保在弹框渲染、表单组件挂载后再赋值
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditForm.value.workloadCategoryName = workloadCategoryName
|
||||||
|
addAndEditForm.value.unitPrice = fenToYuan(unitPrice) // 分转元回显
|
||||||
|
addAndEditForm.value.remark = remark
|
||||||
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -145,7 +149,14 @@ const actionColumns = [
|
||||||
// 新增
|
// 新增
|
||||||
const onHandleAdd = () => {
|
const onHandleAdd = () => {
|
||||||
editId.value = null
|
editId.value = null
|
||||||
|
dialogConfig.outerTitle = '新建工作量类别'
|
||||||
dialogConfig.outerVisible = true
|
dialogConfig.outerVisible = true
|
||||||
|
// 重置表单数据
|
||||||
|
addAndEditForm.value = getInitFormData()
|
||||||
|
// 清除之前的校验信息
|
||||||
|
nextTick(() => {
|
||||||
|
addAndEditFormRef.value?.clearValidate()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消
|
// 取消
|
||||||
|
|
@ -156,32 +167,30 @@ const onHandleCancel = () => {
|
||||||
|
|
||||||
// 保存
|
// 保存
|
||||||
const onHandleSave = async () => {
|
const onHandleSave = async () => {
|
||||||
return new Promise((resolve, reject) => {
|
try {
|
||||||
try {
|
await addAndEditFormRef.value.validate()
|
||||||
addAndEditFormRef.value.validate(async (valid) => {
|
const API = editId.value ? updateWorkloadCategoryAPI : addWorkloadCategoryAPI
|
||||||
if (valid) {
|
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
||||||
const API = editId.value ? updateWorkloadCategoryAPI : addWorkloadCategoryAPI
|
params.unitPrice = yuanToFen(params.unitPrice) // 元转分提交
|
||||||
const params = JSON.parse(JSON.stringify(addAndEditForm.value))
|
editId.value ? (params.workloadCategoryId = editId.value) : null
|
||||||
params.unitPrice = yuanToFen(params.unitPrice) // 元转分提交
|
|
||||||
editId.value ? (params.workloadCategoryId = editId.value) : null
|
|
||||||
|
|
||||||
const result = await API(params)
|
const result = await API(params)
|
||||||
if (result.code === 200) {
|
if (result.code === 200) {
|
||||||
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
proxy.$modal.msgSuccess(editId.value ? '编辑成功' : '新增成功')
|
||||||
addAndEditFormRef.value.resetFields() // 重置表单
|
addAndEditFormRef.value.resetFields() // 重置表单
|
||||||
dialogConfig.outerVisible = false
|
dialogConfig.outerVisible = false
|
||||||
comTableRef.value?.refresh() // 刷新表格
|
comTableRef.value?.refresh() // 刷新表格
|
||||||
}
|
|
||||||
resolve(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} catch (error) {
|
|
||||||
reject()
|
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
|
console.error('表单校验失败或请求错误:', error)
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCloseDialogOuter = (visible) => {
|
const onCloseDialogOuter = (visible) => {
|
||||||
dialogConfig.outerVisible = visible
|
dialogConfig.outerVisible = visible
|
||||||
|
if (!visible) {
|
||||||
|
addAndEditFormRef.value?.resetFields()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue