Przeglądaj źródła

feat:app客服和客服组管理功能

caoliqin 1 tydzień temu
rodzic
commit
6abf8aa88d

+ 36 - 0
src/api/app/customerMember/index.js

@@ -0,0 +1,36 @@
+import request from '@/utils/request'
+
+// 查询客服分页列表
+export function listCustomerMember(query) {
+  return request({
+    url: '/app/cusrole/member/pageList',
+    method: 'get',
+    params: query
+  })
+}
+
+// 新增客服
+export function addCustomerMember(data) {
+  return request({
+    url: '/app/cusrole/member',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改客服
+export function updateCustomerMember(data) {
+  return request({
+    url: '/app/cusrole/member',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除客服
+export function delCustomerMember(ids) {
+  return request({
+    url: '/app/cusrole/member/' + ids,
+    method: 'delete'
+  })
+}

+ 37 - 0
src/api/app/customerRole/index.js

@@ -0,0 +1,37 @@
+import request from '@/utils/request'
+
+// 查询客服组分页列表
+export function listCustomerRole(query) {
+  return request({
+    url: '/app/cusrole/pageList',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询客服组下拉选项
+export function listCustomerRoleOptions() {
+  return request({
+    url: '/app/cusrole/pageList',
+    method: 'get',
+    params: { pageNum: 1, pageSize: 999 }
+  })
+}
+
+// 新增客服组
+export function addCustomerRole(data) {
+  return request({
+    url: '/app/cusrole',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改客服组
+export function updateCustomerRole(data) {
+  return request({
+    url: '/app/cusrole',
+    method: 'put',
+    data: data
+  })
+}

+ 326 - 0
src/views/app/customerMember/index.vue

@@ -0,0 +1,326 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
+      <el-form-item label="成员名称" prop="keyword">
+        <el-input
+          v-model="queryParams.keyword"
+          placeholder="请输入成员名称"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item label="所属客服组" prop="appCustomerId">
+        <el-select
+          v-model="queryParams.appCustomerId"
+          placeholder="请选择客服组"
+          clearable
+          filterable
+          size="small"
+        >
+          <el-option
+            v-for="item in roleOptions"
+            :key="item.id"
+            :label="item.roleName"
+            :value="parseRoleId(item.id)"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          v-hasPermi="['app:customerMember:add']"
+          @click="handleAdd"
+        >新增</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          plain
+          icon="el-icon-edit"
+          size="mini"
+          :disabled="single"
+          v-hasPermi="['app:customerMember:edit']"
+          @click="handleUpdate()"
+        >修改</el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="danger"
+          plain
+          icon="el-icon-delete"
+          size="mini"
+          :disabled="multiple"
+          v-hasPermi="['app:customerMember:remove']"
+          @click="handleDelete()"
+        >删除</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="memberList" @selection-change="handleSelectionChange" border>
+      <el-table-column type="selection" width="55" align="center" />
+      <el-table-column label="所属客服组" align="center" prop="roleName" min-width="140" />
+      <el-table-column label="成员名称" align="center" prop="memberName" min-width="120" />
+      <el-table-column label="头像" align="center" prop="avatar" width="100">
+        <template slot-scope="scope">
+          <el-image
+            v-if="scope.row.avatar"
+            style="width: 50px; height: 50px; border-radius: 4px;"
+            :src="scope.row.avatar"
+            :preview-src-list="[scope.row.avatar]"
+            fit="cover"
+          />
+          <span v-else>-</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="描述" align="center" prop="remark" min-width="160" show-overflow-tooltip />
+      <el-table-column label="创建时间" align="center" prop="createTime" width="160" />
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="140">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            v-hasPermi="['app:customerMember:edit']"
+            @click="handleUpdate(scope.row)"
+          >修改</el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-delete"
+            v-hasPermi="['app:customerMember:remove']"
+            @click="handleDelete(scope.row)"
+          >删除</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <el-dialog :title="title" :visible.sync="open" width="560px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="100px">
+        <el-form-item label="所属客服组" prop="appCustomerId">
+          <el-select
+            v-model="form.appCustomerId"
+            placeholder="请选择所属客服组"
+            filterable
+            style="width: 100%;"
+          >
+            <el-option
+              v-for="item in roleOptions"
+              :key="item.id"
+              :label="item.roleName"
+              :value="parseRoleId(item.id)"
+            />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="成员名称" prop="memberName">
+          <el-input v-model="form.memberName" placeholder="请输入成员名称" />
+        </el-form-item>
+        <el-form-item label="头像" prop="avatar">
+          <ImageUpload
+            v-model="form.avatar"
+            type="image"
+            :limit="1"
+            :file-size="1"
+            :width="150"
+            :height="150"
+          />
+        </el-form-item>
+        <el-form-item label="描述" prop="remark">
+          <el-input v-model="form.remark" type="textarea" placeholder="请输入描述" />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  listCustomerMember,
+  addCustomerMember,
+  updateCustomerMember,
+  delCustomerMember
+} from '@/api/app/customerMember'
+import { listCustomerRoleOptions } from '@/api/app/customerRole'
+import ImageUpload from '@/views/qw/sop/ImageUpload'
+
+export default {
+  name: 'CustomerMember',
+  components: { ImageUpload },
+  data() {
+    return {
+      loading: true,
+      showSearch: true,
+      total: 0,
+      ids: [],
+      single: true,
+      multiple: true,
+      memberList: [],
+      roleOptions: [],
+      title: '',
+      open: false,
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        keyword: null,
+        appCustomerId: null
+      },
+      form: {},
+      rules: {
+        appCustomerId: [
+          { required: true, message: '请选择所属客服组', trigger: 'change' }
+        ],
+        memberName: [
+          { required: true, message: '成员名称不能为空', trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  created() {
+    this.loadRoleOptions()
+    this.getList()
+  },
+  methods: {
+    parseRoleId(value) {
+      if (value === null || value === undefined || value === '') {
+        return null
+      }
+      const num = Number(value)
+      return Number.isNaN(num) ? value : num
+    },
+    getRowAppCustomerId(row) {
+      return this.parseRoleId(
+        row.appCustomerId ?? row.roleId ?? row.cusRoleId ?? row.customerRoleId
+      )
+    },
+    loadRoleOptions() {
+      listCustomerRoleOptions().then(response => {
+        this.roleOptions = (response.rows || []).map(item => ({
+          ...item,
+          id: this.parseRoleId(item.id)
+        }))
+      })
+    },
+    getList() {
+      this.loading = true
+      listCustomerMember(this.queryParams).then(response => {
+        this.memberList = response.rows
+        this.total = response.total
+        this.loading = false
+      }).catch(() => {
+        this.loading = false
+      })
+    },
+    cancel() {
+      this.open = false
+      this.reset()
+    },
+    reset() {
+      this.form = {
+        id: null,
+        appCustomerId: null,
+        memberName: null,
+        avatar: null,
+        remark: null
+      }
+      this.resetForm('form')
+    },
+    handleQuery() {
+      this.queryParams.pageNum = 1
+      this.getList()
+    },
+    resetQuery() {
+      this.queryParams = {
+        pageNum: 1,
+        pageSize: 10,
+        keyword: null,
+        appCustomerId: null
+      }
+      this.handleQuery()
+    },
+    handleSelectionChange(selection) {
+      this.ids = selection.map(item => item.id)
+      this.single = selection.length !== 1
+      this.multiple = !selection.length
+    },
+    handleAdd() {
+      this.reset()
+      this.open = true
+      this.title = '新增客服'
+    },
+    handleUpdate(row) {
+      const target = row || this.memberList.find(item => item.id === this.ids[0])
+      if (!target) {
+        return
+      }
+      this.form = {
+        id: target.id,
+        appCustomerId: this.getRowAppCustomerId(target),
+        memberName: target.memberName,
+        avatar: target.avatar,
+        remark: target.remark
+      }
+      this.open = true
+      this.title = '修改客服'
+      this.$nextTick(() => {
+        this.$refs.form && this.$refs.form.clearValidate()
+      })
+    },
+    handleDelete(row) {
+      const ids = row ? row.id : this.ids.join(',')
+      this.$confirm('是否确认删除选中的客服数据?', '警告', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        return delCustomerMember(ids)
+      }).then(() => {
+        this.getList()
+        this.msgSuccess('删除成功')
+      }).catch(() => {})
+    },
+    submitForm() {
+      this.$refs.form.validate(valid => {
+        if (!valid) {
+          return
+        }
+        if (this.form.id != null) {
+          updateCustomerMember(this.form).then(() => {
+            this.msgSuccess('修改成功')
+            this.open = false
+            this.getList()
+          })
+        } else {
+          addCustomerMember(this.form).then(() => {
+            this.msgSuccess('新增成功')
+            this.open = false
+            this.getList()
+          })
+        }
+      })
+    }
+  }
+}
+</script>

+ 215 - 0
src/views/app/customerRole/index.vue

@@ -0,0 +1,215 @@
+<template>
+  <div class="app-container">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="90px">
+      <el-form-item label="客服组名称" prop="roleName">
+        <el-input
+          v-model="queryParams.roleName"
+          placeholder="请输入客服组名称"
+          clearable
+          size="small"
+          @keyup.enter.native="handleQuery"
+        />
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
+      </el-form-item>
+    </el-form>
+
+    <el-row :gutter="10" class="mb8">
+      <el-col :span="1.5">
+        <el-button
+          type="primary"
+          plain
+          icon="el-icon-plus"
+          size="mini"
+          v-hasPermi="['app:customerRole:add']"
+          @click="handleAdd"
+        >新增</el-button>
+      </el-col>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+    </el-row>
+
+    <el-table v-loading="loading" :data="roleList" border>
+      <el-table-column label="客服组名称" align="center" prop="roleName" min-width="140" />
+      <el-table-column label="头像" align="center" prop="avatar" width="100">
+        <template slot-scope="scope">
+          <el-image
+            v-if="scope.row.avatar"
+            style="width: 50px; height: 50px; border-radius: 4px;"
+            :src="scope.row.avatar"
+            :preview-src-list="[scope.row.avatar]"
+            fit="cover"
+          />
+          <span v-else>-</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="备注" align="center" prop="remark" min-width="160" show-overflow-tooltip />
+      <el-table-column label="创建时间" align="center" prop="createTime" width="160" />
+      <el-table-column label="添加客户最大数量" align="center" prop="memberMaxFriendCount" width="150" />
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
+        <template slot-scope="scope">
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-edit"
+            v-hasPermi="['app:customerRole:edit']"
+            @click="handleUpdate(scope.row)"
+          >修改</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <pagination
+      v-show="total > 0"
+      :total="total"
+      :page.sync="queryParams.pageNum"
+      :limit.sync="queryParams.pageSize"
+      @pagination="getList"
+    />
+
+    <el-dialog :title="title" :visible.sync="open" width="560px" append-to-body>
+      <el-form ref="form" :model="form" :rules="rules" label-width="140px">
+        <el-form-item label="客服组名称" prop="roleName">
+          <el-input v-model="form.roleName" placeholder="请输入客服组名称" />
+        </el-form-item>
+        <el-form-item label="头像" prop="avatar">
+          <ImageUpload
+            v-model="form.avatar"
+            type="image"
+            :limit="1"
+            :file-size="1"
+            :width="150"
+            :height="150"
+          />
+        </el-form-item>
+        <el-form-item label="备注" prop="remark">
+          <el-input v-model="form.remark" type="textarea" placeholder="请输入备注" />
+        </el-form-item>
+        <el-form-item label="添加客户最大数量" prop="memberMaxFriendCount">
+          <el-input-number
+            v-model="form.memberMaxFriendCount"
+            :min="0"
+            :max="999999"
+            controls-position="right"
+            placeholder="请输入数量"
+          />
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import {
+  listCustomerRole,
+  addCustomerRole,
+  updateCustomerRole
+} from '@/api/app/customerRole'
+import ImageUpload from '@/views/qw/sop/ImageUpload'
+
+export default {
+  name: 'CustomerRole',
+  components: { ImageUpload },
+  data() {
+    return {
+      loading: true,
+      showSearch: true,
+      total: 0,
+      roleList: [],
+      title: '',
+      open: false,
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        roleName: null
+      },
+      form: {},
+      rules: {
+        roleName: [
+          { required: true, message: '客服组名称不能为空', trigger: 'blur' }
+        ],
+        memberMaxFriendCount: [
+          { required: true, message: '添加客户最大数量不能为空', trigger: 'blur' }
+        ]
+      }
+    }
+  },
+  created() {
+    this.getList()
+  },
+  methods: {
+    getList() {
+      this.loading = true
+      listCustomerRole(this.queryParams).then(response => {
+        this.roleList = response.rows
+        this.total = response.total
+        this.loading = false
+      }).catch(() => {
+        this.loading = false
+      })
+    },
+    cancel() {
+      this.open = false
+      this.reset()
+    },
+    reset() {
+      this.form = {
+        id: null,
+        roleName: null,
+        avatar: null,
+        remark: null,
+        memberMaxFriendCount: 0
+      }
+      this.resetForm('form')
+    },
+    handleQuery() {
+      this.queryParams.pageNum = 1
+      this.getList()
+    },
+    resetQuery() {
+      this.queryParams = {
+        pageNum: 1,
+        pageSize: 10,
+        roleName: null
+      }
+      this.handleQuery()
+    },
+    handleAdd() {
+      this.reset()
+      this.open = true
+      this.title = '新增客服组'
+    },
+    handleUpdate(row) {
+      this.reset()
+      this.form = { ...row }
+      this.open = true
+      this.title = '修改客服组'
+    },
+    submitForm() {
+      this.$refs.form.validate(valid => {
+        if (!valid) {
+          return
+        }
+        if (this.form.id != null) {
+          updateCustomerRole(this.form).then(() => {
+            this.msgSuccess('修改成功')
+            this.open = false
+            this.getList()
+          })
+        } else {
+          addCustomerRole(this.form).then(() => {
+            this.msgSuccess('新增成功')
+            this.open = false
+            this.getList()
+          })
+        }
+      })
+    }
+  }
+}
+</script>