organization.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="organization-wrap">
  3. <!-- 组织结构根节点 -->
  4. <view class="organization-root-tit">
  5. <view class="structure-con" v-for="(item,index) in nowStructure" :key="index">
  6. <text class="structure-name" @click="checkedStructure(index)">{{item}}</text>
  7. <u-icon class="structure-icon" name="arrow-right" color="#999" size="28"></u-icon>
  8. </view>
  9. </view>
  10. <!-- 组织结构子节点 -->
  11. <view class="organization-node-con">
  12. <view class="organization-node-item" v-for="(item, index) in organizationNowList" :key="index" @click="clickOrganization(item, index)">
  13. <text class="organization-node-item-name">{{item.name}}</text>
  14. <u-icon class="organization-node-item-icon" name="arrow-right" color="#999" size="28"></u-icon>
  15. </view>
  16. </view>
  17. <!-- 门店列表 -->
  18. <view class="list-con">
  19. <view class="list-tit">门店列表</view>
  20. <!-- 列表数据 -->
  21. <view class="listData-con">
  22. <view class="listData-item" v-for="(item, index) in list" :key="index" @click="goPage(item)">
  23. <view class="listData-item-l">
  24. <u-icon class="listData-item-l-icon" name="mendian" custom-prefix="xd-icon" size="40" color="#888"></u-icon>
  25. <text class="listData-item-l-name">{{item.name}}</text>
  26. </view>
  27. <view class="listData-item-r">
  28. <u-icon class="listData-item-r-icon" name="yuanchengxundian" custom-prefix="xd-icon" size="40" color="#2b85e4"></u-icon>
  29. </view>
  30. </view>
  31. <u-empty :text="noDataText" img-width="120" v-if="list.length == 0 && status != 'loading'" style="padding: 150px 0 180px;background: #fff;" mode="list"></u-empty>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { clzConfirm } from '@/libs/tools.js'
  38. import { findStoreList } from '@/api/store.js'
  39. import { queryCurrentTaskUsing } from '@/api/task.js'
  40. import { findUserInfo } from '@/api/atorg.js'
  41. export default{
  42. data(){
  43. return{
  44. organizationNowList: [], // 组织机构 当前显示 列表数据
  45. organizationList: [], // 组织机构 总列表数据
  46. nowStructure: [], // 面包屑
  47. nowInd: [], // 下标数组
  48. status: 'loading', // 加载中状态
  49. noDataText: '暂无数据', // 数据异常提示
  50. list: [], // 门店数据列表
  51. }
  52. },
  53. onLoad() {
  54. // 权限下所有门店数据
  55. this.getStoreList()
  56. // 权限下的组织机构数据
  57. this.getOrgList()
  58. },
  59. methods: {
  60. // 权限下所有门店数据
  61. getStoreList(orgCode){
  62. this.status = 'loading'
  63. // 获取门店列表
  64. findStoreList({ orgCode: orgCode ? orgCode : '' }).then(res => {
  65. if(res.status == 200){
  66. this.list = res.data
  67. this.noDataText = '暂无数据' // 有列表数据时不显示,因此只用默认设置为无数据时所需显示的'暂无数据'即可
  68. }else{
  69. this.list = []
  70. this.noDataText = res.message
  71. }
  72. this.status = 'loadmore'
  73. })
  74. },
  75. // 组织机构数据
  76. getOrgList(){
  77. findUserInfo().then(res => {
  78. if(res.status == 200){
  79. this.nowStructure.push(res.data[0].name)
  80. this.organizationList = res.data
  81. this.organizationNowList = res.data[0].children
  82. }else{
  83. this.organizationList = []
  84. this.organizationNowList = []
  85. this.nowStructure = []
  86. }
  87. })
  88. },
  89. // 组织机构 click
  90. clickOrganization(item, ind){
  91. this.nowInd.push(ind)
  92. if(item.children){
  93. this.organizationNowList = item.children
  94. }else{
  95. this.organizationNowList = []
  96. }
  97. this.nowStructure.push(item.name)
  98. this.getStoreList(item.code)
  99. },
  100. // 切换至当前所选的组织结构
  101. checkedStructure(ind){
  102. if(ind == 0){
  103. this.nowInd = []
  104. this.organizationNowList = this.organizationList[0].children
  105. this.nowStructure = []
  106. this.nowStructure.push(this.organizationList[0].name)
  107. this.getStoreList()
  108. }else{
  109. let subInd = JSON.parse(JSON.stringify(this.nowInd)).splice(0, ind)
  110. this.nowInd = subInd
  111. let code = '' // 组织机构编码
  112. for(let i=0; i< subInd.length;i++){
  113. if(i==0){
  114. this.organizationNowList = this.organizationList[0].children[subInd[i]].children
  115. code = this.organizationList[0].children[subInd[i]].code
  116. }else{
  117. this.organizationNowList = this.organizationNowList[subInd[i]].children
  118. code = this.organizationNowList[subInd[i]].code
  119. }
  120. }
  121. this.nowStructure = JSON.parse(JSON.stringify(this.nowStructure)).splice(0, ind+1)
  122. this.getStoreList(code)
  123. }
  124. },
  125. // 选择门店
  126. goPage(item){
  127. // 校验是否有历史巡店记录
  128. // type VIDEO_INSPECTION:视频巡店、SPOT_INSPECTION:现场巡店、POINT_INSPECTION:点检任务
  129. queryCurrentTaskUsing({ storeId: item.id, type: 'VIDEO_INSPECTION' }).then(res => {
  130. if(res.status == 200){
  131. if(res.data){ // 为true有历史巡店记录
  132. clzConfirm({
  133. title: '提示',
  134. content: '有进行中的巡店任务,是否继续?',
  135. confirmText: '继续巡店',
  136. cancelText: '重新开始',
  137. buttons: ['继续巡店','重新开始'],
  138. success: function (result) {
  139. if (result.confirm || result.index==0) { // 继续巡店
  140. uni.navigateTo({
  141. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&taskId='+ res.data + '&restart=0&types=video'
  142. })
  143. }else if(result.cancel || result.index==1){ // 重新开始
  144. uni.navigateTo({
  145. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&taskId='+ res.data + '&restart=1&types=video'
  146. })
  147. }
  148. }
  149. })
  150. }else{
  151. uni.navigateTo({
  152. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&types=video'
  153. })
  154. }
  155. }else{
  156. uni.showToast({icon: 'none', title: res.message})
  157. }
  158. })
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss">
  164. page {
  165. background-color: #f8f8f8;
  166. height: calc(100vh - 44px);
  167. position: relative;
  168. }
  169. .organization-wrap{
  170. padding-top: 98upx;
  171. .organization-root-tit{
  172. position: fixed;
  173. left: 0;
  174. top: 0;
  175. width: 100%;
  176. padding: 20upx 30upx;
  177. line-height: 48upx;
  178. background-color: #fff;
  179. border-bottom: 20upx solid #f8f8f8;
  180. z-index: 1;
  181. .structure-con{
  182. display: inline-block;
  183. .structure-name{
  184. color: #2979ff;
  185. }
  186. .structure-icon{
  187. padding: 0 10upx;
  188. }
  189. }
  190. }
  191. .organization-node-con{
  192. padding: 0 30upx;
  193. background-color: #fff;
  194. .organization-node-item{
  195. display: flex;
  196. padding: 20upx 0;
  197. border-bottom: 1px solid #f8f8f8;
  198. &-name{
  199. flex-grow: 1;
  200. }
  201. &-icon{
  202. flex-shrink: 0;
  203. }
  204. }
  205. }
  206. // 门店列表
  207. .list-con{
  208. .list-tit{
  209. padding: 20upx 30upx;
  210. border-bottom: 1upx solid #f8f8f8;
  211. }
  212. .listData-con{
  213. padding: 0 30upx;
  214. box-sizing: border-box;
  215. .listData-item{
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. padding: 20upx;
  220. border-bottom: 1px solid #f8f8f8;
  221. background-color: #fff;
  222. &-l{
  223. flex-grow: 1;
  224. padding-right: 10upx;
  225. position: relative;
  226. padding-left: 50upx;
  227. &-icon{
  228. vertical-align: sub;
  229. padding-right: 8upx;
  230. position: absolute;
  231. left: 0;
  232. top: -4upx;
  233. }
  234. }
  235. &-r{
  236. flex-shrink: 0;
  237. }
  238. }
  239. }
  240. }
  241. }
  242. </style>