Bläddra i källkod

refactor(订单管理): 移除删除功能并优化代码结构

yz 1 månad sedan
förälder
incheckning
36682c48bf
2 ändrade filer med 117 tillägg och 79 borttagningar
  1. 74 78
      src/views/order/order/index-avue.vue
  2. 43 1
      src/views/order/order/option.js

+ 74 - 78
src/views/order/order/index-avue.vue

@@ -31,17 +31,7 @@
         >
           新增订单
         </el-button>
-        <el-button
-          type="danger"
-          size="small"
-          plain
-          icon="el-icon-delete"
-          v-if="permission.order_order_delete"
-          @click="handleBatchDelete"
-          :disabled="selectionList.length === 0"
-        >
-          批量删除
-        </el-button>
+
       </template>
 
       <!-- 订单类型显示 -->
@@ -73,29 +63,11 @@
         <el-button
           type="text"
           size="small"
-          icon="el-icon-view"
-          @click="handleView(row)"
-        >
-          查看
-        </el-button>
-        <el-button
-          type="text"
-          size="small"
           icon="el-icon-document"
           @click="handleItemManagement(row)"
         >
           明细管理
         </el-button>
-        <el-button
-          type="text"
-          size="small"
-          icon="el-icon-delete"
-          @click="handleDelete(row)"
-          v-if="permission.order_order_delete"
-          style="color: #f56c6c"
-        >
-          删除
-        </el-button>
       </template>
 
       <!-- 行展开插槽 - 显示订单明细 -->
@@ -136,7 +108,7 @@
 
 <script>
 import { option } from './option'
-import { getList, add, update, remove, getDetail } from '@/api/order/order'
+import { getList, add, update, getDetail } from '@/api/order/order'
 import {
   ORDER_TYPES,
   ORDER_STATUS,
@@ -185,6 +157,14 @@ export default {
   },
   methods: {
     // Avue.js 事件处理
+    /**
+     * 加载表格数据
+     * @param {Object} page - 分页信息
+     * @param {number} page.currentPage - 当前页码
+     * @param {number} page.pageSize - 每页大小
+     * @param {Object} params - 查询参数
+     * @returns {void}
+     */
     onLoad(page, params = {}) {
       this.loading = true
       getList(page.currentPage, page.pageSize, params).then(res => {
@@ -197,31 +177,66 @@ export default {
       })
     },
 
+    /**
+     * 搜索条件变化回调
+     * @param {Object} params - 搜索参数
+     * @param {Function} done - 完成回调
+     * @returns {void}
+     */
     searchChange(params, done) {
       this.onLoad(this.page, params)
       done()
     },
 
+    /**
+     * 重置搜索条件回调
+     * @returns {void}
+     */
     searchReset() {
       this.onLoad(this.page)
     },
 
+    /**
+     * 表格选择变化回调
+     * @param {Array} list - 选中的行数据列表
+     * @returns {void}
+     */
     selectionChange(list) {
       this.selectionList = list
     },
 
+    /**
+     * 当前页码变化回调
+     * @param {number} currentPage - 当前页码
+     * @returns {void}
+     */
     currentChange(currentPage) {
       this.page.currentPage = currentPage
     },
 
+    /**
+     * 每页大小变化回调
+     * @param {number} pageSize - 每页大小
+     * @returns {void}
+     */
     sizeChange(pageSize) {
       this.page.pageSize = pageSize
     },
 
+    /**
+     * 刷新表格回调
+     * @returns {void}
+     */
     refreshChange() {
       this.onLoad(this.page)
     },
 
+    /**
+     * 表单打开前回调
+     * @param {Function} done - 完成回调
+     * @param {string} type - 操作类型 ('add'|'edit'|'view')
+     * @returns {void}
+     */
     beforeOpen(done, type) {
       if (type === 'add') {
         this.form = {
@@ -232,6 +247,13 @@ export default {
       done()
     },
 
+    /**
+     * 保存新增订单
+     * @param {Object} row - 订单数据
+     * @param {Function} done - 完成回调
+     * @param {Function} loading - 加载状态回调
+     * @returns {void}
+     */
     rowSave(row, done, loading) {
       add(row).then(() => {
         this.$message.success('新增成功')
@@ -242,6 +264,14 @@ export default {
       })
     },
 
+    /**
+     * 更新订单数据
+     * @param {Object} row - 订单数据
+     * @param {number} index - 行索引
+     * @param {Function} done - 完成回调
+     * @param {Function} loading - 加载状态回调
+     * @returns {void}
+     */
     rowUpdate(row, index, done, loading) {
       update(row).then(() => {
         this.$message.success('修改成功')
@@ -252,59 +282,21 @@ export default {
       })
     },
 
-    rowDel(row) {
-      this.$confirm('确定将选择数据删除?', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        return remove(row.id)
-      }).then(() => {
-        this.$message.success('删除成功')
-        this.onLoad(this.page)
-      })
-    },
 
-    // 自定义操作方法
+
+    /**
+     * 处理新增订单
+     * @returns {void}
+     */
     handleAdd() {
       this.$refs.crud.rowAdd()
     },
 
-    handleView(row) {
-      this.$refs.crud.rowView(row)
-    },
-
-    handleDelete(row) {
-      this.$confirm('确定删除该订单吗?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        return remove(row.id)
-      }).then(() => {
-        this.$message.success('删除成功')
-        this.onLoad(this.page)
-      })
-    },
-
-    handleBatchDelete() {
-      if (this.selectionList.length === 0) {
-        this.$message.warning('请选择要删除的数据')
-        return
-      }
-      
-      this.$confirm('确定删除选中的订单吗?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        const ids = this.selectionList.map(item => item.id).join(',')
-        return remove(ids)
-      }).then(() => {
-        this.$message.success('删除成功')
-        this.onLoad(this.page)
-      })
-    },
+    /**
+     * 处理订单明细管理
+     * @param {OrderRecord} row - 订单行数据
+     * @returns {void}
+     */
 
     handleItemManagement(row) {
       this.currentOrderId = row.id
@@ -317,6 +309,10 @@ export default {
       this.itemDialogVisible = true
     },
 
+    /**
+     * 处理订单明细弹窗关闭
+     * @returns {void}
+     */
     handleItemDialogClose() {
       this.itemDialogVisible = false
       this.currentOrderId = null

+ 43 - 1
src/views/order/order/option.js

@@ -1,7 +1,46 @@
 import { ORDER_TYPE_OPTIONS, ORDER_STATUS_OPTIONS, ORDER_ITEM_STATUS_OPTIONS } from '@/constants'
 
 /**
+ * @typedef {Object} ColumnConfig
+ * @property {string} label - 列标签
+ * @property {string} prop - 列属性名
+ * @property {number} [minWidth] - 最小宽度
+ * @property {boolean} [search] - 是否可搜索
+ * @property {string} [type] - 列类型
+ * @property {Array} [dicData] - 字典数据
+ * @property {string} [align] - 对齐方式
+ * @property {boolean} [slot] - 是否使用插槽
+ * @property {boolean} [editDisabled] - 编辑时是否禁用
+ * @property {boolean} [addDisplay] - 新增时是否显示
+ * @property {boolean} [hide] - 是否隐藏
+ * @property {number} [precision] - 数字精度
+ * @property {number} [span] - 表单占用列数
+ * @property {Array<Object>} [rules] - 验证规则
+ */
+
+/**
+ * @typedef {Object} AvueOption
+ * @property {string} height - 表格高度
+ * @property {number} calcHeight - 计算高度偏移
+ * @property {boolean} tip - 是否显示提示
+ * @property {boolean} searchShow - 是否显示搜索
+ * @property {number} searchMenuSpan - 搜索菜单占用列数
+ * @property {boolean} border - 是否显示边框
+ * @property {boolean} index - 是否显示序号
+ * @property {boolean} viewBtn - 是否显示查看按钮
+ * @property {boolean} editBtn - 是否显示编辑按钮
+ * @property {boolean} delBtn - 是否显示删除按钮
+ * @property {boolean} selection - 是否显示选择框
+ * @property {boolean} dialogClickModal - 弹窗点击遮罩是否关闭
+ * @property {boolean} expand - 是否启用行展开
+ * @property {Array} expandRowKeys - 默认展开的行
+ * @property {boolean} defaultExpandAll - 是否默认展开所有行
+ * @property {Array<ColumnConfig>} column - 列配置
+ */
+
+/**
  * 订单模块 Avue.js 配置
+ * @type {AvueOption}
  */
 export const option = {
   // 基础配置
@@ -13,6 +52,8 @@ export const option = {
   border: true,
   index: true,
   viewBtn: true,
+  editBtn: true,
+  delBtn: false, // 禁用删除按钮
   selection: true,
   dialogClickModal: false,
   // 行展开配置
@@ -204,7 +245,8 @@ export const option = {
 }
 
 /**
- * 订单明细管理配置
+ * 订单明细配置
+ * @type {AvueOption}
  */
 export const orderItemOption = {
   height: 'auto',