index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <input type="text" v-model="searchInfo.name" @input="toInput" placeholder="搜索用户姓名">
  5. </view>
  6. <view class="two">
  7. <tabs :tabs="tabs" @tabsChange="tabsChange">
  8. <view class="tabsList">
  9. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  10. <view class="list-scroll-view">
  11. <view class="list" v-for="(item,index) in list" :key="index" @tap="toInfo(item)">
  12. <view class="list_1">
  13. <text>
  14. <text class="iconfont icon-yonghu"></text>
  15. {{item.name}}
  16. </text>
  17. <text class="status">{{item.zhStatus}}</text>
  18. </view>
  19. <view class="list_2">
  20. <view class="other">
  21. <text>联系电话:</text>
  22. <text>{{item.tel||'暂无'}}</text>
  23. </view>
  24. <view class="other">
  25. <text>性别:</text>
  26. <text>{{item.zhGender||'暂无'}}</text>
  27. </view>
  28. <view class="other">
  29. <text>角色:</text>
  30. <text>{{item.zhRole||'暂无'}}</text>
  31. </view>
  32. <view class="other">
  33. <text>所属街道:</text>
  34. <text>{{item.zhStreet||'暂无'}}</text>
  35. </view>
  36. <view class="other">
  37. <text>所属社区:</text>
  38. <text>{{item.zhCommunity||'暂无'}}</text>
  39. </view>
  40. </view>
  41. <view class="bottom" v-if="item.status=='0'">
  42. <button size="mini" type="default" @tap.stop="toExam(item,'0')">审核通过</button>
  43. <button size="mini" type="warn" @tap.stop="toExam(item,'1')">审核拒绝</button>
  44. </view>
  45. </view>
  46. <view class="is_bottom" v-if="is_bottom">
  47. <text>{{config.bottom_title}}</text>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. </tabs>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import tabs from '../../components/tabs/index.vue';
  58. export default {
  59. components: {
  60. tabs
  61. },
  62. data() {
  63. return {
  64. // 系统设置
  65. config: {},
  66. user: {},
  67. status: '',
  68. searchInfo: {},
  69. tabs: {
  70. active: '0',
  71. menu: []
  72. },
  73. list: [],
  74. total: 0,
  75. skip: 0,
  76. limit: 6,
  77. page: 0,
  78. // 数据是否触底
  79. is_bottom: false,
  80. scrollTop: 0,
  81. // 字典表
  82. statusList: [],
  83. genderList: [],
  84. roleList: [],
  85. benlongList: []
  86. }
  87. },
  88. onLoad: function(e) {
  89. const that = this;
  90. that.$set(that, `status`, e.status || '0');
  91. that.$set(that.tabs, `active`, e.status || '0');
  92. that.searchConfig();
  93. },
  94. onShow: async function(e) {
  95. const that = this;
  96. await that.searchOther();
  97. that.searchToken();
  98. },
  99. onPullDownRefresh: async function() {
  100. const that = this;
  101. that.clearPage();
  102. await that.search();
  103. uni.stopPullDownRefresh();
  104. },
  105. methods: {
  106. searchConfig() {
  107. const that = this;
  108. try {
  109. const res = uni.getStorageSync('config');
  110. if (res) that.$set(that, `config`, res);
  111. } catch (e) {
  112. uni.showToast({
  113. title: err.errmsg,
  114. icon: 'error',
  115. duration: 2000
  116. });
  117. }
  118. },
  119. searchToken() {
  120. const that = this;
  121. try {
  122. const res = uni.getStorageSync('token');
  123. if (res) {
  124. that.$set(that, `user`, res);
  125. that.search();
  126. }
  127. } catch (e) {
  128. uni.showToast({
  129. title: err.errmsg,
  130. icon: 'error',
  131. duration: 2000
  132. });
  133. }
  134. },
  135. async search() {
  136. const that = this;
  137. let user = that.user;
  138. let status = that.status;
  139. let info = {
  140. skip: that.skip,
  141. limit: that.limit,
  142. street: user.street,
  143. status: status,
  144. }
  145. let res;
  146. res = await that.$api(`/User/queryInfo`, 'GET', {
  147. ...info,
  148. ...that.searchInfo
  149. });
  150. if (res.errcode == '0') {
  151. let list = [...that.list, ...res.data];
  152. for (let val of list) {
  153. val.zhStatus = that.searchDict(val.status, 'status')
  154. val.zhGender = that.searchDict(val.gender, 'gender')
  155. val.zhRole = that.searchDict(val.role, 'role')
  156. val.zhStreet = that.searchDict(val.street, 'street')
  157. val.zhCommunity = that.searchDict(val.community, 'community')
  158. }
  159. that.$set(that, `list`, list);
  160. that.$set(that, `total`, res.total)
  161. } else {
  162. uni.showToast({
  163. title: res.errmsg,
  164. icon: 'none'
  165. })
  166. }
  167. },
  168. // 转换字典表
  169. searchDict(e, model) {
  170. const that = this;
  171. let data;
  172. if (model == 'status') {
  173. data = that.statusList.find((i) => i.value == e);
  174. if (data) return data.label
  175. else return '暂无'
  176. } else if (model == 'gender') {
  177. data = that.genderList.find((i) => i.value == e);
  178. if (data) return data.label
  179. else return '暂无'
  180. } else if (model == 'role') {
  181. data = that.roleList.find((i) => i.code == e);
  182. if (data) return data.name
  183. else return '暂无'
  184. } else if (model == 'street') {
  185. data = that.benlongList.find((i) => i._id == e);
  186. if (data) return data.name
  187. else return '暂无'
  188. } else if (model == 'community') {
  189. data = that.benlongList.find((i) => i._id == e);
  190. if (data) return data.name
  191. else return '暂无'
  192. }
  193. },
  194. // 确认发货
  195. async toExam(item, type) {
  196. const that = this;
  197. let user = that.user;
  198. let obj = {}
  199. if (type == '0') obj.status == '1'
  200. else obj.status == '2'
  201. uni.showModal({
  202. title: '提示',
  203. content: '是否要确认审核?',
  204. success: async function(res) {
  205. if (res.confirm) {
  206. const res = await that.$api(`/User/${item._id}`, 'POST', obj);
  207. if (res.errcode == '0') {
  208. uni.showToast({
  209. title: '维护信息成功',
  210. icon: 'none'
  211. })
  212. that.clearPage()
  213. that.search()
  214. } else {
  215. uni.showToast({
  216. title: res.errmsg,
  217. icon: 'none'
  218. })
  219. }
  220. }
  221. }
  222. });
  223. },
  224. // 查看详情
  225. toInfo(item) {
  226. console.log(item);
  227. },
  228. // 分页
  229. toPage(e) {
  230. const that = this;
  231. let list = that.list;
  232. let limit = that.limit;
  233. if (that.total > list.length) {
  234. uni.showLoading({
  235. title: '加载中',
  236. mask: true
  237. })
  238. let page = that.page + 1;
  239. that.$set(that, `page`, page)
  240. let skip = page * limit;
  241. that.$set(that, `skip`, skip)
  242. that.search();
  243. uni.hideLoading();
  244. } else that.$set(that, `is_bottom`, true)
  245. },
  246. // 触底
  247. toScroll(e) {
  248. const that = this;
  249. let up = that.scrollTop;
  250. that.$set(that, `scrollTop`, e.detail.scrollTop);
  251. let num = Math.sign(up - e.detail.scrollTop);
  252. if (num == 1) that.$set(that, `is_bottom`, false);
  253. },
  254. // 输入框
  255. toInput(e) {
  256. const that = this;
  257. if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
  258. else that.$set(that, `searchInfo`, {})
  259. that.clearPage();
  260. that.search();
  261. },
  262. // 查询其他信息
  263. async searchOther() {
  264. const that = this;
  265. let res;
  266. // 查询状态
  267. res = await that.$api(`/DictData`, 'GET', {
  268. type: 'status',
  269. is_use: '0'
  270. })
  271. if (res.errcode == '0') {
  272. that.$set(that, `statusList`, res.data);
  273. var menu = res.data.map((item) => {
  274. return {
  275. title: item.label,
  276. active: item.value
  277. }
  278. })
  279. that.$set(that.tabs, `menu`, menu)
  280. }
  281. // 性别
  282. res = await that.$api(`/DictData`, 'GET', {
  283. type: 'gender',
  284. is_use: '0'
  285. })
  286. if (res.errcode == '0') that.$set(that, `genderList`, res.data);
  287. // 角色
  288. res = await that.$api(`/Role`, 'GET', {
  289. is_use: '0'
  290. })
  291. if (res.errcode == '0') that.$set(that, `roleList`, res.data);
  292. // 街道/社区
  293. res = await that.$api(`/Office`, 'GET', {
  294. is_use: '0'
  295. })
  296. if (res.errcode == '0') that.$set(that, `benlongList`, res.data);
  297. },
  298. // 选择选项卡
  299. tabsChange(e) {
  300. const that = this;
  301. that.$set(that.tabs, `active`, e.active)
  302. that.$set(that, `status`, e.active);
  303. that.clearPage();
  304. that.search()
  305. },
  306. // 清空列表
  307. clearPage() {
  308. const that = this;
  309. that.$set(that, `list`, [])
  310. that.$set(that, `skip`, 0)
  311. that.$set(that, `limit`, 6)
  312. that.$set(that, `page`, 0)
  313. }
  314. }
  315. }
  316. </script>
  317. <style lang="scss">
  318. .content {
  319. display: flex;
  320. flex-direction: column;
  321. width: 100vw;
  322. height: 100vh;
  323. .one {
  324. padding: 2vw;
  325. input {
  326. padding: 2vw;
  327. background-color: var(--f1Color);
  328. font-size: var(--font14Size);
  329. border-radius: 5px;
  330. }
  331. }
  332. .two {
  333. position: relative;
  334. flex-grow: 1;
  335. background-color: var(--f9Color);
  336. .tabsList {
  337. position: relative;
  338. width: 100vw;
  339. height: 82vh;
  340. .list {
  341. background-color: #fff;
  342. border: 1px solid var(--f5Color);
  343. padding: 2vw;
  344. margin: 0 2vw 2vw 2vw;
  345. border-radius: 5px;
  346. .list_1 {
  347. display: flex;
  348. justify-content: space-between;
  349. padding: 2vw 0;
  350. font-size: var(--font16Size);
  351. .status {
  352. font-size: var(--font14Size);
  353. color: var(--fF0Color);
  354. }
  355. }
  356. .list_2 {
  357. .other {
  358. font-size: var(--font14Size);
  359. text:last-child {
  360. color: var(--f85Color);
  361. }
  362. }
  363. }
  364. .bottom {
  365. text-align: center;
  366. padding: 1vw 0;
  367. button {
  368. margin: 0 5px 0 0;
  369. }
  370. }
  371. }
  372. }
  373. }
  374. }
  375. .scroll-view {
  376. position: absolute;
  377. top: 0;
  378. left: 0;
  379. right: 0;
  380. bottom: 0;
  381. .list-scroll-view {
  382. display: flex;
  383. flex-direction: column;
  384. }
  385. }
  386. .is_bottom {
  387. text-align: center;
  388. text {
  389. padding: 2vw 0;
  390. display: inline-block;
  391. color: var(--f85Color);
  392. font-size: var(--font14Size);
  393. }
  394. }
  395. </style>