Commit c7a5a78f0b30471c80bb5220a37ad23180f0c06e
1 parent
4927ce37
加入巡检工鞥你
Showing
14 changed files
with
1343 additions
and
1 deletions
src/api/inspection/inspectionItemManageApi.js
0 → 100644
| 1 | +import request from '@/utils/request' | |
| 2 | + | |
| 3 | +// 查询巡检项目列表 | |
| 4 | +export function listInspectionItem(params) { | |
| 5 | + return new Promise((resolve, reject) => { | |
| 6 | + request({ | |
| 7 | + url: '/inspectionItem.listInspectionItem', | |
| 8 | + method: 'get', | |
| 9 | + params | |
| 10 | + }).then(response => { | |
| 11 | + const res = response.data | |
| 12 | + if (res.code === 0) { | |
| 13 | + resolve(res) | |
| 14 | + } else { | |
| 15 | + reject(new Error(res.msg || '获取巡检项目列表失败')) | |
| 16 | + } | |
| 17 | + }).catch(error => { | |
| 18 | + reject(error) | |
| 19 | + }) | |
| 20 | + }) | |
| 21 | +} | |
| 22 | + | |
| 23 | +// 添加巡检项目 | |
| 24 | +export function saveInspectionItem(data) { | |
| 25 | + return new Promise((resolve, reject) => { | |
| 26 | + request({ | |
| 27 | + url: '/inspectionItem.saveInspectionItem', | |
| 28 | + method: 'post', | |
| 29 | + data | |
| 30 | + }).then(response => { | |
| 31 | + const res = response.data | |
| 32 | + if (res.code === 0) { | |
| 33 | + resolve(res) | |
| 34 | + } else { | |
| 35 | + reject(new Error(res.msg || '添加巡检项目失败')) | |
| 36 | + } | |
| 37 | + }).catch(error => { | |
| 38 | + reject(error) | |
| 39 | + }) | |
| 40 | + }) | |
| 41 | +} | |
| 42 | + | |
| 43 | +// 更新巡检项目 | |
| 44 | +export function updateInspectionItem(data) { | |
| 45 | + return new Promise((resolve, reject) => { | |
| 46 | + request({ | |
| 47 | + url: '/inspectionItem.updateInspectionItem', | |
| 48 | + method: 'post', | |
| 49 | + data | |
| 50 | + }).then(response => { | |
| 51 | + const res = response.data | |
| 52 | + if (res.code === 0) { | |
| 53 | + resolve(res) | |
| 54 | + } else { | |
| 55 | + reject(new Error(res.msg || '更新巡检项目失败')) | |
| 56 | + } | |
| 57 | + }).catch(error => { | |
| 58 | + reject(error) | |
| 59 | + }) | |
| 60 | + }) | |
| 61 | +} | |
| 62 | + | |
| 63 | +// 删除巡检项目 | |
| 64 | +export function deleteInspectionItem(data) { | |
| 65 | + return new Promise((resolve, reject) => { | |
| 66 | + request({ | |
| 67 | + url: '/inspectionItem.deleteInspectionItem', | |
| 68 | + method: 'post', | |
| 69 | + data | |
| 70 | + }).then(response => { | |
| 71 | + const res = response.data | |
| 72 | + if (res.code === 0) { | |
| 73 | + resolve(res) | |
| 74 | + } else { | |
| 75 | + reject(new Error(res.msg || '删除巡检项目失败')) | |
| 76 | + } | |
| 77 | + }).catch(error => { | |
| 78 | + reject(error) | |
| 79 | + }) | |
| 80 | + }) | |
| 81 | +} | |
| 0 | 82 | \ No newline at end of file | ... | ... |
src/api/inspection/inspectionItemTitleManageApi.js
0 → 100644
| 1 | +import request from '@/utils/request' | |
| 2 | +import { getCommunityId } from '@/api/community/communityApi' | |
| 3 | + | |
| 4 | +// 获取巡检题目列表 | |
| 5 | +export function listInspectionItemTitle(params) { | |
| 6 | + return new Promise((resolve, reject) => { | |
| 7 | + request({ | |
| 8 | + url: '/inspectionItemTitle.listInspectionItemTitle', | |
| 9 | + method: 'get', | |
| 10 | + params: { | |
| 11 | + ...params, | |
| 12 | + communityId: getCommunityId() | |
| 13 | + } | |
| 14 | + }).then(response => { | |
| 15 | + const res = response.data | |
| 16 | + if (res.code === 0) { | |
| 17 | + resolve({ | |
| 18 | + data: res.data, | |
| 19 | + total: res.records | |
| 20 | + }) | |
| 21 | + } else { | |
| 22 | + reject(new Error(res.msg || '获取巡检题目列表失败')) | |
| 23 | + } | |
| 24 | + }).catch(error => { | |
| 25 | + reject(error) | |
| 26 | + }) | |
| 27 | + }) | |
| 28 | +} | |
| 29 | + | |
| 30 | +// 添加巡检题目 | |
| 31 | +export function saveInspectionItemTitle(data) { | |
| 32 | + return new Promise((resolve, reject) => { | |
| 33 | + request({ | |
| 34 | + url: '/inspectionItemTitle.saveInspectionItemTitle', | |
| 35 | + method: 'post', | |
| 36 | + data | |
| 37 | + }).then(response => { | |
| 38 | + const res = response.data | |
| 39 | + if (res.code === 0) { | |
| 40 | + resolve(res) | |
| 41 | + } else { | |
| 42 | + reject(new Error(res.msg || '添加巡检题目失败')) | |
| 43 | + } | |
| 44 | + }).catch(error => { | |
| 45 | + reject(error) | |
| 46 | + }) | |
| 47 | + }) | |
| 48 | +} | |
| 49 | + | |
| 50 | +// 更新巡检题目 | |
| 51 | +export function updateInspectionItemTitle(data) { | |
| 52 | + return new Promise((resolve, reject) => { | |
| 53 | + request({ | |
| 54 | + url: '/inspectionItemTitle.updateInspectionItemTitle', | |
| 55 | + method: 'post', | |
| 56 | + data | |
| 57 | + }).then(response => { | |
| 58 | + const res = response.data | |
| 59 | + if (res.code === 0) { | |
| 60 | + resolve(res) | |
| 61 | + } else { | |
| 62 | + reject(new Error(res.msg || '更新巡检题目失败')) | |
| 63 | + } | |
| 64 | + }).catch(error => { | |
| 65 | + reject(error) | |
| 66 | + }) | |
| 67 | + }) | |
| 68 | +} | |
| 69 | + | |
| 70 | +// 删除巡检题目 | |
| 71 | +export function deleteInspectionItemTitle(data) { | |
| 72 | + return new Promise((resolve, reject) => { | |
| 73 | + request({ | |
| 74 | + url: '/inspectionItemTitle.deleteInspectionItemTitle', | |
| 75 | + method: 'post', | |
| 76 | + data | |
| 77 | + }).then(response => { | |
| 78 | + const res = response.data | |
| 79 | + if (res.code === 0) { | |
| 80 | + resolve(res) | |
| 81 | + } else { | |
| 82 | + reject(new Error(res.msg || '删除巡检题目失败')) | |
| 83 | + } | |
| 84 | + }).catch(error => { | |
| 85 | + reject(error) | |
| 86 | + }) | |
| 87 | + }) | |
| 88 | +} | |
| 0 | 89 | \ No newline at end of file | ... | ... |
src/components/inspection/AddInspectionItem.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <el-dialog | |
| 3 | + :title="$t('inspectionItemManage.addTitle')" | |
| 4 | + :visible.sync="visible" | |
| 5 | + width="50%" | |
| 6 | + @close="handleClose" | |
| 7 | + > | |
| 8 | + <el-form ref="form" :model="formData" :rules="rules" label-width="120px"> | |
| 9 | + <el-form-item :label="$t('inspectionItemManage.itemNameLabel')" prop="itemName"> | |
| 10 | + <el-input | |
| 11 | + v-model="formData.itemName" | |
| 12 | + :placeholder="$t('inspectionItemManage.requiredItem')" | |
| 13 | + /> | |
| 14 | + </el-form-item> | |
| 15 | + <el-form-item :label="$t('inspectionItemManage.remarkLabel')" prop="remark"> | |
| 16 | + <el-input | |
| 17 | + v-model="formData.remark" | |
| 18 | + type="textarea" | |
| 19 | + :rows="4" | |
| 20 | + :placeholder="$t('inspectionItemManage.requiredRemark')" | |
| 21 | + /> | |
| 22 | + </el-form-item> | |
| 23 | + </el-form> | |
| 24 | + | |
| 25 | + <span slot="footer" class="dialog-footer"> | |
| 26 | + <el-button @click="visible = false"> | |
| 27 | + {{ $t('inspectionItemManage.cancel') }} | |
| 28 | + </el-button> | |
| 29 | + <el-button type="primary" @click="handleSubmit" :loading="loading"> | |
| 30 | + {{ $t('inspectionItemManage.save') }} | |
| 31 | + </el-button> | |
| 32 | + </span> | |
| 33 | + </el-dialog> | |
| 34 | +</template> | |
| 35 | + | |
| 36 | +<script> | |
| 37 | +import { saveInspectionItem } from '@/api/inspection/inspectionItemManageApi' | |
| 38 | +import { getCommunityId } from '@/api/community/communityApi' | |
| 39 | + | |
| 40 | +export default { | |
| 41 | + name: 'AddInspectionItem', | |
| 42 | + data() { | |
| 43 | + return { | |
| 44 | + visible: false, | |
| 45 | + loading: false, | |
| 46 | + formData: { | |
| 47 | + itemName: '', | |
| 48 | + remark: '', | |
| 49 | + communityId: '' | |
| 50 | + }, | |
| 51 | + rules: { | |
| 52 | + itemName: [ | |
| 53 | + { required: true, message: this.$t('inspectionItemManage.requiredItem'), trigger: 'blur' }, | |
| 54 | + { max: 256, message: this.$t('inspectionItemManage.maxLength256'), trigger: 'blur' } | |
| 55 | + ], | |
| 56 | + remark: [ | |
| 57 | + { required: true, message: this.$t('inspectionItemManage.requiredRemark'), trigger: 'blur' }, | |
| 58 | + { max: 512, message: this.$t('inspectionItemManage.maxLength512'), trigger: 'blur' } | |
| 59 | + ] | |
| 60 | + } | |
| 61 | + } | |
| 62 | + }, | |
| 63 | + methods: { | |
| 64 | + open() { | |
| 65 | + this.visible = true | |
| 66 | + this.resetForm() | |
| 67 | + }, | |
| 68 | + resetForm() { | |
| 69 | + this.formData = { | |
| 70 | + itemName: '', | |
| 71 | + remark: '', | |
| 72 | + communityId: getCommunityId() | |
| 73 | + } | |
| 74 | + if (this.$refs.form) { | |
| 75 | + this.$refs.form.resetFields() | |
| 76 | + } | |
| 77 | + }, | |
| 78 | + handleClose() { | |
| 79 | + this.resetForm() | |
| 80 | + }, | |
| 81 | + async handleSubmit() { | |
| 82 | + this.$refs.form.validate(async valid => { | |
| 83 | + if (valid) { | |
| 84 | + this.loading = true | |
| 85 | + try { | |
| 86 | + await saveInspectionItem(this.formData) | |
| 87 | + this.$message.success(this.$t('inspectionItemManage.addSuccess')) | |
| 88 | + this.visible = false | |
| 89 | + this.$emit('success') | |
| 90 | + } catch (error) { | |
| 91 | + console.error('添加巡检项目失败:', error) | |
| 92 | + this.$message.error(error.message || this.$t('inspectionItemManage.addFailed')) | |
| 93 | + } finally { | |
| 94 | + this.loading = false | |
| 95 | + } | |
| 96 | + } | |
| 97 | + }) | |
| 98 | + } | |
| 99 | + } | |
| 100 | +} | |
| 101 | +</script> | |
| 0 | 102 | \ No newline at end of file | ... | ... |
src/components/inspection/DeleteInspectionItem.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <el-dialog | |
| 3 | + :title="$t('inspectionItemManage.confirmDelete')" | |
| 4 | + :visible.sync="visible" | |
| 5 | + width="30%" | |
| 6 | + > | |
| 7 | + <div class="text-center"> | |
| 8 | + <p>{{ $t('inspectionItemManage.confirmDeleteMsg') }}: {{ formData.itemName }}?</p> | |
| 9 | + </div> | |
| 10 | + <span slot="footer" class="dialog-footer"> | |
| 11 | + <el-button @click="visible = false"> | |
| 12 | + {{ $t('inspectionItemManage.cancelDelete') }} | |
| 13 | + </el-button> | |
| 14 | + <el-button type="primary" @click="handleSubmit" :loading="loading"> | |
| 15 | + {{ $t('inspectionItemManage.confirmDeleteBtn') }} | |
| 16 | + </el-button> | |
| 17 | + </span> | |
| 18 | + </el-dialog> | |
| 19 | +</template> | |
| 20 | + | |
| 21 | +<script> | |
| 22 | +import { deleteInspectionItem } from '@/api/inspection/inspectionItemManageApi' | |
| 23 | +import { getCommunityId } from '@/api/community/communityApi' | |
| 24 | + | |
| 25 | +export default { | |
| 26 | + name: 'DeleteInspectionItem', | |
| 27 | + data() { | |
| 28 | + return { | |
| 29 | + visible: false, | |
| 30 | + loading: false, | |
| 31 | + formData: { | |
| 32 | + itemId: '', | |
| 33 | + itemName: '', | |
| 34 | + communityId: '' | |
| 35 | + } | |
| 36 | + } | |
| 37 | + }, | |
| 38 | + methods: { | |
| 39 | + open(item) { | |
| 40 | + this.formData = { | |
| 41 | + itemId: item.itemId, | |
| 42 | + itemName: item.itemName, | |
| 43 | + communityId: getCommunityId() | |
| 44 | + } | |
| 45 | + this.visible = true | |
| 46 | + }, | |
| 47 | + async handleSubmit() { | |
| 48 | + this.loading = true | |
| 49 | + try { | |
| 50 | + await deleteInspectionItem(this.formData) | |
| 51 | + this.$message.success(this.$t('inspectionItemManage.deleteSuccess')) | |
| 52 | + this.visible = false | |
| 53 | + this.$emit('success') | |
| 54 | + } catch (error) { | |
| 55 | + console.error('删除巡检项目失败:', error) | |
| 56 | + this.$message.error(error.message || this.$t('inspectionItemManage.deleteFailed')) | |
| 57 | + } finally { | |
| 58 | + this.loading = false | |
| 59 | + } | |
| 60 | + } | |
| 61 | + } | |
| 62 | +} | |
| 63 | +</script> | |
| 0 | 64 | \ No newline at end of file | ... | ... |
src/components/inspection/EditInspectionItem.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <el-dialog | |
| 3 | + :title="$t('inspectionItemManage.editTitle')" | |
| 4 | + :visible.sync="visible" | |
| 5 | + width="50%" | |
| 6 | + @close="handleClose" | |
| 7 | + > | |
| 8 | + <el-form ref="form" :model="formData" :rules="rules" label-width="120px"> | |
| 9 | + <el-form-item :label="$t('inspectionItemManage.itemNameLabel')" prop="itemName"> | |
| 10 | + <el-input | |
| 11 | + v-model="formData.itemName" | |
| 12 | + :placeholder="$t('inspectionItemManage.requiredItem')" | |
| 13 | + /> | |
| 14 | + </el-form-item> | |
| 15 | + <el-form-item :label="$t('inspectionItemManage.remarkLabel')" prop="remark"> | |
| 16 | + <el-input | |
| 17 | + v-model="formData.remark" | |
| 18 | + type="textarea" | |
| 19 | + :rows="4" | |
| 20 | + :placeholder="$t('inspectionItemManage.requiredRemark')" | |
| 21 | + /> | |
| 22 | + </el-form-item> | |
| 23 | + </el-form> | |
| 24 | + | |
| 25 | + <span slot="footer" class="dialog-footer"> | |
| 26 | + <el-button @click="visible = false"> | |
| 27 | + {{ $t('inspectionItemManage.cancel') }} | |
| 28 | + </el-button> | |
| 29 | + <el-button type="primary" @click="handleSubmit" :loading="loading"> | |
| 30 | + {{ $t('inspectionItemManage.save') }} | |
| 31 | + </el-button> | |
| 32 | + </span> | |
| 33 | + </el-dialog> | |
| 34 | +</template> | |
| 35 | + | |
| 36 | +<script> | |
| 37 | +import { updateInspectionItem } from '@/api/inspection/inspectionItemManageApi' | |
| 38 | +import { getCommunityId } from '@/api/community/communityApi' | |
| 39 | + | |
| 40 | +export default { | |
| 41 | + name: 'EditInspectionItem', | |
| 42 | + data() { | |
| 43 | + return { | |
| 44 | + visible: false, | |
| 45 | + loading: false, | |
| 46 | + formData: { | |
| 47 | + itemId: '', | |
| 48 | + itemName: '', | |
| 49 | + remark: '', | |
| 50 | + communityId: '' | |
| 51 | + }, | |
| 52 | + rules: { | |
| 53 | + itemName: [ | |
| 54 | + { required: true, message: this.$t('inspectionItemManage.requiredItem'), trigger: 'blur' }, | |
| 55 | + { max: 256, message: this.$t('inspectionItemManage.maxLength256'), trigger: 'blur' } | |
| 56 | + ], | |
| 57 | + remark: [ | |
| 58 | + { required: true, message: this.$t('inspectionItemManage.requiredRemark'), trigger: 'blur' }, | |
| 59 | + { max: 512, message: this.$t('inspectionItemManage.maxLength512'), trigger: 'blur' } | |
| 60 | + ], | |
| 61 | + itemId: [ | |
| 62 | + { required: true, message: this.$t('inspectionItemManage.requiredId'), trigger: 'blur' } | |
| 63 | + ] | |
| 64 | + } | |
| 65 | + } | |
| 66 | + }, | |
| 67 | + methods: { | |
| 68 | + open(item) { | |
| 69 | + this.formData = { | |
| 70 | + ...item, | |
| 71 | + communityId: getCommunityId() | |
| 72 | + } | |
| 73 | + this.visible = true | |
| 74 | + }, | |
| 75 | + handleClose() { | |
| 76 | + this.formData = { | |
| 77 | + itemId: '', | |
| 78 | + itemName: '', | |
| 79 | + remark: '', | |
| 80 | + communityId: '' | |
| 81 | + } | |
| 82 | + }, | |
| 83 | + async handleSubmit() { | |
| 84 | + this.$refs.form.validate(async valid => { | |
| 85 | + if (valid) { | |
| 86 | + this.loading = true | |
| 87 | + try { | |
| 88 | + await updateInspectionItem(this.formData) | |
| 89 | + this.$message.success(this.$t('inspectionItemManage.editSuccess')) | |
| 90 | + this.visible = false | |
| 91 | + this.$emit('success') | |
| 92 | + } catch (error) { | |
| 93 | + console.error('更新巡检项目失败:', error) | |
| 94 | + this.$message.error(error.message || this.$t('inspectionItemManage.editFailed')) | |
| 95 | + } finally { | |
| 96 | + this.loading = false | |
| 97 | + } | |
| 98 | + } | |
| 99 | + }) | |
| 100 | + } | |
| 101 | + } | |
| 102 | +} | |
| 103 | +</script> | |
| 0 | 104 | \ No newline at end of file | ... | ... |
src/components/inspection/addInspectionItemTitle.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <el-dialog | |
| 3 | + :title="$t('inspectionItemTitleManage.addTitle')" | |
| 4 | + :visible.sync="visible" | |
| 5 | + width="50%" | |
| 6 | + @close="resetForm" | |
| 7 | + > | |
| 8 | + <el-form ref="form" :model="formData" label-width="120px"> | |
| 9 | + <el-form-item | |
| 10 | + :label="$t('inspectionItemTitleManage.title')" | |
| 11 | + prop="itemTitle" | |
| 12 | + :rules="[{ required: true, message: $t('common.required') }]" | |
| 13 | + > | |
| 14 | + <el-input | |
| 15 | + v-model="formData.itemTitle" | |
| 16 | + :placeholder="$t('inspectionItemTitleManage.placeholderItemTitleRequired')" | |
| 17 | + /> | |
| 18 | + </el-form-item> | |
| 19 | + | |
| 20 | + <el-form-item | |
| 21 | + :label="$t('inspectionItemTitleManage.titleType')" | |
| 22 | + prop="titleType" | |
| 23 | + :rules="[{ required: true, message: $t('common.required') }]" | |
| 24 | + > | |
| 25 | + <el-select | |
| 26 | + v-model="formData.titleType" | |
| 27 | + :placeholder="$t('inspectionItemTitleManage.placeholderTitleTypeRequired')" | |
| 28 | + style="width:100%" | |
| 29 | + @change="handleTypeChange" | |
| 30 | + > | |
| 31 | + <el-option | |
| 32 | + :label="$t('inspectionItemTitleManage.singleChoice')" | |
| 33 | + value="1001" | |
| 34 | + /> | |
| 35 | + <el-option | |
| 36 | + :label="$t('inspectionItemTitleManage.multipleChoice')" | |
| 37 | + value="2002" | |
| 38 | + /> | |
| 39 | + <el-option | |
| 40 | + :label="$t('inspectionItemTitleManage.shortAnswer')" | |
| 41 | + value="3003" | |
| 42 | + /> | |
| 43 | + </el-select> | |
| 44 | + </el-form-item> | |
| 45 | + | |
| 46 | + <template v-if="formData.titleType && formData.titleType !== '3003'"> | |
| 47 | + <div v-for="(item, index) in formData.titleValues" :key="index"> | |
| 48 | + <el-form-item | |
| 49 | + :label="`${$t('inspectionItemTitleManage.option')} ${index + 1}`" | |
| 50 | + :prop="`titleValues.${index}.itemValue`" | |
| 51 | + :rules="[{ required: true, message: $t('common.required') }]" | |
| 52 | + > | |
| 53 | + <el-input v-model="item.itemValue" /> | |
| 54 | + <el-button | |
| 55 | + v-if="index === formData.titleValues.length - 1" | |
| 56 | + type="text" | |
| 57 | + @click="addOption" | |
| 58 | + > | |
| 59 | + <i class="el-icon-plus"></i> | |
| 60 | + {{ $t('inspectionItemTitleManage.addOption') }} | |
| 61 | + </el-button> | |
| 62 | + <el-button | |
| 63 | + v-else | |
| 64 | + type="text" | |
| 65 | + @click="removeOption(index)" | |
| 66 | + > | |
| 67 | + <i class="el-icon-minus"></i> | |
| 68 | + {{ $t('inspectionItemTitleManage.removeOption') }} | |
| 69 | + </el-button> | |
| 70 | + </el-form-item> | |
| 71 | + </div> | |
| 72 | + </template> | |
| 73 | + | |
| 74 | + <el-form-item | |
| 75 | + :label="$t('inspectionItemTitleManage.seq')" | |
| 76 | + prop="seq" | |
| 77 | + :rules="[ | |
| 78 | + { required: true, message: $t('common.required') }, | |
| 79 | + { type: 'number', message: $t('inspectionItemTitleManage.seqMustNumber') } | |
| 80 | + ]" | |
| 81 | + > | |
| 82 | + <el-input | |
| 83 | + v-model.number="formData.seq" | |
| 84 | + :placeholder="$t('inspectionItemTitleManage.placeholderSeq')" | |
| 85 | + type="number" | |
| 86 | + /> | |
| 87 | + </el-form-item> | |
| 88 | + </el-form> | |
| 89 | + | |
| 90 | + <div slot="footer" class="dialog-footer"> | |
| 91 | + <el-button @click="visible = false"> | |
| 92 | + {{ $t('common.cancel') }} | |
| 93 | + </el-button> | |
| 94 | + <el-button type="primary" @click="submitForm"> | |
| 95 | + {{ $t('common.save') }} | |
| 96 | + </el-button> | |
| 97 | + </div> | |
| 98 | + </el-dialog> | |
| 99 | +</template> | |
| 100 | + | |
| 101 | +<script> | |
| 102 | +import { saveInspectionItemTitle } from '@/api/inspection/inspectionItemTitleManageApi' | |
| 103 | +import { getCommunityId } from '@/api/community/communityApi' | |
| 104 | + | |
| 105 | +export default { | |
| 106 | + name: 'AddInspectionItemTitle', | |
| 107 | + data() { | |
| 108 | + return { | |
| 109 | + visible: false, | |
| 110 | + formData: { | |
| 111 | + titleType: '', | |
| 112 | + itemTitle: '', | |
| 113 | + seq: '', | |
| 114 | + itemId: '', | |
| 115 | + titleValues: [] | |
| 116 | + } | |
| 117 | + } | |
| 118 | + }, | |
| 119 | + methods: { | |
| 120 | + open(data) { | |
| 121 | + this.formData = { | |
| 122 | + ...this.formData, | |
| 123 | + ...data | |
| 124 | + } | |
| 125 | + this.visible = true | |
| 126 | + }, | |
| 127 | + handleTypeChange(val) { | |
| 128 | + if (val === '1001') { | |
| 129 | + this.formData.titleValues = [{ itemValue: '', seq: 1 }] | |
| 130 | + } else if (val === '2002') { | |
| 131 | + this.formData.titleValues = [ | |
| 132 | + { itemValue: '', seq: 1 }, | |
| 133 | + { itemValue: '', seq: 2 } | |
| 134 | + ] | |
| 135 | + } else if (val === '3003') { | |
| 136 | + this.formData.titleValues = [] | |
| 137 | + } | |
| 138 | + }, | |
| 139 | + addOption() { | |
| 140 | + this.formData.titleValues.push({ | |
| 141 | + itemValue: '', | |
| 142 | + seq: this.formData.titleValues.length + 1 | |
| 143 | + }) | |
| 144 | + }, | |
| 145 | + removeOption(index) { | |
| 146 | + this.formData.titleValues.splice(index, 1) | |
| 147 | + // 重新排序 | |
| 148 | + this.formData.titleValues.forEach((item, i) => { | |
| 149 | + item.seq = i + 1 | |
| 150 | + }) | |
| 151 | + }, | |
| 152 | + resetForm() { | |
| 153 | + this.$refs.form.resetFields() | |
| 154 | + this.formData = { | |
| 155 | + titleType: '', | |
| 156 | + itemTitle: '', | |
| 157 | + seq: '', | |
| 158 | + itemId: '', | |
| 159 | + titleValues: [] | |
| 160 | + } | |
| 161 | + }, | |
| 162 | + submitForm() { | |
| 163 | + this.$refs.form.validate(async valid => { | |
| 164 | + if (!valid) return | |
| 165 | + | |
| 166 | + try { | |
| 167 | + const params = { | |
| 168 | + ...this.formData, | |
| 169 | + communityId: getCommunityId() | |
| 170 | + } | |
| 171 | + | |
| 172 | + await saveInspectionItemTitle(params) | |
| 173 | + this.$message.success(this.$t('common.saveSuccess')) | |
| 174 | + this.visible = false | |
| 175 | + this.$emit('success') | |
| 176 | + } catch (error) { | |
| 177 | + this.$message.error(error.message || this.$t('common.saveError')) | |
| 178 | + } | |
| 179 | + }) | |
| 180 | + } | |
| 181 | + } | |
| 182 | +} | |
| 183 | +</script> | |
| 0 | 184 | \ No newline at end of file | ... | ... |
src/components/inspection/deleteInspectionItemTitle.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <el-dialog | |
| 3 | + :title="$t('common.delete')" | |
| 4 | + :visible.sync="visible" | |
| 5 | + width="30%" | |
| 6 | + > | |
| 7 | + <p>{{ $t('inspectionItemTitleManage.confirmDelete') }}</p> | |
| 8 | + <span slot="footer" class="dialog-footer"> | |
| 9 | + <el-button @click="visible = false"> | |
| 10 | + {{ $t('common.cancel') }} | |
| 11 | + </el-button> | |
| 12 | + <el-button type="primary" @click="confirmDelete"> | |
| 13 | + {{ $t('common.confirm') }} | |
| 14 | + </el-button> | |
| 15 | + </span> | |
| 16 | + </el-dialog> | |
| 17 | +</template> | |
| 18 | + | |
| 19 | +<script> | |
| 20 | +import { deleteInspectionItemTitle } from '@/api/inspection/inspectionItemTitleManageApi' | |
| 21 | +import { getCommunityId } from '@/api/community/communityApi' | |
| 22 | + | |
| 23 | +export default { | |
| 24 | + name: 'DeleteInspectionItemTitle', | |
| 25 | + data() { | |
| 26 | + return { | |
| 27 | + visible: false, | |
| 28 | + currentData: {} | |
| 29 | + } | |
| 30 | + }, | |
| 31 | + methods: { | |
| 32 | + open(data) { | |
| 33 | + this.currentData = { ...data } | |
| 34 | + this.visible = true | |
| 35 | + }, | |
| 36 | + async confirmDelete() { | |
| 37 | + try { | |
| 38 | + const params = { | |
| 39 | + ...this.currentData, | |
| 40 | + communityId: getCommunityId() | |
| 41 | + } | |
| 42 | + | |
| 43 | + await deleteInspectionItemTitle(params) | |
| 44 | + this.$message.success(this.$t('common.deleteSuccess')) | |
| 45 | + this.visible = false | |
| 46 | + this.$emit('success') | |
| 47 | + } catch (error) { | |
| 48 | + this.$message.error(error.message || this.$t('common.deleteError')) | |
| 49 | + } | |
| 50 | + } | |
| 51 | + } | |
| 52 | +} | |
| 53 | +</script> | |
| 0 | 54 | \ No newline at end of file | ... | ... |
src/components/inspection/editInspectionItemTitle.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <el-dialog :title="$t('inspectionItemTitleManage.editTitle')" :visible.sync="visible" width="50%" @close="resetForm"> | |
| 3 | + <el-form ref="form" :model="formData" label-width="120px"> | |
| 4 | + <el-form-item :label="$t('inspectionItemTitleManage.title')" prop="itemTitle" | |
| 5 | + :rules="[{ required: true, message: $t('common.required') }]"> | |
| 6 | + <el-input v-model="formData.itemTitle" | |
| 7 | + :placeholder="$t('inspectionItemTitleManage.placeholderItemTitleRequired')" /> | |
| 8 | + </el-form-item> | |
| 9 | + <el-form-item :label="$t('inspectionItemTitleManage.titleType')" prop="titleType" | |
| 10 | + :rules="[{ required: true, message: $t('common.required') }]"> | |
| 11 | + <el-select v-model="formData.titleType" | |
| 12 | + :placeholder="$t('inspectionItemTitleManage.placeholderTitleTypeRequired')" style="width:100%" | |
| 13 | + @change="handleTypeChange"> | |
| 14 | + <el-option :label="$t('inspectionItemTitleManage.singleChoice')" value="1001" /> | |
| 15 | + <el-option :label="$t('inspectionItemTitleManage.multipleChoice')" value="2002" /> | |
| 16 | + <el-option :label="$t('inspectionItemTitleManage.shortAnswer')" value="3003" /> | |
| 17 | + </el-select> | |
| 18 | + </el-form-item> | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + <template v-if="formData.titleType && formData.titleType !== '3003'"> | |
| 23 | + <div v-for="(item, index) in formData.titleValues" :key="index"> | |
| 24 | + <el-form-item :label="`${$t('inspectionItemTitleManage.option')} ${index + 1}`" | |
| 25 | + :prop="`titleValues.${index}.itemValue`" :rules="[{ required: true, message: $t('common.required') }]"> | |
| 26 | + <el-input v-model="item.itemValue" /> | |
| 27 | + <el-button v-if="index === formData.titleValues.length - 1" type="text" @click="addOption"> | |
| 28 | + <i class="el-icon-plus"></i> | |
| 29 | + {{ $t('inspectionItemTitleManage.addOption') }} | |
| 30 | + </el-button> | |
| 31 | + <el-button v-else type="text" @click="removeOption(index)"> | |
| 32 | + <i class="el-icon-minus"></i> | |
| 33 | + {{ $t('inspectionItemTitleManage.removeOption') }} | |
| 34 | + </el-button> | |
| 35 | + </el-form-item> | |
| 36 | + </div> | |
| 37 | + </template> | |
| 38 | + | |
| 39 | + <el-form-item :label="$t('inspectionItemTitleManage.seq')" prop="seq" :rules="[ | |
| 40 | + { required: true, message: $t('common.required') } | |
| 41 | + ]"> | |
| 42 | + <el-input v-model.number="formData.seq" :placeholder="$t('inspectionItemTitleManage.placeholderSeq')" | |
| 43 | + type="number" /> | |
| 44 | + </el-form-item> | |
| 45 | + </el-form> | |
| 46 | + | |
| 47 | + <div slot="footer" class="dialog-footer"> | |
| 48 | + <el-button @click="visible = false"> | |
| 49 | + {{ $t('common.cancel') }} | |
| 50 | + </el-button> | |
| 51 | + <el-button type="primary" @click="submitForm"> | |
| 52 | + {{ $t('common.save') }} | |
| 53 | + </el-button> | |
| 54 | + </div> | |
| 55 | + </el-dialog> | |
| 56 | +</template> | |
| 57 | + | |
| 58 | +<script> | |
| 59 | +import { updateInspectionItemTitle } from '@/api/inspection/inspectionItemTitleManageApi' | |
| 60 | +import { getCommunityId } from '@/api/community/communityApi' | |
| 61 | + | |
| 62 | +export default { | |
| 63 | + name: 'EditInspectionItemTitle', | |
| 64 | + data() { | |
| 65 | + return { | |
| 66 | + visible: false, | |
| 67 | + formData: { | |
| 68 | + titleId: '', | |
| 69 | + titleType: '', | |
| 70 | + itemTitle: '', | |
| 71 | + seq: '', | |
| 72 | + itemId: '', | |
| 73 | + titleValues: [] | |
| 74 | + } | |
| 75 | + } | |
| 76 | + }, | |
| 77 | + methods: { | |
| 78 | + open(data) { | |
| 79 | + this.formData = { ...data } | |
| 80 | + console.log(data) | |
| 81 | + this.formData.titleValues = data.inspectionItemTitleValueDtos; | |
| 82 | + this.visible = true | |
| 83 | + }, | |
| 84 | + handleTypeChange(val) { | |
| 85 | + if (val === '1001' && (!this.formData.titleValues || this.formData.titleValues.length === 0)) { | |
| 86 | + this.formData.titleValues = [{ itemValue: '', seq: 1 }] | |
| 87 | + } else if (val === '2002' && (!this.formData.titleValues || this.formData.titleValues.length < 2)) { | |
| 88 | + this.formData.titleValues = [ | |
| 89 | + { itemValue: '', seq: 1 }, | |
| 90 | + { itemValue: '', seq: 2 } | |
| 91 | + ] | |
| 92 | + } else if (val === '3003') { | |
| 93 | + this.formData.titleValues = [] | |
| 94 | + } | |
| 95 | + }, | |
| 96 | + addOption() { | |
| 97 | + this.formData.titleValues.push({ | |
| 98 | + itemValue: '', | |
| 99 | + seq: this.formData.titleValues.length + 1 | |
| 100 | + }) | |
| 101 | + }, | |
| 102 | + removeOption(index) { | |
| 103 | + this.formData.titleValues.splice(index, 1) | |
| 104 | + // 重新排序 | |
| 105 | + this.formData.titleValues.forEach((item, i) => { | |
| 106 | + item.seq = i + 1 | |
| 107 | + }) | |
| 108 | + }, | |
| 109 | + resetForm() { | |
| 110 | + this.$refs.form.resetFields() | |
| 111 | + this.formData = { | |
| 112 | + titleId: '', | |
| 113 | + titleType: '', | |
| 114 | + itemTitle: '', | |
| 115 | + seq: '', | |
| 116 | + itemId: '', | |
| 117 | + titleValues: [] | |
| 118 | + } | |
| 119 | + }, | |
| 120 | + submitForm() { | |
| 121 | + this.$refs.form.validate(async valid => { | |
| 122 | + if (!valid) return | |
| 123 | + | |
| 124 | + try { | |
| 125 | + const params = { | |
| 126 | + ...this.formData, | |
| 127 | + communityId: getCommunityId() | |
| 128 | + } | |
| 129 | + | |
| 130 | + await updateInspectionItemTitle(params) | |
| 131 | + this.$message.success(this.$t('common.updateSuccess')) | |
| 132 | + this.visible = false | |
| 133 | + this.$emit('success') | |
| 134 | + } catch (error) { | |
| 135 | + this.$message.error(error.message || this.$t('common.updateError')) | |
| 136 | + } | |
| 137 | + }) | |
| 138 | + } | |
| 139 | + } | |
| 140 | +} | |
| 141 | +</script> | |
| 0 | 142 | \ No newline at end of file | ... | ... |
src/i18n/index.js
| ... | ... | @@ -170,7 +170,8 @@ import { messages as repairDispatchManageMessages } from '../views/work/repairDi |
| 170 | 170 | import { messages as myRepairDispatchManageMessages } from '../views/work/myRepairDispatchManageLang' |
| 171 | 171 | import { messages as repairReturnVisitMessages } from '../views/work/repairReturnVisitLang' |
| 172 | 172 | import { messages as repairForceFinishManageMessages } from '../views/work/repairForceFinishManageLang' |
| 173 | - | |
| 173 | +import { messages as inspectionItemManageMessages } from '../views/inspection/inspectionItemManageLang' | |
| 174 | +import { messages as inspectionItemTitleManageMessages } from '../views/inspection/inspectionItemTitleManageLang' | |
| 174 | 175 | Vue.use(VueI18n) |
| 175 | 176 | |
| 176 | 177 | // 合并所有语言配置 |
| ... | ... | @@ -344,6 +345,8 @@ const messages = { |
| 344 | 345 | ...myRepairDispatchManageMessages.en, |
| 345 | 346 | ...repairReturnVisitMessages.en, |
| 346 | 347 | ...repairForceFinishManageMessages.en, |
| 348 | + ...inspectionItemManageMessages.en, | |
| 349 | + ...inspectionItemTitleManageMessages.en, | |
| 347 | 350 | }, |
| 348 | 351 | zh: { |
| 349 | 352 | ...loginMessages.zh, |
| ... | ... | @@ -514,6 +517,8 @@ const messages = { |
| 514 | 517 | ...myRepairDispatchManageMessages.zh, |
| 515 | 518 | ...repairReturnVisitMessages.zh, |
| 516 | 519 | ...repairForceFinishManageMessages.zh, |
| 520 | + ...inspectionItemManageMessages.zh, | |
| 521 | + ...inspectionItemTitleManageMessages.zh, | |
| 517 | 522 | } |
| 518 | 523 | } |
| 519 | 524 | ... | ... |
src/router/index.js
| ... | ... | @@ -841,6 +841,16 @@ const routes = [ |
| 841 | 841 | name: '/pages/property/repairForceFinishManage', |
| 842 | 842 | component: () => import('@/views/work/repairForceFinishManageList.vue') |
| 843 | 843 | }, |
| 844 | + { | |
| 845 | + path:'/pages/property/inspectionItemManage', | |
| 846 | + name:'/pages/property/inspectionItemManage', | |
| 847 | + component: () => import('@/views/inspection/inspectionItemManageList.vue') | |
| 848 | + }, | |
| 849 | + { | |
| 850 | + path:'/views/inspection/inspectionItemTitleManage', | |
| 851 | + name:'/views/inspection/inspectionItemTitleManage', | |
| 852 | + component: () => import('@/views/inspection/inspectionItemTitleManageList.vue') | |
| 853 | + }, | |
| 844 | 854 | // 其他子路由可以在这里添加 |
| 845 | 855 | ] |
| 846 | 856 | }, | ... | ... |
src/views/inspection/inspectionItemManageLang.js
0 → 100644
| 1 | +export const messages = { | |
| 2 | + en: { | |
| 3 | + inspectionItemManage: { | |
| 4 | + searchCondition: 'Search Condition', | |
| 5 | + itemIdPlaceholder: 'Please enter item number', | |
| 6 | + itemNamePlaceholder: 'Please enter inspection item', | |
| 7 | + searchBtn: 'Search', | |
| 8 | + resetBtn: 'Reset', | |
| 9 | + inspectionItems: 'Inspection Items', | |
| 10 | + doc: 'Document', | |
| 11 | + addBtn: 'Add', | |
| 12 | + id: 'ID', | |
| 13 | + itemName: 'Inspection Item', | |
| 14 | + createTime: 'Create Time', | |
| 15 | + remark: 'Remark', | |
| 16 | + operation: 'Operation', | |
| 17 | + edit: 'Edit', | |
| 18 | + delete: 'Delete', | |
| 19 | + question: 'Question', | |
| 20 | + addTitle: 'Add', | |
| 21 | + editTitle: 'Edit', | |
| 22 | + deleteTitle: 'Delete', | |
| 23 | + itemNameLabel: 'Inspection Item', | |
| 24 | + remarkLabel: 'Remark', | |
| 25 | + requiredItem: 'Required, please fill in inspection item', | |
| 26 | + requiredRemark: 'Required, please fill in remark', | |
| 27 | + save: 'Save', | |
| 28 | + cancel: 'Cancel', | |
| 29 | + confirmDelete: 'Confirm deletion?', | |
| 30 | + confirmDeleteMsg: 'Are you sure to delete the inspection item?', | |
| 31 | + cancelDelete: 'Cancel', | |
| 32 | + confirmDeleteBtn: 'Confirm Delete', | |
| 33 | + deleteSuccess: 'Delete successfully', | |
| 34 | + addSuccess: 'Add successfully', | |
| 35 | + editSuccess: 'Edit successfully' | |
| 36 | + } | |
| 37 | + }, | |
| 38 | + zh: { | |
| 39 | + inspectionItemManage: { | |
| 40 | + searchCondition: '查询条件', | |
| 41 | + itemIdPlaceholder: '请输入项目编号', | |
| 42 | + itemNamePlaceholder: '请输入巡检项目', | |
| 43 | + searchBtn: '查询', | |
| 44 | + resetBtn: '重置', | |
| 45 | + inspectionItems: '巡检项目', | |
| 46 | + doc: '文档', | |
| 47 | + addBtn: '添加', | |
| 48 | + id: '编号', | |
| 49 | + itemName: '巡检项目', | |
| 50 | + createTime: '创建时间', | |
| 51 | + remark: '备注', | |
| 52 | + operation: '操作', | |
| 53 | + edit: '修改', | |
| 54 | + delete: '删除', | |
| 55 | + question: '题目', | |
| 56 | + addTitle: '添加', | |
| 57 | + editTitle: '修改', | |
| 58 | + deleteTitle: '删除', | |
| 59 | + itemNameLabel: '巡检项目', | |
| 60 | + remarkLabel: '备注', | |
| 61 | + requiredItem: '必填,请填写巡检项目', | |
| 62 | + requiredRemark: '必填,请填写备注', | |
| 63 | + save: '保存', | |
| 64 | + cancel: '取消', | |
| 65 | + confirmDelete: '请确认您的操作', | |
| 66 | + confirmDeleteMsg: '确定删除巡检项目', | |
| 67 | + cancelDelete: '点错了', | |
| 68 | + confirmDeleteBtn: '确认删除', | |
| 69 | + deleteSuccess: '删除成功', | |
| 70 | + addSuccess: '添加成功', | |
| 71 | + editSuccess: '修改成功' | |
| 72 | + } | |
| 73 | + } | |
| 74 | +} | |
| 0 | 75 | \ No newline at end of file | ... | ... |
src/views/inspection/inspectionItemManageList.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <div class="inspection-item-manage-container"> | |
| 3 | + <!-- 查询条件 --> | |
| 4 | + <el-card class="search-card"> | |
| 5 | + <div slot="header" class="flex justify-between"> | |
| 6 | + <span>{{ $t('inspectionItemManage.searchCondition') }}</span> | |
| 7 | + </div> | |
| 8 | + <el-row :gutter="20"> | |
| 9 | + <el-col :span="6"> | |
| 10 | + <el-input v-model="searchForm.itemId" :placeholder="$t('inspectionItemManage.itemIdPlaceholder')" clearable /> | |
| 11 | + </el-col> | |
| 12 | + <el-col :span="6"> | |
| 13 | + <el-input v-model="searchForm.itemName" :placeholder="$t('inspectionItemManage.itemNamePlaceholder')" | |
| 14 | + clearable /> | |
| 15 | + </el-col> | |
| 16 | + <el-col :span="6"> | |
| 17 | + <el-button type="primary" @click="handleSearch"> | |
| 18 | + {{ $t('inspectionItemManage.searchBtn') }} | |
| 19 | + </el-button> | |
| 20 | + <el-button @click="handleReset"> | |
| 21 | + {{ $t('inspectionItemManage.resetBtn') }} | |
| 22 | + </el-button> | |
| 23 | + </el-col> | |
| 24 | + </el-row> | |
| 25 | + </el-card> | |
| 26 | + | |
| 27 | + <!-- 巡检项目列表 --> | |
| 28 | + <el-card> | |
| 29 | + <div slot="header" class="flex justify-between"> | |
| 30 | + <span>{{ $t('inspectionItemManage.inspectionItems') }}</span> | |
| 31 | + <div style="float: right;"> | |
| 32 | + <el-button type="primary" size="small" @click="handleShowDoc"> | |
| 33 | + <i class="el-icon-document"></i> | |
| 34 | + {{ $t('inspectionItemManage.doc') }} | |
| 35 | + </el-button> | |
| 36 | + <el-button type="primary" size="small" @click="openAddModal"> | |
| 37 | + <i class="el-icon-plus"></i> | |
| 38 | + {{ $t('inspectionItemManage.addBtn') }} | |
| 39 | + </el-button> | |
| 40 | + </div> | |
| 41 | + </div> | |
| 42 | + | |
| 43 | + <el-table v-loading="loading" :data="tableData" border style="width: 100%"> | |
| 44 | + <el-table-column prop="itemId" :label="$t('inspectionItemManage.id')" align="center" /> | |
| 45 | + <el-table-column prop="itemName" :label="$t('inspectionItemManage.itemName')" align="center" /> | |
| 46 | + <el-table-column prop="createTime" :label="$t('inspectionItemManage.createTime')" align="center" /> | |
| 47 | + <el-table-column prop="remark" :label="$t('inspectionItemManage.remark')" align="center" /> | |
| 48 | + <el-table-column :label="$t('inspectionItemManage.operation')" align="center" width="300"> | |
| 49 | + <template slot-scope="scope"> | |
| 50 | + <el-button size="mini" @click="openEditModal(scope.row)"> | |
| 51 | + {{ $t('inspectionItemManage.edit') }} | |
| 52 | + </el-button> | |
| 53 | + <el-button size="mini" type="danger" @click="openDeleteModal(scope.row)"> | |
| 54 | + {{ $t('inspectionItemManage.delete') }} | |
| 55 | + </el-button> | |
| 56 | + <el-button size="mini" type="success" @click="handleToQuestion(scope.row)"> | |
| 57 | + {{ $t('inspectionItemManage.question') }} | |
| 58 | + </el-button> | |
| 59 | + </template> | |
| 60 | + </el-table-column> | |
| 61 | + </el-table> | |
| 62 | + | |
| 63 | + <el-pagination class="pagination" :current-page="pagination.current" :page-sizes="[10, 20, 30, 50]" | |
| 64 | + :page-size="pagination.size" :total="pagination.total" layout="total, sizes, prev, pager, next, jumper" | |
| 65 | + @size-change="handleSizeChange" @current-change="handlePageChange" /> | |
| 66 | + </el-card> | |
| 67 | + | |
| 68 | + <!-- 子组件 --> | |
| 69 | + <add-inspection-item ref="addModal" @success="handleSuccess" /> | |
| 70 | + <edit-inspection-item ref="editModal" @success="handleSuccess" /> | |
| 71 | + <delete-inspection-item ref="deleteModal" @success="handleSuccess" /> | |
| 72 | + </div> | |
| 73 | +</template> | |
| 74 | + | |
| 75 | +<script> | |
| 76 | +import { listInspectionItem } from '@/api/inspection/inspectionItemManageApi' | |
| 77 | +import AddInspectionItem from '@/components/inspection/AddInspectionItem' | |
| 78 | +import EditInspectionItem from '@/components/inspection/EditInspectionItem' | |
| 79 | +import DeleteInspectionItem from '@/components/inspection/DeleteInspectionItem' | |
| 80 | +import { getCommunityId } from '@/api/community/communityApi' | |
| 81 | + | |
| 82 | +export default { | |
| 83 | + name: 'InspectionItemManageList', | |
| 84 | + components: { | |
| 85 | + AddInspectionItem, | |
| 86 | + EditInspectionItem, | |
| 87 | + DeleteInspectionItem | |
| 88 | + }, | |
| 89 | + data() { | |
| 90 | + return { | |
| 91 | + loading: false, | |
| 92 | + searchForm: { | |
| 93 | + itemId: '', | |
| 94 | + itemName: '', | |
| 95 | + communityId: '' | |
| 96 | + }, | |
| 97 | + tableData: [], | |
| 98 | + pagination: { | |
| 99 | + current: 1, | |
| 100 | + size: 10, | |
| 101 | + total: 0 | |
| 102 | + } | |
| 103 | + } | |
| 104 | + }, | |
| 105 | + created() { | |
| 106 | + this.searchForm.communityId = getCommunityId() | |
| 107 | + this.getList() | |
| 108 | + }, | |
| 109 | + methods: { | |
| 110 | + async getList() { | |
| 111 | + this.loading = true | |
| 112 | + try { | |
| 113 | + const params = { | |
| 114 | + ...this.searchForm, | |
| 115 | + page: this.pagination.current, | |
| 116 | + row: this.pagination.size | |
| 117 | + } | |
| 118 | + const res = await listInspectionItem(params) | |
| 119 | + this.tableData = res.data | |
| 120 | + this.pagination.total = res.total | |
| 121 | + } catch (error) { | |
| 122 | + console.error('获取巡检项目列表失败:', error) | |
| 123 | + this.$message.error(this.$t('inspectionItemManage.fetchError')) | |
| 124 | + } finally { | |
| 125 | + this.loading = false | |
| 126 | + } | |
| 127 | + }, | |
| 128 | + handleSearch() { | |
| 129 | + this.pagination.current = 1 | |
| 130 | + this.getList() | |
| 131 | + }, | |
| 132 | + handleReset() { | |
| 133 | + this.searchForm.itemId = '' | |
| 134 | + this.searchForm.itemName = '' | |
| 135 | + this.handleSearch() | |
| 136 | + }, | |
| 137 | + handleSizeChange(size) { | |
| 138 | + this.pagination.size = size | |
| 139 | + this.getList() | |
| 140 | + }, | |
| 141 | + handlePageChange(page) { | |
| 142 | + this.pagination.current = page | |
| 143 | + this.getList() | |
| 144 | + }, | |
| 145 | + handleShowDoc() { | |
| 146 | + // 显示文档逻辑 | |
| 147 | + console.log('显示文档') | |
| 148 | + }, | |
| 149 | + handleToQuestion(item) { | |
| 150 | + this.$router.push(`/views/inspection/inspectionItemTitleManage?itemId=${item.itemId}`) | |
| 151 | + }, | |
| 152 | + openAddModal() { | |
| 153 | + this.$refs.addModal.open() | |
| 154 | + }, | |
| 155 | + openEditModal(item) { | |
| 156 | + this.$refs.editModal.open(item) | |
| 157 | + }, | |
| 158 | + openDeleteModal(item) { | |
| 159 | + this.$refs.deleteModal.open(item) | |
| 160 | + }, | |
| 161 | + handleSuccess() { | |
| 162 | + this.getList() | |
| 163 | + } | |
| 164 | + } | |
| 165 | +} | |
| 166 | +</script> | |
| 167 | + | |
| 168 | +<style lang="scss" scoped> | |
| 169 | +.inspection-item-manage-container { | |
| 170 | + padding: 20px; | |
| 171 | + | |
| 172 | + .search-card { | |
| 173 | + margin-bottom: 20px; | |
| 174 | + } | |
| 175 | + | |
| 176 | + .pagination { | |
| 177 | + margin-top: 20px; | |
| 178 | + text-align: right; | |
| 179 | + } | |
| 180 | +} | |
| 181 | +</style> | |
| 0 | 182 | \ No newline at end of file | ... | ... |
src/views/inspection/inspectionItemTitleManageLang.js
0 → 100644
| 1 | +export const messages = { | |
| 2 | + en: { | |
| 3 | + inspectionItemTitleManage: { | |
| 4 | + searchTitle: 'Search Conditions', | |
| 5 | + listTitle: 'Inspection Items', | |
| 6 | + placeholderTitleId: 'Please enter title ID', | |
| 7 | + placeholderItemTitle: 'Please enter question name', | |
| 8 | + placeholderTitleType: 'Please select title type', | |
| 9 | + selectTitleType: 'Select title type', | |
| 10 | + singleChoice: 'Single choice', | |
| 11 | + multipleChoice: 'Multiple choice', | |
| 12 | + shortAnswer: 'Short answer', | |
| 13 | + titleId: 'Title ID', | |
| 14 | + title: 'Title', | |
| 15 | + titleType: 'Title Type', | |
| 16 | + seq: 'Sequence', | |
| 17 | + createTime: 'Create Time', | |
| 18 | + operation: 'Operation', | |
| 19 | + addTitle: 'Add Title', | |
| 20 | + editTitle: 'Edit Title', | |
| 21 | + confirmDelete: 'Are you sure to delete this title?', | |
| 22 | + placeholderItemTitleRequired: 'Required, please enter title', | |
| 23 | + placeholderTitleTypeRequired: 'Required, please select title type', | |
| 24 | + option: 'Option', | |
| 25 | + addOption: 'Add Option', | |
| 26 | + removeOption: 'Remove Option', | |
| 27 | + placeholderSeq: 'Required, please enter sequence', | |
| 28 | + seqMustNumber: 'Sequence must be a number' | |
| 29 | + } | |
| 30 | + }, | |
| 31 | + zh: { | |
| 32 | + inspectionItemTitleManage: { | |
| 33 | + searchTitle: '查询条件', | |
| 34 | + listTitle: '巡检项', | |
| 35 | + placeholderTitleId: '请输入题目ID', | |
| 36 | + placeholderItemTitle: '请输入问题名称', | |
| 37 | + placeholderTitleType: '请选择题目类型', | |
| 38 | + selectTitleType: '请选择题目类型', | |
| 39 | + singleChoice: '单选', | |
| 40 | + multipleChoice: '多选', | |
| 41 | + shortAnswer: '简答题', | |
| 42 | + titleId: '题目ID', | |
| 43 | + title: '题目', | |
| 44 | + titleType: '题目类型', | |
| 45 | + seq: '顺序', | |
| 46 | + createTime: '创建时间', | |
| 47 | + operation: '操作', | |
| 48 | + addTitle: '添加题目', | |
| 49 | + editTitle: '修改题目', | |
| 50 | + confirmDelete: '确定删除题目?', | |
| 51 | + placeholderItemTitleRequired: '必填,请填写题目', | |
| 52 | + placeholderTitleTypeRequired: '必填,请选择题目类型', | |
| 53 | + option: '选项', | |
| 54 | + addOption: '增加选项', | |
| 55 | + removeOption: '删除选项', | |
| 56 | + placeholderSeq: '必填,请填写顺序', | |
| 57 | + seqMustNumber: '顺序必须是数字' | |
| 58 | + } | |
| 59 | + } | |
| 60 | +} | |
| 0 | 61 | \ No newline at end of file | ... | ... |
src/views/inspection/inspectionItemTitleManageList.vue
0 → 100644
| 1 | +<template> | |
| 2 | + <div> | |
| 3 | + <!-- 查询条件 --> | |
| 4 | + <el-card class="search-wrapper"> | |
| 5 | + <div slot="header" class="flex juistify-between"> | |
| 6 | + <span>{{ $t('inspectionItemTitleManage.searchTitle') }}</span> | |
| 7 | + </div> | |
| 8 | + <el-row :gutter="20"> | |
| 9 | + <el-col :span="6"> | |
| 10 | + <el-input v-model="searchForm.titleId" :placeholder="$t('inspectionItemTitleManage.placeholderTitleId')" | |
| 11 | + clearable /> | |
| 12 | + </el-col> | |
| 13 | + <el-col :span="6"> | |
| 14 | + <el-input v-model="searchForm.itemTitle" :placeholder="$t('inspectionItemTitleManage.placeholderItemTitle')" | |
| 15 | + clearable /> | |
| 16 | + </el-col> | |
| 17 | + <el-col :span="6"> | |
| 18 | + <el-select v-model="searchForm.titleType" :placeholder="$t('inspectionItemTitleManage.placeholderTitleType')" | |
| 19 | + style="width:100%"> | |
| 20 | + <el-option :label="$t('inspectionItemTitleManage.selectTitleType')" value="" /> | |
| 21 | + <el-option :label="$t('inspectionItemTitleManage.singleChoice')" value="1001" /> | |
| 22 | + <el-option :label="$t('inspectionItemTitleManage.multipleChoice')" value="2002" /> | |
| 23 | + <el-option :label="$t('inspectionItemTitleManage.shortAnswer')" value="3003" /> | |
| 24 | + </el-select> | |
| 25 | + </el-col> | |
| 26 | + <el-col :span="6"> | |
| 27 | + <el-button type="primary" @click="handleSearch"> | |
| 28 | + <i class="el-icon-search"></i> | |
| 29 | + {{ $t('common.search') }} | |
| 30 | + </el-button> | |
| 31 | + <el-button @click="handleReset"> | |
| 32 | + <i class="el-icon-refresh"></i> | |
| 33 | + {{ $t('common.reset') }} | |
| 34 | + </el-button> | |
| 35 | + </el-col> | |
| 36 | + </el-row> | |
| 37 | + </el-card> | |
| 38 | + | |
| 39 | + <!-- 列表 --> | |
| 40 | + <el-card> | |
| 41 | + <div slot="header" class="flex justify-between"> | |
| 42 | + <span>{{ $t('inspectionItemTitleManage.listTitle') }}</span> | |
| 43 | + <div style="float:right"> | |
| 44 | + <el-button size="small" @click="goBack"> | |
| 45 | + <i class="el-icon-close"></i> | |
| 46 | + {{ $t('common.back') }} | |
| 47 | + </el-button> | |
| 48 | + <el-button type="primary" size="small" @click="openAddModal"> | |
| 49 | + <i class="el-icon-plus"></i> | |
| 50 | + {{ $t('common.add') }} | |
| 51 | + </el-button> | |
| 52 | + </div> | |
| 53 | + </div> | |
| 54 | + | |
| 55 | + <el-table :data="tableData" border v-loading="loading" style="width:100%"> | |
| 56 | + <el-table-column prop="titleId" :label="$t('inspectionItemTitleManage.titleId')" align="center" /> | |
| 57 | + <el-table-column prop="itemTitle" :label="$t('inspectionItemTitleManage.title')" align="center" /> | |
| 58 | + <el-table-column prop="titleType" :label="$t('inspectionItemTitleManage.titleType')" align="center"> | |
| 59 | + <template slot-scope="scope"> | |
| 60 | + {{ getTitleTypeName(scope.row.titleType) }} | |
| 61 | + </template> | |
| 62 | + </el-table-column> | |
| 63 | + <el-table-column prop="seq" :label="$t('inspectionItemTitleManage.seq')" align="center" /> | |
| 64 | + <el-table-column prop="createTime" :label="$t('inspectionItemTitleManage.createTime')" align="center" /> | |
| 65 | + <el-table-column :label="$t('common.operation')" align="center" width="200"> | |
| 66 | + <template slot-scope="scope"> | |
| 67 | + <el-button size="mini" @click="openEditModal(scope.row)"> | |
| 68 | + {{ $t('common.edit') }} | |
| 69 | + </el-button> | |
| 70 | + <el-button size="mini" type="danger" @click="openDeleteModal(scope.row)"> | |
| 71 | + {{ $t('common.delete') }} | |
| 72 | + </el-button> | |
| 73 | + </template> | |
| 74 | + </el-table-column> | |
| 75 | + </el-table> | |
| 76 | + | |
| 77 | + <el-pagination class="pagination" :current-page.sync="pagination.current" :page-sizes="[10, 20, 30, 50]" | |
| 78 | + :page-size="pagination.size" :total="pagination.total" layout="total, sizes, prev, pager, next, jumper" | |
| 79 | + @size-change="handleSizeChange" @current-change="handlePageChange" /> | |
| 80 | + </el-card> | |
| 81 | + | |
| 82 | + <!-- 组件 --> | |
| 83 | + <add-inspection-item-title ref="addModal" @success="fetchList" /> | |
| 84 | + <edit-inspection-item-title ref="editModal" @success="fetchList" /> | |
| 85 | + <delete-inspection-item-title ref="deleteModal" @success="fetchList" /> | |
| 86 | + </div> | |
| 87 | +</template> | |
| 88 | + | |
| 89 | +<script> | |
| 90 | +import { listInspectionItemTitle } from '@/api/inspection/inspectionItemTitleManageApi' | |
| 91 | +import AddInspectionItemTitle from '@/components/inspection/addInspectionItemTitle' | |
| 92 | +import EditInspectionItemTitle from '@/components/inspection/editInspectionItemTitle' | |
| 93 | +import DeleteInspectionItemTitle from '@/components/inspection/deleteInspectionItemTitle' | |
| 94 | +import { getCommunityId } from '@/api/community/communityApi' | |
| 95 | + | |
| 96 | +export default { | |
| 97 | + name: 'InspectionItemTitleManageList', | |
| 98 | + components: { | |
| 99 | + AddInspectionItemTitle, | |
| 100 | + EditInspectionItemTitle, | |
| 101 | + DeleteInspectionItemTitle | |
| 102 | + }, | |
| 103 | + data() { | |
| 104 | + return { | |
| 105 | + searchForm: { | |
| 106 | + titleId: '', | |
| 107 | + itemTitle: '', | |
| 108 | + titleType: '', | |
| 109 | + itemId: this.$route.query.itemId || '' | |
| 110 | + }, | |
| 111 | + tableData: [], | |
| 112 | + loading: false, | |
| 113 | + pagination: { | |
| 114 | + current: 1, | |
| 115 | + size: 10, | |
| 116 | + total: 0 | |
| 117 | + } | |
| 118 | + } | |
| 119 | + }, | |
| 120 | + created() { | |
| 121 | + this.fetchList() | |
| 122 | + }, | |
| 123 | + methods: { | |
| 124 | + async fetchList() { | |
| 125 | + this.loading = true | |
| 126 | + try { | |
| 127 | + const params = { | |
| 128 | + ...this.searchForm, | |
| 129 | + page: this.pagination.current, | |
| 130 | + row: this.pagination.size, | |
| 131 | + communityId: getCommunityId() | |
| 132 | + } | |
| 133 | + | |
| 134 | + const { data, total } = await listInspectionItemTitle(params) | |
| 135 | + this.tableData = data | |
| 136 | + this.pagination.total = total | |
| 137 | + } catch (error) { | |
| 138 | + this.$message.error(this.$t('common.fetchError')) | |
| 139 | + } finally { | |
| 140 | + this.loading = false | |
| 141 | + } | |
| 142 | + }, | |
| 143 | + handleSearch() { | |
| 144 | + this.pagination.current = 1 | |
| 145 | + this.fetchList() | |
| 146 | + }, | |
| 147 | + handleReset() { | |
| 148 | + this.searchForm = { | |
| 149 | + titleId: '', | |
| 150 | + itemTitle: '', | |
| 151 | + titleType: '', | |
| 152 | + itemId: this.searchForm.itemId | |
| 153 | + } | |
| 154 | + this.handleSearch() | |
| 155 | + }, | |
| 156 | + handleSizeChange(size) { | |
| 157 | + this.pagination.size = size | |
| 158 | + this.fetchList() | |
| 159 | + }, | |
| 160 | + handlePageChange(page) { | |
| 161 | + this.pagination.current = page | |
| 162 | + this.fetchList() | |
| 163 | + }, | |
| 164 | + getTitleTypeName(type) { | |
| 165 | + const types = { | |
| 166 | + '1001': this.$t('inspectionItemTitleManage.singleChoice'), | |
| 167 | + '2002': this.$t('inspectionItemTitleManage.multipleChoice'), | |
| 168 | + '3003': this.$t('inspectionItemTitleManage.shortAnswer') | |
| 169 | + } | |
| 170 | + return types[type] || type | |
| 171 | + }, | |
| 172 | + goBack() { | |
| 173 | + this.$router.go(-1) | |
| 174 | + }, | |
| 175 | + openAddModal() { | |
| 176 | + this.$refs.addModal.open({ | |
| 177 | + itemId: this.searchForm.itemId | |
| 178 | + }) | |
| 179 | + }, | |
| 180 | + openEditModal(row) { | |
| 181 | + this.$refs.editModal.open(row) | |
| 182 | + }, | |
| 183 | + openDeleteModal(row) { | |
| 184 | + this.$refs.deleteModal.open(row) | |
| 185 | + } | |
| 186 | + } | |
| 187 | +} | |
| 188 | +</script> | |
| 189 | + | |
| 190 | +<style scoped> | |
| 191 | +.search-wrapper { | |
| 192 | + margin-bottom: 20px; | |
| 193 | +} | |
| 194 | + | |
| 195 | +.pagination { | |
| 196 | + margin-top: 20px; | |
| 197 | + text-align: right; | |
| 198 | +} | |
| 199 | +</style> | |
| 0 | 200 | \ No newline at end of file | ... | ... |