organization.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. '西安车领主网络科技有限公司'
  48. ],
  49. nowInd: [],
  50. status: 'loading', // 加载中状态
  51. noDataText: '暂无数据', // 数据异常提示
  52. list: [], // 门店数据列表
  53. organizationData: []
  54. }
  55. },
  56. onLoad() {
  57. // 权限下所有门店数据
  58. this.getStoreList()
  59. // 权限下的组织机构数据
  60. this.getOrgList()
  61. },
  62. methods: {
  63. // 权限下所有门店数据
  64. getStoreList(orgCode){
  65. this.status = 'loading'
  66. // 获取门店列表
  67. findStoreList({ orgCode: orgCode ? orgCode : '' }).then(res => {
  68. if(res.status == 200){
  69. this.list = res.data
  70. this.noDataText = '暂无数据' // 有列表数据时不显示,因此只用默认设置为无数据时所需显示的'暂无数据'即可
  71. }else{
  72. this.list = []
  73. this.noDataText = res.message
  74. }
  75. this.status = 'loadmore'
  76. })
  77. },
  78. // 组织机构数据
  79. getOrgList(){
  80. findUserInfo().then(res => {
  81. if(res.status == 200){
  82. this.organizationList = res.data
  83. this.organizationNowList = res.data
  84. }else{
  85. this.organizationList = []
  86. this.organizationNowList = []
  87. }
  88. })
  89. },
  90. // 组织机构 click
  91. clickOrganization(item, ind){
  92. this.nowInd.push(ind)
  93. if(item.children){
  94. this.organizationNowList = item.children
  95. }else{
  96. this.organizationNowList = []
  97. }
  98. this.nowStructure.push(item.name)
  99. this.getStoreList(item.code)
  100. },
  101. // 切换至当前所选的组织结构
  102. checkedStructure(ind){
  103. if(ind == 0){
  104. this.nowInd = []
  105. this.organizationNowList = this.organizationList
  106. this.nowStructure = ['西安车领主网络科技有限公司']
  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[subInd[i]].children
  115. code = this.organizationList[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. queryCurrentTaskUsing({ storeId: item.id }).then(res => {
  129. if(res.status == 200){
  130. if(res.data){ // 为true有历史巡店记录
  131. clzConfirm({
  132. title: '提示',
  133. content: '有进行中的巡店任务,是否继续?',
  134. confirmText: '继续巡店',
  135. cancelText: '重新开始',
  136. buttons: ['继续巡店','重新开始'],
  137. success: function (result) {
  138. if (result.confirm || result.index==0) { // 继续巡店
  139. uni.navigateTo({
  140. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&taskId='+ res.data + '&restart=0&types=video'
  141. })
  142. }else if(result.cancel || result.index==1){ // 重新开始
  143. uni.navigateTo({
  144. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&taskId='+ res.data + '&restart=1&types=video'
  145. })
  146. }
  147. }
  148. })
  149. }else{
  150. uni.navigateTo({
  151. url: '/pages/shopTour/shopTour?storeId=' + item.id + '&types=video'
  152. })
  153. }
  154. }else{
  155. uni.showToast({icon: 'none', title: res.message})
  156. }
  157. })
  158. }
  159. },
  160. watch: {
  161. nowStructure(val){
  162. if(val.length == 1){
  163. this.nowStructure[0] = '西安车领主网络科技有限公司'
  164. }else{
  165. this.nowStructure[0] = '车领主'
  166. }
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="scss">
  172. page {
  173. background-color: #f8f8f8;
  174. height: calc(100vh - 44px);
  175. position: relative;
  176. }
  177. .organization-wrap{
  178. padding-top: 98upx;
  179. .organization-root-tit{
  180. position: fixed;
  181. left: 0;
  182. top: 0;
  183. width: 100%;
  184. padding: 20upx 30upx;
  185. background-color: #fff;
  186. border-bottom: 20upx solid #f8f8f8;
  187. z-index: 1;
  188. .structure-con{
  189. display: inline-block;
  190. .structure-name{
  191. color: #2979ff;
  192. }
  193. .structure-icon{
  194. padding: 0 10upx;
  195. }
  196. }
  197. }
  198. .organization-node-con{
  199. padding: 0 30upx;
  200. background-color: #fff;
  201. .organization-node-item{
  202. display: flex;
  203. padding: 20upx 0;
  204. border-bottom: 1px solid #f8f8f8;
  205. &-name{
  206. flex-grow: 1;
  207. }
  208. &-icon{
  209. flex-shrink: 0;
  210. }
  211. }
  212. }
  213. // 门店列表
  214. .list-con{
  215. .list-tit{
  216. padding: 20upx 30upx;
  217. border-bottom: 1upx solid #f8f8f8;
  218. }
  219. .listData-con{
  220. padding: 0 30upx;
  221. box-sizing: border-box;
  222. .listData-item{
  223. display: flex;
  224. justify-content: space-between;
  225. align-items: center;
  226. padding: 20upx;
  227. border-bottom: 1px solid #f8f8f8;
  228. background-color: #fff;
  229. &-l{
  230. flex-grow: 1;
  231. padding-right: 10upx;
  232. position: relative;
  233. padding-left: 50upx;
  234. &-icon{
  235. vertical-align: sub;
  236. padding-right: 8upx;
  237. position: absolute;
  238. left: 0;
  239. top: -4upx;
  240. }
  241. }
  242. &-r{
  243. flex-shrink: 0;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. </style>