瀏覽代碼

feat(订单管理): 迁移订单管理模块至 Avue.js 框架

yz 3 周之前
父節點
當前提交
bbb3bb1df7
共有 4 個文件被更改,包括 672 次插入9 次删除
  1. 1 1
      src/router/views/index.js
  2. 328 0
      src/views/order/order/index-avue.vue
  3. 50 8
      src/views/order/order/index.vue
  4. 293 0
      src/views/order/order/option.js

+ 1 - 1
src/router/views/index.js

@@ -93,7 +93,7 @@ export default [
             {
                 path: "index",
                 name: "订单管理",
-                component: () => import("@/views/order/order/index"),
+                component: () => import("@/views/order/order/index-avue"),
                 meta: {
                     keepAlive: true,
                     isAuth: true,

+ 328 - 0
src/views/order/order/index-avue.vue

@@ -0,0 +1,328 @@
+<template>
+  <basic-container>
+    <avue-crud
+      :option="option"
+      :table-loading="loading"
+      :data="data"
+      :page.sync="page"
+      :permission="permissionList"
+      :before-open="beforeOpen"
+      v-model="form"
+      ref="crud"
+      @search-change="searchChange"
+      @search-reset="searchReset"
+      @selection-change="selectionChange"
+      @current-change="currentChange"
+      @size-change="sizeChange"
+      @refresh-change="refreshChange"
+      @on-load="onLoad"
+      @row-update="rowUpdate"
+      @row-save="rowSave"
+      @row-del="rowDel"
+    >
+      <!-- 自定义左侧菜单按钮 -->
+      <template slot="menuLeft">
+        <el-button
+          type="primary"
+          size="small"
+          icon="el-icon-plus"
+          v-if="permission.order_order_add"
+          @click="handleAdd"
+        >
+          新增订单
+        </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>
+
+      <!-- 订单类型显示 -->
+      <template slot="orderType" slot-scope="{row}">
+        <el-tag :type="getOrderTypeTagType(row.orderType)">
+          {{ getOrderTypeLabel(row.orderType) }}
+        </el-tag>
+      </template>
+
+      <!-- 订单总金额显示 -->
+      <template slot="totalAmount" slot-scope="{row}">
+        ¥{{ parseFloat(row.totalAmount || 0).toFixed(2) }}
+      </template>
+
+      <!-- 订单总数量显示 -->
+      <template slot="totalQuantity" slot-scope="{row}">
+        {{ parseFloat(row.totalQuantity || 0).toFixed(4) }}
+      </template>
+
+      <!-- 订单状态显示 -->
+      <template slot="status" slot-scope="{row}">
+        <el-tag :type="getOrderStatusTagType(row.status)">
+          {{ getOrderStatusLabel(row.status) }}
+        </el-tag>
+      </template>
+
+      <!-- 自定义操作菜单 -->
+      <template slot-scope="{row}" slot="menu">
+        <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>
+    </avue-crud>
+
+    <!-- 订单明细管理弹窗 -->
+    <el-dialog
+      title="订单明细管理"
+      :visible.sync="itemDialogVisible"
+      width="1200px"
+      :close-on-click-modal="false"
+      :close-on-press-escape="false"
+      :modal="true"
+      :modal-append-to-body="true"
+      :append-to-body="true"
+      custom-class="order-item-dialog"
+    >
+      <order-item-management
+        v-if="itemDialogVisible"
+        :order-info="currentOrderInfo"
+        :visible="itemDialogVisible"
+        @close="handleItemDialogClose"
+      />
+    </el-dialog>
+  </basic-container>
+</template>
+
+<script>
+import { option } from './option'
+import { getList, add, update, remove, getDetail } from '@/api/order/order'
+import {
+  ORDER_TYPE_LABELS,
+  ORDER_STATUS_LABELS,
+  ORDER_TYPE_TAG_TYPES,
+  ORDER_STATUS_TAG_TYPES,
+  getOrderTypeLabel,
+  getOrderTypeTagType,
+  getOrderStatusLabel,
+  getOrderStatusTagType
+} from './constants'
+import OrderItemManagement from '@/components/order-item-management'
+import { mapGetters } from 'vuex'
+
+export default {
+  name: 'OrderAvue',
+  components: {
+    OrderItemManagement
+  },
+  data() {
+    return {
+      option,
+      data: [],
+      form: {},
+      loading: true,
+      selectionList: [],
+      page: {
+        pageSize: 10,
+        currentPage: 1,
+        total: 0
+      },
+      itemDialogVisible: false,
+      currentOrderId: null,
+      currentOrderInfo: null
+    }
+  },
+  computed: {
+    ...mapGetters(['permission']),
+    permissionList() {
+      return {
+        addBtn: this.permission.order_order_add,
+        viewBtn: this.permission.order_order_view,
+        editBtn: this.permission.order_order_edit,
+        delBtn: this.permission.order_order_delete
+      }
+    }
+  },
+  methods: {
+    // Avue.js 事件处理
+    onLoad(page, params = {}) {
+      this.loading = true
+      getList(page.currentPage, page.pageSize, params).then(res => {
+        const data = res.data.data
+        this.data = data.records
+        this.page.total = data.total
+        this.loading = false
+      }).catch(() => {
+        this.loading = false
+      })
+    },
+
+    searchChange(params, done) {
+      this.onLoad(this.page, params)
+      done()
+    },
+
+    searchReset() {
+      this.onLoad(this.page)
+    },
+
+    selectionChange(list) {
+      this.selectionList = list
+    },
+
+    currentChange(currentPage) {
+      this.page.currentPage = currentPage
+    },
+
+    sizeChange(pageSize) {
+      this.page.pageSize = pageSize
+    },
+
+    refreshChange() {
+      this.onLoad(this.page)
+    },
+
+    beforeOpen(done, type) {
+      if (type === 'add') {
+        this.form = {
+          orderType: 1,
+          status: 0
+        }
+      }
+      done()
+    },
+
+    rowSave(row, done, loading) {
+      add(row).then(() => {
+        this.$message.success('新增成功')
+        this.onLoad(this.page)
+        done()
+      }).catch(() => {
+        loading()
+      })
+    },
+
+    rowUpdate(row, index, done, loading) {
+      update(row).then(() => {
+        this.$message.success('修改成功')
+        this.onLoad(this.page)
+        done()
+      }).catch(() => {
+        loading()
+      })
+    },
+
+    rowDel(row) {
+      this.$confirm('确定将选择数据删除?', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        return remove(row.id)
+      }).then(() => {
+        this.$message.success('删除成功')
+        this.onLoad(this.page)
+      })
+    },
+
+    // 自定义操作方法
+    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)
+      })
+    },
+
+    handleItemManagement(row) {
+      this.currentOrderId = row.id
+      this.currentOrderInfo = {
+        id: row.id,
+        orderCode: row.orderCode,
+        customerName: row.customerName,
+        status: row.status
+      }
+      this.itemDialogVisible = true
+    },
+
+    handleItemDialogClose() {
+      this.itemDialogVisible = false
+      this.currentOrderId = null
+      this.currentOrderInfo = null
+    },
+
+    // 工具方法
+    getOrderTypeLabel,
+    getOrderTypeTagType,
+    getOrderStatusLabel,
+    getOrderStatusTagType
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.order-item-dialog {
+  .el-dialog__body {
+    padding: 10px 20px;
+  }
+}
+</style>

+ 50 - 8
src/views/order/order/index.vue

@@ -89,11 +89,11 @@
             style="width: 200px"
           />
         </el-form-item>
-        <el-form-item>
-          <el-button type="primary" @click="handleSearch" :loading="loading">
+        <el-form-item class="search-buttons">
+          <el-button type="primary" @click="handleSearch" :loading="loading" size="small">
             <i class="el-icon-search"></i> 搜索
           </el-button>
-          <el-button @click="handleResetSearch">
+          <el-button @click="handleResetSearch" size="small">
             <i class="el-icon-refresh"></i> 重置
           </el-button>
         </el-form-item>
@@ -581,15 +581,57 @@ export default {
 
 <style lang="scss" scoped >
 .search-container {
-  background: #fff;
-  padding: 20px;
-  margin-bottom: 20px;
+  background-color: #f8f9fa;
+  border: 1px solid #e9ecef;
   border-radius: 4px;
-  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
+  padding: 15px;
+  margin-bottom: 15px;
 
   .search-form {
     .el-form-item {
-      margin-bottom: 16px;
+      margin-bottom: 10px;
+
+      .el-form-item__label {
+        color: #606266;
+        font-weight: 500;
+      }
+
+      .el-input,
+      .el-select {
+        width: 200px;
+      }
+    }
+    
+    .el-form-item.search-buttons {
+      text-align: right;
+      margin-top: 10px;
+      
+      .el-button {
+        margin-left: 10px;
+        border-radius: 4px;
+        padding: 7px 15px;
+        font-size: 12px;
+        
+        &:first-child {
+          margin-left: 0;
+        }
+        
+        &.el-button--primary {
+          background-color: #409eff;
+          border-color: #409eff;
+          
+          &:hover {
+            background-color: #66b1ff;
+            border-color: #66b1ff;
+          }
+        }
+        
+        &.el-button--small {
+          padding: 7px 15px;
+          font-size: 12px;
+          border-radius: 4px;
+        }
+      }
     }
   }
 }

+ 293 - 0
src/views/order/order/option.js

@@ -0,0 +1,293 @@
+import { ORDER_TYPE_OPTIONS, ORDER_STATUS_OPTIONS } from './constants'
+
+/**
+ * 订单模块 Avue.js 配置
+ */
+export const option = {
+  // 基础配置
+  height: 'auto',
+  calcHeight: 30,
+  tip: false,
+  searchShow: true,
+  searchMenuSpan: 6,
+  border: true,
+  index: true,
+  viewBtn: true,
+  selection: true,
+  dialogClickModal: false,
+  
+  // 列配置
+  column: [
+    {
+      label: '订单编码',
+      prop: 'orderCode',
+      minWidth: 150,
+      search: true,
+      editDisabled: true,
+      addDisplay: false,
+      rules: [{
+        required: true,
+        message: '请输入订单编码',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '组织编码',
+      prop: 'orgCode',
+      minWidth: 120,
+      search: true,
+      rules: [{
+        required: true,
+        message: '请输入组织编码',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '组织名称',
+      prop: 'orgName',
+      minWidth: 200,
+      search: true,
+      rules: [{
+        required: true,
+        message: '请输入组织名称',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '客户编码',
+      prop: 'customerCode',
+      minWidth: 150,
+      search: true,
+      rules: [{
+        required: true,
+        message: '请输入客户编码',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '客户名称',
+      prop: 'customerName',
+      minWidth: 200,
+      search: true,
+      rules: [{
+        required: true,
+        message: '请输入客户名称',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '订单类型',
+      prop: 'orderType',
+      type: 'select',
+      dicData: ORDER_TYPE_OPTIONS,
+      search: true,
+      minWidth: 100,
+      align: 'center',
+      slot: true,
+      rules: [{
+        required: true,
+        message: '请选择订单类型',
+        trigger: 'change'
+      }]
+    },
+    {
+      label: '订单总金额',
+      prop: 'totalAmount',
+      type: 'number',
+      precision: 2,
+      minWidth: 120,
+      align: 'right',
+      slot: true,
+      rules: [{
+        required: true,
+        message: '请输入订单总金额',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '订单总数量',
+      prop: 'totalQuantity',
+      type: 'number',
+      precision: 4,
+      minWidth: 120,
+      align: 'right',
+      slot: true,
+      rules: [{
+        required: true,
+        message: '请输入订单总数量',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '收货人姓名',
+      prop: 'receiverName',
+      minWidth: 120,
+      search: true,
+      rules: [{
+        required: true,
+        message: '请输入收货人姓名',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '收货人电话',
+      prop: 'receiverPhone',
+      minWidth: 130,
+      search: true,
+      rules: [{
+        required: true,
+        message: '请输入收货人电话',
+        trigger: 'blur'
+      }, {
+        pattern: /^1[3-9]\d{9}$/,
+        message: '请输入正确的手机号码',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '收货地址',
+      prop: 'receiverAddress',
+      minWidth: 200,
+      type: 'textarea',
+      span: 24,
+      rules: [{
+        required: true,
+        message: '请输入收货地址',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '订单状态',
+      prop: 'status',
+      type: 'select',
+      dicData: ORDER_STATUS_OPTIONS,
+      search: true,
+      minWidth: 100,
+      align: 'center',
+      slot: true,
+      editDisabled: true,
+      addDisplay: false
+    },
+    {
+      label: '备注',
+      prop: 'remark',
+      type: 'textarea',
+      span: 24,
+      hide: true
+    },
+    {
+      label: '创建时间',
+      prop: 'createTime',
+      type: 'datetime',
+      format: 'yyyy-MM-dd HH:mm:ss',
+      valueFormat: 'yyyy-MM-dd HH:mm:ss',
+      minWidth: 160,
+      editDisabled: true,
+      addDisplay: false
+    },
+    {
+      label: '更新时间',
+      prop: 'updateTime',
+      type: 'datetime',
+      format: 'yyyy-MM-dd HH:mm:ss',
+      valueFormat: 'yyyy-MM-dd HH:mm:ss',
+      minWidth: 160,
+      hide: true,
+      editDisabled: true,
+      addDisplay: false
+    }
+  ]
+}
+
+/**
+ * 订单明细管理配置
+ */
+export const orderItemOption = {
+  height: 'auto',
+  calcHeight: 30,
+  tip: false,
+  searchShow: true,
+  border: true,
+  index: true,
+  selection: true,
+  dialogClickModal: false,
+  
+  column: [
+    {
+      label: '商品编码',
+      prop: 'itemCode',
+      minWidth: 150,
+      search: true,
+      rules: [{
+        required: true,
+        message: '请输入商品编码',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '商品名称',
+      prop: 'itemName',
+      minWidth: 200,
+      search: true,
+      rules: [{
+        required: true,
+        message: '请输入商品名称',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '规格型号',
+      prop: 'specification',
+      minWidth: 150
+    },
+    {
+      label: '单位',
+      prop: 'unit',
+      minWidth: 80,
+      align: 'center'
+    },
+    {
+      label: '数量',
+      prop: 'quantity',
+      type: 'number',
+      precision: 4,
+      minWidth: 100,
+      align: 'right',
+      rules: [{
+        required: true,
+        message: '请输入数量',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '单价',
+      prop: 'unitPrice',
+      type: 'number',
+      precision: 2,
+      minWidth: 100,
+      align: 'right',
+      rules: [{
+        required: true,
+        message: '请输入单价',
+        trigger: 'blur'
+      }]
+    },
+    {
+      label: '金额',
+      prop: 'amount',
+      type: 'number',
+      precision: 2,
+      minWidth: 120,
+      align: 'right',
+      editDisabled: true,
+      addDisplay: false
+    },
+    {
+      label: '备注',
+      prop: 'remark',
+      type: 'textarea',
+      span: 24,
+      hide: true
+    }
+  ]
+}