command.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view class="container">
  3. <view style="position: fixed; z-index: 2; top: 0; width: 100%; background: #ffffff">
  4. <view class="top_search">
  5. <u-search
  6. width="75%"
  7. shape="round"
  8. :action-style="styobj"
  9. bgColor="#f7f7f7"
  10. searchIconColor="#ccc"
  11. searchIconSize="28"
  12. placeholderColor="#BDBDBD"
  13. height="72"
  14. clearabled
  15. placeholder="请输入关键词搜索"
  16. v-model="form.body"
  17. @custom="custom"
  18. @search="search"
  19. @clear="clear"
  20. />
  21. </view>
  22. <view style="margin-top: 24rpx">
  23. <u-tabs
  24. :list="typeList"
  25. :is-scroll="true"
  26. :current="current"
  27. @change="change"
  28. inactive-color="#999999"
  29. font-size="32"
  30. :gutter="gutter"
  31. height="88"
  32. active-color="#DE2E27"
  33. bar-height="4"
  34. bar-width="64"
  35. :offset="offset"
  36. :bold="true"
  37. ></u-tabs>
  38. </view>
  39. </view>
  40. <view class="list" v-if="list.length">
  41. <view class="mim-view" v-for="item in list" :key="item.id" @click="goComplaintDetails(item)">
  42. <view class="h mim-font-16">
  43. {{ item.category_1 ? item.category_1.name : '' }}
  44. {{ item.category_2 ? '/' + item.category_2.name : '' }}
  45. {{ item.category_3 ? '/' + item.category_3.name : '' }}
  46. {{ item.category_4 ? '/' + item.category_4.name : '' }}
  47. {{ item.category_5 ? '/' + item.category_5.name : '' }}
  48. <u-tag v-if="item.is_more_department == 1 && item.check_status == 1" text="待指派" type="warning" size="mini" />
  49. <u-tag v-if="item.is_more_department == 1 && item.check_status == 2" text="指派任务" type="warning" size="mini" />
  50. <u-tag v-if="item.is_more_department == 0" text="主任务" type="success" size="mini" />
  51. </view>
  52. <view class="p1 mim-font-14 mim-multi-line">{{ item.body }}</view>
  53. <view class="t mim-font-14">{{ item.created_at }}</view>
  54. <view class="img_type">
  55. <u-image v-if="item.deal_status == '1'" src="@/static/images/index/dcl.png" width="240rpx" height="240rpx"></u-image>
  56. <u-image v-else-if="item.deal_status == '2'" src="@/static/images/index/clz.png" width="240rpx" height="240rpx"></u-image>
  57. <u-image v-else-if="item.deal_status == '3'" src="@/static/images/index/clwj.png" width="240rpx" height="240rpx"></u-image>
  58. </view>
  59. </view>
  60. <u-divider bg-color="#f7f7f7" fontSize="24">{{ divider }}</u-divider>
  61. </view>
  62. <view v-else style="margin-top: 350rpx">
  63. <u-empty></u-empty>
  64. </view>
  65. <view class="mim-view-list"></view>
  66. </view>
  67. </template>
  68. <script>
  69. export default {
  70. data() {
  71. return {
  72. name: '',
  73. styobj: {
  74. width: '104rpx',
  75. height: '56rpx',
  76. background: '#de2e27',
  77. 'border-radius': '32rpx',
  78. 'line-height': '32px',
  79. opacity: '1',
  80. display: 'flex',
  81. 'align-items': 'center',
  82. 'justify-content': 'center',
  83. color: '#ffffff',
  84. 'font-size': '28rpx',
  85. 'z-index': '2'
  86. },
  87. typeList: [],
  88. current: 0,
  89. offset: [10, -2],
  90. form: {
  91. deal_status: '',
  92. page: 1,
  93. per_page: 10,
  94. body: '',
  95. is_more_department: '',
  96. check_status: ''
  97. },
  98. list: [],
  99. page: '',
  100. divider: '没有更多数据啦~',
  101. gutter: '42',
  102. admin: false //当前用户是否为管理员
  103. };
  104. },
  105. onShow() {
  106. let roles = this.userRoles;
  107. let arr = roles.filter((item) => {
  108. return item.name == 'admin';
  109. });
  110. if (arr.length > 0) {
  111. this.admin = true;
  112. } else {
  113. this.admin = false;
  114. }
  115. this.commandListFn();
  116. this.commandNumFn();
  117. },
  118. onPullDownRefresh() {
  119. //下拉刷新
  120. this.commandListFn();
  121. this.commandNumFn();
  122. },
  123. onReachBottom() {
  124. //触底加载
  125. console.log('触底加载');
  126. this.divider = '加载中。。。';
  127. if (this.page > this.form.page) {
  128. this.form.page++;
  129. this.commandListFn(false);
  130. } else {
  131. this.divider = '没有更多数据啦~';
  132. this.$u.toast('没有更多数据啦~');
  133. }
  134. },
  135. methods: {
  136. async commandListFn(empty) {
  137. try {
  138. uni.showNavigationBarLoading();
  139. if (empty !== false) {
  140. this.form.page = 1;
  141. this.list = [];
  142. }
  143. const {
  144. data: { data, meta }
  145. } = await this.$u.api.commandList(this.form);
  146. this.page = meta.pagination.total_pages;
  147. this.list = this.page > 1 ? [...this.list, ...data] : data;
  148. this.divider = '没有更多数据啦~';
  149. } catch (error) {
  150. console.error(error);
  151. } finally {
  152. uni.hideNavigationBarLoading();
  153. uni.stopPullDownRefresh();
  154. }
  155. },
  156. //指挥交办数量查询
  157. async commandNumFn() {
  158. const res = await this.$u.api.commandNum();
  159. if (res.status === 'success') {
  160. this.typeList = res.data;
  161. }
  162. if (this.typeList.length == 5) {
  163. this.gutter = '26';
  164. }
  165. },
  166. //切换
  167. change(index) {
  168. this.current = index;
  169. if (index == 0) {
  170. this.form.deal_status = '';
  171. } else {
  172. if (this.typeList.length == 4) {
  173. this.form.deal_status = index;
  174. } else {
  175. switch (index) {
  176. case 2:
  177. this.form.deal_status = 1;
  178. this.form.is_more_department = 1;
  179. this.form.check_status = 1;
  180. this.form.sortedBy = 'asc';
  181. this.form.orderBy = 'created_at';
  182. break;
  183. case 3:
  184. this.form.deal_status = 2;
  185. this.form.is_more_department = '';
  186. this.form.check_status = '';
  187. this.form.sortedBy = 'asc';
  188. this.form.orderBy = 'created_at';
  189. break;
  190. case 4:
  191. this.form.deal_status = 3;
  192. this.form.is_more_department = '';
  193. this.form.check_status = '';
  194. this.form.sortedBy = 'desc';
  195. this.form.orderBy = 'created_at';
  196. break;
  197. default:
  198. this.form.deal_status = index;
  199. this.form.is_more_department = '';
  200. this.form.check_status = '';
  201. this.form.sortedBy = 'asc';
  202. this.form.orderBy = 'created_at';
  203. break;
  204. }
  205. }
  206. }
  207. this.commandListFn();
  208. },
  209. search() {
  210. this.commandListFn();
  211. },
  212. custom() {
  213. this.commandListFn();
  214. },
  215. clear() {
  216. //清空输入框内容
  217. this.form.body = '';
  218. this.commandListFn();
  219. },
  220. goComplaintDetails(item) {
  221. if (item.is_more_department == 1 && item.check_status == 1 && this.admin) {
  222. this.$u.route('/pages/command/application', {
  223. id: item.id,
  224. type: 2
  225. });
  226. } else {
  227. this.$u.route('/pages/command/commandDetails', {
  228. id: item.id
  229. });
  230. }
  231. }
  232. }
  233. };
  234. </script>
  235. <style lang="scss">
  236. page {
  237. background-color: #f7f7f7;
  238. .container {
  239. /deep/.u-badge {
  240. min-width: 36rpx;
  241. height: 36rpx;
  242. padding: 0;
  243. }
  244. .top_search {
  245. background: #f7f7f7;
  246. border-radius: 50rpx;
  247. margin: 24rpx;
  248. padding-right: 16rpx;
  249. }
  250. .list {
  251. // margin-top: 240rpx;
  252. padding-top: 220rpx;
  253. .mim-view {
  254. overflow: hidden;
  255. .h {
  256. font-weight: bold;
  257. }
  258. .p1 {
  259. color: #999;
  260. margin-top: 24rpx;
  261. }
  262. .t {
  263. color: #bdbdbd;
  264. margin-top: 48rpx;
  265. }
  266. .img_type {
  267. position: absolute;
  268. bottom: -80rpx;
  269. right: -60rpx;
  270. border-bottom: none;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. </style>