企微助手 ,仓库名 短剧

memberManage.vue 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. <template>
  2. <div>
  3. <div class="flex-align-center" style="background: #fff;padding: 0 16px;margin-bottom: 10px;">
  4. <!-- S 激活状态 -->
  5. <div class="flex" style="margin-right: 20px;">
  6. <span style="font-size: 14px; color: #666; margin-right: 8px;">激活状态</span>
  7. <el-select class="select-cls" v-model="is_active" size="small" placeholder="请选择激活状态" clearable filterable :style="{width: '210px'}" @change="onChangeActiveStatus">
  8. <el-option v-for="item in activeStatusOptions" :key="item.value" :label="item.label" :value="item.value" />
  9. </el-select>
  10. </div>
  11. <!-- E 激活状态 -->
  12. <selfCustomerservice labelWidth="auto" style="margin-right: 20px;" title="成员" @customerDefine="onChangeUserIds" />
  13. <selfinput :hasLabel="false" @inputChange="inputChange"></selfinput>
  14. </div>
  15. <div class="tableInfo">
  16. <div class="flex">
  17. <!-- 客户数据统计 -->
  18. <div v-if="isShowCustomerData" class="totalCustom">
  19. 共<span>{{ customerData.customer_count }}</span>个客户;
  20. 昨日新增<span>{{ customerData.user_add_yesterday }}</span>;
  21. 昨日流失<span>{{ customerData.user_loss_yesterday }}</span>;
  22. </div>
  23. <!-- 客服成员数 -->
  24. <template v-else>
  25. <div class="totalCustom">
  26. <i class="el-icon-user-solid" /> 共<span>{{total}}</span>个成员
  27. </div>
  28. <div class="totalCustom ml-20">
  29. 待分配许可<span>{{ waitForAssignNum }}</span>
  30. <el-tooltip class="disinblock" popper-class="member-tooltip">
  31. <div slot="content">
  32. <p>购买许可—需要联系开发人员进行许可购买</p>
  33. <p>分配许可—只能将许可分配给未激活的成员,激活时间为分配时间,过期时间为1年。</p>
  34. <p>转移许可—转移许可为离职成员或不在服务商应用可见范围内的成员时,不显转移时间间隔,转移许可的成员为在职成员在服务商应用可见范围内时,转移后30天才可进行下一次转移;转移许可接收成员不能与转移成员的许可重叠</p>
  35. </div>
  36. <i class="el-icon-question c-999" />
  37. </el-tooltip>
  38. </div>
  39. </template>
  40. </div>
  41. <batchAssign ref="batchAssign" @change="onChangeBatchAssign" />
  42. </div>
  43. <div style="display: flex;">
  44. <div style="width: 300px;flex-shrink: 0;margin-right: 10px;background-color: #fff;padding: 15px">
  45. <div class="fWeight600">
  46. 部门信息
  47. </div>
  48. <div>
  49. <div v-for="c in depart_List" :key="c.department_id" class="tMar20 flex-align-center pointer f15" @click="checkDepartId(c.department_id)">
  50. <i class="el-icon-success c-00B38A f16 rMar7" v-if="checkVals.indexOf(c.department_id)>-1"></i>
  51. <i class="el-icon-circle rMar7" v-else></i>
  52. {{c.department_name}}
  53. </div>
  54. </div>
  55. </div>
  56. <div style="flex: 1; overflow: hidden;" v-loading="loading">
  57. <el-table ref="multipleTable" :height='height' :data="tableData" tooltip-effect="dark">
  58. <el-table-column min-width="180" label="成员列表" show-overflow-tooltip fixed="left">
  59. <template slot-scope="scope">
  60. <div class="flex-align-center">
  61. <div>
  62. <img :src="scope.row.avatar" alt="" style="width: 40px;margin-right: 10px;border-radius:3px">
  63. </div>
  64. <div>
  65. <div>{{scope.row.name}}</div>
  66. <div>共有{{scope.row.customer_number}}个客户</div>
  67. </div>
  68. </div>
  69. </template>
  70. </el-table-column>
  71. <el-table-column min-width="200" label="所属部门" align="center">
  72. <template slot-scope="scope">
  73. <div>
  74. <span class="rMar7">{{scope.row.department_list&&scope.row.department_list.join(',')}}</span>
  75. </div>
  76. </template>
  77. </el-table-column>
  78. <el-table-column label="授权状态" align="center" min-width="100">
  79. <template slot-scope="scope">
  80. <div class="flex-align-jus-center">
  81. <i class="el-icon-circle-check f16 c-00B38A rMar7" v-if="scope.row.status == 1"></i>
  82. <i class="el-icon-warning-outline f16 c-FF604D rMar7" v-if="scope.row.status == 4"></i>
  83. {{scope.row.status == 1 ? '已授权' : '未授权'}}
  84. </div>
  85. </template>
  86. </el-table-column>
  87. <el-table-column label="所属类型" align="center" min-width="80">
  88. <template slot-scope="{row}">
  89. <span>{{ getOrderTypeDesc(row.order_type) }}</span>
  90. </template>
  91. </el-table-column>
  92. <el-table-column label="ADQ投放账号ID" align="center" min-width="130">
  93. <template slot-scope="{row}">
  94. <span>{{ row.account_id || '-' }}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column label="昨日流失客户数" prop="loss_contact_cnt" min-width="120" align="center" />
  98. <el-table-column label="昨日新增客户数" prop="new_contact_cnt" min-width="120" align="center" />
  99. <el-table-column label="激活时间" min-width="170" align="center">
  100. <template slot-scope="{ row }">
  101. <span>{{ row.active_time || '-' }}</span>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="过期时间" min-width="170" align="center">
  105. <!-- <template slot="header">
  106. <span>过期时间</span>
  107. <el-tooltip class="disinblock" placement="top">
  108. <div slot="content">系统根据过期时间判断许可到期时间,到期前14天通知续费</div>
  109. <i class="el-icon-question"></i>
  110. </el-tooltip>
  111. </template> -->
  112. <template slot-scope="{ row }">
  113. <div v-if="row.expire_time">
  114. <div>{{ row.expire_time }}</div>
  115. <!-- 无可用状态码 目前通过后端返回的文案判断 -->
  116. <div v-if="row.active_desc === '已到期'" class="expired-tips">已到期</div>
  117. <div v-if="row.active_desc === '即将到期'" class="expired-tips danger">即将到期</div>
  118. </div>
  119. <span v-else> - </span>
  120. </template>
  121. </el-table-column>
  122. <el-table-column label="操作" align="center" min-width="170" fixed="right">
  123. <template slot-scope="scope">
  124. <span class="c-00B38A pointer" @click="detailEvent(scope.row)">详情</span>
  125. <span class="c-00B38A pointer ml-3" @click="onClickInfoBind(scope.row)">信息绑定</span>
  126. <template>
  127. <span v-if="scope.row.is_active == 1" class="c-00B38A pointer ml-3" @click="onClickTransfer(scope.row)">转移许可</span>
  128. <span v-else class="c-00B38A pointer ml-3" @click="onClickAssign(scope.row)">分配许可</span>
  129. </template>
  130. </template>
  131. </el-table-column>
  132. <!--
  133. <el-table-column label="备用客服">
  134. <template slot-scope="scope">
  135. <div class="flex-align-center">
  136. <div>
  137. <img :src="scope.row.avatar" alt="" style="width: 40px;margin-right: 10px;border-radius:3px">
  138. </div>
  139. <div>
  140. <div>{{scope.row.name}}</div>
  141. <div>共有{{scope.row.customer_number}}个客户</div>
  142. </div>
  143. </div>
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="操作" align="center">
  147. <template slot-scope="scope">
  148. <el-popover
  149. :ref="scope.row.user_id"
  150. width="260" v-model="scope.row.visible">
  151. <div class="box">
  152. <div class="txt">备用客服</div>
  153. <div class="lMar20">
  154. <el-select size="mini" v-model="standbyVal" placeholder="请选择备用客服">
  155. <el-option
  156. v-for="item in standbyList"
  157. :key="item.value"
  158. :label="item.label"
  159. :value="item.value">
  160. </el-option>
  161. </el-select>
  162. </div>
  163. </div>
  164. <div style="text-align: right; margin: 10px 0 0">
  165. <el-button size="mini" type="text" @click="$refs[scope.row.user_id].doClose()">取消</el-button>
  166. <el-button size="mini" type="text" @click="$refs[scope.row.user_id].doClose()">确定</el-button>
  167. </div>
  168. <div class="c-00B38A pointer" slot="reference"> 编辑 </div>
  169. </el-popover>
  170. </template>
  171. </el-table-column>
  172. -->
  173. </el-table>
  174. <div class="pagination" v-show="total>0">
  175. <el-pagination background :current-page="page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count='Number(pages)'>
  176. </el-pagination>
  177. </div>
  178. </div>
  179. </div>
  180. <!--详情-->
  181. <el-drawer :size="drawerSize" :visible.sync="userDetailFlag" :with-header="false">
  182. <user-detail v-if="userDetailFlag" @changeDrawerSize="changeDrawerSize" @closeDrawer="closeDrawer" :user_id="user_detail_id"></user-detail>
  183. </el-drawer>
  184. <!-- S 信息绑定 - 弹框 -->
  185. <memberInfoBind
  186. :dialogVisible="infoBindDialogVisible"
  187. :userInfo="currentBindInfo"
  188. @cancel="handleInfoBindCancel"
  189. @confirm="handleInfoBindConfirm"
  190. />
  191. <!-- E 信息绑定 - 弹框 -->
  192. <!-- S 分配许可 - 弹框 -->
  193. <assignDialog
  194. :dialogVisible="assignDialogVisible"
  195. :userInfo="currentAssignInfo"
  196. :waitForAssignNum="waitForAssignNum"
  197. @cancel="handleAssignCancel"
  198. @confirm="handleAssignConfirm"
  199. />
  200. <!-- E 分配许可 - 弹框 -->
  201. <!-- S 转移许可 - 弹框 -->
  202. <transferDialog
  203. :dialogVisible="transferDialogVisible"
  204. :userInfo="currentTransferInfo"
  205. @cancel="handleTransferCancel"
  206. @confirm="handleTransferConfirm"
  207. />
  208. <!-- E 转移许可 - 弹框 -->
  209. </div>
  210. </template>
  211. <script>
  212. import selfinput from '../assembly/screen/input.vue'
  213. import userDetail from './userDetail/index.vue'
  214. import memberInfoBind from './memberComp/memberInfoBind.vue'
  215. import selfCustomerservice from '@/components/assembly/screen/customerService.vue'
  216. import batchAssign from './memberComp/batchAssign.vue'
  217. import assignDialog from './memberComp/assignDialog.vue'
  218. import transferDialog from './memberComp/transferDialog.vue'
  219. import { orderTypeOptions } from '@/assets/js/staticTypes'
  220. const orderTypeDesc = new Map([
  221. [String(orderTypeOptions.MP), 'MP'],
  222. [String(orderTypeOptions.ADQ), 'ADQ'],
  223. ])
  224. // 激活状态选项
  225. const activeStatusOptions = [
  226. { label: '未激活', value: 0 },
  227. { label: '已激活', value: 1 },
  228. ]
  229. export default {
  230. name: 'memberManage',
  231. components: {
  232. selfinput,
  233. userDetail,
  234. memberInfoBind,
  235. selfCustomerservice,
  236. batchAssign,
  237. assignDialog,
  238. transferDialog,
  239. },
  240. data () {
  241. return {
  242. userDetailFlag: false,
  243. drawerSize: '60%',
  244. loading: false,
  245. page: 1,
  246. pages: 0,
  247. total: 0,
  248. page_size: 20,
  249. tableData: [],
  250. checkVals: [],
  251. depart_List: [],
  252. keyword: '',
  253. height: '',
  254. user_detail_id: '',
  255. // standbyList:[],
  256. // standbyVal:'',
  257. // visible:false,
  258. infoBindDialogVisible: false, // 控制“信息绑定”弹框显示
  259. currentBindInfo: {}, // 当前需要绑定的成员信息
  260. user_ids: [],//客服user_id列表
  261. customerData: { // 客户信息
  262. customer_count: 0,
  263. user_add_yesterday: 0,
  264. user_loss_yesterday: 0,
  265. },
  266. is_active: '', // 激活状态
  267. activeStatusOptions: Object.freeze(activeStatusOptions), // 激活状态选项
  268. waitForAssignNum: 0, // 待分配许可数
  269. assignDialogVisible: false, // 控制“分配许可”弹框显示
  270. currentAssignInfo: {}, // 当前需要分配许可的成员信息
  271. transferDialogVisible: false, // 控制“转移许可”弹框显示
  272. currentTransferInfo: {}, // 当前需要转移许可的成员信息
  273. }
  274. },
  275. computed: {
  276. // 是否显示“客户数据统计”(当选择“客服”筛选时显示)
  277. isShowCustomerData() {
  278. return this.user_ids && this.user_ids.length
  279. },
  280. },
  281. created () {
  282. this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
  283. this.init_depart()
  284. this.init(1)
  285. this.handleGetWaitForAssignNum()
  286. },
  287. methods: {
  288. detailEvent (data) {
  289. this.userDetailFlag = true
  290. this.user_detail_id = data.user_id;
  291. },
  292. closeDrawer () {
  293. this.userDetailFlag = false
  294. },
  295. changeDrawerSize () {
  296. this.drawerSize = this.drawerSize == '80%' ? '60%' : '80%'
  297. },
  298. inputChange (keyword) {
  299. this.keyword = keyword
  300. this.init(1, keyword)
  301. this.handleGetWaitForAssignNum()
  302. },
  303. init_depart () {
  304. this.$axios.get(this.URL.BASEURL + this.URL.departmentList, {}).then((res) => {
  305. var res = res.data
  306. if (res && res.errno == 0) {
  307. this.depart_List = res.rst
  308. this.checkVals = res.rst.map((v) => {
  309. return v.department_id
  310. })
  311. } else if (res.errno != 4002) {
  312. this.$message({
  313. message: res.err,
  314. type: "warning"
  315. })
  316. }
  317. })
  318. },
  319. init (page, keyword) {
  320. this.handleInitCustomerData()
  321. this.page = page ? page : this.page;
  322. this.loading = true
  323. this.$axios.get(this.URL.BASEURL + this.URL.memberList, {
  324. params: {
  325. user_name: keyword,
  326. department_list: this.checkVals,
  327. user_ids: this.user_ids ? this.user_ids.join(',') : '',
  328. is_active: this.is_active,
  329. page: this.page,
  330. page_size: this.page_size
  331. }
  332. }).then((res) => {
  333. var res = res.data
  334. this.loading = false
  335. if (res && res.errno == 0) {
  336. if (res.rst.data[0]) { // mock
  337. res.rst.data[0].is_active = 1
  338. }
  339. this.tableData = res.rst.data;
  340. // this.tableData.forEach(item=>{
  341. // item.visible = false
  342. // })
  343. this.total = res.rst.pageInfo.total;
  344. this.pages = res.rst.pageInfo.pages;
  345. // 客户数据回显
  346. this.customerData.customer_count = res.rst.extra.customer_count
  347. this.customerData.user_add_yesterday = res.rst.extra.user_add_yesterday
  348. this.customerData.user_loss_yesterday = res.rst.extra.user_loss_yesterday
  349. } else if (res.errno != 4002) {
  350. this.$message({
  351. message: res.err,
  352. type: "warning"
  353. })
  354. this.tableData = []
  355. this.pages = 0
  356. this.handleInitCustomerData()
  357. }
  358. }).catch((err) => {
  359. this.loading = false
  360. });
  361. },
  362. // 重置客户统计数据
  363. handleInitCustomerData() {
  364. this.total = 0
  365. this.customerData.customer_count = 0
  366. this.customerData.user_add_yesterday = 0
  367. this.customerData.user_loss_yesterday = 0
  368. },
  369. handleCurrentChange (val) {
  370. this.init(val, this.keyword)
  371. this.handleGetWaitForAssignNum()
  372. },
  373. checkDepartId (id) {
  374. if (this.checkVals.indexOf(id) == -1) {
  375. this.checkVals.push(id)
  376. } else {
  377. this.checkVals.splice(this.checkVals.indexOf(id), 1)
  378. }
  379. this.init(1, this.keyword)
  380. this.handleGetWaitForAssignNum()
  381. },
  382. async onClickInfoBind({ name = '', user_id = '', account_id = '' }) {
  383. try {
  384. if (account_id) {
  385. const h = this.$createElement
  386. await this.$confirm('', {
  387. message:h('div',null, [
  388. h('span', { style:'color: #32B38A;' }, `${name}`),
  389. h('span', null, '已经关联投放账号,是否确认修改?')
  390. ]),
  391. confirmButtonText: '确定',
  392. cancelButtonText: '取消',
  393. type: 'warning',
  394. })
  395. }
  396. this.currentBindInfo = { user_id, account_id }
  397. this.infoBindDialogVisible = true
  398. } catch (error) {
  399. console.log(error)
  400. }
  401. },
  402. // 执行信息绑定 => 取消
  403. handleInfoBindCancel() {
  404. this.currentBindInfo = {}
  405. this.infoBindDialogVisible = false
  406. },
  407. // 执行信息绑定 => 发送
  408. handleInfoBindConfirm() {
  409. this.infoBindDialogVisible = false
  410. this.init(undefined, this.keyword)
  411. this.handleGetWaitForAssignNum()
  412. },
  413. getOrderTypeDesc(type) {
  414. return orderTypeDesc.get(String(type)) || '-'
  415. },
  416. // 监听多选客服变化
  417. onChangeUserIds(val) {
  418. this.user_ids = val ? val : []
  419. this.init(1, this.keyword)
  420. this.handleGetWaitForAssignNum()
  421. },
  422. // 监听激活状态变化
  423. onChangeActiveStatus(val) {
  424. this.is_active = val
  425. this.init(1, this.keyword)
  426. this.handleGetWaitForAssignNum()
  427. },
  428. // 获取“待分配许可数”
  429. handleGetWaitForAssignNum() {
  430. return new Promise(async (resolve, reject) => {
  431. try {
  432. this.loading = true
  433. const url = `${this.URL.BASEURL}${this.URL.member_licenseCount}`
  434. const params = {
  435. corpid: this.$localSelfStore.getLocal('defaultCorp') && this.$localSelfStore.getLocal('defaultCorp') != 'undefined' ? JSON.parse(this.$localSelfStore.getLocal('defaultCorp')).corpid : '',
  436. }
  437. const { data: res = {} } = await this.$axios.get(url, { params })
  438. if (res && res.errno == 0) {
  439. this.waitForAssignNum = res.rst.count
  440. this.waitForAssignNum = parseInt(Math.random() * 100) // mock
  441. resolve(this.waitForAssignNum)
  442. } else if (res.errno != 4002) {
  443. this.$message.warning(res.err)
  444. this.waitForAssignNum = 0
  445. reject(this.waitForAssignNum)
  446. }
  447. } catch (error) {
  448. console.log('error => ', error)
  449. this.waitForAssignNum = 0
  450. reject(this.waitForAssignNum)
  451. } finally {
  452. this.loading = false
  453. }
  454. })
  455. },
  456. // 监听点击“分配许可”
  457. async onClickAssign(current) {
  458. console.log('onClickAssign => ', JSON.parse(JSON.stringify(current)))
  459. this.currentAssignInfo = {...current}
  460. const num = await this.handleGetWaitForAssignNum()
  461. if (!num) return this.$message.warning('暂无待分配许可')
  462. this.assignDialogVisible = true
  463. },
  464. // 执行分配许可 => 取消
  465. handleAssignCancel() {
  466. this.currentAssignInfo = {}
  467. this.assignDialogVisible = false
  468. },
  469. // 执行分配许可 => 确定
  470. handleAssignConfirm() {
  471. this.assignDialogVisible = false
  472. this.init(undefined, this.keyword)
  473. this.handleGetWaitForAssignNum()
  474. },
  475. // 监听点击“转移许可”
  476. onClickTransfer(current) {
  477. console.log('onClickTransfer => ', JSON.parse(JSON.stringify(current)))
  478. this.currentTransferInfo = {...current}
  479. this.transferDialogVisible = true
  480. },
  481. // 执行转移许可 => 取消
  482. handleTransferCancel() {
  483. this.currentTransferInfo = {}
  484. this.transferDialogVisible = false
  485. },
  486. // 执行转移许可 => 确定
  487. handleTransferConfirm() {
  488. this.transferDialogVisible = false
  489. this.init(undefined, this.keyword)
  490. },
  491. // 监听“批量分配许可”变化
  492. onChangeBatchAssign(val) {
  493. console.log('onChangeBatchAssign => ', val)
  494. this.init(undefined, this.keyword)
  495. this.handleGetWaitForAssignNum()
  496. },
  497. }
  498. }
  499. </script>
  500. <style lang="scss">
  501. .member-tooltip {
  502. max-width: 300px;
  503. p {
  504. margin-bottom: 10px;
  505. &:last-child {
  506. margin-bottom: 0;
  507. }
  508. }
  509. }
  510. </style>
  511. <style lang="scss" scoped>
  512. @import "@/style/list.scss";
  513. .select-cls {
  514. /deep/ .el-input__inner {
  515. height: 30px;
  516. line-height: 30px;
  517. }
  518. /deep/ .el-input__suffix {
  519. border-top-right-radius: 4px;
  520. border-bottom-right-radius: 4px;
  521. border: 1px solid #DCDFE6;
  522. right: 0;
  523. width: 30px;
  524. background-color: #F1F1F1;
  525. .el-input__icon {
  526. line-height: 26px;
  527. color: #909399;
  528. }
  529. }
  530. }
  531. .ml-3 {
  532. margin-left: 3px;
  533. }
  534. .ml-20 {
  535. margin-left: 20px;
  536. }
  537. .tableInfo {
  538. height: 50px;
  539. }
  540. .el-icon-circle {
  541. width: 14px;
  542. height: 14px;
  543. margin: 0 1px;
  544. border-radius: 50%;
  545. border: 1px solid #999;
  546. margin-right: 8px;
  547. }
  548. .box {
  549. display: flex;
  550. align-items: center;
  551. justify-content: center;
  552. .txt {
  553. font-size: 14px;
  554. flex-shrink: 0;
  555. }
  556. }
  557. .expired-tips {
  558. display: inline-block;
  559. padding: 0 4px;
  560. border-radius: 2px;
  561. background-color: #F2F2F2;
  562. color: #AAAAAA;
  563. &.danger {
  564. background-color: #FDE3E3;
  565. color: #EC808D;
  566. }
  567. }
  568. </style>