CashierManagement.vue 5.38 KB
Newer Older
liang ce committed
1 2
<template>
  <div class="cashierManagement">
liang ce committed
3
    <a-button type="primary" style="margin-bottom: 20px" @click="choosePeople">添加收银人</a-button>
liang ce committed
4 5 6 7 8 9 10 11 12
    <div class="searchUserMessage" v-if="searchSource.UserMessage.emplId">
      <div class="positionDiv"></div>
      <div class="clearUserMessage"><a href="javascript:;" @click="clearUserMessage">清除</a></div>
      <img v-if="searchSource.UserMessage.avatar" :src="searchSource.UserMessage.avatar" :alt="searchSource.UserMessage.name"/>
      <img v-else :src="this.avatarCanvasFn(searchSource.UserMessage.name)" :alt="searchSource.UserMessage.name">
      <span>{{ searchSource.UserMessage.name }}</span>
    </div>
    <a-table :columns="columns" :dataSource="cashierManagementList" size="default" rowKey="id" :pagination="pagination" @change="handleTableChange">
      <span slot="name">成员</span>
liang ce committed
13
      <span slot="createDate"></span>
liang ce committed
14
      <span slot="action" slot-scope="text, record, index">
liang ce committed
15 16
        <a v-if="record.status === '0'" href="javascript:;" @click="showModel(record, text, index)">删除</a>
        <a v-else href="javascript:;" style="color:#cccccc">已删除</a>
liang ce committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
      </span>
    </a-table>
  </div>
</template>

<script>
import { config } from './../../../api/config.js'
import { $http } from './../../../api/axios.js'
export default {
  name: 'cashierManagement',
  data () {
    return {
      searchSource: {
        UserMessage: {
          avatar: '',
          emplId: '',
          name: ''
        },
        status: '',
        agentId: ''
      },
      columns: [{
        title: '成员',
        dataIndex: 'name'
      }, {
        title: '时间',
liang ce committed
43
        dataIndex: 'createDate'
liang ce committed
44 45 46 47 48 49 50 51 52
      }, {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' }
      }],
      cashierManagementList: [],
      pagination: {
        current: 1,
        defaultCurrent: 1,
liang ce committed
53
        defaultPageSize: 10,
liang ce committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
        hideOnSinglePage: true,
        total: 0
      }
    }
  },
  watch: {},
  computed: {},
  created: function () {
    this.getCashierList()
  },
  methods: {
    showModel (record, text, index) {
      const _that = this
      this.$confirm({
        title: '确认要删除该收银员吗?',
        content: '删除后,该人员无法在设备上进行收钱操作',
        okText: '确定',
        cancelText: '取消',
        onOk () {
          _that.deleteCashier(record)
        }
      })
    },
    deleteCashier (record) {
liang ce committed
78
      let DeleteCashierData = {
liang ce committed
79 80
        ddUserId: record.userId,
        cashierStatus: '1',
liang ce committed
81 82
        userType: '0',
        id: record.id
liang ce committed
83 84
      }
      $http.get(`/mingpay/v1/isv/cashier/delete_cashier`, DeleteCashierData).then((res) => {
85
        if (res.data.resultCode === 0) {
liang ce committed
86 87 88 89 90 91 92 93 94 95
          this.$message.success('操作成功')
          this.getCashierList()
        } else {
          this.$message.error(res.data.message)
        }
      }).catch(() => {
        this.$message.error('删除失败')
      })
    },
    getCashierList () {
liang ce committed
96
      let CashierListData = {
liang ce committed
97 98
        pageNumber: this.pagination.defaultPageSize,
        currentPage: this.pagination.current,
liang ce committed
99
        userType: '0'
liang ce committed
100 101
      }
      $http.get(`/mingpay/v1/isv/cashier/list_cashier`, CashierListData).then((res) => {
liang ce committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
        this.pagination.total = parseInt(res.data.data.total)
        this.cashierManagementList = res.data.data.list
      }).catch(() => {
        this.$message.error('获取收银员信息失败')
      })
    },
    createTimeToStr (time) {
      let timeData = new Date(parseInt(time))
      let year = timeData.getFullYear()
      let month = timeData.getMonth() + 1
      let date = timeData.getDate()
      let hour = timeData.getHours()
      let minute = timeData.getMinutes()
      return `${year}${month}${date}${hour}:${minute}`
    },
    choosePeople () {
      config.ddready('ddchooseOne').then((res) => {
liang ce committed
119
        let insertCashierData = {
liang ce committed
120 121 122
          cashierName: res[0].name,
          ddUserId: res[0].emplId,
          cashierStatus: '0',
liang ce committed
123
          userType: '0'
liang ce committed
124 125
        }
        $http.get(`/mingpay/v1/isv/cashier/insert_cashier`, insertCashierData).then((res) => {
126
          if (res.data.resultCode === 0) {
liang ce committed
127 128 129 130 131 132
            this.$message.success('添加成功')
            this.getCashierList()
          } else {
            this.$message.error(res.data.message)
          }
        }).catch((err) => {
liang ce committed
133
          this.$message.error('网络异常请重试')
liang ce committed
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
          console.log(err)
        })
      })
    },
    handleTableChange (pagination, filters, sorter) {
      this.pagination.current = pagination.current
      this.getCashierList()
    }
  }
}
</script>

<style lang="less" scoped>
.searchUserMessage{
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 12px;
  padding: 8px 8px;
  border: 1px solid #cccccc;
  margin-bottom: 15px;
  border-radius: 8px;
  position: relative;
}
.searchUserMessage img{
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-bottom: 8px;
}
.positionDiv{
  height: 12px;
  width: 12px;
  transform:rotate(45deg);
  border-left: 1px solid #cccccc;
  border-top: 1px solid #cccccc;
  position: absolute;
  top: -7px;
  left: 30px;
  background: white;
  z-index: 99;
}
.clearUserMessage{
  position: absolute;
  right: 10px;
}
.peopleBox{
  width: 100%;
  border: 1px solid #d9d9d9;
  min-height: 40px;
  border-radius: 4px;
  padding: 4px 11px;
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
}
</style>