|  | @@ -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>
 |