index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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. console.log(response, 'response');
  119. // 取到用户对应的单位名称与id
  120. response.data.map(v => {
  121. this.actions.push({
  122. id: v.dwid,
  123. name: v.orgName
  124. });
  125. });
  126. console.log(response.data, '21321312');
  127. this.formData.orgName = response.data[0].orgName;
  128. this.formData.orgId = response.data[0].dwid;
  129. this.tableData = []
  130. this.getData();
  131. });
  132. },
  133. onReady() {},
  134. mixins: [uni.$u.mixin],
  135. methods: {
  136. search(val) {
  137. console.log(val, 'valvals');
  138. this.isLoaded =false
  139. this.tableData = []
  140. this.getData(1)
  141. },
  142. // 获取数据
  143. getData() {
  144. this.loading = true;
  145. // 获取培训演练信息详细信息
  146. getDrill({
  147. pageNo: this.pageNo,
  148. pageSize: this.pageSize,
  149. orgId: this.formData.orgId,
  150. drillTitle: this.keyword
  151. }).then(response => {
  152. this.isLoaded = true
  153. this.tableData = [...this.tableData, ...response.data.list]
  154. this.total=response.data.total
  155. this.loading = false
  156. this.tableData.map(i => {
  157. console.log(i);
  158. if (i.drillType == 1) {
  159. i.drillTypeName = '培训'
  160. } else if (i.drillType == 2) {
  161. i.drillTypeName = '演练'
  162. }
  163. })
  164. });
  165. },
  166. // 传递数据
  167. onClick(val, orgName) {
  168. console.log(val, orgName, 'val');
  169. this.isLoaded = false
  170. uni.navigateTo({
  171. url: '/pagesA/fire/drill/drill_details/drill_details?id=' + val.id + '&orgName=' + orgName+'&historyView=historyView',
  172. events: {
  173. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  174. acceptDataFromOpenedPage: function(val) {
  175. console.log(val, '打开页面传送到当前页面的数据');
  176. }
  177. },
  178. success: function(res) {
  179. // 通过eventChannel向被打开页面传送数据
  180. res.eventChannel.emit('acceptDataFromOpenerPage', val);
  181. }
  182. });
  183. },
  184. sexSelect(e) {
  185. this.formData.orgId = e.id;
  186. this.formData.orgName = e.name;
  187. // 获取培训演练信息详细信息
  188. getDrill({
  189. pageNo: this.pageNo,
  190. pageSize: this.pageSize,
  191. orgId: this.formData.orgId
  192. }).then(response => {
  193. this.tableData = response.data.list;
  194. });
  195. },
  196. // 触底的事件
  197. onReachBottom() {
  198. // 判断是否还有下一页数据
  199. if (this.pageNo * this.pageSize >= this.total)
  200. return uni.showToast({
  201. title: `数据加载完毕`
  202. });
  203. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  204. if (this.loading) return;
  205. this.pageNo += 1;
  206. this.getData(this.pageNo);
  207. },
  208. // 隐藏键盘
  209. hideKeyboard() {
  210. uni.hideKeyboard();
  211. }
  212. }
  213. };
  214. </script>
  215. <style lang="scss" scoped>
  216. body {
  217. background-color: #f5f7f9;
  218. }
  219. page {
  220. background-color: #f5f7f9;
  221. }
  222. /deep/ .u-tabs__wrapper[data-v-0de61367],
  223. /deep/ .u-tabs__wrapper.data-v-0de61367,
  224. /deep/ .u-tabs__wrapper {
  225. width: 99%;
  226. }
  227. /deep/.u-tabs__wrapper__nav__item[data-v-0de61367],
  228. /deep/.u-tabs__wrapper__nav__item.data-v-0de61367,
  229. /deep/.u-tabs__wrapper__nav__item {
  230. padding: 0 60rpx;
  231. }
  232. .uni-container {
  233. height: 100vh;
  234. padding-right: 20upx;
  235. }
  236. .addInsp {
  237. width: 40px;
  238. position: fixed;
  239. right: 4px;
  240. z-index: 99999;
  241. }
  242. ::v-deep .u-icon__icon {
  243. margin-right: 0px !important;
  244. }
  245. .an-niu {
  246. float: right;
  247. font-size: 10px;
  248. text-align: center;
  249. display: flex;
  250. margin-top: -64upx;
  251. padding-bottom: 30rpx;
  252. // margin-top: 50rpx;
  253. color: #fff;
  254. .detail {
  255. width: 60px;
  256. height: 60rpx;
  257. padding: 0 20rpx;
  258. border-radius: 30px;
  259. background-color: #f7c41e;
  260. margin-right: 20rpx;
  261. text-align: center;
  262. line-height: 60rpx;
  263. font-size: 27upx;
  264. }
  265. .detailDel {
  266. width: 60px;
  267. height: 60rpx;
  268. padding: 0 20rpx;
  269. border-radius: 30px;
  270. background-color: #ff2e31;
  271. color: white;
  272. margin-right: 20rpx;
  273. text-align: center;
  274. line-height: 60rpx;
  275. font-size: 30upx;
  276. }
  277. .solve {
  278. width: 62px;
  279. height: 60rpx;
  280. margin-right: 20rpx;
  281. border-radius: 30px;
  282. background-color: #4cb2b6;
  283. line-height: 60rpx;
  284. }
  285. /deep/ .padding-tb-sm {
  286. padding-top: 0px;
  287. padding-bottom: 10px;
  288. }
  289. .deletes {
  290. width: 62px;
  291. height: 60rpx;
  292. border-radius: 60rpx;
  293. background-color: red;
  294. color: #fff;
  295. line-height: 60rpx;
  296. }
  297. }
  298. /deep/.segmented-control__item--button {
  299. background-color: rgb(76, 178, 182) !important;
  300. }
  301. /deep/.segmented-control__item--button--active {
  302. background-color: #ffffff !important;
  303. }
  304. /deep/.uni-card {
  305. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  306. border-radius: 30rpx;
  307. }
  308. .tiantupian {
  309. width: 110rpx;
  310. height: 110rpx;
  311. position: fixed;
  312. right: 15px;
  313. bottom: 80rpx;
  314. }
  315. //列表样式
  316. .titles {
  317. font-weight: 600;
  318. margin-bottom: 10rpx;
  319. color: black;
  320. font-size: 32rpx;
  321. }
  322. .conts {
  323. max-width: 470rpx;
  324. display: -webkit-box;
  325. /*弹性伸缩盒子模型显示*/
  326. -webkit-box-orient: vertical;
  327. /*排列方式*/
  328. -webkit-line-clamp: 1;
  329. /*显示文本行数*/
  330. overflow: hidden;
  331. /*溢出隐藏*/
  332. color: #274647;
  333. text-overflow: ellipsis;
  334. /*不知道干嘛的*/
  335. .conts-title {
  336. margin-right: 10rpx;
  337. color: #728f90;
  338. }
  339. }
  340. .max-width {
  341. max-width: 180upx;
  342. }
  343. /deep/ .u-form-item__body__left__content__label {
  344. font-size: 28upx !important;
  345. }
  346. </style>