index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  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. <!-- 删除按钮 -->
  47. <view class="an-niu" @click.native="showModal(item)">
  48. <view class="detailDel">删除</view>
  49. </view>
  50. <view class="an-niu" @click.native="onClick(item,formData.orgName)" link><text
  51. class="detail">查看详情</text></view>
  52. </uni-card>
  53. </view>
  54. </view>
  55. <!-- tableData为空时显示 -->
  56. <view v-else-if="tableData.length==0 && isLoaded" style="text-align: center;">
  57. <view class="text-gray" style="padding-top: 20px;" v-if="tableData == 0">
  58. <img :src="tan90" alt="暂无数据" />
  59. </view>
  60. </view>
  61. <view>
  62. <image :src="Group" @click="addClick" class="tiantupian"></image>
  63. </view>
  64. <u-action-sheet :show="showOrg" :actions="actions" title="请选择单位" @close="showOrg = false"
  65. @select="sexSelect"></u-action-sheet>
  66. <u-modal :show="show" @confirm="confirm" @cancel="cancel" @close="close" asyncClose closeOnClickOverlay
  67. showCancelButton confirmColor="red" :title="title" :content="content" ref="uModal"></u-modal>
  68. <!-- 加载中 -->
  69. <isLodingModel></isLodingModel>
  70. </view>
  71. </template>
  72. <script>
  73. var that = '';
  74. import {
  75. getDrill, //获取培训演练信息列表
  76. delDrill, //删除培训演练信息
  77. getOrgId //获取orgId
  78. } from '@/api/drill';
  79. import config from '@/config'
  80. const baseUrlImg = config.baseUrlImg
  81. export default {
  82. data() {
  83. return {
  84. isLoaded: false,
  85. Group: `${baseUrlImg}/checkActive/Group.png`,
  86. showOrg: false,
  87. actions: [],
  88. // 数据
  89. tableData: [],
  90. title: '是否删除该数据项?',
  91. content: '确认删除?',
  92. id: '',
  93. tan90: `${baseUrlImg}/tan90.png`,
  94. // 每页数据量
  95. pageSize: 10,
  96. // 当前页
  97. pageNo: 1,
  98. // 数据总量
  99. total: 0,
  100. // tableData数据加载中
  101. loading: false,
  102. // 初始化时搜索框的值
  103. keyword: '',
  104. // 存放orgid,orgname
  105. formData: {
  106. orgName: ''
  107. },
  108. show: false,
  109. showtimeStart: false,
  110. showtimeEnd: false
  111. };
  112. },
  113. onLoad: function(option) {
  114. },
  115. watch: {
  116. loading: {
  117. handler(newLength, oldLength) {
  118. this.$modal.isLoadingModel(this.loading)
  119. },
  120. immediate: true
  121. }
  122. },
  123. onShow() {
  124. this.actions = []
  125. that = this;
  126. getOrgId({
  127. pageNo: this.pageNo,
  128. pageSize: this.pageSize,
  129. userId: this.$store.state.user.id
  130. }).then(response => {
  131. // 取到用户对应的单位名称与id
  132. response.data.map(v => {
  133. this.actions.push({
  134. id: v.dwid,
  135. name: v.orgName
  136. });
  137. });
  138. this.formData.orgName = response.data[0].orgName;
  139. this.formData.orgId = response.data[0].dwid;
  140. this.tableData = []
  141. this.getData();
  142. });
  143. },
  144. onReady() {},
  145. mixins: [uni.$u.mixin],
  146. methods: {
  147. search(val) {
  148. this.isLoaded =false
  149. this.tableData = []
  150. this.getData(1)
  151. },
  152. // 模态框内容
  153. showModal(val) {
  154. this.show = true;
  155. this.id = val.id;
  156. },
  157. confirm() {
  158. this.show = false;
  159. delDrill({
  160. id: this.id
  161. }).then(response => {
  162. this.loading = true;
  163. this.isLoaded = false
  164. this.tableData = []
  165. this.getData();
  166. });
  167. },
  168. close() {
  169. this.show = false;
  170. },
  171. cancel() {
  172. this.show = false;
  173. },
  174. //查看详情
  175. addClickDetail(val) {
  176. uni.navigateTo({
  177. url: `/pagesA/fire/drill/add_drill/add_drill?item=${JSON.stringify(val)}`
  178. });
  179. },
  180. // 获取数据
  181. getData() {
  182. this.loading = true;
  183. // 获取培训演练信息详细信息
  184. getDrill({
  185. pageNo: this.pageNo,
  186. pageSize: this.pageSize,
  187. orgId: this.formData.orgId,
  188. drillTitle: this.keyword
  189. }).then(response => {
  190. this.isLoaded = true
  191. this.tableData = [...this.tableData, ...response.data.list]
  192. this.total=response.data.total
  193. this.loading = false
  194. // this.tableData = response.data.list;
  195. // 根据返回值,显示记录类型的中文名称
  196. this.tableData.map(i => {
  197. if (i.drillType == 1) {
  198. i.drillTypeName = '培训'
  199. } else if (i.drillType == 2) {
  200. i.drillTypeName = '演练'
  201. }
  202. })
  203. });
  204. },
  205. // 传递数据
  206. onClick(val, orgName) {
  207. this.isLoaded = false
  208. uni.navigateTo({
  209. url: '/pagesA/fire/drill/drill_details/drill_details?id=' + val.id + '&orgName=' + orgName,
  210. events: {
  211. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  212. acceptDataFromOpenedPage: function(val) {
  213. }
  214. },
  215. success: function(res) {
  216. // 通过eventChannel向被打开页面传送数据
  217. res.eventChannel.emit('acceptDataFromOpenerPage', val);
  218. }
  219. });
  220. },
  221. // 删除培训演练信息
  222. onClickDel(val) {
  223. this.id = val.id;
  224. delDrill({
  225. id: this.id
  226. }).then(response => {
  227. this.loading = true;
  228. this.isLoaded = false
  229. this.tableData = []
  230. this.getData();
  231. });
  232. },
  233. addClick() {
  234. this.isLoaded = false
  235. uni.navigateTo({
  236. url: `/pagesA/fire/drill/add_drill/add_drill?&orgName=${this.formData.orgName}&orgId=${this.formData.orgId}`,
  237. });
  238. },
  239. sexSelect(e) {
  240. this.formData.orgId = e.id;
  241. this.formData.orgName = e.name;
  242. // 获取培训演练信息详细信息
  243. getDrill({
  244. pageNo: this.pageNo,
  245. pageSize: this.pageSize,
  246. orgId: this.formData.orgId
  247. }).then(response => {
  248. this.tableData = response.data.list;
  249. });
  250. },
  251. // 触底的事件
  252. onReachBottom() {
  253. // 判断是否还有下一页数据
  254. if (this.pageNo * this.pageSize >= this.total)
  255. return uni.showToast({
  256. title: `数据加载完毕`
  257. });
  258. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  259. if (this.loading) return;
  260. this.pageNo += 1;
  261. this.getData(this.pageNo);
  262. },
  263. // 隐藏键盘
  264. hideKeyboard() {
  265. uni.hideKeyboard();
  266. },
  267. //日期范围
  268. // 开始日期
  269. confirmStarttime(e) {
  270. this.showtimeStart = false;
  271. let value = new Date(e.value);
  272. this.formData.start = uni.$u.timeFormat(e.value, 'yyyy/mm/dd');
  273. }
  274. }
  275. };
  276. </script>
  277. <style lang="scss" scoped>
  278. body {
  279. background-color: #f5f7f9;
  280. }
  281. page {
  282. background-color: #f5f7f9;
  283. }
  284. /deep/ .u-tabs__wrapper[data-v-0de61367],
  285. /deep/ .u-tabs__wrapper.data-v-0de61367,
  286. /deep/ .u-tabs__wrapper {
  287. width: 99%;
  288. }
  289. /deep/.u-tabs__wrapper__nav__item[data-v-0de61367],
  290. /deep/.u-tabs__wrapper__nav__item.data-v-0de61367,
  291. /deep/.u-tabs__wrapper__nav__item {
  292. padding: 0 60rpx;
  293. }
  294. .uni-container {
  295. height: 100vh;
  296. padding-right: 20upx;
  297. }
  298. .addInsp {
  299. width: 40px;
  300. position: fixed;
  301. right: 4px;
  302. z-index: 99999;
  303. }
  304. ::v-deep .u-icon__icon {
  305. margin-right: 0px !important;
  306. }
  307. .an-niu {
  308. float: right;
  309. font-size: 10px;
  310. text-align: center;
  311. display: flex;
  312. margin-top: -64upx;
  313. padding-bottom: 30rpx;
  314. // margin-top: 50rpx;
  315. color: #fff;
  316. .detail {
  317. width: 60px;
  318. height: 60rpx;
  319. padding: 0 20rpx;
  320. border-radius: 30px;
  321. background-color: #f7c41e;
  322. margin-right: 20rpx;
  323. text-align: center;
  324. line-height: 60rpx;
  325. font-size: 27upx;
  326. }
  327. .detailDel {
  328. width: 60px;
  329. height: 60rpx;
  330. padding: 0 20rpx;
  331. border-radius: 30px;
  332. background-color: #ff2e31;
  333. color: white;
  334. margin-right: 20rpx;
  335. text-align: center;
  336. line-height: 60rpx;
  337. font-size: 30upx;
  338. }
  339. .solve {
  340. width: 62px;
  341. height: 60rpx;
  342. margin-right: 20rpx;
  343. border-radius: 30px;
  344. background-color: #4cb2b6;
  345. line-height: 60rpx;
  346. }
  347. /deep/ .padding-tb-sm {
  348. padding-top: 0px;
  349. padding-bottom: 10px;
  350. }
  351. .deletes {
  352. width: 62px;
  353. height: 60rpx;
  354. border-radius: 60rpx;
  355. background-color: red;
  356. color: #fff;
  357. line-height: 60rpx;
  358. }
  359. }
  360. /deep/.segmented-control__item--button {
  361. background-color: rgb(76, 178, 182) !important;
  362. }
  363. /deep/.segmented-control__item--button--active {
  364. background-color: #ffffff !important;
  365. }
  366. /deep/.uni-card {
  367. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  368. border-radius: 30rpx;
  369. }
  370. .tiantupian {
  371. width: 110rpx;
  372. height: 110rpx;
  373. position: fixed;
  374. right: 15px;
  375. bottom: 80rpx;
  376. }
  377. //列表样式
  378. .titles {
  379. font-weight: 600;
  380. margin-bottom: 10rpx;
  381. color: black;
  382. font-size: 32rpx;
  383. }
  384. .conts {
  385. max-width: 470rpx;
  386. display: -webkit-box;
  387. /*弹性伸缩盒子模型显示*/
  388. -webkit-box-orient: vertical;
  389. /*排列方式*/
  390. -webkit-line-clamp: 1;
  391. /*显示文本行数*/
  392. overflow: hidden;
  393. /*溢出隐藏*/
  394. color: #274647;
  395. text-overflow: ellipsis;
  396. /*不知道干嘛的*/
  397. .conts-title {
  398. margin-right: 10rpx;
  399. color: #728f90;
  400. }
  401. }
  402. .max-width {
  403. max-width: 180upx;
  404. }
  405. /deep/ .u-form-item__body__left__content__label {
  406. font-size: 28upx !important;
  407. }
  408. </style>