fleetManage.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. //车队管理
  2. <template>
  3. <view class="center">
  4. <view class="fleetInfo">
  5. <view class="fleetInfo_name">队长身份</view>
  6. <view class="fleetInfo_phone" v-if="fleetInfo.status">{{fleetInfo.status}}</view>
  7. <view class="fleetInfo_phone" v-else>去认证</view>
  8. </view>
  9. <view class="btn_css">
  10. <view class="btn_item" v-if="!fleetInfo.name">
  11. <u-button type="primary" text="去认证" @click="operation(1)"></u-button>
  12. </view>
  13. <view class="btn_item" v-else>
  14. <u-button type="primary" text="编辑" @click="operation(2)"></u-button>
  15. </view>
  16. </view>
  17. <u-divider></u-divider>
  18. <view class="tips_info">
  19. <span>绑定司机</span>
  20. <image class='yanjingicon' @click="changeStatus(1)" v-if="isShow == 2" src="../../../static/yioncang.png">
  21. </image>
  22. <image class='yanjingicon' @click="changeStatus(2)" v-if="isShow == 1" src="../../../static/xianshi.png">
  23. </image>
  24. <!-- <u--image :showLoading="true" src="../../../static/yioncang.png" width="80px" height="80px" @click="click"></u--image> -->
  25. </view>
  26. <view class="list_css" v-for="(item,index) in formList">
  27. <view class="list_left">{{item.driverName}}({{item.accountNumber}})</view>
  28. <view class="list_right">
  29. <view class="list_text" v-if="item.status == '待确认'" @click="audit(item,1)">拒绝</view>
  30. <view class="list_text" v-if="item.status == '待确认'" @click="audit(item,2)">接受</view>
  31. <view class="list_text"
  32. v-if="item.status == '已绑定'||item.status == '已解绑'||item.status == '已接受'||item.status == '已拒绝'">
  33. {{item.status}}</view>
  34. <view class="list_text"
  35. v-if="item.status == '已绑定'||item.status == '已解绑'||item.status == '已接受'||item.status == '已拒绝'"
  36. @click="next(item)">删除</view>
  37. </view>
  38. </view>
  39. <view>
  40. <u-loadmore :status="loadStatus" />
  41. </view>
  42. <u-toast ref="uToast"></u-toast>
  43. <u-modal :show="tipsShow" :title="alertTitle" :closeOnClickOverlay='true' :showCancelButton='true'
  44. confirmColor='#2772FB' @confirm="$u.throttle(confirmClick, 1000)" @close="cancelClick"
  45. @cancel="cancelClick"></u-modal>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. mapState
  51. } from 'vuex';
  52. export default {
  53. data() {
  54. return {
  55. //分页
  56. pageSize: 20,
  57. currentPage: 1,
  58. fleetInfo: {},
  59. tipsShow: false,
  60. alertTitle: "",
  61. formList: [],
  62. distinguish: "",
  63. id: "",
  64. sign: "",
  65. isShow: 1,
  66. isLoadMore: false, //是否加载中
  67. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  68. }
  69. },
  70. onLoad() {
  71. this.getInfo()
  72. },
  73. onShow() {},
  74. //下拉刷新
  75. onPullDownRefresh() {
  76. this.currentPage = 1
  77. this.isLoadMore = false
  78. this.loadStatus = 'loading'
  79. this.nextGetInfo()
  80. setTimeout(function() {
  81. uni.stopPullDownRefresh();
  82. }, 1000);
  83. },
  84. onReachBottom() { //上拉触底函数
  85. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  86. this.isLoadMore = true
  87. this.currentPage += 1
  88. this.nextGetInfo()
  89. }
  90. },
  91. computed: {
  92. ...mapState(['hasLogin', 'userInfo']),
  93. },
  94. onNavigationBarButtonTap(e) {
  95. if (this.fleetInfo.name) { //判断是否有队长身份
  96. this.$u.route("/pages/mine/fleet/fleetBill")
  97. } else {
  98. this.$refs.uToast.show({
  99. type: 'error',
  100. message: "您还没有认证车队长身份!",
  101. complete() {
  102. that.getInfo()
  103. }
  104. })
  105. }
  106. },
  107. methods: {
  108. changeStatus(val) {
  109. this.isShow = val
  110. if (val == 1) {
  111. if (this.fleetInfo.name) { //判断是否有队长身份
  112. this.currentPage = 1
  113. this.nextGetInfo()
  114. }
  115. } else if (val == 2) {
  116. this.formList = []
  117. }
  118. },
  119. solution() {
  120. let that = this
  121. uni.showLoading({
  122. mask: true,
  123. title: '加载中'
  124. })
  125. this.tipsShow = false
  126. this.$request.baseRequest('post', '/hyBindCarCaptainInfo/api/deleteBind', {
  127. id: this.id
  128. }).then(res => {
  129. uni.hideLoading()
  130. if (res.code == 200) {
  131. this.$refs.uToast.show({
  132. type: 'success',
  133. message: "删除成功!",
  134. complete() {
  135. that.getInfo()
  136. }
  137. })
  138. } else {
  139. uni.hideLoading()
  140. uni.$u.toast(res.message);
  141. }
  142. }).catch(res => {
  143. uni.hideLoading()
  144. uni.$u.toast(res.message);
  145. });
  146. },
  147. next(obj) {
  148. this.tipsShow = true
  149. this.alertTitle = "确定删除" + obj.driverName + "信息?"
  150. this.id = obj.id
  151. this.sign = "删除"
  152. },
  153. audit(obj, val) {
  154. if (val == 1) {
  155. this.alertTitle = "确定拒绝" + obj.driverName + "加入车队?"
  156. this.distinguish = "2"
  157. } else if (val == 2) {
  158. this.alertTitle = "确定接受" + obj.driverName + "加入车队?"
  159. this.distinguish = "1"
  160. }
  161. this.id = obj.id
  162. this.tipsShow = true
  163. },
  164. operation(val) {
  165. if (val == 1) {
  166. uni.$u.route('/pages/mine/fleet/carCaptainAuthentication');
  167. } else {
  168. uni.$u.route('/pages/mine/fleet/carCaptainAuthentication', {
  169. data: JSON.stringify(this.fleetInfo),
  170. });
  171. }
  172. },
  173. leave() {
  174. this.tipsShow = true
  175. },
  176. cancelClick() {
  177. this.tipsShow = false
  178. },
  179. confirmClick() {
  180. let that = this
  181. if (this.sign == "删除") { //删除操作
  182. this.solution()
  183. } else {
  184. uni.showLoading({
  185. mask: true,
  186. title: '加载中'
  187. })
  188. this.tipsShow = false
  189. this.$request.baseRequest('post', '/hyBindCarCaptainInfo/api/examine', {
  190. id: this.id,
  191. examineFlag: this.distinguish
  192. }).then(res => {
  193. if (res.code == 200) {
  194. uni.hideLoading()
  195. if (this.distinguish == 1) {
  196. this.$refs.uToast.show({
  197. type: 'success',
  198. message: "接受成功!",
  199. complete() {
  200. that.getInfo()
  201. }
  202. })
  203. } else {
  204. this.$refs.uToast.show({
  205. type: 'success',
  206. message: "拒绝成功!",
  207. complete() {
  208. that.getInfo()
  209. }
  210. })
  211. }
  212. } else {
  213. uni.hideLoading()
  214. uni.$u.toast(res.message);
  215. }
  216. })
  217. .catch(res => {
  218. uni.hideLoading()
  219. uni.$u.toast(res.message);
  220. });
  221. }
  222. },
  223. getInfo() {
  224. this.$request.baseRequest('get', '/hyCarCaptainInfo/getCarCaptain', {
  225. commonId: this.userInfo.id
  226. }).then(res => {
  227. if (res.code == 200) {
  228. if (res.data) {
  229. this.fleetInfo = res.data
  230. this.nextGetInfo()
  231. }else{
  232. this.isLoadMore = true
  233. this.loadStatus = 'nomore'
  234. }
  235. } else {
  236. uni.$u.toast(res.message);
  237. }
  238. })
  239. .catch(res => {
  240. uni.$u.toast(res.message);
  241. });
  242. },
  243. nextGetInfo() {
  244. //车队人员
  245. uni.showLoading({
  246. title: '加载中',
  247. mask: true
  248. })
  249. this.$request.baseRequest('get', '/hyBindCarCaptainInfo/api/selectPage', {
  250. carCaptainCommonId: this.userInfo.id,
  251. pageSize: this.pageSize,
  252. currentPage: this.currentPage
  253. }).then(res => {
  254. if (res.code == 200) {
  255. // this.formList = res.data.records
  256. if (res.data.records.length > 0) {
  257. this.isLoadMore = false
  258. this.loadStatus = 'loadmore'
  259. } else {
  260. this.isLoadMore = true
  261. this.loadStatus = 'nomore'
  262. }
  263. if (this.currentPage == 1) {
  264. this.formList = res.data.records
  265. if (res.data.records.length < 20) {
  266. this.loadStatus = 'nomore'
  267. }
  268. } else {
  269. this.formList = this.formList.concat(res.data.records)
  270. }
  271. uni.hideLoading()
  272. } else {
  273. uni.hideLoading()
  274. }
  275. })
  276. .catch(res => {
  277. uni.hideLoading()
  278. uni.$u.toast(res.message);
  279. });
  280. }
  281. }
  282. }
  283. </script>
  284. <style lang="scss" scoped>
  285. .center {
  286. padding: 20rpx 30rpx;
  287. }
  288. .fleetInfo {
  289. display: flex;
  290. width: 100%;
  291. margin-top: 30rpx;
  292. .fleetInfo_name {
  293. width: 50%;
  294. }
  295. .fleetInfo_phone {
  296. width: 50%;
  297. text-align: right;
  298. }
  299. }
  300. .btn_css {
  301. display: flex;
  302. margin-top: 30rpx;
  303. .btn_item {
  304. width: 120rpx;
  305. margin-right: 20rpx;
  306. }
  307. }
  308. .list_css {
  309. display: flex;
  310. margin: 30rpx 0;
  311. .list_left {
  312. width: 50%;
  313. }
  314. .list_right {
  315. display: flex;
  316. justify-content: flex-end;
  317. width: 50%;
  318. .list_text {
  319. margin: 0 10rpx;
  320. }
  321. }
  322. }
  323. .tips_info {
  324. margin: 20rpx 0;
  325. .yanjingicon {
  326. margin: 0 20rpx;
  327. width: 22px;
  328. height: 22px;
  329. top: 10rpx
  330. }
  331. }
  332. </style>