From e6dd93498f3deaf8898ea1267966e2bba6873ee9 Mon Sep 17 00:00:00 2001 From: xce Date: Wed, 14 Jan 2026 00:09:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82=E6=B8=85=E5=8D=95---?= =?UTF-8?q?=E5=A2=9E=E5=88=A0=E6=94=B9=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/system/require.js | 7 + pages/mine/require/index.vue | 462 ++++++++++++++++++++++++++++------- static/scss/global.scss | 2 + 3 files changed, 379 insertions(+), 92 deletions(-) diff --git a/api/system/require.js b/api/system/require.js index 12825a0..c450789 100644 --- a/api/system/require.js +++ b/api/system/require.js @@ -42,3 +42,10 @@ export function delRequire(id) { method: 'delete' }) } +export function delRequires(ids) { + return request({ + url: '/system/require/remove', + method: 'delete', + data: ids + }) +} diff --git a/pages/mine/require/index.vue b/pages/mine/require/index.vue index e350722..edd65f1 100644 --- a/pages/mine/require/index.vue +++ b/pages/mine/require/index.vue @@ -1,7 +1,7 @@ @@ -145,28 +220,72 @@ import UniTh from "../../../uni_modules/uni-table/components/uni-th/uni-th.vue"; import UniTr from "../../../uni_modules/uni-table/components/uni-tr/uni-tr.vue"; import UniTd from "../../../uni_modules/uni-table/components/uni-td/uni-td.vue"; -import UniPagination from "../../../uni_modules/uni-pagination/components/uni-pagination/uni-pagination.vue"; -import { listRequire } from "../../../api/system/require"; +import {addRequire, delRequire, delRequires, listRequire, updateRequire} from "../../../api/system/require"; import UniTable from "../../../uni_modules/uni-table/components/uni-table/uni-table.vue"; +import UniPopup from "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.vue"; +import UniForms from "../../../uni_modules/uni-forms/components/uni-forms/uni-forms.vue"; +import UniFormsItem from "../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue"; +import UniEasyinput from "../../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue"; +import UniDataSelect from "../../../uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue"; export default { - components: {UniTable, UniPagination, UniTd, UniTr, UniTh }, + components: { + UniTable, UniTd, UniTr, UniTh, + UniPopup, UniForms, UniFormsItem, UniEasyinput, UniDataSelect + }, data() { return { searchVal: '', tableData: [], - pageSize: 10, - pageCurrent: 1, total: 0, - range:[], + // 优先级下拉选项 + priorityList: [ + { value: 0, text: '高' }, + { value: 1, text: '中' }, + { value: 2, text: '低' } + ], + // 进度下拉选项 + progressList: [ + { value: 0, text: '未完成' }, + { value: 1, text: '进行中' }, + { value: 2, text: '已完成' } + ], + // 需求类型下拉选项(可根据实际需求补充) + reqTypeList: [ + { value: 0, text: '功能需求' }, + { value: 1, text: '优化需求' }, + { value: 2, text: 'BUG修复' } + ], form: { - title:null, - detail:null, - priority:null, - progress: null + title: null, + detail: null, + priority: null, + progress: null, + pageNum: 1, + pageSize: 10 }, loading: false, - selectedIndexs: [] // 已选择的行索引 + selectedIndexs: [], // 已选择的行索引 + // 弹窗相关 + dialogType: 'add', // add-新增 edit-编辑 + dialogFormData: { + title: '', + detail: '', + priority: 0, // 默认高 + progress: 0, + reqType: '', + assigneeName: '' + }, + // 表单校验规则 + formRules: { + title: { + rules: [{ required: true, errorMessage: '请输入需求标题' }] + }, + detail: { + rules: [{ required: true, errorMessage: '请输入需求详情' }] + } + }, + currentEditItem: null // 当前编辑的行数据 } }, onLoad() { @@ -177,20 +296,53 @@ export default { selectedItems() { return this.selectedIndexs.map(i => this.tableData[i]) }, - // 多选(修复参数传递) - handleCheckboxChange(e, index) { - if (e.detail.value) { - // 去重处理 - if (!this.selectedIndexs.includes(index)) { - this.selectedIndexs.push(index) - } - } else { - this.selectedIndexs = this.selectedIndexs.filter(item => item !== index) - } + // 补充selection-change事件 + selectionChange(e) { + this.selectedIndexs = e.detail.index + console.info(e) }, + idSort(e) { + if (e["order"] === 'descending') { + this.tableData.sort((a, b) => b.id - a.id); + return; + } + this.tableData.sort((a, b) => a.id - b.id); + }, + prioritySort(e) { + if (e.order === 'descending') { + this.tableData.sort((a, b) => b.priority - a.priority); + return; + } + this.tableData.sort((a, b) => a.priority - b.priority); + }, + // ========== 删除相关方法 ========== // 批量删除 - delTable() { - console.log(this.selectedItems()) + batchDel() { + const selectedItems = this.selectedItems() + if (selectedItems.length === 0) { + uni.showToast({ title: '请选择要删除的数据', icon: 'none' }) + return + } + const selectedIds = selectedItems.map(item => Number(item.id)) + .filter(id => id !== undefined && id !== null && id !== ''); + + uni.showModal({ + title: '提示', + content: `确定要删除选中的${selectedItems.length}条数据吗?`, + success: (res) => { + if (res.confirm) { + delRequires(selectedIds).then((response) => { + if (response.code === 200) { + uni.showToast({ title: '批量删除成功', icon: 'success' }) + } else { + uni.showToast({ title: '批量删除失败', icon: 'error' }) + } + this.getData() + this.selectedIndexs=[] + }) + } + } + }) }, // 分页触发 change(e) { @@ -201,19 +353,11 @@ export default { search() { this.getData() }, - submit(form) { - console.info(form) - }, // 获取数据 - getData(pageCurrent) { + getData(pageNum) { this.loading = true - this.pageCurrent = pageCurrent || this.pageCurrent - const queryParams = { - imei: this.imei, - pageNum: this.pageCurrent, - pageSize: this.pageSize, - } - listRequire(queryParams).then(response => { + this.form.pageNum = pageNum || this.form.pageNum + listRequire(this.form).then(response => { if (response.code === 200 && response.rows) { this.tableData = response.rows this.total = response.total @@ -224,9 +368,93 @@ export default { this.loading = false }) }, - // 补充selection-change事件 - selectionChange(e) { - console.log('表格选中项:', e) + + + // ========== 弹窗相关方法 ========== + // 打开弹窗 + openDialog(type, item = null) { + this.dialogType = type + // 重置表单 + this.dialogFormData = { + title: '', + detail: '', + priority: 0, + progress: 0, + reqType: '', + assigneeName: '' + } + // 编辑模式:回显数据 + if (type === 'edit') { + // 批量编辑取第一个选中项,行内编辑取传入的item + const editItem = item || this.selectedItems()[0] + if (editItem) { + this.currentEditItem = editItem + this.dialogFormData = { ...editItem } + } else { + uni.showToast({ title: '请选择要编辑的数据', icon: 'none' }) + return + } + } + // 打开弹窗 + this.$refs.formDialog.open() + }, + // 关闭弹窗 + closeDialog() { + this.$refs.formDialog.close() + // 重置表单校验 + this.$refs.dialogForm.clearValidate() + }, + // 提交弹窗表单 + submitDialog() { + // 表单校验 + this.$refs.dialogForm.validate().then(() => { + if (this.dialogType === 'add') { + addRequire(this.dialogFormData).then(response => { + if (response.code===200) { + this.$modal.msgSuccess("新增成功") + } else { + this.$modal.msgError("新增失败") + } + this.getData() + }) + } else { + updateRequire(this.dialogFormData).then(response => { + if (response.code===200) { + this.$modal.msgSuccess("修改成功") + } else { + this.$modal.msgError("修改失败") + } + this.getData() + }) + } + // 关闭弹窗并刷新数据 + this.closeDialog() + + }).catch(err => { + console.error('表单校验失败:', err) + }) + }, + + + // 单行删除 + delSingle(item) { + uni.showModal({ + title: '提示', + content: '确定要删除这条数据吗?', + success: (res) => { + if (res.confirm) { + delRequire(item.id).then(response => { + if (response.code === 200) { + uni.showToast({title: '删除成功', icon: 'success'}) + } else { + uni.showToast({title: '删除失败', icon: 'success'}) + } + }) + this.getData() + this.selectedIndexs=[] + } + } + }) } } } @@ -320,7 +548,6 @@ page { height: 30px; } - .form-item { display: flex; align-items: center; @@ -329,5 +556,56 @@ page { margin: 0 !important; /* 清除默认间距 */ } +/* 弹窗样式 */ +.dialog-container { + background: #fff; + border-radius: 10rpx; + padding: 20rpx; + width: 600rpx; +} +.dialog-title { + font-size: 16px; + font-weight: bold; + text-align: center; + padding: 10rpx 0; + border-bottom: 1px solid #eee; + margin-bottom: 10rpx; +} + +.dialog-btn-group { + display: flex; + justify-content: flex-end; + margin-top: 20rpx; + gap: 10rpx; +} + +/* 禁用按钮样式 */ +/deep/ button[disabled] { + background-color: #e5e5e5 !important; + color: #999 !important; + border-color: #ddd !important; +} +/deep/ .uni-forms-item { + margin-bottom: 12rpx; +} + +/deep/ .uni-table-td { + text-align: center !important; +} +.ui-th { + width: auto; + height: 18px; + line-height: 18px; + font-size: 13px; +} +.ui-th:last-child { + width: 160rpx; +} +/deep/ .uni-table-th { + padding: 16rpx 5rpx; +} +.uni-group button:last-child { + margin-left: 0; +} \ No newline at end of file diff --git a/static/scss/global.scss b/static/scss/global.scss index 47a653f..ba6698f 100644 --- a/static/scss/global.scss +++ b/static/scss/global.scss @@ -112,6 +112,8 @@ .del-btn { color: #71e2a3 !important; background: #e7faf0 !important; border-color: #d0f5e0 !important; } /* 编辑按钮 */ .edit-btn { color: #ff9292 !important; background: #ffeded !important; border-color: #ffdbdb !important; } +.cancel-btn { color: #333 !important; background: #f5f5f5 !important; border-color: #f5f5f5 !important; height: 55rpx; line-height: 55rpx; font-size: 14px !important; } +.confirm-btn { color: #fff !important; background: #1890ff !important; border-color: #1890ff !important; height: 55rpx; line-height: 55rpx; font-size: 14px !important; } /* hover统一样式 */ .is-hover {