| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- <template>
- <div class="store_page">
- <div class="page_header">
- <div class="header_left">
- <div class="header_label">用户管理</div>
- </div>
- <div class="header_right">
- <userBox />
- </div>
- </div>
- <div class="filter_box">
- <div class="filter_left">
- <div class="filter_item">
- <label>手机号:</label>
- <Input v-model="phone" icon="ios-search" placeholder="请输入" clearable @on-change="handleSearch" />
- </div>
- <div class="filter_item">
- <label>经销商:</label>
- <Select v-model="storeId" clearable @on-change="handleSearch">
- <Option v-for="item in storeList" :key="item.id" :value="item.id" :label="item.name">
- {{ item.name }}</Option>
- </Select>
- </div>
- </div>
- <div class="filter_right">
- <div class="add_btn" @click="handleAdd">新增用户</div>
- </div>
- </div>
- <div class="page_content" ref="tableContent">
- <div class="table_content">
- <!--表格-->
- <Table row-key="id" :loading="loading" :height="tableHeight" :columns="tableColumns" :data="tableData">
- </Table>
- <!-- 分页 -->
- <Page :total="total" :current="currentPage" show-total show-sizer @on-change="handleCurrentChange"
- @on-page-size-change="handlePageSize" :page-size-opts="pageSizeOpts" />
- </div>
- </div>
- <Modal scrollable v-model="showDialog" width="442">
- <div slot="header">
- <p>{{ formValidate.id ? '编辑用户' : '新增用户' }}</p>
- </div>
- <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="120">
- <FormItem :label="`手机号:`" prop="phone">
- <Input v-model="formValidate.phone" :maxlength="11" placeholder="请输入"></Input>
- </FormItem>
- <FormItem label="经销商:" prop="storeId">
- <Select v-model="formValidate.storeId" transfer @on-change="getWxcpMemberList">
- <Option v-for="item in storeList" :key="item.id" :value="item.id" :label="item.name">
- {{ item.name }}</Option>
- </Select>
- </FormItem>
- <FormItem :label="`短信模板ID:`">
- <Input v-model="formValidate.smsAfterCallParam" placeholder="请输入" />
- </FormItem>
- <FormItem label="绑定企微:" v-if="formValidate.storeId">
- <Select v-model="formValidate.wxcpMemberId" transfer clearable @on-clear="handleClearWxcpMemberId">
- <Option v-for="item in wxcpMemberList" :key="item.memberId" :value="item.memberId"
- :label="item.name">
- {{ item.name }}</Option>
- </Select>
- </FormItem>
- </Form>
- <template slot="footer">
- <Button class="cancel-btn" @click="showDialog = false">取消</Button>
- <Button class="confirm-btn" type="primary" :loading="btnLoading"
- @click="handleOk('formValidate')">确定</Button>
- </template>
- </Modal>
- </div>
- </template>
- <script>
- import { mapState } from 'vuex'
- import { debounce, checkPhone } from '@/utils'
- import userBox from '@/pages/platform/components/userBox'
- import tablePageMixin from '_m/tablePage.mixin'
- export default {
- mixins: [tablePageMixin],
- components: {
- userBox
- },
- data() {
- return {
- loading: false,
- btnLoading: false,
- tableData: [],
- showDialog: false,
- formValidate: {
- id: undefined,
- phone: undefined,
- smsAfterCallParam: undefined,
- storeId: undefined,
- wxcpMemberId: undefined,
- },
- ruleValidate: {
- phone: [
- { required: true, validator: this.handleValidatePhone.bind(this), trigger: 'blur' }
- ],
- // smsAfterCallParam: [
- // { type: 'string', required: true, message: '请输入', trigger: 'blur' }
- // ],
- storeId: [
- { type: 'number', required: true, message: '请选择', trigger: 'change' }
- ],
- },
- phone: null,
- tableHeight: 0,
- storeList: [],
- storeId: null,
- wxcpMemberList: [],
- }
- },
- computed: {
- ...mapState({
- user: (state) => state.user, //
- }),
- tableColumns() {
- let columns = [
- {
- title: '手机号',
- minWidth: 140,
- key: 'phone',
- align: 'left',
- },
- {
- title: '经销商',
- minWidth: 140,
- key: 'store',
- align: 'left',
- render: (h, params) => {
- const { row } = params
- let text = (row.store && row.store.name) || ''
- return h('span', undefined, text)
- },
- },
- {
- title: '短信模板ID',
- minWidth: 140,
- key: 'smsAfterCallParam',
- align: 'left'
- },
- {
- title: '绑定企微',
- minWidth: 140,
- key: 'wxcpMemberName',
- align: 'left'
- },
- {
- title: '状态',
- minWidth: 140,
- key: 'status',
- align: 'left',
- render: (h, params) => {
- const { row } = params
- let text = ''
- if (row.userStatus === 1) {
- return (
- h('span', {
- style: {
- color: '#35E89A'
- }
- }, '正常')
- )
- } else if (row.userStatus === -1) {
- return (
- h('span', {
- style: {
- color: '#cccccc'
- }
- }, '已禁用')
- )
- } else {
- return (
- h('span', {
- style: {
- color: '#999999'
- }
- }, '未激活')
- )
- }
- }
- },
- {
- title: '操作',
- align: 'left',
- width: 130,
- render: (h, params) => {
- const array = []
- const { row, index } = params
- array.push(h('div', {
- style: {
- color: '#1677FF',
- cursor: 'pointer',
- },
- on: {
- click: (event) => {
- this.handleEdit(row)
- }
- }
- }, '编辑'))
- if (row.userStatus !== -1) {
- array.push(h('div', {
- style: {
- color: '#FF4E4E',
- cursor: 'pointer',
- },
- on: {
- click: (event) => {
- this.handleDelete(row)
- }
- }
- }, '禁用'))
- }
- return h('div', {
- style: {
- display: 'flex',
- lineHeight: '17px',
- gap: '5px 30px',
- whiteSpace: 'nowrap'
- },
- }, array)
- }
- }
- ]
- return columns
- }
- },
- created() {
- this.handleCalcTableHeight()
- const resize = debounce(() => {
- this.handleCalcTableHeight()
- }, 300)
- window.addEventListener('resize', resize)
- this.$once('hook:beforeDestroy', () => {
- window.removeEventListener('resize', resize)
- })
- this.getStoreList()
- this.initData()
- },
- methods: {
- handleValidatePhone(rule, value, callback) {
- if (!value) {
- //callback(new Error('请输入手机号'))
- callback()
- } else if (!checkPhone(value)) {
- callback(new Error('请输入正确的手机号'))
- } else {
- callback()
- }
- },
- handleCalcTableHeight() {
- this.$nextTick().then(() => {
- const tableContent = this.$refs['tableContent']
- let tableContentHeight = 0
- if (tableContent) {
- // 普通的 html节点
- tableContentHeight = tableContent.getBoundingClientRect().height
- }
- this.tableHeight = tableContentHeight - (32 + 40 + 58)
- })
- },
- handleSearch() {
- this.currentPage = 1
- this.initData()
- },
- initData() {
- this.$http.post(`/call/api/user/m/findListByPage?page=${this.currentPage}&pageCount=${this.pageSize}`, {
- phone: this.phone,
- storeId: this.storeId
- }).then((response) => {
- let { data, code, msg } = response
- if (code === 1) {
- this.tableData = data.records
- this.total = data.total
- } else {
- this.$Notice.warning({
- desc: msg
- })
- }
- })
- },
- handleAdd() {
- this.showDialog = true
- this.formValidate = {
- id: undefined,
- phone: undefined,
- smsAfterCallParam: undefined,
- storeId: undefined,
- wxcpMemberId: undefined,
- }
- if (this.formValidate.storeId) {
- this.getWxcpMemberList()
- }
- },
- handleEdit(row) {
- this.showDialog = true
- this.formValidate = {
- id: row.id,
- phone: row.phone,
- smsAfterCallParam: row.smsAfterCallParam || undefined,
- storeId: (row.store && row.store.id) || undefined,
- wxcpMemberId: row.wxcpMemberId || undefined,
- }
- if (this.formValidate.storeId) {
- this.getWxcpMemberList()
- }
- },
- getStoreList() {
- this.$http.post(`/call/api/call-store/findListByPage?page=1&pageCount=1000`, {}).then((response) => {
- const { code, data, msg } = response
- if (code === 1) {
- this.storeList = data.records
- }
- })
- },
- getWxcpMemberList() {
- this.$http.get(`/call/api/user/m/member-options`, {
- params: {
- tenancyId: this.storeList.find(item => item.id === this.formValidate.storeId).tenancyId,
- page: 1,
- pageCount: 1000
- }
- }).then((response) => {
- const { code, data, msg } = response
- if (code === 1) {
- this.wxcpMemberList = data.records || []
- }
- })
- },
- handleClearWxcpMemberId() {
- this.formValidate.wxcpMemberId = null
- },
- handleOk(name) {
- this.$refs[name].validate((valid) => {
- if (valid) {
- this.btnLoading = true
- this.$http.post(`/call/api/user/m/${this.formValidate.id ? 'updateUser' : 'addUser'}`, {
- ...this.formValidate,
- }).then((response) => {
- let { code, msg } = response
- if (code === 1) {
- this.$Notice.success({
- title: msg,
- })
- this.showDialog = false
- this.handleSearch()
- } else {
- this.$Notice.warning({
- desc: msg
- })
- }
- }).finally(() => {
- this.btnLoading = false
- })
- }
- })
- },
- handleDelete(row) {
- this.$Modal.confirm({
- title: '提示',
- content: `<div class="confirm_cont text_conter">确认禁用该用户?</div>`,
- onOk: () => {
- this.$http.post(`/call/api/user/m/forbiddenUser`, {
- id: row.id
- }).then((response) => {
- let { code, msg } = response
- if (code === 1) {
- this.$Notice.success({
- title: msg,
- })
- this.handleSearch()
- } else {
- this.$Notice.warning({
- desc: msg
- })
- }
- })
- }
- })
- },
- },
- }
- </script>
- <style lang="less" scoped>
- .store_page {
- .page_content {}
- }
- </style>
|