Procházet zdrojové kódy

fix: modify prodList & category

furffico před 1 rokem
rodič
revize
15a80ced4c

+ 23 - 10
src/crud/prod/prodList.js

@@ -1,13 +1,16 @@
+import { row_currencyFormatter } from "@/utils/formatters"
+
 export const tableOption = {
   searchMenuSpan: 6,
   columnBtn: false,
   border: true,
   selection: true,
-  index: false,
-  indexLabel: '序号',
+  // index: true,
+  // indexLabel: '#',
   stripe: true,
   menuAlign: 'center',
-  menuWidth: 350,
+  // menuWidth: 350,
+  menuFixed: false,
   align: 'center',
   refreshBtn: true,
   searchSize: 'mini',
@@ -19,28 +22,38 @@ export const tableOption = {
     label: 'label',
     value: 'value'
   },
-  column: [{
+  column: [
+  {
+    label: "#",
+    prop: "prodId",
+  }, {
     label: '产品名字',
     prop: 'prodName',
-    search: true
+    search: true,
+    minWidth: 300,
   }, {
     label: '商品原价',
-    prop: 'oriPrice'
+    prop: 'oriPrice',
+    formatter: row_currencyFormatter,
+    // sortable: true,
   }, {
     label: '商品现价',
-    prop: 'price'
+    prop: 'price',
+    formatter: row_currencyFormatter,
+    // sortable: true,
   }, {
     label: '商品库存',
-    prop: 'totalStocks'
+    prop: 'totalStocks',
+    // sortable: true,
   }, {
     label: '产品图片',
     prop: 'pic',
     type: 'upload',
-    width: 150,
+    // width: 150,
     listType: 'picture-img'
 
   }, {
-    width: 150,
+    // width: 150,
     label: '状态',
     prop: 'status',
     search: true,

+ 4 - 0
src/utils/formatters.ts

@@ -0,0 +1,4 @@
+
+
+export const currencyFormatter = (v:number) => "¥"+v.toFixed(2)
+export const row_currencyFormatter = (_:any, v:number) => "¥"+v.toFixed(2)

+ 2 - 2
src/views/modules/prod/category-add-or-update.vue

@@ -7,11 +7,11 @@
              ref="dataForm"
              @keyup.enter.native="dataFormSubmit()"
              label-width="80px">
-      <el-form-item v-if="dataForm.type !== 2"
+      <!--el-form-item v-if="dataForm.type !== 2"
                     label="分类图片"
                     prop="pic">
         <pic-upload v-model="dataForm.pic"></pic-upload>
-      </el-form-item>
+      </el-form-item-->
       <el-form-item v-if="dataForm.type !== 2"
                     label="分类名称"
                     prop="categoryName">

+ 12 - 5
src/views/modules/prod/category.vue

@@ -14,21 +14,27 @@
               border
               row-key="categoryId"
               style="width: 100%;">
+      
+      <el-table-column prop="categoryId"
+                       header-align="left"
+                       treeKey="categoryId"
+                       width="150"
+                       label="#">
+      </el-table-column>
 
       <el-table-column prop="categoryName"
                        header-align="center"
-                       treeKey="categoryId"
                        width="150"
                        label="分类名称">
       </el-table-column>
-      <el-table-column prop="pic"
+      <!--el-table-column prop="pic"
                        header-align="center"
                        align="center"
                        label="图片">
         <template slot-scope="scope">
           <img :src="resourcesUrl + scope.row.pic " />
         </template>
-      </el-table-column>
+      </el-table-column-->
       <el-table-column prop="status"
                        header-align="center"
                        align="center"
@@ -44,7 +50,7 @@
       <el-table-column prop="seq"
                        header-align="center"
                        align="center"
-                       label="排序号">
+                       label="优先级">
       </el-table-column>
       <el-table-column 
                        header-align="center"
@@ -98,7 +104,8 @@ export default {
         method: 'get',
         params: this.$http.adornParams()
       }).then(({ data }) => {
-        this.dataList = treeDataTranslate(data, 'categoryId', 'parentId')
+        // this.dataList = treeDataTranslate(data, 'categoryId', 'parentId')
+        this.dataList = treeDataTranslate(data, 'parentId')
         this.dataListLoading = false
       })
     },

+ 5 - 1
src/views/modules/prod/prodList.vue

@@ -8,7 +8,8 @@
                :option="tableOption"
                @search-change="searchChange"
                @selection-change="selectionChange"
-               @on-load="getDataList">
+               @on-load="getDataList"
+               @row-update="onedit">
       <template slot="menuLeft">
         <el-button type="primary"
                    icon="el-icon-plus"
@@ -73,6 +74,9 @@ export default {
     }
   },
   methods: {
+    onedit(...data){
+      console.log(...data)
+    },
     // 获取数据列表
     getDataList (page, params, done) {
       this.dataListLoading = true