index.vue 12 KB

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