瀏覽代碼

Merge branch 'dev-furffico'

furffico 1 年之前
父節點
當前提交
93816c8813

+ 60 - 0
src/avue/crud/orderList.js

@@ -0,0 +1,60 @@
+export const order = {
+  columns: [
+    {
+      title: "编号",
+      dataIndex: "id",
+    },
+    {
+      title: "订单号",
+      dataIndex: "orderNo",
+    },
+    {
+      title: "下单人",
+      dataIndex: "addressName",
+    },
+    {
+      title: "订单金额",
+      dataIndex: "totalFee",
+    },
+    {
+      title: "支付方式",
+      dataIndex: "payType",
+    },
+    {
+      title: "订单状态",
+      dataIndex: "status",
+    },
+    {
+      title: "操作",
+      dataIndex: "action",
+      scopedSlots: { customRender: "action" },
+    },
+  ],
+  condition: [
+    {
+      title: "手机号",
+      dataIndex: "phone",
+      type: "input",
+    },
+    {
+      title: "订单状态",
+      dataIndex: "status",
+      type: "select",
+      defaultValue: '全部',
+      options: [
+        {
+          label: "全部",
+          value: "全部",
+        },
+        {
+          label: "待支付",
+          value: "待支付",
+        },
+        {
+          label: "已支付",
+          value: "已支付",
+        },
+      ],
+    },
+  ],
+}

+ 198 - 0
src/views/modules/order/order-BaseTable.vue

@@ -0,0 +1,198 @@
+<template>
+  <div class="table-wrap" v-loading='loading'>
+    <div class="table-page-search-wrapper" v-if="condition.length">
+      <el-form :inline="true" class="demo-form-inline" label-width='80px' size="small">
+        <el-row :gutter='10'>
+          <el-col :span='span' v-for='v in condition' :key='v.dataIndex'>
+            <el-form-item :label="layout === 'include' ? '' : v.title" style="display: flex">
+              <el-input v-model='queryParam[v.dataIndex]' :placeholder="layout === 'include' ? v.title : '请输入'"
+                v-if="v.type === 'input'" clearable />
+              <el-date-picker v-model='queryParam[v.dataIndex]' valueFormat="YYYY-MM-DD"
+                v-else-if="v.type === 'time-range'" :placeholder="layout === 'include' ? v.title : '请选择'" />
+              <el-select v-model='queryParam[v.dataIndex]' :placeholder="layout === 'include' ? v.title : '请选择'"
+                :default-value='v.defaultValue' v-else-if="v.type === 'select'" clearable>
+                <el-option :value='v1.value' :label="v1.label" v-for='v1 in v.options' :key='v1.value'></el-option>
+              </el-select>
+            </el-form-item>
+          </el-col>
+          <el-col :span='24 - condition.length % (24 / span) * span'>
+            <span class="table-page-search-submitButtons">
+              <el-button type="primary" @click='onQueryClick' size="small">
+                查询
+              </el-button>
+              <el-button style="margin-left: 8px" @click='reset' size="small">
+                重置
+              </el-button>
+              <slot name='append-btn'></slot>
+            </span>
+          </el-col>
+        </el-row>
+      </el-form>
+    </div>
+    <el-table :data='tableData' style="margin: 6px 0;" v-bind="$attrs" v-on='$listeners' ref='table'>
+      <el-table-column type="selection" width="55" v-if="isSelection">
+      </el-table-column>
+      <el-table-column v-bind='v' :prop='v.dataIndex' :label='v.title' v-for="(v, i) in columns" :key='i'>
+        <template slot-scope="scope">
+          <!-- 格式化函数 -->
+          <span
+            v-if="v.scopedSlots && v.scopedSlots.customRender && Object.prototype.toString.call(v.scopedSlots.customRender) === '[object Function]'">
+            {{ v.scopedSlots.customRender(scope.row[v.dataIndex], scope.row, scope.$index) }}
+          </span>
+          <!-- 格式化插槽 -->
+          <slot v-else-if="v.scopedSlots && v.scopedSlots.customRender" v-bind='scope' :name="v.scopedSlots.customRender">
+          </slot>
+          <span v-else>{{ scope.row[v.dataIndex] }}</span>
+        </template>
+      </el-table-column>
+    </el-table>
+    <el-pagination :layout="paginationSize === 'mini' ? 'prev, pager, next' : 'total, sizes, prev, pager, next, jumper'"
+      :currentPage.sync='localPagination.currentPage' :pageCount.sync='localPagination.totalPage'
+      :style="paginationSize === 'mini' ? 'display: flex;justify-content: center;' : 'display: flex;justify-content: flex-end;'"
+      :page-sizes="[5, 10, 20, 30, 50]" @size-change="queryTable" @current-change="queryTable" v-if='showPagination'>
+    </el-pagination>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'BaseTable',
+  props: {
+    columns: {
+      default: () => [],
+      required: true,
+    },
+    condition: {
+      default: () => [],
+      required: false
+    },
+    queryFunction: {
+      required: false
+    },
+    pagination: {
+      required: false,
+      default: () => ({
+        pageSize: 10,
+      }),
+    },
+    paginationText: {
+      required: false,
+      default: () => ({
+        currentPage: 'currentPage', total: 'total', totalPage: 'totalPage', data: 'data'
+      }),
+    },
+    span: {
+      required: false,
+      default: 6
+    },
+    paginationSize: {
+      required: false,
+      default: 'small'
+    },
+    layout: {
+      required: false,
+      default: 'normal'
+    },
+    // 无需查询的静态数据
+    injectData: {
+      required: false,
+      default: null
+    },
+    isSelection: {
+      required: false,
+      default: false
+    },
+    rowKey: {
+      required: false,
+      default: 'id'
+    },
+  },
+  data() {
+    return {
+      tableData: [],
+      queryParam: {}, // 暂存
+      confirmParam: {}, // 点击查询键后赋值
+
+      localPagination: Object.assign({
+        currentPage: 1,
+        total: 10
+      }, this.pagination),
+      loading: false,
+
+      selectedRows: [],
+      selectedRowKeys: [],
+
+      showPagination: true
+    };
+  },
+  async created() {
+    this.condition.forEach(v => {
+      v.defaultValue && this.$set(this.queryParam, v.dataIndex, v.defaultValue)
+    })
+    if (this.injectData) {
+      this.tableData = this.injectData
+      this.showPagination = false
+    } else {
+      this.queryTable()
+    }
+  },
+  watch: {
+    injectData: {
+      handler(v) {
+        this.tableData = v
+      },
+      deep: true
+    }
+  },
+  methods: {
+    async submit() {
+    },
+    onQueryClick() {
+      this.confirmParam = JSON.parse(JSON.stringify(this.queryParam))
+      this.localPagination.currentPage = 1
+      this.queryTable()
+    },
+    async queryTable() {
+      this.loading = true
+      try {
+        const { confirmParam, paginationText, localPagination } = this
+        const queryParamFilter = {}
+        Object.keys(confirmParam).forEach(key => confirmParam[key] && (queryParamFilter[key] = confirmParam[key]))
+        const queryResult = await this.queryFunction(
+          {
+            [paginationText.currentPage]: localPagination.currentPage,
+            query: queryParamFilter
+          }
+        )
+        this.tableData = queryResult[paginationText.data]
+        this.localPagination = {
+          currentPage: queryResult[paginationText.currentPage],
+          total: queryResult[paginationText.total],
+          totalPage: queryResult[paginationText.totalPage]
+        }
+      } finally {
+        this.loading = false
+      }
+    },
+    reset() {
+      this.queryParam = {}
+      this.confirmParam = {}
+      this.queryTable()
+    },
+    /**
+     * 表格重新加载方法
+     * 如果参数为 true, 则强制刷新到第一页
+     * @param Boolean bool
+     */
+    refresh(bool = false) {
+      bool && (this.localPagination.currentPage = 1)
+      this.queryTable()
+    },
+    test(v) {
+      console.log(v)
+    }
+  },
+};
+</script>
+
+<style lang="scss" scoped></style>

+ 2 - 2
src/views/modules/order/order.vue

@@ -14,8 +14,8 @@
 </template>
 
 <script>
-import BaseTable from "./Table/BaseTable.vue"
-import * as tableConfig from './Table/table.config'
+import BaseTable from "./order-BaseTable.vue"
+import * as tableConfig from '@/avue/crud/orderList'
 import showDialog from "./showDialog.vue"
 export default {
   data() {

+ 3 - 2
src/views/modules/order/showDialog.vue

@@ -1,5 +1,6 @@
 <template>
-    <el-dialog title="订单详情" :visible.sync="dialogVisible" width="50%" top="7vh" v-loading="loading" :destroy-on-close="true">
+    <el-dialog title="订单详情" :visible.sync="dialogVisible" width="50%" top="7vh" v-loading="loading"
+        :destroy-on-close="true">
         <el-form :model="form" :label-position="formLabelWidth" label-width="120px" size="mini" class="form-wrap">
             <el-form-item label="下单时间">
                 <el-input v-model="form.paidAt" disabled></el-input>
@@ -29,7 +30,7 @@
 </template>
 
 <script>
-import BaseTable from "./Table/BaseTable.vue"
+import BaseTable from "./order-BaseTable.vue"
 export default {
     name: 'showDialog',
     components: { BaseTable, },

+ 1 - 0
src/views/modules/prod/prodInfo.vue

@@ -53,6 +53,7 @@ export default Vue.extend({
         this.categories = data.goodsTypeList
       })
     },
+    // @ts-ignore
     onSubmit(form: typeof this.form, done: Function) {
       console.log(form)
       // TODO

+ 1 - 1
vue.config.js

@@ -46,7 +46,7 @@ module.exports = {
     devServer:{
       proxy: {
         // "^/user": {target: "http://192.168.58.137:10086"},
-        "^/(user|goods|goodsTypes)/": {target: "http://127.0.0.1:10086"},
+        "^/(user|goods|goodsTypes|order)/": {target: "http://127.0.0.1:10086"},
         "^/.*": {target: "http://116.63.32.160:8085"},
       },
     }