index1.vue 9.18 KB
<template>
  <d2-container>
    <div class="measurement-header">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="收入测算" name="first">
        </el-tab-pane>
        <el-tab-pane label="收入测算配置" name="second">
          <div class="d2-container-content">
            <div class="app-config">
              展业助手收入测算入口配置:
              <el-radio-group v-model="configFlag" @change="radioChange">
                <el-radio :label="0">会员全开</el-radio>
                <el-radio :label="1">会员关闭</el-radio>
                <el-radio :label="2">白名单开启</el-radio>
              </el-radio-group>
            </div>
            <template v-if="configFlag == '2'">
              <div class="theader">
                <h2>白名单管理</h2>
                <div>
                  <el-button @click="handleAdd" size="small" type="primary">
                    增加
                  </el-button>
                </div>
              </div>
              <d2-table ref="measurementConfigTable" :hasNum="false" :get-list-api="getListApi"
                :search-form="searchFormSearch" :table-params="tableParams">
                <template slot="auth-button" slot-scope="scope">
                  <el-button type="text" @click="delWhite(scope.scope)">删除</el-button>
                </template>
              </d2-table>
            </template>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <template v-if="activeName == 'first'">
      <d2-table ref="measurementTable" :search-form="searchForm" :table-params="measurementTableParams"></d2-table>
    </template>
    <el-dialog class="white-dialog" title="新增白名单" :visible.sync="dialogVisible" width="668px"
      :before-close="handleClose" :close-on-click-modal="false">
      <el-form ref="whiteForm" class="white-form" :model="whiteForm" label-width="150px">
        <el-form-item label="手机号码:">
          <el-input v-model="whiteForm.staffPhone" placeholder="请输入手机号码"></el-input>
        </el-form-item>
        <div class="line"></div>
        <el-form-item label="员工姓名:">
          {{whiteForm.staffName}}
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
      <template v-if="whiteForm.staffName">
        <el-button type="primary" @click="addWhite">加入白名单</el-button>
      </template>
      <template v-else>
        <el-button type="primary" @click="searchStaff">查询</el-button>
        <el-button @click="dialogVisible = false">取 消</el-button>
      </template>
      </span>
    </el-dialog>
  </d2-container>
</template>

<script>
import { getWhiteStaff, getSwitchConfig, addSwitchConfig, getStaffInfo, addWhiteStaff, delWhiteStaff } from "@api/resident"
export default {
  data() {
    return {
      activeName: 'first',
      // 收入测算
      searchForm: {},
      labelWidth: '110px',
      showFormData: [
        {
          label: '员工姓名',
					name: 'staffName',
          type: 'input'
        },
        {
          label: '电话号码',
          name: 'staffPhone',
          type: 'input'
        },
        {
          label: '门店名称',
          name: 'merchantName',
          type: 'input'
        },
        {
          label: '所属业务',
          name: 'staffPhone',
          type: 'select',
          optionId: 'value',
					optionLabel: 'label',
          optionList: [
            {
              label: '全部',
              value: ''
            },
            {
              label: '会员权益/升级',
              value: '0'
            },
            {
              label: '轻改',
              value: '1'
            }
          ]
        },
        {
          label: '产品名称',
          name: 'staffPhone',
          type: 'input'
        },
        {
          label: '品牌',
          name: 'staffPhone',
          type: 'input'
        },
        {
          label: '测算收入日期',
          name: 'staffPhone',
          type: 'input'
        }
      ],
      measurementTableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableColumns: [
          {
            label: '姓名',
            prop: 'staffName'
          },
          {
            label: '电话号码',
            prop: 'staffName'
          },
          {
            label: '职级',
            prop: 'staffName'
          },
          {
            label: '服务门店',
            prop: 'staffName'
          },
          {
            label: '所属业务',
            prop: 'staffName'
          },
          {
            label: '品牌',
            prop: 'staffName'
          },
          {
            label: '应触客台数',
            prop: 'staffName'
          },
          {
            label: '产值',
            prop: 'staffName'
          },
          {
            label: '成交量',
            prop: 'staffName'
          },
          {
            label: '渗透率',
            prop: 'staffName'
          },
          {
            label: '提成系数',
            prop: 'staffName'
          },
          {
            label: '提成比例',
            prop: 'staffName'
          },
          {
            label: '客单价',
            prop: 'staffName'
          },
          {
            label: '客单价提成系数',
            prop: 'staffName'
          },
          {
            label: '提成金额',
            prop: 'staffName'
          },
          {
            label: '测算收入日期',
            prop: 'staffName'
          },
        ]
      },
      // 收入测算配置
      configFlag: 0,
      getListApi: getWhiteStaff,
      searchFormSearch: {},
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '员工姓名',
            prop: 'staffName'
          },
          {
            label: '电话号码',
            prop: 'staffPhone'
          },
          {
            label: '适配业务',
            prop: 'staffScenes'
          },
          {
            label: '服务门店',
            prop: 'serviceMerchantName'
          }
        ]
      },
      dialogVisible: false,
      whiteForm: {
        staffName: '',
        staffPhone: ''
      }
    }
  },
  created() {
    this.getSwitch()
  },
  methods: {
    // 查询测试配置开关
    async getSwitch() {
      const res = await getSwitchConfig()
      this.configFlag = res.configFlag
    },
    handleAdd() {
      console.log('111');
      this.dialogVisible = true
    },
    handleClose() {
      this.dialogVisible = false
      this.whiteForm = {
        staffName: '',
        staffPhone: ''
      }
    },
    handleClick(tab) {
      console.log(tab);
    },
    radioChange(e) {
      console.log(e);
      addSwitchConfig({ configFlag: e }).then(res => {
        console.log(res)
        if (res) this.$message.success('修改成功')
      })
    },
    // 查询员工
    searchStaff() {
      const {staffPhone} = this.whiteForm
      if (!staffPhone) return this.$message.error('请输入手机号码')
      getStaffInfo({staffPhone: this.whiteForm.staffPhone}).then(res => {
        console.log(res);
        if (res) {
          this.whiteForm.staffName = res.staffName
        } else {
          this.$message.error('不存在该直营驻店人员')
        }        
      })
    },
    // 加入白名单
    addWhite() {
      const {staffPhone, staffName} = this.whiteForm
      addWhiteStaff({staffPhone, staffName}).then(res => {
        console.log(res);
        if (res) {
          this.$message.success('修改成功')
          this.$refs.measurementConfigTable.refreshTable(true, true)
          this.handleClose()
        }
      })
    },
    delWhite(row) {
      console.log(row);
      delWhiteStaff({id: row.id}).then(res => {
        if (res) {
          this.$message.success('删除成功')
          this.$refs.measurementConfigTable.refreshTable(true, true)
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.measurement-header {
  background-color: #fff;

  // padding: 0 20px;
  .app-config {
    color: #333333;
    font-size: 16px;
    padding: 12.5px 20px;
    background-color: #F8FAFF;
    // margin: 0 20px;
  }

  .d2-container-content {
    margin-top: 0 !important;
    padding: 0 20px 20px !important;
  }

  .theader {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;

    h2 {
      font-weight: 600;
      font-size: 16px;
      color: #333333;
    }
  }
}
.white-form {
  height: 108px;
  .line {
    width: 100%;
    height: 1px;
    background-color: #E5E5E5;
    margin-bottom: 20px;
  }
}

</style>
<style lang="scss">
.measurement-header {
  #tab-first {
    padding-left: 20px !important;
  }

  .el-tabs__nav-wrap {
    line-height: 54px;

    .el-tabs__item {
      font-size: 16px !important;
    }
  }
}
.white-dialog {
  .el-dialog__header {
    border-bottom: 1px solid #E5E5E5 !important;
  }
  .el-dialog__footer {
    border-top: 1px solid #E5E5E5 !important;
    padding: 14px 20px !important;

    .el-button {
      width: auto;
    }
  }
}
</style>