index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  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. console.log(response, 'response');
  132. // 取到用户对应的单位名称与id
  133. response.data.map(v => {
  134. this.actions.push({
  135. id: v.dwid,
  136. name: v.orgName
  137. });
  138. });
  139. console.log(response.data, '21321312');
  140. this.formData.orgName = response.data[0].orgName;
  141. this.formData.orgId = response.data[0].dwid;
  142. this.tableData = []
  143. this.getData();
  144. });
  145. },
  146. onReady() {},
  147. mixins: [uni.$u.mixin],
  148. methods: {
  149. search(val) {
  150. console.log(val, 'valvals');
  151. this.isLoaded =false
  152. this.tableData = []
  153. this.getData(1)
  154. },
  155. // 模态框内容
  156. showModal(val) {
  157. this.show = true;
  158. this.id = val.id;
  159. },
  160. confirm() {
  161. this.show = false;
  162. delDrill({
  163. id: this.id
  164. }).then(response => {
  165. this.loading = true;
  166. this.isLoaded = false
  167. this.tableData = []
  168. this.getData();
  169. console.log(this.tableData, '获取培训演练信息详细信息获取培训演练信息详细信息获取培训演练信息详细信息获取培训演练信息详细信息');
  170. });
  171. },
  172. close() {
  173. this.show = false;
  174. console.log('close');
  175. },
  176. cancel() {
  177. this.show = false;
  178. console.log('cancel');
  179. },
  180. //查看详情
  181. addClickDetail(val) {
  182. console.log(val, 'val');
  183. uni.navigateTo({
  184. url: `/pagesA/fire/drill/add_drill/add_drill?item=${JSON.stringify(val)}`
  185. });
  186. },
  187. // 获取数据
  188. getData() {
  189. this.loading = true;
  190. // 获取培训演练信息详细信息
  191. getDrill({
  192. pageNo: this.pageNo,
  193. pageSize: this.pageSize,
  194. orgId: this.formData.orgId,
  195. drillTitle: this.keyword
  196. }).then(response => {
  197. this.isLoaded = true
  198. this.tableData = [...this.tableData, ...response.data.list]
  199. this.total=response.data.total
  200. this.loading = false
  201. // this.tableData = response.data.list;
  202. // console.log(this.tableData, '获取培训演练信息详细信息获取培训演练信息详细信息获取培训演练信息详细信息获取培训演练信息详细信息');
  203. // 根据返回值,显示记录类型的中文名称
  204. this.tableData.map(i => {
  205. console.log(i);
  206. if (i.drillType == 1) {
  207. i.drillTypeName = '培训'
  208. } else if (i.drillType == 2) {
  209. i.drillTypeName = '演练'
  210. }
  211. })
  212. });
  213. },
  214. // 传递数据
  215. onClick(val, orgName) {
  216. console.log(val, orgName, 'val');
  217. this.isLoaded = false
  218. uni.navigateTo({
  219. url: '/pagesA/fire/drill/drill_details/drill_details?id=' + val.id + '&orgName=' + orgName,
  220. events: {
  221. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  222. acceptDataFromOpenedPage: function(val) {
  223. console.log(val, '打开页面传送到当前页面的数据');
  224. }
  225. },
  226. success: function(res) {
  227. // 通过eventChannel向被打开页面传送数据
  228. res.eventChannel.emit('acceptDataFromOpenerPage', val);
  229. }
  230. });
  231. },
  232. // 删除培训演练信息
  233. onClickDel(val) {
  234. this.id = val.id;
  235. console.log(this.id);
  236. delDrill({
  237. id: this.id
  238. }).then(response => {
  239. this.loading = true;
  240. this.isLoaded = false
  241. this.tableData = []
  242. this.getData();
  243. console.log(this.tableData, '删除了');
  244. });
  245. },
  246. addClick() {
  247. this.isLoaded = false
  248. uni.navigateTo({
  249. url: `/pagesA/fire/drill/add_drill/add_drill?&orgName=${this.formData.orgName}&orgId=${this.formData.orgId}`,
  250. });
  251. },
  252. sexSelect(e) {
  253. this.formData.orgId = e.id;
  254. this.formData.orgName = e.name;
  255. // 获取培训演练信息详细信息
  256. getDrill({
  257. pageNo: this.pageNo,
  258. pageSize: this.pageSize,
  259. orgId: this.formData.orgId
  260. }).then(response => {
  261. this.tableData = response.data.list;
  262. });
  263. },
  264. // 触底的事件
  265. onReachBottom() {
  266. // 判断是否还有下一页数据
  267. if (this.pageNo * this.pageSize >= this.total)
  268. return uni.showToast({
  269. title: `数据加载完毕`
  270. });
  271. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  272. if (this.loading) return;
  273. this.pageNo += 1;
  274. this.getData(this.pageNo);
  275. },
  276. // 隐藏键盘
  277. hideKeyboard() {
  278. uni.hideKeyboard();
  279. },
  280. //日期范围
  281. // 开始日期
  282. confirmStarttime(e) {
  283. this.showtimeStart = false;
  284. console.log(e.value, e.mode);
  285. let value = new Date(e.value);
  286. this.formData.start = uni.$u.timeFormat(e.value, 'yyyy/mm/dd');
  287. }
  288. }
  289. };
  290. </script>
  291. <style lang="scss" scoped>
  292. body {
  293. background-color: #f5f7f9;
  294. }
  295. page {
  296. background-color: #f5f7f9;
  297. }
  298. /deep/ .u-tabs__wrapper[data-v-0de61367],
  299. /deep/ .u-tabs__wrapper.data-v-0de61367,
  300. /deep/ .u-tabs__wrapper {
  301. width: 99%;
  302. }
  303. /deep/.u-tabs__wrapper__nav__item[data-v-0de61367],
  304. /deep/.u-tabs__wrapper__nav__item.data-v-0de61367,
  305. /deep/.u-tabs__wrapper__nav__item {
  306. padding: 0 60rpx;
  307. }
  308. .uni-container {
  309. height: 100vh;
  310. padding-right: 20upx;
  311. }
  312. .addInsp {
  313. width: 40px;
  314. position: fixed;
  315. right: 4px;
  316. z-index: 99999;
  317. }
  318. ::v-deep .u-icon__icon {
  319. margin-right: 0px !important;
  320. }
  321. .an-niu {
  322. float: right;
  323. font-size: 10px;
  324. text-align: center;
  325. display: flex;
  326. margin-top: -64upx;
  327. padding-bottom: 30rpx;
  328. // margin-top: 50rpx;
  329. color: #fff;
  330. .detail {
  331. width: 60px;
  332. height: 60rpx;
  333. padding: 0 20rpx;
  334. border-radius: 30px;
  335. background-color: #f7c41e;
  336. margin-right: 20rpx;
  337. text-align: center;
  338. line-height: 60rpx;
  339. font-size: 27upx;
  340. }
  341. .detailDel {
  342. width: 60px;
  343. height: 60rpx;
  344. padding: 0 20rpx;
  345. border-radius: 30px;
  346. background-color: #ff2e31;
  347. color: white;
  348. margin-right: 20rpx;
  349. text-align: center;
  350. line-height: 60rpx;
  351. font-size: 30upx;
  352. }
  353. .solve {
  354. width: 62px;
  355. height: 60rpx;
  356. margin-right: 20rpx;
  357. border-radius: 30px;
  358. background-color: #4cb2b6;
  359. line-height: 60rpx;
  360. }
  361. /deep/ .padding-tb-sm {
  362. padding-top: 0px;
  363. padding-bottom: 10px;
  364. }
  365. .deletes {
  366. width: 62px;
  367. height: 60rpx;
  368. border-radius: 60rpx;
  369. background-color: red;
  370. color: #fff;
  371. line-height: 60rpx;
  372. }
  373. }
  374. /deep/.segmented-control__item--button {
  375. background-color: rgb(76, 178, 182) !important;
  376. }
  377. /deep/.segmented-control__item--button--active {
  378. background-color: #ffffff !important;
  379. }
  380. /deep/.uni-card {
  381. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  382. border-radius: 30rpx;
  383. }
  384. .tiantupian {
  385. width: 110rpx;
  386. height: 110rpx;
  387. position: fixed;
  388. right: 15px;
  389. bottom: 80rpx;
  390. }
  391. //列表样式
  392. .titles {
  393. font-weight: 600;
  394. margin-bottom: 10rpx;
  395. color: black;
  396. font-size: 32rpx;
  397. }
  398. .conts {
  399. max-width: 470rpx;
  400. display: -webkit-box;
  401. /*弹性伸缩盒子模型显示*/
  402. -webkit-box-orient: vertical;
  403. /*排列方式*/
  404. -webkit-line-clamp: 1;
  405. /*显示文本行数*/
  406. overflow: hidden;
  407. /*溢出隐藏*/
  408. color: #274647;
  409. text-overflow: ellipsis;
  410. /*不知道干嘛的*/
  411. .conts-title {
  412. margin-right: 10rpx;
  413. color: #728f90;
  414. }
  415. }
  416. .max-width {
  417. max-width: 180upx;
  418. }
  419. /deep/ .u-form-item__body__left__content__label {
  420. font-size: 28upx !important;
  421. }
  422. </style>