index.vue 6.5 KB

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