index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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.clearPage();
  126. that.search();
  127. }
  128. } catch (e) {
  129. uni.showToast({
  130. title: err.errmsg,
  131. icon: 'error',
  132. duration: 2000
  133. });
  134. }
  135. },
  136. async search() {
  137. const that = this;
  138. let user = that.user;
  139. let status = that.status;
  140. let info = {
  141. skip: that.skip,
  142. limit: that.limit,
  143. street: user.street,
  144. status: status,
  145. }
  146. let res;
  147. res = await that.$api(`/User/queryInfo`, 'GET', {
  148. ...info,
  149. ...that.searchInfo
  150. });
  151. if (res.errcode == '0') {
  152. let list = [...that.list, ...res.data];
  153. for (let val of list) {
  154. val.zhStatus = that.searchDict(val.status, 'status')
  155. val.zhGender = that.searchDict(val.gender, 'gender')
  156. val.zhRole = that.searchDict(val.role, 'role')
  157. val.zhStreet = that.searchDict(val.street, 'street')
  158. val.zhCommunity = that.searchDict(val.community, 'community')
  159. }
  160. that.$set(that, `list`, list);
  161. that.$set(that, `total`, res.total)
  162. } else {
  163. uni.showToast({
  164. title: res.errmsg,
  165. icon: 'none'
  166. })
  167. }
  168. },
  169. // 转换字典表
  170. searchDict(e, model) {
  171. const that = this;
  172. let data;
  173. if (model == 'status') {
  174. data = that.statusList.find((i) => i.value == e);
  175. if (data) return data.label
  176. else return '暂无'
  177. } else if (model == 'gender') {
  178. data = that.genderList.find((i) => i.value == e);
  179. if (data) return data.label
  180. else return '暂无'
  181. } else if (model == 'role') {
  182. data = that.roleList.find((i) => i.code == e);
  183. if (data) return data.name
  184. else return '暂无'
  185. } else if (model == 'street') {
  186. data = that.benlongList.find((i) => i._id == e);
  187. if (data) return data.name
  188. else return '暂无'
  189. } else if (model == 'community') {
  190. data = that.benlongList.find((i) => i._id == e);
  191. if (data) return data.name
  192. else return '暂无'
  193. }
  194. },
  195. // 确认发货
  196. async toExam(item, type) {
  197. const that = this;
  198. let user = that.user;
  199. let obj = {}
  200. if (type == '0') obj.status == '1'
  201. else obj.status == '2'
  202. uni.showModal({
  203. title: '提示',
  204. content: '是否要确认审批?',
  205. success: async function(res) {
  206. if (res.confirm) {
  207. const res = await that.$api(`/User/${item._id}`, 'POST', obj);
  208. if (res.errcode == '0') {
  209. uni.showToast({
  210. title: '维护信息成功',
  211. icon: 'none'
  212. })
  213. that.clearPage()
  214. that.search()
  215. } else {
  216. uni.showToast({
  217. title: res.errmsg,
  218. icon: 'none'
  219. })
  220. }
  221. }
  222. }
  223. });
  224. },
  225. // 查看详情
  226. toInfo(e) {
  227. console.log(e);
  228. },
  229. // 分页
  230. toPage(e) {
  231. const that = this;
  232. let list = that.list;
  233. let limit = that.limit;
  234. if (that.total > list.length) {
  235. uni.showLoading({
  236. title: '加载中',
  237. mask: true
  238. })
  239. let page = that.page + 1;
  240. that.$set(that, `page`, page)
  241. let skip = page * limit;
  242. that.$set(that, `skip`, skip)
  243. that.search();
  244. uni.hideLoading();
  245. } else that.$set(that, `is_bottom`, true)
  246. },
  247. // 触底
  248. toScroll(e) {
  249. const that = this;
  250. let up = that.scrollTop;
  251. that.$set(that, `scrollTop`, e.detail.scrollTop);
  252. let num = Math.sign(up - e.detail.scrollTop);
  253. if (num == 1) that.$set(that, `is_bottom`, false);
  254. },
  255. // 输入框
  256. toInput(e) {
  257. const that = this;
  258. if (that.searchInfo.name) that.$set(that.searchInfo, `name`, e.detail.value)
  259. else that.$set(that, `searchInfo`, {})
  260. that.clearPage();
  261. that.search();
  262. },
  263. // 查询其他信息
  264. async searchOther() {
  265. const that = this;
  266. let res;
  267. // 查询状态
  268. res = await that.$api(`/DictData`, 'GET', {
  269. type: 'status',
  270. is_use: '0'
  271. })
  272. if (res.errcode == '0') {
  273. that.$set(that, `statusList`, res.data);
  274. var menu = res.data.map((item) => {
  275. return {
  276. title: item.label,
  277. active: item.value
  278. }
  279. })
  280. that.$set(that.tabs, `menu`, menu)
  281. }
  282. // 性别
  283. res = await that.$api(`/DictData`, 'GET', {
  284. type: 'gender',
  285. is_use: '0'
  286. })
  287. if (res.errcode == '0') that.$set(that, `genderList`, res.data);
  288. // 角色
  289. res = await that.$api(`/Role`, 'GET', {
  290. is_use: '0'
  291. })
  292. if (res.errcode == '0') that.$set(that, `roleList`, res.data);
  293. // 街道/社区
  294. res = await that.$api(`/Office`, 'GET', {
  295. is_use: '0'
  296. })
  297. if (res.errcode == '0') that.$set(that, `benlongList`, res.data);
  298. },
  299. // 选择选项卡
  300. tabsChange(e) {
  301. const that = this;
  302. that.$set(that.tabs, `active`, e.active)
  303. that.$set(that, `status`, e.active);
  304. that.clearPage();
  305. that.search()
  306. },
  307. // 清空列表
  308. clearPage() {
  309. const that = this;
  310. that.$set(that, `list`, [])
  311. that.$set(that, `skip`, 0)
  312. that.$set(that, `limit`, 6)
  313. that.$set(that, `page`, 0)
  314. }
  315. }
  316. }
  317. </script>
  318. <style lang="scss">
  319. .content {
  320. display: flex;
  321. flex-direction: column;
  322. width: 100vw;
  323. height: 100vh;
  324. .one {
  325. padding: 2vw;
  326. input {
  327. padding: 2vw;
  328. background-color: var(--f1Color);
  329. font-size: var(--font14Size);
  330. border-radius: 5px;
  331. }
  332. }
  333. .two {
  334. position: relative;
  335. flex-grow: 1;
  336. background-color: var(--f9Color);
  337. .tabsList {
  338. position: relative;
  339. width: 100vw;
  340. height: 82vh;
  341. .list {
  342. background-color: #fff;
  343. border: 1px solid var(--f5Color);
  344. padding: 2vw;
  345. margin: 0 2vw 2vw 2vw;
  346. border-radius: 5px;
  347. .list_1 {
  348. display: flex;
  349. justify-content: space-between;
  350. padding: 2vw 0;
  351. font-size: var(--font16Size);
  352. .status {
  353. font-size: var(--font14Size);
  354. color: var(--fF0Color);
  355. }
  356. }
  357. .list_2 {
  358. .other {
  359. font-size: var(--font14Size);
  360. text:last-child {
  361. color: var(--f85Color);
  362. }
  363. }
  364. }
  365. .bottom {
  366. text-align: center;
  367. padding: 1vw 0;
  368. button {
  369. margin: 0 5px 0 0;
  370. }
  371. }
  372. }
  373. }
  374. }
  375. }
  376. .scroll-view {
  377. position: absolute;
  378. top: 0;
  379. left: 0;
  380. right: 0;
  381. bottom: 0;
  382. .list-scroll-view {
  383. display: flex;
  384. flex-direction: column;
  385. }
  386. }
  387. .is_bottom {
  388. width: 100%;
  389. text-align: center;
  390. text {
  391. padding: 2vw 0;
  392. display: inline-block;
  393. color: var(--f85Color);
  394. font-size: var(--font14Size);
  395. }
  396. }
  397. </style>