index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <template>
  2. <view class="uni-container uni-container-bg">
  3. <view class="example container">
  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 class="" v-if="tableData.length>0 && isLoaded" style="margin-bottom: 90rpx;">
  28. <uni-card v-for="(item, index) in tableData" :isFull="true">
  29. <!-- :thumbnail="qr&ids==item.id?item.fpdQcode:''" :key="index"
  30. :title="item.fpdName"
  31. :sub-title="'设施编号:' + item.fpdCode" :extra="'设施类别:' + item.fpdTypeName"-->
  32. <!-- @click="saveQRCodeToLocal(qr&ids==item.id?item.fpdQcode:'')" -->
  33. <!-- @click.native="previewQRCode(qr&ids==item.id?item.fpdQcode:'')" -->
  34. <!-- 标题 -->
  35. <template #title>
  36. <view class="nav-title">
  37. <view @click="saveQRCodeToLocal(qr&ids==item.id?item.fpdQcode:'')" v-if="qr && ids == item.id">
  38. <img :src="qr && ids == item.id ? item.fpdQcode : ''"
  39. style="with:100rpx;height:100rpx;margin-top:10rpx" v-if="qr && ids == item.id">
  40. </view>
  41. <view class="">
  42. <view class="title-fpdname">
  43. {{item.fpdName}}
  44. </view>
  45. <view class="title-fpdcode">
  46. {{`设施编号:${item.fpdCode}`}}
  47. </view>
  48. </view>
  49. <view class="">
  50. {{`设施类别:${item.fpdTypeName?item.fpdTypeName:''}`}}
  51. </view>
  52. </view>
  53. </template>
  54. <view class="titles">{{ item.buildingName }}</view>
  55. <!-- 简要内容 -->
  56. <view style="display: flex;margin-bottom: 15rpx; color: #728f90;">
  57. <text>设备状态:</text>
  58. <text v-if="item.fpdStatus==0" class="conts">正常</text>
  59. <text v-if="item.fpdStatus==1" class="conts">有问题</text>
  60. </view>
  61. <view style="display: flex;margin-bottom: 15rpx; color: #728f90;">
  62. <text>所在位置:</text>
  63. <text class="conts">{{ item.fpdLocal }}</text>
  64. </view>
  65. <view style="display: flex;margin-bottom: 15rpx; color: #728f90;">
  66. <text>所属建筑:</text>
  67. <text class="conts">{{ item.buildingId }}</text>
  68. </view>
  69. <view style="display: flex;margin-bottom: 15rpx; color: #728f90;">
  70. <text>所属单位:</text>
  71. <text class="conts max-width">{{ item.orgDO.orgName }}</text>
  72. </view>
  73. <!-- 删除按钮 -->
  74. <view class="an-niu" @click="showModal(item)" style="z-index:99">
  75. <!-- @click.native="onClickDel(item)" -->
  76. <view class="detailDel">删除</view>
  77. </view>
  78. <view class="an-niu" @click="onClick(item, formData.orgName)" link>
  79. <text class="detail">编辑</text>
  80. </view>
  81. <view class="an-niu" link>
  82. <text class="detail" @click.native="anniuQR(item.fpdQcode,item.id)">生成二维码</text>
  83. </view>
  84. <!-- <view class="an-niu" @click.stop="saveQRCodeToLocal(item.fpdQcode)" link>
  85. <text class="detail">保存图片</text>
  86. </view> -->
  87. </uni-card>
  88. </view>
  89. <!-- tableData为空时显示 -->
  90. <view v-else-if="tableData.length==0 && isLoaded" style="text-align: center;">
  91. <view class="text-gray" style="padding-top: 20px;" v-if="tableData == 0">
  92. <img :src="tan90" alt="暂无数据" />
  93. </view>
  94. </view>
  95. <view>
  96. <image :src="Group" @click="addClick" class="tiantupian"></image>
  97. </view>
  98. <u-action-sheet :show="showOrg" :actions="actions" title="请选择单位" @close="showOrg = false"
  99. @select="">
  100. </u-action-sheet>
  101. <!-- <u-modal
  102. :show="show"
  103. @confirm="confirm"
  104. @cancel="cancel"
  105. @close="close"
  106. asyncClose
  107. closeOnClickOverlay
  108. showCancelButton
  109. confirmColor="red"
  110. :title="title"
  111. :content="content"
  112. ref="uModal"
  113. ></u-modal> -->
  114. <u-modal :show="show" @confirm="confirm" @cancel="cancel" @close="close" asyncClose closeOnClickOverlay
  115. showCancelButton confirmColor="red" :title="title" :content="content" ref="uModal" :asyncClose="true">
  116. </u-modal>
  117. <!-- 加载中 -->
  118. <isLodingModel></isLodingModel>
  119. </view>
  120. </view>
  121. </template>
  122. <script>
  123. var that = '';
  124. import {
  125. getDevice, //获取消防设施列表
  126. delDevice, //删除
  127. getOrgId //获取orgId
  128. } from '@/api/fire_device';
  129. import config from '@/config'
  130. import {
  131. DICT_TYPE,
  132. getDictDatas
  133. } from '@/utils/dict';
  134. const baseUrlImg = config.baseUrlImg
  135. export default {
  136. data() {
  137. return {
  138. typeDict: getDictDatas(DICT_TYPE.FPD_TYPE),
  139. screenHeight: this.$screenHeight,
  140. isLoaded: false,
  141. Group: `${baseUrlImg}/checkActive/Group.png`,
  142. showOrg: false,
  143. actions: [],
  144. orgId: '',
  145. // 数据
  146. tableData: [],
  147. title: '是否删除该数据项?',
  148. content: '确认删除?',
  149. id: '',
  150. tan90: `${baseUrlImg}/tan90.png`,
  151. // 每页数据量
  152. pageSize: 10,
  153. FPDstatus: '',
  154. // 当前页
  155. pageNo: 1,
  156. // 数据总量
  157. total: 0,
  158. // tableData数据加载中
  159. loading: false,
  160. // 初始化时搜索框的值
  161. keyword: '',
  162. qr: false, //二维码是否展示
  163. ids: '', //点击生成的是哪个二维码
  164. // 开始时间与结束时间
  165. formData: {
  166. orgName: '',
  167. fpdStatusValue: ''
  168. },
  169. show: false,
  170. showtimeStart: false,
  171. showtimeEnd: false
  172. };
  173. },
  174. // 在 vue页面,向起始页通过事件传递数据
  175. onLoad: function(option) {
  176. that = this;
  177. },
  178. onShow() {
  179. this.actions = []
  180. getOrgId({
  181. pageNo: this.pageNo,
  182. pageSize: this.pageSize,
  183. userId: this.$store.state.user.id
  184. }).then(response => {
  185. console.log(response, 'response');
  186. // 取到用户对应的单位名称与id
  187. response.data.map(v => {
  188. this.actions.push({
  189. id: v.dwid,
  190. name: v.orgName
  191. });
  192. });
  193. console.log(response.data, '21321312');
  194. this.formData.orgName = response.data[0].orgName;
  195. this.formData.orgId = response.data[0].dwid;
  196. this.tableData = []
  197. this.getData();
  198. }).catch(err => {
  199. this.loading = false
  200. this.$modal.msg(err)
  201. })
  202. // this.tableData={}
  203. // this.getData();
  204. },
  205. watch: {
  206. loading: {
  207. handler(newLength, oldLength) {
  208. this.$modal.isLoadingModel(this.loading)
  209. },
  210. immediate: true
  211. }
  212. },
  213. mixins: [uni.$u.mixin],
  214. methods: {
  215. search(val) {
  216. console.log(val, 'valvals');
  217. this.isLoaded = false
  218. this.loading = true
  219. this.tableData = []
  220. this.getData()
  221. },
  222. async saveQRCodeToLocal(qrCodeUrl) {
  223. uni.previewImage({
  224. current: qrCodeUrl,
  225. urls: [qrCodeUrl],
  226. width: 50, // 设置预览图片的宽度
  227. height: 50, // 设置预览图片的高度
  228. });
  229. const authSetting = await uni.getSetting();
  230. if (authSetting[1].authSetting['scope.writePhotosAlbum'] === false) {
  231. uni.showModal({
  232. title: '提示',
  233. content: '请开启相册权限以保存二维码',
  234. success: res => {
  235. if (res.confirm) {
  236. uni.openSetting();
  237. }
  238. },
  239. });
  240. return;
  241. }
  242. const tempFilePath = qrCodeUrl
  243. uni.showLoading({
  244. title: '正在保存',
  245. });
  246. uni.saveImageToPhotosAlbum({
  247. filePath: tempFilePath,
  248. success: () => {
  249. uni.showToast({
  250. title: '保存成功',
  251. icon: 'success',
  252. });
  253. },
  254. fail: () => {
  255. uni.showToast({
  256. title: '保存失败,请重试',
  257. icon: 'none',
  258. });
  259. },
  260. complete: () => {
  261. uni.hideLoading();
  262. },
  263. });
  264. },
  265. // previewQRCode(qrCodeUrl) {
  266. // console.log(qrCodeUrl, 'qrCodeUrlqrCodeUrl');
  267. // uni.previewImage({
  268. // current: qrCodeUrl,
  269. // urls: [qrCodeUrl],
  270. // width: 50, // 设置预览图片的宽度
  271. // height: 50, // 设置预览图片的高度
  272. // });
  273. // },
  274. anniuQR(qrCodeUrl, valid) { //生成二维码
  275. this.ids = valid
  276. this.qr = true
  277. uni.previewImage({
  278. urls: [qrCodeUrl],
  279. });
  280. },
  281. // 模态框内容
  282. showModal(val) {
  283. this.show = true;
  284. this.id = val.id;
  285. },
  286. confirm() {
  287. this.show = false;
  288. delDevice({
  289. id: this.id
  290. }).then(response => {
  291. this.isLoaded = false
  292. this.tableData = []
  293. this.getData();
  294. // this.tableData = response.data;
  295. console.log(this.tableData, '获取设施信息详细信息获取设施信息详细信息获取设施信息详细信息获取设施信息详细信息');
  296. });
  297. },
  298. close() {
  299. this.show = false;
  300. console.log('close');
  301. },
  302. cancel() {
  303. this.show = false;
  304. console.log('cancel');
  305. },
  306. // 编辑
  307. addClickDetail(val) {
  308. uni.navigateTo({
  309. url: `/pagesA/fire/fire_device/edit_device/edit_device?item=${JSON.stringify(val)}`
  310. });
  311. },
  312. // 获取数据
  313. getData(pageNo) {
  314. this.loading = true;
  315. // 获取设施信息详细信息
  316. getDevice({
  317. pageNo: this.pageNo,
  318. pageSize: this.pageSize,
  319. orgId: this.formData.orgId,
  320. fpdName: this.keyword
  321. }).then(response => {
  322. console.log(response);
  323. this.isLoaded = true
  324. this.tableData = [...this.tableData, ...response.data.records]
  325. this.loading = false
  326. this.total=response.data.total
  327. // this.tableData = response.data.records;
  328. console.log(this.tableData, '获得消防设施详细信息',this.typeDict );
  329. // 根据返回值,显示记录类型的中文名称
  330. this.tableData.map(i => {
  331. this.typeDict.map(k=>{
  332. if(i.fpdType==k.fpdType){
  333. console.log(i.fpdType,'i.fpdType');
  334. i.i.fpdTypeName=k.fpdName
  335. }
  336. })
  337. })
  338. }).catch(err => {
  339. this.loading = false
  340. this.$modal.msg(err)
  341. })
  342. },
  343. sexSelect(e) {
  344. this.formData.orgId = e.id;
  345. this.formData.orgName = e.name;
  346. // 获取培训演练信息详细信息
  347. getDevice({
  348. pageNo: this.pageNo,
  349. pageSize: this.pageSize,
  350. orgId: this.formData.orgId
  351. }).then(response => {
  352. this.tableData = response.data.list;
  353. });
  354. this.$$forceUpdate()
  355. },
  356. // 传递数据
  357. onClick(val, orgName) {
  358. console.log(val, 'val');
  359. this.isLoaded = false
  360. uni.navigateTo({
  361. url: '/pagesA/fire/fire_device/edit_device/edit_device?id=' + val.id + '&orgName=' + orgName,
  362. events: {
  363. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  364. acceptDataFromOpenedPage: function(val) {
  365. console.log(val, '打开页面传送到当前页面的数据');
  366. }
  367. },
  368. success: function(res) {
  369. // 通过eventChannel向被打开页面传送数据
  370. res.eventChannel.emit('acceptDataFromOpenerPage', val);
  371. }
  372. });
  373. },
  374. // 删除
  375. onClickDel(val) {
  376. this.id = val.id;
  377. console.log(this.id);
  378. delDevice({
  379. id: this.id
  380. }).then(response => {
  381. this.loading = true;
  382. this.isLoaded = false
  383. this.tableData = []
  384. this.getData();
  385. console.log(this.tableData, '获取');
  386. });
  387. },
  388. addClick() {
  389. this.isLoaded = false
  390. uni.navigateTo({
  391. url: `/pagesA/fire/fire_device/add_device/add_device?&orgName=${this.formData.orgName}&orgId=${this.formData.orgId}`,
  392. });
  393. },
  394. // 隐藏键盘
  395. hideKeyboard() {
  396. uni.hideKeyboard();
  397. },
  398. },
  399. // 触底的事件
  400. onReachBottom() {
  401. console.log(this.loading,'ssss');
  402. // 判断是否还有下一页数据
  403. if (this.pageNo * this.pageSize >= this.total)
  404. return uni.showToast({
  405. title: `数据加载完毕`
  406. });
  407. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  408. if (this.loading) return;
  409. this.pageNo += 1;
  410. this.getData(this.pageNo);
  411. }
  412. };
  413. </script>
  414. <style lang="scss" scoped>
  415. body {
  416. background-color: #f5f7f9;
  417. }
  418. page {
  419. background-color: #f5f7f9;
  420. }
  421. /deep/ .u-tabs__wrapper[data-v-0de61367],
  422. .u-tabs__wrapper.data-v-0de61367,
  423. /deep/.u-tabs__wrapper {
  424. width: 99%;
  425. }
  426. /deep/.u-tabs__wrapper__nav__item[data-v-0de61367],
  427. /deep/.u-tabs__wrapper__nav__item.data-v-0de61367,
  428. /deep/.u-tabs__wrapper__nav__item {
  429. padding: 0 60rpx;
  430. }
  431. .uni-container {
  432. height: 100vh;
  433. padding-right: 20upx;
  434. }
  435. .addInsp {
  436. width: 40px;
  437. position: fixed;
  438. right: 4px;
  439. z-index: 99999;
  440. }
  441. ::v-deep .u-icon__icon {
  442. margin-right: 0px !important;
  443. }
  444. .an-niu {
  445. float: right;
  446. font-size: 10px;
  447. text-align: center;
  448. display: flex;
  449. margin-top: 20upx;
  450. padding-bottom: 30rpx;
  451. // margin-top: 50rpx;
  452. color: #fff;
  453. .detail {
  454. padding: 0 40rpx;
  455. height: 60rpx;
  456. border-radius: 30px;
  457. background-color: #4cb2b6;
  458. margin-right: 20rpx;
  459. text-align: center;
  460. line-height: 60rpx;
  461. }
  462. .detailDel {
  463. padding: 0 40rpx;
  464. height: 60rpx;
  465. border-radius: 30px;
  466. background-color: #ff2e31;
  467. color: white;
  468. margin-right: 20rpx;
  469. text-align: center;
  470. line-height: 60rpx;
  471. font-size: 30upx;
  472. }
  473. .solve {
  474. width: 62px;
  475. height: 60rpx;
  476. margin-right: 20rpx;
  477. border-radius: 30px;
  478. background-color: #4cb2b6;
  479. line-height: 60rpx;
  480. }
  481. .deletes {
  482. width: 62px;
  483. height: 60rpx;
  484. border-radius: 60rpx;
  485. background-color: red;
  486. color: #fff;
  487. line-height: 60rpx;
  488. }
  489. }
  490. /deep/.segmented-control__item--button {
  491. background-color: rgb(76, 178, 182) !important;
  492. }
  493. /deep/.segmented-control__item--button--active {
  494. background-color: #ffffff !important;
  495. }
  496. /deep/.uni-card {
  497. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  498. border-radius: 30rpx;
  499. }
  500. .tiantupian {
  501. width: 110rpx;
  502. height: 110rpx;
  503. position: fixed;
  504. right: 15px;
  505. bottom: 10rpx;
  506. }
  507. // 控制二维码缩略图大小
  508. /deep/ .uni-card .uni-card__header .uni-card__header-avatar {
  509. width: 65px;
  510. height: 65px;
  511. overflow: hidden;
  512. border-radius: 5px;
  513. margin-right: 10px;
  514. }
  515. /deep/ .uni-card .uni-card__header .uni-card__header-avatar .uni-card__header-avatar-image {
  516. flex: 1;
  517. width: 65px;
  518. height: 65px;
  519. }
  520. //列表样式
  521. .titles {
  522. font-weight: 600;
  523. margin-bottom: 10rpx;
  524. color: black;
  525. font-size: 32rpx;
  526. }
  527. .conts {
  528. max-width: 470rpx;
  529. display: -webkit-box;
  530. /*弹性伸缩盒子模型显示*/
  531. -webkit-box-orient: vertical;
  532. /*排列方式*/
  533. -webkit-line-clamp: 1;
  534. /*显示文本行数*/
  535. overflow: hidden;
  536. /*溢出隐藏*/
  537. color: #274647;
  538. text-overflow: ellipsis;
  539. /*不知道干嘛的*/
  540. .conts-title {
  541. margin-right: 10rpx;
  542. color: #728f90;
  543. }
  544. }
  545. .max-width {
  546. max-width: 180upx;
  547. }
  548. /deep/ .u-form-item__body__left__content__label {
  549. font-size: 28upx !important;
  550. }
  551. .nav-title {
  552. display: flex;
  553. align-items: center;
  554. justify-content: space-between;
  555. color: #728f90;
  556. border-bottom: 1px solid #DCDCDC;
  557. ;
  558. padding-bottom: 20rpx;
  559. .title-fpdname {
  560. color: #000;
  561. }
  562. .title-fpdcode {
  563. margin-top: 10rpx
  564. }
  565. }
  566. .example{
  567. overflow-y: auto;
  568. }
  569. /deep/.u-action-sheet {
  570. overflow-y: auto;
  571. height: 1000rpx;
  572. background-color: #fff;
  573. }
  574. </style>