list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <view class="app-main app-content">
  3. <view class="input-wrap_box">
  4. <view>
  5. <AppSearchModule placeholder="输入首字母搜索" @input="searchFn"/>
  6. </view>
  7. </view>
  8. <view class="app-tabs">
  9. <app-tabs :tabs="tabs" :isFixed="false" :top="50" :currentTab="tabIndex" :height="100" @change="change" itemWidth="50%" :isAdd="false" />
  10. </view>
  11. <block v-if="tabIndex == 0">
  12. <div class="list-wrap staff-list">
  13. <block v-if="!$util.isEmpty(list.data)">
  14. <div class="list" v-for="(item, index) in list.data" :key="index">
  15. <div>
  16. <image :src="item.avatar" mode="aspectFit" style="width:100upx;height:100upx;border-radius: 50%"></image>
  17. </div>
  18. <div class="list-det">
  19. <div class="list-det-left">
  20. <div>
  21. <span class="staff-name">{{ item.name }}</span>
  22. <span>{{ item.mobile }}</span>
  23. </div>
  24. <div></div>
  25. <div class="flex-center">
  26. <div class="status-list">
  27. <i class="iconfont icondagou" :class="[item.remind == 1 ? 'app-color-1' : '' ]"></i>
  28. <span :class="[item.remind == 1 ? 'app-color-1' : 'app-color-3' ]">新订单通知</span>
  29. </div>
  30. <div class="status-list">
  31. <span :class="[item.status == 1 ? 'app-color-1' : 'app-color-3' ]">业绩 ¥{{item.kdAmount}}</span>
  32. </div>
  33. </div>
  34. <view class="super-class" v-if="item.founder == 2">超管</view>
  35. </div>
  36. <div class="list-det-right">
  37. <div v-if="item.founder != 2 && item.id != loginInfo.shopAdminId" @click="delModalFn(item)"> <i class="iconfont iconshanchu1"></i> </div>
  38. <div @click="pageTo({url: '/admin/staff/detail',query: {id: item.id}})"> <i class="iconfont iconbianji"></i> </div>
  39. </div>
  40. </div>
  41. </div>
  42. </block>
  43. <block v-else>
  44. <app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
  45. </block>
  46. </div>
  47. <!-- 按钮 -->
  48. <div class="app-footer">
  49. <div class="admin-button-com middle blue" @click="pageTo({url: '/admin/staff/add'})">添加员工</div>
  50. </div>
  51. </block>
  52. <!-- 角色管理 -->
  53. <block v-if="tabIndex == 1">
  54. <!-- 列表 -->
  55. <div class="list-wrap role-list">
  56. <block v-if="!$util.isEmpty(list.data)">
  57. <div class="list" v-for="(item, index) in list.data" :key="index">
  58. <div class="app-size-32">{{ item.roleName }}({{ item.num }})</div>
  59. <div class="role-option">
  60. <!--
  61. <div @click="modifyRoleFn(item)">
  62. <i class="iconfont iconbianji"></i>
  63. </div>
  64. <div @click="delModalFn(item)">
  65. <i class="iconfont iconshanchu1"></i>
  66. </div>
  67. -->
  68. </div>
  69. </div>
  70. </block>
  71. <block v-else>
  72. <app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
  73. </block>
  74. </div>
  75. <!-- 按钮 -->
  76. <!--
  77. <div class="app-footer">
  78. <div class="admin-button-com middle blue" @click="addRoleFn">添加角色</div>
  79. </div>
  80. -->
  81. </block>
  82. <!-- 操作记录 -->
  83. <block v-if="tabIndex == 2">
  84. <!-- 列表 -->
  85. <div class="axis-wrap">
  86. <block v-if="!$util.isEmpty(list.data)">
  87. <time-axis>
  88. <timeaxis-item class="axis-list" bgcolor="none" v-for="(item, index) in list.data" :key="index">
  89. <template v-slot:content>
  90. <div class="axis-title">{{ item.content }}</div>
  91. <div class="axis-det">
  92. <div>ID:{{ item.id }}</div>
  93. <div>IP:{{ item.ip }}</div>
  94. <div>操作者:{{ item.name }}</div>
  95. <div>操作时间:{{ item.addTime | formatTime }}</div>
  96. </div>
  97. </template>
  98. </timeaxis-item>
  99. </time-axis>
  100. </block>
  101. <block v-else>
  102. <app-wrapper-empty title="暂无数据" :is-empty="$util.isEmpty(list.data)" />
  103. </block>
  104. </div>
  105. </block>
  106. <!-- 角色操作 -->
  107. <modal-module :show="roleModal" @cancel="modalCancel" @click="roleModalClick" :title="roleModalText" padding="30upx 30upx">
  108. <template v-slot:content>
  109. <div class="app-modal-input-wrap">
  110. <div class="inp-list-line required">
  111. <div class="line-label">角色名称</div>
  112. <div class="line-input">
  113. <input v-model="roleModalVal" type="text" :adjust-position="false" class="inp-input">
  114. </div>
  115. </div>
  116. </div>
  117. </template>
  118. </modal-module>
  119. <!-- 删除弹窗 -->
  120. <modal-module :show="delModal" @cancel="modalCancel" @click="delModalClick" :content="delModalText" color="#333" :size="32" padding="30upx 30upx"></modal-module>
  121. </view>
  122. </template>
  123. <script>
  124. import AppTabs from '@/components/plugin/tabs'
  125. import AppAvatarModule from '@/components/module/app-avatar'
  126. import TimeAxis from '@/admin/home/components/plugin/time-axis'
  127. import TimeaxisItem from '@/admin/home/components/plugin/timeaxis-item'
  128. import AppWrapperEmpty from '@/components/app-wrapper-empty'
  129. import ModalModule from '@/components/plugin/modal'
  130. import AppSearchModule from "@/components/module/app-search";
  131. import { list } from '@/mixins'
  132. import { mapGetters } from "vuex"
  133. import { getStaffList, delStaff, getRoleList, addRole, updateRole, delRole, getLogList } from '@/api/staff'
  134. export default {
  135. name: 'list',
  136. components: {
  137. AppTabs,
  138. AppAvatarModule,
  139. TimeAxis,
  140. TimeaxisItem,
  141. AppWrapperEmpty,
  142. ModalModule,
  143. AppSearchModule
  144. },
  145. mixins: [list],
  146. data() {
  147. return {
  148. tabIndex: 0,
  149. tabs: [
  150. {
  151. name: '员工列表',
  152. value: 0
  153. },
  154. {
  155. name: '角色管理',
  156. value: 2
  157. }
  158. ],
  159. // 删除弹窗操作
  160. delModal: false,
  161. delModalText: '确定删除该员工吗?',
  162. operateData: {},
  163. // 角色弹窗操作
  164. roleModal: false,
  165. roleModalText: '添加',
  166. roleModalVal: '',
  167. roleOperateData: {}
  168. }
  169. },
  170. onPullDownRefresh() {
  171. this.resetList()
  172. this._list().then(res => {
  173. uni.stopPullDownRefresh()
  174. })
  175. },
  176. computed: {
  177. ...mapGetters({ loginInfo: "getLoginInfo" }),
  178. },
  179. onReachBottom() {
  180. if (!this.list.finished) {
  181. this._list().then(res => {
  182. uni.stopPullDownRefresh()
  183. })
  184. } else {
  185. uni.stopPullDownRefresh()
  186. }
  187. },
  188. onLoad: function() {
  189. },
  190. methods: {
  191. async init() {
  192. this._list()
  193. },
  194. searchFn(){
  195. },
  196. _list() {
  197. let hostFn = this.tabIndex == 0 ? getStaffList : this.tabIndex == 1 ? getRoleList : getLogList
  198. return hostFn().then(res => {
  199. this.completes(res)
  200. })
  201. },
  202. change(e) {
  203. if (this.tabIndex == e.index) {
  204. return false
  205. } else {
  206. this.tabIndex = e.index
  207. this.resetList()
  208. this._list()
  209. }
  210. },
  211. // 关闭弹窗
  212. modalCancel() {
  213. this.delModal = false
  214. this.roleModal = false
  215. },
  216. modifyModalFn(item) {
  217. },
  218. // 删除弹窗
  219. delModalFn(item) {
  220. this.delModalText = this.tabIndex == 0 ? '确定删除该员工吗?' : '确定删除该角色吗?'
  221. this.operateData = item
  222. this.delModal = true
  223. },
  224. delModalClick(e) {
  225. let index = e.index
  226. if (index === 0) {
  227. this.modalCancel()
  228. } else {
  229. let hostFn = this.tabIndex == 0 ? delStaff : delRole
  230. hostFn({ id: this.operateData.id }).then(res => {
  231. this.modalCancel()
  232. this.$msg('删除成功!')
  233. setTimeout(() => {
  234. this.resetList()
  235. this._list()
  236. }, 1000)
  237. })
  238. }
  239. },
  240. // 角色操作
  241. addRoleFn() {
  242. this.roleModal = true
  243. this.roleModalText = '添加'
  244. this.roleModalVal = ''
  245. },
  246. modifyRoleFn(item) {
  247. this.roleModal = true
  248. this.roleModalText = '修改'
  249. this.roleModalVal = item.roleName
  250. this.roleOperateData = item
  251. },
  252. roleModalClick(e) {
  253. let index = e.index
  254. if (index === 0) {
  255. this.modalCancel()
  256. } else {
  257. let hostFn = this.roleModalText == '添加' ? addRole : updateRole
  258. let params = {
  259. roleName: this.roleModalVal
  260. }
  261. if (this.roleModalText == '修改') {
  262. params.id = this.roleOperateData.id
  263. }
  264. hostFn(params).then(res => {
  265. this.modalCancel()
  266. this.$msg(`${this.roleModalText}成功!`)
  267. setTimeout(() => {
  268. this.resetList()
  269. this._list()
  270. }, 1000)
  271. })
  272. }
  273. }
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .app-content {
  279. padding-top: 100upx;
  280. padding-bottom: 20upx;
  281. }
  282. .app-tabs {
  283. position: fixed;
  284. /* 手机mobile屏幕小于1000px */
  285. @media screen and (max-width: 1100px) {
  286. width: 100%;
  287. }
  288. /* 收银台cashier屏幕大于1000px */
  289. @media screen and (min-width:1100px) {
  290. width: 40%;
  291. }
  292. z-index: 9;
  293. }
  294. .input-wrap_box {
  295. background-color: #fff;
  296. position: fixed;
  297. top: 0;
  298. z-index: 10;
  299. /* 手机mobile屏幕小于1000px */
  300. @media screen and (max-width: 1100px) {
  301. width: 100%;
  302. }
  303. /* 收银台cashier屏幕大于1000px */
  304. @media screen and (min-width:1100px) {
  305. width: 40%;
  306. }
  307. height: 100upx;
  308. display: flex;
  309. align-items: center;
  310. padding: 0 30upx;
  311. & > view:nth-child(1) {
  312. flex: 1;
  313. }
  314. }
  315. .list-wrap {
  316. background-color: #fff;
  317. margin-top:85upx;
  318. .list {
  319. @include disFlex(center, flex-start);
  320. margin: 0 30upx;
  321. padding: 30upx 0;
  322. border-bottom: 2upx solid $borderColor;
  323. }
  324. }
  325. .staff-list {
  326. padding-bottom:100upx;
  327. .list-det {
  328. width: calc(100% - 110upx);
  329. color: $fontColor3;
  330. margin-left: 20upx;
  331. @include disFlex(center, space-between);
  332. .list-det-left {
  333. position:relative;
  334. .staff-name {
  335. color: #333;
  336. font-size: 30upx;
  337. font-weight: 600;
  338. margin-right: 10upx;
  339. display: inline-block;
  340. overflow: hidden;
  341. text-overflow:ellipsis;
  342. white-space: nowrap;
  343. width:150upx;
  344. }
  345. .super-class{
  346. background-color: #3385FF;
  347. border:none;
  348. color:white;
  349. font-size:20upx;
  350. border-radius:20upx;
  351. width:70upx;
  352. text-align: center;
  353. padding:6upx 0 6upx 0;
  354. position:absolute;
  355. right:-90upx;
  356. top:9upx;
  357. }
  358. .flex-center {
  359. margin-top: 10upx;
  360. }
  361. .status-list {
  362. margin-left: 25upx;
  363. &:first-child {
  364. margin-left: 0;
  365. }
  366. .iconfont {
  367. // color: $fontColor3;
  368. font-size: 24upx;
  369. margin-right: 10upx;
  370. }
  371. }
  372. }
  373. .list-det-right {
  374. @include disFlex(center, flex-start);
  375. & > div {
  376. margin-left: 50upx;
  377. &:first-child {
  378. margin-left: 0;
  379. }
  380. }
  381. .iconfont {
  382. font-size: 36upx;
  383. color: $fontColor3;
  384. }
  385. }
  386. }
  387. }
  388. // 角色管理
  389. .role-list {
  390. .list {
  391. justify-content: space-between;
  392. }
  393. .role-option {
  394. @include disFlex(center, flex-start);
  395. & > div {
  396. margin-left: 50upx;
  397. &:first-child {
  398. margin-left: 0;
  399. }
  400. }
  401. .iconfont {
  402. font-size: 36upx;
  403. color: $fontColor3;
  404. }
  405. }
  406. }
  407. // 操作记录
  408. .axis-wrap {
  409. position: relative;
  410. padding: 30upx 30upx 30upx 40upx;
  411. background-color: #fff;
  412. .axis-list {
  413. &:last-child .axis-det {
  414. margin-bottom: 0;
  415. }
  416. }
  417. .axis-title {
  418. font-size: 30upx;
  419. font-weight: 600;
  420. margin-bottom: 14upx;
  421. }
  422. .axis-det {
  423. color: $fontColor2;
  424. margin-bottom: 40upx;
  425. & > div {
  426. margin-top: 6upx;
  427. &:first-child {
  428. margin-top: 0;
  429. }
  430. }
  431. }
  432. }
  433. // 按钮
  434. .app-footer {
  435. justify-content: flex-end;
  436. .admin-button-com {
  437. width: 160upx;
  438. margin-right: 30upx;
  439. }
  440. }
  441. </style>