Delivery.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view class="content">
  3. <view class="search">
  4. <u-search placeholder="请输入信息搜索配送员" v-model="keyword" @custom="getData" @search="getData"></u-search>
  5. </view>
  6. <view class="card" v-for="(item,index) in dataList" :key="index">
  7. <view class="row">
  8. <view class="row half">
  9. <view class="name">
  10. 公司名称
  11. </view>
  12. <view class="text">
  13. {{item.company}}
  14. </view>
  15. </view>
  16. </view>
  17. <view class="row">
  18. <view class="row half">
  19. <view class="name">
  20. 姓名
  21. </view>
  22. <view class="text">
  23. {{item.name}}
  24. </view>
  25. </view>
  26. <view class="row half">
  27. <view class="name">
  28. 联系方式
  29. </view>
  30. <view class="text">
  31. {{item.mobile}}
  32. </view>
  33. </view>
  34. </view>
  35. <view class="row">
  36. <view class="row half">
  37. <view class="name">
  38. 账号
  39. </view>
  40. <view class="text">
  41. {{item.username}}
  42. </view>
  43. </view>
  44. </view>
  45. <view class="row">
  46. <view class="row locationName">
  47. <view class="name">
  48. 所属区域
  49. </view>
  50. <view class="text">
  51. <view v-for="(obj,key) in item.area">
  52. {{obj.name}}
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="row">
  58. <view class="row half">
  59. <view class="name">
  60. 是否禁用
  61. </view>
  62. <u-switch class="text" style="margin-left: 20rpx;" v-model="item.status"
  63. :active-value="item.id + ',1'" :inactive-value="item.id + ',2'" @change="open"
  64. active-color="#F6B301" inactive-color="#eee" size="25"></u-switch>
  65. </view>
  66. <view class="row half">
  67. <view class="btn" @click="del(item.id)">
  68. 删除
  69. </view>
  70. <view class="btn" @click="eidt(item)">
  71. 编辑
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="bottom-btn">
  77. <view class="buttom-dom" @click="create">
  78. 创建配送员
  79. </view>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. // 搜索条件
  88. keyword: "",
  89. // 数量
  90. limit: 10,
  91. // 页码
  92. page: 1,
  93. // 数据
  94. dataList: []
  95. }
  96. },
  97. onShow() {
  98. this.getData()
  99. },
  100. onLoad() {
  101. this.getData()
  102. },
  103. methods: {
  104. // 禁用
  105. open(e) {
  106. let _this = this
  107. let data = e.split(',')
  108. // 开启
  109. if (data[1] === '1') {
  110. uni.showModal({
  111. title: '确定要开启此配送员吗?',
  112. success: function(res) {
  113. if (res.confirm) {
  114. _this.request("/admin_user/enable", {
  115. user_id: data[0],
  116. status: 'normal'
  117. }, "GET").then(res => {
  118. if (res.code === 1) {
  119. _this.getData()
  120. }
  121. })
  122. } else if (res.cancel) {
  123. console.log('用户点击取消');
  124. _this.getData()
  125. }
  126. }
  127. })
  128. }
  129. // 关闭
  130. if (data[1] === '2') {
  131. uni.showModal({
  132. title: '确定要禁用此配送员吗?',
  133. success: function(res) {
  134. if (res.confirm) {
  135. _this.request("/admin_user/enable", {
  136. user_id: data[0],
  137. status: 'hidden'
  138. }, "GET").then(res => {
  139. if (res.code === 1) {
  140. _this.getData()
  141. }
  142. })
  143. } else if (res.cancel) {
  144. console.log('用户点击取消');
  145. _this.getData()
  146. }
  147. }
  148. })
  149. }
  150. },
  151. // 获取数据列表
  152. getData() {
  153. this.request("/admin_user/senders", {
  154. keyword: this.keyword,
  155. limit: this.limit,
  156. page: this.page
  157. }, "GET").then(res => {
  158. console.log(res)
  159. if (res.code === 1) {
  160. this.dataList = res.data.data
  161. }
  162. })
  163. },
  164. // 点击新建
  165. create() {
  166. uni.navigateTo({
  167. url: './create?type=1'
  168. })
  169. },
  170. // 点击删除
  171. del(id) {
  172. let _this = this;
  173. console.log('del')
  174. uni.showModal({
  175. title: "提示",
  176. content: "确定要删除此配送员吗?",
  177. showCancel: true,
  178. success(e) {
  179. if (e.confirm) {
  180. console.log('确定')
  181. _this.request("/admin_user/delete", {
  182. user_id: id
  183. }, "GET").then(res => {
  184. console.log(res)
  185. if (res.code === 1) {
  186. _this.$u.toast('操作成功')
  187. _this.getData()
  188. }
  189. })
  190. }
  191. }
  192. })
  193. },
  194. // 点击编辑
  195. eidt(info) {
  196. console.log('edit')
  197. uni.navigateTo({
  198. url: "./create?info=" + JSON.stringify(info) + "&type=2"
  199. })
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="scss">
  205. .content {
  206. padding-top: 120rpx;
  207. overflow-y: scroll;
  208. padding-bottom: 15vh;
  209. .search {
  210. padding: 30rpx;
  211. background-color: #FFFFFF;
  212. position: fixed;
  213. top: 0;
  214. width: 100vw;
  215. }
  216. .card {
  217. background-color: #FFFFFF;
  218. width: 93%;
  219. margin: 0 auto;
  220. margin-top: 40rpx;
  221. padding: 30rpx;
  222. border-radius: 30rpx;
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. justify-content: space-between;
  227. .row {
  228. margin-bottom: 10rpx;
  229. }
  230. .locationName {
  231. width: 100%;
  232. justify-content: flex-start;
  233. .text {
  234. text-indent: 1em;
  235. width: 80%;
  236. text-overflow: ellipsis;
  237. overflow: hidden;
  238. display: flex;
  239. flex-direction: row;
  240. align-items: center;
  241. justify-content: flex-start;
  242. white-space: nowrap;
  243. }
  244. }
  245. .row:nth-child(5) {
  246. margin-bottom: 0;
  247. }
  248. .half {
  249. width: 50%;
  250. justify-content: flex-start;
  251. .name {
  252. color: #999;
  253. }
  254. .text {
  255. text-indent: 1em;
  256. }
  257. .btn {
  258. width: 100%;
  259. display: flex;
  260. flex-direction: row;
  261. align-items: center;
  262. justify-content: flex-end;
  263. }
  264. }
  265. }
  266. .bottom-btn {
  267. position: fixed;
  268. bottom: 0;
  269. width: 100vw;
  270. height: 10vh;
  271. background-color: #FFFFFF;
  272. display: flex;
  273. flex-direction: column;
  274. align-items: center;
  275. justify-content: center;
  276. .buttom-dom {
  277. height: 80rpx;
  278. width: 93%;
  279. background-color: #F6B301;
  280. color: #FFFFFF;
  281. text-align: center;
  282. line-height: 80rpx;
  283. color: #FFFFFF;
  284. border-radius: 80rpx;
  285. }
  286. }
  287. }
  288. </style>