deliverySetting.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <div class="delivery-setting">
  3. <div class="model">
  4. <div class="title">运力设置<span class="tips">(推荐的运力在聚合发单时会置顶展示,屏蔽的运力在发单时将不进行计价)</span></div>
  5. <div class="list">
  6. <div class="item" v-for="(v,i) in deliveryList" :key=i>
  7. <div class="left">
  8. <div class="left-top">
  9. <div class="name">{{v.name}}</div>
  10. </div>
  11. <div class="left-bot">{{v.tips}}</div>
  12. </div>
  13. <div class="right">
  14. <div class="con" @click="changeDelivery(v,3)" v-if="billDeliveryIds.includes(String(v.deliveryId))">取消推荐</div>
  15. <div class="con con1" @click="changeDelivery(v,2)" v-if="billDeliveryIds.includes(String(v.deliveryId)) || !shieldDeliveryIds.includes(String(v.deliveryId))">屏蔽</div>
  16. <div class="con con1" @click="changeDelivery(v,3)" v-if="shieldDeliveryIds.includes(String(v.deliveryId))">取消屏蔽</div>
  17. <div class="con" @click="changeDelivery(v,1)" v-if="shieldDeliveryIds.includes(String(v.deliveryId)) || !billDeliveryIds.includes(String(v.deliveryId))">推荐</div>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import {
  26. getDeliveryFloorList,
  27. getConfig,
  28. updateConfig,
  29. } from "../../api/setting.js";
  30. export default {
  31. name: "deliverySetting",
  32. data() {
  33. return {
  34. billDeliveryIds: [], // 推荐运力
  35. shieldDeliveryIds: [], // 屏蔽运力
  36. deliveryList: [],
  37. centerDialogVisible: false,
  38. curIndex: 0,
  39. time: 0,
  40. };
  41. },
  42. // 监听属性 类似于data概念
  43. computed: {},
  44. // 监控data中的数据变化
  45. watch: {},
  46. // 生命周期 - 创建完成(可以访问当前this实例)
  47. created() {
  48. this.getDelivery();
  49. this.getConfig();
  50. },
  51. // 生命周期 - 挂载完成(可以访问DOM元素)
  52. mounted() {},
  53. // 生命周期 - 创建之前
  54. beforeCreate() {},
  55. // 生命周期 - 挂载之前
  56. beforeMount() {},
  57. // 生命周期 - 更新之前
  58. beforeUpdate() {},
  59. // 生命周期 - 更新之后
  60. updated() {},
  61. // 生命周期 - 销毁之前
  62. beforeDestroy() {},
  63. // 生命周期 - 销毁完成
  64. destroyed() {},
  65. // 如果页面有keep-alive缓存功能,这个函数会触发
  66. activated() {},
  67. // 方法集合
  68. methods: {
  69. changeDelivery(v, type) {
  70. let id = v.deliveryId;
  71. // 推荐该运力
  72. if (type === 1) {
  73. this.shieldDeliveryIds = this.shieldDeliveryIds.filter((v) => {
  74. return v !== String(id);
  75. });
  76. this.billDeliveryIds.push(String(id));
  77. this.billDeliveryIds = [...new Set(this.billDeliveryIds)];
  78. }
  79. // 屏蔽该运力
  80. if (type === 2) {
  81. this.billDeliveryIds = this.billDeliveryIds.filter((v) => {
  82. return v !== String(id);
  83. });
  84. this.shieldDeliveryIds.push(String(id));
  85. this.shieldDeliveryIds = [...new Set(this.shieldDeliveryIds)];
  86. }
  87. // 恢复为普通运力
  88. if (type === 3) {
  89. this.billDeliveryIds = this.billDeliveryIds.filter((v) => {
  90. return v !== String(id);
  91. });
  92. this.shieldDeliveryIds = this.shieldDeliveryIds.filter((v) => {
  93. return v !== String(id);
  94. });
  95. }
  96. let data = {
  97. billDeliveryIds: String(this.billDeliveryIds),
  98. shieldDeliveryIds: String(this.shieldDeliveryIds),
  99. };
  100. this.updateConfig(data);
  101. },
  102. change(e) {
  103. let data = { [e.field]: e.value };
  104. this.updateConfig(data);
  105. },
  106. getDelivery() {
  107. getDeliveryFloorList().then((res) => {
  108. if (res.code === 200) {
  109. // 电脑端暂时不支持货拉拉
  110. this.deliveryList = res.data.filter((v) => {
  111. return v.type !== 12;
  112. });
  113. } else {
  114. this.$message({
  115. type: "error",
  116. message: res.msg,
  117. });
  118. }
  119. });
  120. },
  121. getConfig() {
  122. getConfig().then((res) => {
  123. if (res.code === 200) {
  124. this.billDeliveryIds = res.data.billDeliveryIds
  125. ? res.data.billDeliveryIds.split(",")
  126. : [];
  127. this.shieldDeliveryIds = res.data.shieldDeliveryIds
  128. ? res.data.shieldDeliveryIds.split(",")
  129. : [];
  130. } else {
  131. this.$message({
  132. type: "error",
  133. message: res.msg,
  134. });
  135. }
  136. this.centerDialogVisible = false;
  137. });
  138. },
  139. updateConfig(data) {
  140. updateConfig(data).then((res) => {
  141. if (res.code !== 200) {
  142. this.$message({
  143. type: "error",
  144. message: res.msg,
  145. });
  146. }
  147. this.getConfig();
  148. });
  149. },
  150. },
  151. };
  152. </script>
  153. <style lang="scss" scoped type="text/css">
  154. /deep/ .el-button--default:hover {
  155. background-color: rgba(252, 114, 0, 0.2);
  156. border-color: rgba(252, 114, 0, 0.2);
  157. color: #fc7200;
  158. }
  159. /deep/ .el-button--primary {
  160. background-color: #fc7200;
  161. border-color: #fc7200;
  162. }
  163. .model {
  164. .title {
  165. position: relative;
  166. font-size: 16px;
  167. font-weight: bold;
  168. line-height: 22px;
  169. color: #333333;
  170. padding-left: 10px;
  171. margin-top: 24px;
  172. .tips {
  173. font-size: 14px;
  174. font-weight: 400;
  175. line-height: 22px;
  176. color: #999999;
  177. }
  178. }
  179. .title::before {
  180. width: 3px;
  181. height: 16px;
  182. background: #fc7200;
  183. border-radius: 2px;
  184. content: "";
  185. position: absolute;
  186. top: 2px;
  187. left: 0;
  188. }
  189. .list {
  190. .item {
  191. display: flex;
  192. justify-content: space-between;
  193. align-items: center;
  194. background: #ffffff;
  195. margin-top: 10px;
  196. padding: 16px 20px;
  197. .left {
  198. display: flex;
  199. flex-direction: column;
  200. font-size: 14px;
  201. font-weight: bold;
  202. line-height: 20px;
  203. color: #000000;
  204. .left-top {
  205. display: flex;
  206. align-items: center;
  207. .set-tips {
  208. font-weight: 400;
  209. color: #fc7200;
  210. margin-left: 10px;
  211. cursor: pointer;
  212. }
  213. }
  214. .left-bot {
  215. margin-top: 2px;
  216. font-size: 12px;
  217. font-weight: 400;
  218. line-height: 17px;
  219. color: #999999;
  220. }
  221. }
  222. .right {
  223. display: flex;
  224. align-items: center;
  225. .time {
  226. font-size: 12px;
  227. font-family: PingFang SC;
  228. font-weight: 400;
  229. line-height: 17px;
  230. color: #333333;
  231. margin-right: 20px;
  232. }
  233. .time1 {
  234. color: #999999;
  235. }
  236. .con {
  237. font-size: 14px;
  238. font-weight: 400;
  239. line-height: 20px;
  240. color: #fc7200;
  241. padding-left: 20px;
  242. cursor: pointer;
  243. }
  244. .con1 {
  245. color: #999999;
  246. }
  247. .img {
  248. width: 20px;
  249. height: 20px;
  250. cursor: pointer;
  251. }
  252. }
  253. }
  254. }
  255. }
  256. </style>