index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="uni-container uni-container-bg">
  3. <!-- 搜索框 -->
  4. <uni-row class="demo-uni-row padding-tb-sm" :gutter="20" width="100%">
  5. <uni-col :span="24">
  6. <view class="u-page__tag-item">
  7. <u-search placeholder="请输入培训演练名称" bgColor="#edf6f9" borderColor="#4cb2b6" v-model="keyword"
  8. :show-action="true" @custom="search"></u-search>
  9. </view>
  10. </uni-col>
  11. </uni-row>
  12. <!-- 下拉框 -->
  13. <view class="u-page__tag-item"
  14. style="margin-bottom: 26upx;width: 700upx;border-bottom: 2px solid #55cbbf;background-color: #f5f7fa;">
  15. <u-form>
  16. <u-form-item prop="orgName" @click="
  17. showOrg = true;
  18. hideKeyboard();
  19. " label="单位选择:" labelWidth="100px">
  20. <!-- <u-picker :show="showOrg" :columns="actions"></u-picker> -->
  21. <u--input border="none" disabled v-model="formData.orgName" placeholder="请选择所属单位"></u--input>
  22. <u-icon slot="right" name="arrow-down"></u-icon>
  23. </u-form-item>
  24. </u-form>
  25. </view>
  26. <!-- 卡片栏 -->
  27. <view v-if="tableData.length>0 && isLoaded">
  28. <view v-for="(item, index) in tableData" :key="index"
  29. v-if="formData.orgName == item.orgName || formData.orgId == item.orgId">
  30. <uni-card>
  31. <!-- 标题 -->
  32. <view class="titles">{{ item.drillTitle }}</view>
  33. <!-- 简要内容 -->
  34. <view style="display: flex;margin-bottom: 15rpx; color: #728f90;">
  35. <text class="name-align-drill">培训演练时间:</text>
  36. <text class="conts">{{ item.drillDate }}</text>
  37. </view>
  38. <view style="display: flex;margin-bottom: 15rpx; color: #728f90;">
  39. <text class="name-align-drill">培训演练地点:</text>
  40. <text class="conts">{{ item.drillPlace }}</text>
  41. </view>
  42. <view style="display: flex;margin-bottom: 15rpx; color: #728f90;">
  43. <text class="name-align-drill">记录类型:</text>
  44. <text class="conts max-width">{{ item.drillTypeName }}</text>
  45. </view>
  46. <view class="an-niu" @click.native="onClick(item,formData.orgName)" link><text
  47. class="detail">查看详情</text></view>
  48. </uni-card>
  49. </view>
  50. </view>
  51. <!-- tableData为空时显示 -->
  52. <view v-else-if="tableData.length==0 && isLoaded" style="text-align: center;">
  53. <view class="text-gray" style="padding-top: 20px;" v-if="tableData == 0">
  54. <img :src="tan90" alt="暂无数据" />
  55. </view>
  56. </view>
  57. <u-action-sheet :show="showOrg" :actions="actions" title="请选择单位" @close="showOrg = false"
  58. @select="sexSelect"></u-action-sheet>
  59. <!-- 加载中 -->
  60. <isLodingModel></isLodingModel>
  61. </view>
  62. </template>
  63. <script>
  64. var that = '';
  65. import {
  66. getDrill, //获取培训演练信息列表
  67. delDrill, //删除培训演练信息
  68. getOrgId //获取orgId
  69. } from '@/api/drill';
  70. import config from '@/config'
  71. const baseUrlImg = config.baseUrlImg
  72. export default {
  73. data() {
  74. return {
  75. isLoaded: false,
  76. Group: `${baseUrlImg}/checkActive/Group.png`,
  77. showOrg: false,
  78. actions: [],
  79. // 数据
  80. tableData: [],
  81. id: '',
  82. tan90: `${baseUrlImg}/tan90.png`,
  83. // 每页数据量
  84. pageSize: 10,
  85. // 当前页
  86. pageNo: 1,
  87. // 数据总量
  88. total: 0,
  89. // tableData数据加载中
  90. loading: false,
  91. // 初始化时搜索框的值
  92. keyword: '',
  93. // 存放orgid,orgname
  94. formData: {
  95. orgName: ''
  96. },
  97. show: false,
  98. showtimeStart: false,
  99. showtimeEnd: false
  100. };
  101. },
  102. watch: {
  103. loading: {
  104. handler(newLength, oldLength) {
  105. this.$modal.isLoadingModel(this.loading)
  106. },
  107. immediate: true
  108. }
  109. },
  110. mounted() {
  111. this.actions = []
  112. that = this;
  113. getOrgId({
  114. pageNo: this.pageNo,
  115. pageSize: this.pageSize,
  116. userId: this.$store.state.user.id
  117. }).then(response => {
  118. // 取到用户对应的单位名称与id
  119. response.data.map(v => {
  120. this.actions.push({
  121. id: v.dwid,
  122. name: v.orgName
  123. });
  124. });
  125. this.formData.orgName = response.data[0].orgName;
  126. this.formData.orgId = response.data[0].dwid;
  127. this.tableData = []
  128. this.getData();
  129. });
  130. },
  131. onReady() {},
  132. mixins: [uni.$u.mixin],
  133. methods: {
  134. search(val) {
  135. this.isLoaded =false
  136. this.tableData = []
  137. this.getData(1)
  138. },
  139. // 获取数据
  140. getData() {
  141. this.loading = true;
  142. // 获取培训演练信息详细信息
  143. getDrill({
  144. pageNo: this.pageNo,
  145. pageSize: this.pageSize,
  146. orgId: this.formData.orgId,
  147. drillTitle: this.keyword
  148. }).then(response => {
  149. this.isLoaded = true
  150. this.tableData = [...this.tableData, ...response.data.list]
  151. this.total=response.data.total
  152. this.loading = false
  153. this.tableData.map(i => {
  154. if (i.drillType == 1) {
  155. i.drillTypeName = '培训'
  156. } else if (i.drillType == 2) {
  157. i.drillTypeName = '演练'
  158. }
  159. })
  160. });
  161. },
  162. // 传递数据
  163. onClick(val, orgName) {
  164. this.isLoaded = false
  165. uni.navigateTo({
  166. url: '/pagesA/fire/drill/drill_details/drill_details?id=' + val.id + '&orgName=' + orgName+'&historyView=historyView',
  167. events: {
  168. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  169. acceptDataFromOpenedPage: function(val) {
  170. }
  171. },
  172. success: function(res) {
  173. // 通过eventChannel向被打开页面传送数据
  174. res.eventChannel.emit('acceptDataFromOpenerPage', val);
  175. }
  176. });
  177. },
  178. sexSelect(e) {
  179. this.formData.orgId = e.id;
  180. this.formData.orgName = e.name;
  181. // 获取培训演练信息详细信息
  182. getDrill({
  183. pageNo: this.pageNo,
  184. pageSize: this.pageSize,
  185. orgId: this.formData.orgId
  186. }).then(response => {
  187. this.tableData = response.data.list;
  188. });
  189. },
  190. // 触底的事件
  191. onReachBottom() {
  192. // 判断是否还有下一页数据
  193. if (this.pageNo * this.pageSize >= this.total)
  194. return uni.showToast({
  195. title: `数据加载完毕`
  196. });
  197. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  198. if (this.loading) return;
  199. this.pageNo += 1;
  200. this.getData(this.pageNo);
  201. },
  202. // 隐藏键盘
  203. hideKeyboard() {
  204. uni.hideKeyboard();
  205. }
  206. }
  207. };
  208. </script>
  209. <style lang="scss" scoped>
  210. body {
  211. background-color: #f5f7f9;
  212. }
  213. page {
  214. background-color: #f5f7f9;
  215. }
  216. /deep/ .u-tabs__wrapper[data-v-0de61367],
  217. /deep/ .u-tabs__wrapper.data-v-0de61367,
  218. /deep/ .u-tabs__wrapper {
  219. width: 99%;
  220. }
  221. /deep/.u-tabs__wrapper__nav__item[data-v-0de61367],
  222. /deep/.u-tabs__wrapper__nav__item.data-v-0de61367,
  223. /deep/.u-tabs__wrapper__nav__item {
  224. padding: 0 60rpx;
  225. }
  226. .uni-container {
  227. height: 100vh;
  228. padding-right: 20upx;
  229. }
  230. .addInsp {
  231. width: 40px;
  232. position: fixed;
  233. right: 4px;
  234. z-index: 99999;
  235. }
  236. ::v-deep .u-icon__icon {
  237. margin-right: 0px !important;
  238. }
  239. .an-niu {
  240. float: right;
  241. font-size: 10px;
  242. text-align: center;
  243. display: flex;
  244. margin-top: -64upx;
  245. padding-bottom: 30rpx;
  246. // margin-top: 50rpx;
  247. color: #fff;
  248. .detail {
  249. width: 60px;
  250. height: 60rpx;
  251. padding: 0 20rpx;
  252. border-radius: 30px;
  253. background-color: #f7c41e;
  254. margin-right: 20rpx;
  255. text-align: center;
  256. line-height: 60rpx;
  257. font-size: 27upx;
  258. }
  259. .detailDel {
  260. width: 60px;
  261. height: 60rpx;
  262. padding: 0 20rpx;
  263. border-radius: 30px;
  264. background-color: #ff2e31;
  265. color: white;
  266. margin-right: 20rpx;
  267. text-align: center;
  268. line-height: 60rpx;
  269. font-size: 30upx;
  270. }
  271. .solve {
  272. width: 62px;
  273. height: 60rpx;
  274. margin-right: 20rpx;
  275. border-radius: 30px;
  276. background-color: #4cb2b6;
  277. line-height: 60rpx;
  278. }
  279. /deep/ .padding-tb-sm {
  280. padding-top: 0px;
  281. padding-bottom: 10px;
  282. }
  283. .deletes {
  284. width: 62px;
  285. height: 60rpx;
  286. border-radius: 60rpx;
  287. background-color: red;
  288. color: #fff;
  289. line-height: 60rpx;
  290. }
  291. }
  292. /deep/.segmented-control__item--button {
  293. background-color: rgb(76, 178, 182) !important;
  294. }
  295. /deep/.segmented-control__item--button--active {
  296. background-color: #ffffff !important;
  297. }
  298. /deep/.uni-card {
  299. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  300. border-radius: 30rpx;
  301. }
  302. .tiantupian {
  303. width: 110rpx;
  304. height: 110rpx;
  305. position: fixed;
  306. right: 15px;
  307. bottom: 80rpx;
  308. }
  309. //列表样式
  310. .titles {
  311. font-weight: 600;
  312. margin-bottom: 10rpx;
  313. color: black;
  314. font-size: 32rpx;
  315. }
  316. .conts {
  317. max-width: 470rpx;
  318. display: -webkit-box;
  319. /*弹性伸缩盒子模型显示*/
  320. -webkit-box-orient: vertical;
  321. /*排列方式*/
  322. -webkit-line-clamp: 1;
  323. /*显示文本行数*/
  324. overflow: hidden;
  325. /*溢出隐藏*/
  326. color: #274647;
  327. text-overflow: ellipsis;
  328. /*不知道干嘛的*/
  329. .conts-title {
  330. margin-right: 10rpx;
  331. color: #728f90;
  332. }
  333. }
  334. .max-width {
  335. max-width: 180upx;
  336. }
  337. /deep/ .u-form-item__body__left__content__label {
  338. font-size: 28upx !important;
  339. }
  340. </style>