diff --git a/src/views/measure/measureDept/components/addDialog.vue b/src/views/measure/measureDept/components/addDialog.vue index 9f15066..b9557f5 100644 --- a/src/views/measure/measureDept/components/addDialog.vue +++ b/src/views/measure/measureDept/components/addDialog.vue @@ -452,6 +452,7 @@ else if (title.value.split('-')[1] === '工程组') { changeList.value = changeList_gcz.value current.value = changeList_gcz.value[0].name + // 获取所属部门 } } onMounted(() => { @@ -482,6 +483,16 @@ + + + + + + + + + + diff --git a/src/views/measure/measureDept/components/addDialog.vue b/src/views/measure/measureDept/components/addDialog.vue index 9f15066..b9557f5 100644 --- a/src/views/measure/measureDept/components/addDialog.vue +++ b/src/views/measure/measureDept/components/addDialog.vue @@ -452,6 +452,7 @@ else if (title.value.split('-')[1] === '工程组') { changeList.value = changeList_gcz.value current.value = changeList_gcz.value[0].name + // 获取所属部门 } } onMounted(() => { @@ -482,6 +483,16 @@ + + + + + + + + + + diff --git a/src/views/measure/person/components/addPerson.vue b/src/views/measure/person/components/addPerson.vue index 1e4373c..7850502 100644 --- a/src/views/measure/person/components/addPerson.vue +++ b/src/views/measure/person/components/addPerson.vue @@ -16,7 +16,6 @@ import { getStaffAdd, getStaffDetail, getStaffupdate } from '@/api/measure/person' import { getPhotoUrl } from '@/api/system/tool' // import showPhoto from '@/views/system/tool/showPhoto.vue' -const emits = defineEmits(['resetData']) const $route = useRoute() const $router = useRouter() const ruleFormRef = ref() // from组件 @@ -192,110 +191,235 @@ } return true } +// 证书对象 +const addObj = { + 证书基本信息: { + certificateNo: '', // 证书号 + certificateName: '', // 证书名称 + certificateCompany: '', // 发证单位 + certificateDate: '', // 发证日期 + validDate: '', // 有效日期 + editable: true, // 编辑模式 + checked: -1, + }, + 计量工作培训记录: { + a1: '', + a2: '', + a3: '', + a4: '', + a5: '', + a6: '', + editable: true, // 编辑模式 + checked: -1, + }, + 业务记录: { + b1: '', + b2: '', + b3: '', + b4: '', + b5: '', + b6: '', + b7: '', + editable: true, // 编辑模式 + checked: -1, + }, +} const changeList = ref([ { name: '证书基本信息', data: [] as any[], column: [ { - label: '发证单位', - data: 'certificateCompany', + text: '发证单位', + value: 'certificateCompany', id: 'zs01', + required: true, + isDate: false, // 是否日期 }, { - label: '证书号', - data: 'certificateNo', + text: '证书号', + value: 'certificateNo', id: 'zs02', + required: true, + isDate: false, // 是否日期 }, { - label: '证书名称', - data: 'certificateName', + text: '证书名称', + value: 'certificateName', id: 'zs03', + required: true, + isDate: false, // 是否日期 }, { - label: '发证日期', - data: 'certificateDate', + text: '发证日期', + value: 'certificateDate', id: 'zs04', + required: true, + isDate: true, // 是否日期 }, { - label: '有效日期', - data: 'validDate', + text: '有效日期', + value: 'validDate', id: 'zs05', + required: true, + isDate: true, // 是否日期 }, ], }, { name: '计量工作培训记录', - data: [], - column: [], + data: [] as any[], + column: [ + { + text: '培训时间', + value: 'a1', + id: 'zs01', + required: true, + isDate: true, // 是否日期 + }, + { + text: '培训班名称', + value: 'a2', + id: 'zs02', + required: true, + isDate: false, // 是否日期 + }, + { + text: '类别', + value: 'a3', + id: 'zs03', + required: true, + isSelect: true, // 是否下拉框 + }, + { + text: '计划编号', + value: 'a4', + id: 'zs04', + required: true, + isDate: false, // 是否日期 + }, + { + text: '培训对象', + value: 'a5', + id: 'zs05', + required: true, + isDate: false, // 是否日期 + }, + { + text: '培训结果', + value: 'a6', + id: 'zs05', + required: true, + isDate: false, // 是否日期 + }, + ], }, { name: '业务记录', - data: [], - column: [], + data: [] as any[], + column: [ + { + text: '样品编号', + value: 'b1', + id: 'zs01', + required: true, + isDate: false, // 是否日期 + }, + { + text: '样品名称', + value: 'b2', + id: 'zs02', + required: true, + isDate: false, // 是否日期 + }, + { + text: '委托书编号', + value: 'b3', + id: 'zs03', + required: true, + isDate: false, // 是否日期 + }, + { + text: '合同编号', + value: 'b4', + id: 'zs04', + required: true, + isDate: false, // 是否日期 + }, + { + text: '检定时间', + value: 'b5', + id: 'zs05', + required: true, + isDate: true, // 是否日期 + }, + { + text: '检定结果', + value: 'b6', + id: 'zs05', + required: true, + isDate: false, // 是否日期 + }, + { + text: '业务额', + value: 'b7', + id: 'zs05', + required: true, + isDate: false, // 是否日期 + }, + ], }, ]) const current = ref('证书基本信息') const currentShow = computed(() => { return changeList.value.filter(item => item.name === current.value)[0] }) -const certificateRef = ref() // 添加证书信息弹窗 -const currenSelect = ref(-1) // 当前选中行 + +// 检查证书列表 +function checkPersonList() { + for (let index = 0; index < currentShow.value.data.length; index++) { + const item = currentShow.value.data[index] + for (const prop of currentShow.value.column) { + // 检查必填 + if (prop.required && !item[prop.value]) { + ElMessage.warning(`请先完善第${index + 1}行中${prop.text}`) + return false + } + } + } + return true +} +// 将证书列表置为不可编辑状态 +function setAllRowReadable() { + for (const item of currentShow.value.data) { + item.editable = false + } +} +// 双击行显示输入框 +const dblclickRow = (row) => { + setAllRowReadable() + row.editable = true +} +const SelectionList = ref() +// 表格选中 +const handleSelectionChange = (e) => { + SelectionList.value = e +} // 添加行 const addRow = () => { - certificateRef.value.initDialog({ title: '添加' }) -} -// 编辑行 -const editRow = () => { - if (currenSelect.value >= 0) { - const row: object = changeList.value[0].data.filter((item, index) => index === currenSelect.value)[0] - certificateRef.value.initDialog({ ...row, title: '编辑' }) - } - else { - ElMessage.warning('请先选择需要编辑的数据') - } -} -// 证书信息行内添加数据 -const addRowcertificate = (row: any, _: string) => { - if (_ === 'update') { - changeList.value[0].data = changeList.value[0].data.map((item, index) => { - if (index === currenSelect.value) { - return { - ...item, - ...row, - } - } - else { - return item - } + // certificateRef.value.initDialog({ title: '添加' }) + if (checkPersonList()) { + setAllRowReadable() + currentShow.value.data.push({ + ...addObj[current.value], }) } - else { - changeList.value[0].data.push(row) - } } - // 删除行 const removeRow = () => { - console.log(currenSelect.value) - if (currenSelect.value >= 0) { - ElMessageBox.confirm( - '确认删除选中的数据吗?', - '提示', - { - confirmButtonText: '确认', - cancelButtonText: '取消', - type: 'warning', - }, - ).then(() => { - changeList.value[0].data = changeList.value[0].data.filter((item, index) => index !== currenSelect.value) - currenSelect.value = -1 - ElMessage.success('删除成功') - }) - } - else { - ElMessage.warning('请先选择需要删除的数据') - } + currentShow.value.data = currentShow.value.data.filter((item) => { + return !SelectionList.value.includes(item) + }) } // 提交 const submitForm = async (formEl: FormInstance | undefined) => { @@ -311,6 +435,7 @@ type: 'warning', }, ).then(() => { + changeList.value[0].data = changeList.value[0].data.filter(item => item.certificateName !== '') if (changeList.value[0].data.length) { for (const key in ruleForm.value) { if (ruleForm.value[key] === '') { @@ -502,7 +627,14 @@ - + + - - + + + + + - - - - - - - + + + diff --git a/src/views/measure/measureDept/components/addDialog.vue b/src/views/measure/measureDept/components/addDialog.vue index 9f15066..b9557f5 100644 --- a/src/views/measure/measureDept/components/addDialog.vue +++ b/src/views/measure/measureDept/components/addDialog.vue @@ -452,6 +452,7 @@ else if (title.value.split('-')[1] === '工程组') { changeList.value = changeList_gcz.value current.value = changeList_gcz.value[0].name + // 获取所属部门 } } onMounted(() => { @@ -482,6 +483,16 @@ + + + + + + + + + + diff --git a/src/views/measure/person/components/addPerson.vue b/src/views/measure/person/components/addPerson.vue index 1e4373c..7850502 100644 --- a/src/views/measure/person/components/addPerson.vue +++ b/src/views/measure/person/components/addPerson.vue @@ -16,7 +16,6 @@ import { getStaffAdd, getStaffDetail, getStaffupdate } from '@/api/measure/person' import { getPhotoUrl } from '@/api/system/tool' // import showPhoto from '@/views/system/tool/showPhoto.vue' -const emits = defineEmits(['resetData']) const $route = useRoute() const $router = useRouter() const ruleFormRef = ref() // from组件 @@ -192,110 +191,235 @@ } return true } +// 证书对象 +const addObj = { + 证书基本信息: { + certificateNo: '', // 证书号 + certificateName: '', // 证书名称 + certificateCompany: '', // 发证单位 + certificateDate: '', // 发证日期 + validDate: '', // 有效日期 + editable: true, // 编辑模式 + checked: -1, + }, + 计量工作培训记录: { + a1: '', + a2: '', + a3: '', + a4: '', + a5: '', + a6: '', + editable: true, // 编辑模式 + checked: -1, + }, + 业务记录: { + b1: '', + b2: '', + b3: '', + b4: '', + b5: '', + b6: '', + b7: '', + editable: true, // 编辑模式 + checked: -1, + }, +} const changeList = ref([ { name: '证书基本信息', data: [] as any[], column: [ { - label: '发证单位', - data: 'certificateCompany', + text: '发证单位', + value: 'certificateCompany', id: 'zs01', + required: true, + isDate: false, // 是否日期 }, { - label: '证书号', - data: 'certificateNo', + text: '证书号', + value: 'certificateNo', id: 'zs02', + required: true, + isDate: false, // 是否日期 }, { - label: '证书名称', - data: 'certificateName', + text: '证书名称', + value: 'certificateName', id: 'zs03', + required: true, + isDate: false, // 是否日期 }, { - label: '发证日期', - data: 'certificateDate', + text: '发证日期', + value: 'certificateDate', id: 'zs04', + required: true, + isDate: true, // 是否日期 }, { - label: '有效日期', - data: 'validDate', + text: '有效日期', + value: 'validDate', id: 'zs05', + required: true, + isDate: true, // 是否日期 }, ], }, { name: '计量工作培训记录', - data: [], - column: [], + data: [] as any[], + column: [ + { + text: '培训时间', + value: 'a1', + id: 'zs01', + required: true, + isDate: true, // 是否日期 + }, + { + text: '培训班名称', + value: 'a2', + id: 'zs02', + required: true, + isDate: false, // 是否日期 + }, + { + text: '类别', + value: 'a3', + id: 'zs03', + required: true, + isSelect: true, // 是否下拉框 + }, + { + text: '计划编号', + value: 'a4', + id: 'zs04', + required: true, + isDate: false, // 是否日期 + }, + { + text: '培训对象', + value: 'a5', + id: 'zs05', + required: true, + isDate: false, // 是否日期 + }, + { + text: '培训结果', + value: 'a6', + id: 'zs05', + required: true, + isDate: false, // 是否日期 + }, + ], }, { name: '业务记录', - data: [], - column: [], + data: [] as any[], + column: [ + { + text: '样品编号', + value: 'b1', + id: 'zs01', + required: true, + isDate: false, // 是否日期 + }, + { + text: '样品名称', + value: 'b2', + id: 'zs02', + required: true, + isDate: false, // 是否日期 + }, + { + text: '委托书编号', + value: 'b3', + id: 'zs03', + required: true, + isDate: false, // 是否日期 + }, + { + text: '合同编号', + value: 'b4', + id: 'zs04', + required: true, + isDate: false, // 是否日期 + }, + { + text: '检定时间', + value: 'b5', + id: 'zs05', + required: true, + isDate: true, // 是否日期 + }, + { + text: '检定结果', + value: 'b6', + id: 'zs05', + required: true, + isDate: false, // 是否日期 + }, + { + text: '业务额', + value: 'b7', + id: 'zs05', + required: true, + isDate: false, // 是否日期 + }, + ], }, ]) const current = ref('证书基本信息') const currentShow = computed(() => { return changeList.value.filter(item => item.name === current.value)[0] }) -const certificateRef = ref() // 添加证书信息弹窗 -const currenSelect = ref(-1) // 当前选中行 + +// 检查证书列表 +function checkPersonList() { + for (let index = 0; index < currentShow.value.data.length; index++) { + const item = currentShow.value.data[index] + for (const prop of currentShow.value.column) { + // 检查必填 + if (prop.required && !item[prop.value]) { + ElMessage.warning(`请先完善第${index + 1}行中${prop.text}`) + return false + } + } + } + return true +} +// 将证书列表置为不可编辑状态 +function setAllRowReadable() { + for (const item of currentShow.value.data) { + item.editable = false + } +} +// 双击行显示输入框 +const dblclickRow = (row) => { + setAllRowReadable() + row.editable = true +} +const SelectionList = ref() +// 表格选中 +const handleSelectionChange = (e) => { + SelectionList.value = e +} // 添加行 const addRow = () => { - certificateRef.value.initDialog({ title: '添加' }) -} -// 编辑行 -const editRow = () => { - if (currenSelect.value >= 0) { - const row: object = changeList.value[0].data.filter((item, index) => index === currenSelect.value)[0] - certificateRef.value.initDialog({ ...row, title: '编辑' }) - } - else { - ElMessage.warning('请先选择需要编辑的数据') - } -} -// 证书信息行内添加数据 -const addRowcertificate = (row: any, _: string) => { - if (_ === 'update') { - changeList.value[0].data = changeList.value[0].data.map((item, index) => { - if (index === currenSelect.value) { - return { - ...item, - ...row, - } - } - else { - return item - } + // certificateRef.value.initDialog({ title: '添加' }) + if (checkPersonList()) { + setAllRowReadable() + currentShow.value.data.push({ + ...addObj[current.value], }) } - else { - changeList.value[0].data.push(row) - } } - // 删除行 const removeRow = () => { - console.log(currenSelect.value) - if (currenSelect.value >= 0) { - ElMessageBox.confirm( - '确认删除选中的数据吗?', - '提示', - { - confirmButtonText: '确认', - cancelButtonText: '取消', - type: 'warning', - }, - ).then(() => { - changeList.value[0].data = changeList.value[0].data.filter((item, index) => index !== currenSelect.value) - currenSelect.value = -1 - ElMessage.success('删除成功') - }) - } - else { - ElMessage.warning('请先选择需要删除的数据') - } + currentShow.value.data = currentShow.value.data.filter((item) => { + return !SelectionList.value.includes(item) + }) } // 提交 const submitForm = async (formEl: FormInstance | undefined) => { @@ -311,6 +435,7 @@ type: 'warning', }, ).then(() => { + changeList.value[0].data = changeList.value[0].data.filter(item => item.certificateName !== '') if (changeList.value[0].data.length) { for (const key in ruleForm.value) { if (ruleForm.value[key] === '') { @@ -502,7 +627,14 @@ - + + - - + + + + + - - - - - - - + + + diff --git a/src/views/measure/person/components/certificateAddDialog.vue b/src/views/measure/person/components/certificateAddDialog.vue index d0116f3..310d303 100644 --- a/src/views/measure/person/components/certificateAddDialog.vue +++ b/src/views/measure/person/components/certificateAddDialog.vue @@ -1,4 +1,4 @@ - +