index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="page-wrap">
  3. <view class="head">
  4. <uni-card padding="0" margin="5px 0">
  5. <uni-search-bar @confirm="search" v-model="keywords" @clear="search"></uni-search-bar>
  6. </uni-card>
  7. <view class="addbt" @click="handle({type:'add'})">
  8. <view class="word"><uni-icons type="plusempty" size="30" color="#fff"></uni-icons></view>
  9. </view>
  10. </view>
  11. <view class="pageMain">
  12. <uni-swipe-action class="item-action-box">
  13. <uni-card padding="10px 0" margin="5px 0" v-for="(item,idx) in items" :key="item.entId">
  14. <uni-swipe-action-item class="item-action" :auto-close="true">
  15. <template v-slot:right>
  16. <view class="slot-button">
  17. <view class="bt edit" @click="handle({type:'edit',item})"><text class="slot-button-text">编辑</text></view>
  18. <view class="bt del" @click="handle({type:'del',item})"><text class="slot-button-text">删除</text></view>
  19. </view>
  20. </template>
  21. <view class="item" @click="handle({type:'detail',item})">
  22. <view class="title">
  23. <view class="name">{{item.entName}}</view>
  24. <view class="camera" @click.stop="showCamera(item)">
  25. <uni-icons v-if='item.cameraNum>0' type="videocam-filled" size="20" color="#007aff" ></uni-icons>
  26. </view>
  27. </view>
  28. <view class="item-row space-between">
  29. <view class="icon-item">
  30. <uni-icons type="location-filled" size="15" color="#999"></uni-icons>
  31. <text class="word">{{item.entAddress||'--'}}</text>
  32. </view>
  33. </view>
  34. <view class="item-row space-between">
  35. <uni-tag :text="item.entCatTitle" custom-style="background-color: #ecf5ff; border-color: #d9ecff; color: #409eff;"></uni-tag>
  36. </view>
  37. <view class="bottom">
  38. <view class="item-row space-between">
  39. <view class="icon-item">
  40. <uni-icons type="person-filled" size="15" color="#999"></uni-icons>
  41. <text class="word">{{item.charger||'--'}}【负责人】</text>
  42. </view>
  43. <view class="icon-item">
  44. <uni-icons type="phone-filled" size="15" color="#999"></uni-icons>
  45. <text class="word">{{item.chargerPhone||'--'}}</text>
  46. </view>
  47. </view>
  48. <view class="item-row space-between">
  49. <view class="icon-item">
  50. <uni-icons type="auth-filled" size="15" color="#999"></uni-icons>
  51. <text class="word">{{item.safetyManager||'--'}}【安全负责人】</text>
  52. </view>
  53. <view class="icon-item">
  54. <uni-icons type="phone-filled" size="15" color="#999"></uni-icons>
  55. <text class="word">{{item.safetyManagerPhone||'--'}}</text>
  56. </view>
  57. </view>
  58. <view class="icon-item">
  59. <image class="icon" src="/static/images/admin_icon.png" mode="widthFix"></image>
  60. <text class="word">{{item.groupName}}</text>
  61. </view>
  62. </view>
  63. </view>
  64. </uni-swipe-action-item>
  65. </uni-card>
  66. </uni-swipe-action>
  67. </view>
  68. <Create ref="industry" @success="search" :cats="entCats"></Create>
  69. <Detail ref="detail"></Detail>
  70. </view>
  71. </template>
  72. <script>
  73. import industryApi from '@/api/industry.js'
  74. import Create from './components/Create.vue'
  75. import Detail from './components/Detail.vue'
  76. export default {
  77. components:{
  78. Create,
  79. Detail
  80. },
  81. data() {
  82. return {
  83. items:[],
  84. page:1,
  85. limit:10,
  86. total:0,
  87. keywords: "",
  88. entCats:[]
  89. }
  90. },
  91. onShow() {
  92. this.getData();
  93. this.init()
  94. },
  95. methods: {
  96. init(){
  97. if(!uni.getStorageSync('entCats')){
  98. industryApi.getCatByList().then((res)=>{
  99. uni.setStorageSync('entCats',res.data)
  100. this.entCats=res.data
  101. })
  102. }else{
  103. this.entCats=uni.getStorageSync('entCats')
  104. }
  105. },
  106. search(){
  107. this.resetFilter();
  108. this.getData()
  109. },
  110. getData(){
  111. industryApi.getByPage({
  112. page:this.page,
  113. limit:this.limit,
  114. keywords:this.keywords
  115. }).then((res)=>{
  116. this.items=this.items.concat(res.data)
  117. })
  118. },
  119. handle({type,item}){
  120. const self=this;
  121. if(type==='detail'){
  122. this.$refs.detail.show(item)
  123. }else if(type==='del'){
  124. uni.showModal({
  125. title: '提示',
  126. content: '是否确定删除',
  127. success: function (res) {
  128. if (res.confirm) {
  129. industryApi.deleteById(item.entId).then(()=>{
  130. uni.showToast({
  131. title:'删除成功!',
  132. icon:'none'
  133. })
  134. self.search()
  135. })
  136. }
  137. }
  138. });
  139. }else{
  140. this.$refs.industry.show({type,item})
  141. }
  142. },
  143. resetFilter(){
  144. this.page = 1
  145. this.limit = 10
  146. this.total = 0
  147. this.items=[]
  148. },
  149. showCamera(){
  150. }
  151. },
  152. onReachBottom() {
  153. if(this.total>this.size*this.page){
  154. this.page++
  155. this.getData()
  156. }
  157. }
  158. }
  159. </script>
  160. <style lang="scss" scoped>
  161. .page-wrap{
  162. padding:0 20rpx;
  163. // position: fixed;
  164. // left: 0;
  165. // right: 0;
  166. // height: 100%;
  167. overflow-y: auto;
  168. .pageTabs{
  169. background-color: #fff;
  170. }
  171. .head{
  172. margin-top: 20rpx;
  173. .handle{
  174. display: inline-block;
  175. // background-color: #007aff;
  176. color: #777777;
  177. text-align: center;
  178. padding:16rpx 20rpx;
  179. border-radius: 30rpx;
  180. // border: 1px solid #007aff;
  181. font-size: 28rpx;
  182. line-height: 1;
  183. box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  184. }
  185. .addbt{
  186. width: 100rpx;
  187. height: 100rpx;
  188. border-radius: 50%;
  189. color: #fff;
  190. background-color: rgba(64,158,255,0.6);
  191. box-shadow:0 0 10rpx rgba(0,0,0,0.6);
  192. position: fixed;
  193. right: 10rpx;
  194. bottom: 20%;
  195. z-index: 99;
  196. text-align: center;
  197. display: flex;
  198. justify-content: center;
  199. align-items: center;
  200. .word{
  201. width: 80rpx;
  202. height: 80rpx;
  203. border-radius: 50%;
  204. margin: 5rpx auto;
  205. font-size: 28rpx;
  206. letter-spacing: 2px;
  207. display: flex;
  208. justify-content: center;
  209. align-items: center;
  210. }
  211. }
  212. }
  213. .pageMain{
  214. margin-top: 20rpx;
  215. background-color: #f5f5f5;
  216. padding-bottom: 50rpx;
  217. .slot-button{
  218. width: 400rpx;
  219. height: 100%;
  220. display: flex;
  221. flex-direction: row;
  222. justify-content: center;
  223. align-items: center;
  224. color: #fff;
  225. padding-left: 10px;
  226. .bt{
  227. width: 50%;
  228. height: 100%;
  229. font-size: 30rpx;
  230. box-sizing: border-box;
  231. display: flex;
  232. justify-content: center;
  233. align-items: center;
  234. &.edit{
  235. background-color:#007aff;
  236. }
  237. &.del{
  238. background-color:#F56C6C;
  239. }
  240. &.detail{
  241. background-color: #e6a23c;
  242. }
  243. }
  244. }
  245. .item{
  246. color: #666;
  247. .title{
  248. display: flex;
  249. justify-content: space-between;
  250. align-items: center;
  251. .name{
  252. font-size: 32rpx;
  253. color: #222222;
  254. line-height: 1;
  255. padding-bottom: 10rpx;
  256. text-overflow: ellipsis;
  257. overflow: hidden;
  258. white-space: nowrap;
  259. flex: 1;
  260. }
  261. .camera{
  262. width: 100rpx;
  263. text-align: right;
  264. flex-shrink: 0;
  265. }
  266. }
  267. image{
  268. &.icon{
  269. width: 30rpx;
  270. height: 30rpx;
  271. display: block;
  272. }
  273. }
  274. .item-row{
  275. display: flex;
  276. align-items: center;
  277. padding-top: 14rpx;
  278. &.space-between{
  279. justify-content: space-between;
  280. }
  281. }
  282. .icon-item{
  283. display: flex;
  284. align-items: center;
  285. .word{
  286. margin-left: 8rpx;
  287. font-size: 24rpx;
  288. }
  289. }
  290. }
  291. }
  292. }
  293. </style>