lichao пре 3 година
родитељ
комит
49c0341919

+ 14 - 3
src/views/maintenance/integral/config/mainList.json

@@ -9,7 +9,7 @@
   "addBtn": false,
   "align": "center",
   "menuWidth": "120",
-  "menu": false,
+  "menu": true,
   "showSummary": true,
   "searchIcon": true,
   "searchIndex": 2,
@@ -25,7 +25,16 @@
       "index": 1,
       "minWidth": 80,
       "overHidden": true,
-      "searchSpan": 8
+      "searchSpan": 8,
+      "cell": false,
+      "slot": true,
+      "rules": [
+        {
+          "required": true,
+          "message": "请选择客户",
+          "trigger": "blur"
+        }
+      ]
     },{
       "label": "积分",
       "prop": "inPoints",
@@ -33,7 +42,9 @@
       "index": 2,
       "minWidth": 80,
       "overHidden": true,
-      "searchSpan": 8
+      "searchSpan": 8,
+      "cell": false,
+      "slot": true
     },{
       "label": "兑换",
       "prop": "outPoints",

+ 99 - 4
src/views/maintenance/integral/index.vue

@@ -17,11 +17,13 @@
         @saveColumn="saveColumn"
         @resetColumn="resetColumn"
         @expand-change="expandChange"
+        @row-update="rowUpdate"
+        @row-save="rowSave"
       >
         <template slot-scope="scope" slot="expand">
           <el-table :data="scope.row.insideList" v-loading="scope.row.loading">
             <el-table-column  label="发货单号" prop="billNo" align="center" show-overflow-tooltip width="200"></el-table-column>
-            <el-table-column  label="订单号" prop="orderNo" align="center" show-overflow-tooltip width="200"></el-table-column>
+            <el-table-column  label="积分" prop="points" align="center" show-overflow-tooltip width="200"></el-table-column>
             <el-table-column  label="状态" prop="status" align="center" show-overflow-tooltip width="200">
               <template slot-scope="scope">
                 <span>{{ scope.row.status == 0? '正常': '停用' }}</span>
@@ -44,7 +46,49 @@
           ></crop-select>
         </template>
         <template slot-scope="scope" slot="corpId">
-          {{ scope.row.corpName }}
+          <crop-select
+            style="width: 90% !important;display: inline-block"
+            v-if="scope.row.$cellEdit && !scope.row.id"
+            v-model="scope.row.corpId"
+            :cropIndex="scope.index"
+            @getCorpData="getCorpData"
+            corpType="KG"
+          ></crop-select>
+         <span v-else>{{ scope.row.corpName }}</span>
+        </template>
+        <template slot-scope="{row}" slot="inPoints">
+          <el-input
+            v-if="row.$cellEdit"
+            v-model="row.inPoints"
+            placeholder="请输入"
+            size="small"
+            oninput='this.value=this.value.replace(/[^(\d.)]/g,"").replace(/^(\d+)\.(\d\d).*$/, "$1.$2")'
+            @change="pointsChange(row)"
+          ></el-input>
+          <span v-else>{{row.inPoints}}</span>
+        </template>
+        <template slot="menuLeft">
+          <el-button
+            type="primary"
+            icon="el-icon-plus"
+            size="small"
+            @click.stop="rowAdd"
+          >录入明细</el-button>
+        </template>
+        <template slot="menu" slot-scope="{ row, index }">
+          <el-button
+            size="small"
+            icon="el-icon-edit"
+            type="text"
+            @click="rowCell(row, index)"
+          >{{ row.$cellEdit ? "保存" : "修改" }}</el-button>
+          <el-button
+            v-if="!row.id && row.$cellEdit"
+            size="small"
+            icon="el-icon-delete"
+            type="text"
+            @click="rowDelete(row, index)"
+          >删除</el-button>
         </template>
       </avue-crud>
     </basic-container>
@@ -53,7 +97,7 @@
 
 <script>
 import option from './config/mainList.json';
-import {getList, detail} from '@/api/maintenance/integral';
+import {getList, detail, updateList} from '@/api/maintenance/integral';
 
 export default {
   name: "index",
@@ -69,6 +113,7 @@ export default {
       },
       search: {},
       loading: false,
+      savePoints: 0,
     }
   },
   async created() {
@@ -103,6 +148,9 @@ export default {
       this.onLoad(this.page, this.search);
     },
     onLoad(page, params) {
+      this.dataList.forEach(item => {
+        this.$refs.crud.toggleRowExpansion(item, false)
+      })
       this.loading = true;
       getList(page.currentPage, page.pageSize, params)
         .then(res => {
@@ -141,17 +189,64 @@ export default {
       }
     },
     async resetColumn() {
+      this.option = option;
       const inSave = await this.delColumnData(
         this.getColumnName(54),
         option
       );
       if (inSave) {
         this.$message.success("重置成功");
-        this.option = option;
         //关闭窗口
         this.$refs.crud.$refs.dialogColumn.columnBox = false;
       }
     },
+    rowAdd() {
+      const params = {
+        inPoints: 0,
+        outPoints: 0,
+        balancePoints: 0,
+      }
+      this.$refs.crud.rowCellAdd(params);
+    },
+    //编辑
+    rowCell(row, index) {
+      this.$refs.crud.rowCell(row, index)
+      if (row.$cellEdit) {
+        this.savePoints = row.inPoints
+      }
+    },
+    // 修改保存调用
+    rowUpdate(row, index, done) {
+      updateList(row).then(res => {
+        this.$message.success(row.id? '修改成功':'新增成功')
+      })
+      done()
+    },
+    // 新增触发
+    rowSave(row,done,loading) {
+      if (!row.corpId) return this.$message.error('客户不能为空')
+      const repeat = this.dataList.some(item => item.corpId == row.corpId)
+      if (repeat) return this.$message.error('客户已存在')
+      updateList(row).then(res => {
+        this.$message.success(row.id? '修改成功':'新增成功')
+      })
+      done()
+    },
+    // 删除
+    rowDelete(row, index) {
+      this.dataList.splice(index, 1)
+    },
+    getCorpData(row) {
+      this.dataList[row.index].corpName = row.cname;
+    },
+    // 积分变更触发
+    pointsChange(row) {
+      if (Number(row.inPoints) < Number(row.outPoints)) {
+        row.inPoints = this.savePoints
+        return this.$message.error('积分不能小于兑换积分')
+      }
+      row.balancePoints = (Number(row.inPoints) - Number(row.outPoints)).toFixed(2)
+    },
   },
 }
 </script>

+ 4 - 1
src/views/maintenance/overpayment/index.vue

@@ -99,6 +99,9 @@ export default {
       this.onLoad(this.page, this.search);
     },
     onLoad(page, params) {
+      this.dataList.forEach(item => {
+        this.$refs.crud.toggleRowExpansion(item, false)
+      })
       this.loading = true;
       getList(page.currentPage, page.pageSize, params)
         .then(res => {
@@ -137,13 +140,13 @@ export default {
       }
     },
     async resetColumn() {
+      this.option = option;
       const inSave = await this.delColumnData(
         this.getColumnName(53),
         option
       );
       if (inSave) {
         this.$message.success("重置成功");
-        this.option = option;
         //关闭窗口
         this.$refs.crud.$refs.dialogColumn.columnBox = false;
       }

+ 55 - 0
src/views/maintenance/rebate/config/mainList.json

@@ -0,0 +1,55 @@
+{
+  "searchShow": true,
+  "searchMenuSpan": 8,
+  "border": true,
+  "index": true,
+  "viewBtn": false,
+  "editBtn": false,
+  "delBtn": false,
+  "addBtn": false,
+  "align": "center",
+  "menuWidth": "120",
+  "menu": false,
+  "showSummary": true,
+  "searchIcon": true,
+  "searchIndex": 2,
+  "selection": true,
+  "tip":false,
+  "expand": true,
+  "expandWidth": 38,
+  "column": [
+    {
+      "label": "客户",
+      "prop": "corpId",
+      "search": true,
+      "index": 1,
+      "minWidth": 80,
+      "overHidden": true,
+      "searchSpan": 8
+    },{
+      "label": "增加",
+      "prop": "inOverpayment",
+      "search": false,
+      "index": 2,
+      "minWidth": 80,
+      "overHidden": true,
+      "searchSpan": 8
+    },{
+      "label": "使用",
+      "prop": "outOverpaymen",
+      "search": false,
+      "index": 3,
+      "minWidth": 80,
+      "overHidden": true,
+      "searchSpan": 8
+    },{
+      "label": "余额",
+      "prop": "balanceOverpaymen",
+      "search": false,
+      "index": 4,
+      "minWidth": 80,
+      "overHidden": true,
+      "searchSpan": 8
+    }
+  ]
+}

+ 164 - 0
src/views/maintenance/rebate/index.vue

@@ -0,0 +1,164 @@
+<template>
+  <div>
+    <basic-container>
+      <avue-crud
+        :option="option"
+        :data="dataList"
+        ref="crud"
+        v-model="form"
+        :page.sync="page"
+        :search.sync="search"
+        @search-change="searchChange"
+        @current-change="currentChange"
+        @size-change="sizeChange"
+        @refresh-change="refreshChange"
+        @on-load="onLoad"
+        :table-loading="loading"
+        @saveColumn="saveColumn"
+        @resetColumn="resetColumn"
+        @expand-change="expandChange"
+      >
+        <template slot-scope="scope" slot="expand">
+          <el-table :data="scope.row.insideList" v-loading="scope.row.loading">
+            <el-table-column  label="发货单号" prop="billNo" align="center" show-overflow-tooltip width="200"></el-table-column>
+            <el-table-column  label="金额" prop="overpayment" align="center" show-overflow-tooltip width="200"></el-table-column>
+            <el-table-column  label="消费类型" prop="overpaymentType" align="center" show-overflow-tooltip width="200">
+              <template slot-scope="scope">
+                <span>{{ scope.row.overpaymentType == 0? '增加': '消费' }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column  label="创建时间" prop="createTime" align="center" show-overflow-tooltip width="200"></el-table-column>
+            <el-table-column  label="创建人" prop="createUserName" align="center" show-overflow-tooltip width="200"></el-table-column>
+          </el-table>
+        </template>
+        <template slot="corpIdSearch">
+          <crop-select
+            v-model="search.corpId"
+            corpType="KH"
+          ></crop-select>
+        </template>
+        <template slot-scope="scope" slot="corpId">
+          {{ scope.row.corpName }}
+        </template>
+      </avue-crud>
+    </basic-container>
+  </div>
+</template>
+
+<script>
+import option from './config/mainList.json';
+import {getList, overpaymentDetail} from '@/api/maintenance/overpayment';
+
+export default {
+  name: "index",
+  data() {
+    return {
+      option: {},
+      dataList: [],
+      form: {},
+      page: {
+        pageSize: 10,
+        pagerCount: 5,
+        total: 0,
+      },
+      search: {},
+      loading: false,
+    }
+  },
+  async created() {
+    // this.option = option
+    this.option = await this.getColumnData(this.getColumnName(68), option);
+    let i = 0;
+    this.option.column.forEach(item => {
+      if (item.search) i++
+    })
+    if (i % 3 !== 0){
+      const num = 3 - Number(i % 3)
+      this.option.searchMenuSpan = num * 8;
+      this.option.searchMenuPosition = "right";
+    }
+  },
+  methods: {
+    searchChange(params, done) {
+      this.onLoad(this.page, params);
+      done();
+    },
+    currentChange(val) {
+      this.page.currentPage = val;
+    },
+    sizeChange(val) {
+      this.page.currentPage = 1;
+      this.page.pageSize = val;
+    },
+    refreshChange() {
+      this.dataList.forEach(item => {
+        this.$refs.crud.toggleRowExpansion(item, false)
+      })
+      this.page.currentPage = 1;
+      this.onLoad(this.page, this.search);
+    },
+    onLoad(page, params) {
+      this.dataList.forEach(item => {
+        this.$refs.crud.toggleRowExpansion(item, false)
+      })
+      this.loading = true;
+      getList(page.currentPage, page.pageSize, params)
+        .then(res => {
+          this.dataList = res.data.data.records ? res.data.data.records : [];
+          this.page.total = res.data.data.total;
+          if (this.page.total) {
+            this.option.height = window.innerHeight - 260;
+          }
+          this.dataList.forEach(item => {
+            this.$set(item,'insideList',[])
+            this.$set(item,'loading', true)
+          })
+        })
+        .finally(() => {
+          this.loading = false;
+        });
+    },
+    // 表格展开触发
+    expandChange(row, index) {
+      if (row.loading) {
+        overpaymentDetail({pid: row.id}).then(res => {
+          row.insideList = res.data.data? res.data.data.records: []
+          row.loading = false
+        })
+      }
+    },
+    async saveColumn() {
+      const inSave = await this.saveColumnData(
+        this.getColumnName(68),
+        this.option
+      );
+      if (inSave) {
+        this.$message.success("保存成功");
+        //关闭窗口
+        this.$refs.crud.$refs.dialogColumn.columnBox = false;
+      }
+    },
+    async resetColumn() {
+      this.option = option;
+      const inSave = await this.delColumnData(
+        this.getColumnName(68),
+        option
+      );
+      if (inSave) {
+        this.$message.success("重置成功");
+        //关闭窗口
+        this.$refs.crud.$refs.dialogColumn.columnBox = false;
+      }
+    },
+  },
+}
+</script>
+
+<style scoped>
+/deep/ .el-table__expanded-cell .el-table__header-wrapper .cell {
+  font-size: 8px !important;
+}
+/deep/ .el-table__body-wrapper .cell {
+  font-size: 8px;
+}
+</style>