deliverySetting.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="delivery-content">
  3. <div>
  4. <!-- <el-button type="primary">保存操作</el-button> -->
  5. </div>
  6. <div class="recommend">
  7. <div class="title">
  8. <!-- <el-button type="primary" @click.stop="toPay">发起支付</el-button> -->
  9. <span>推荐/屏蔽运力</span>
  10. <span>用户选择非聚合配送发单时,优先选中的运力置顶显示,提高您的下单效率</span>
  11. </div>
  12. <div class="delivery-list">
  13. <div @click="changeStatus(v.deliveryId)" class="item" v-for="(v,i) in list" :key="i">
  14. <img :src="v.pcLogo" class="icon" />
  15. <div v-if="shieldDeliveryIds.includes(String(v.deliveryId))" class="mask mantle">
  16. {{v.name}}已屏蔽
  17. </div>
  18. <div v-if="billDeliveryIds.includes(String(v.deliveryId))" class="mask recommend-delivery">
  19. {{v.name}}已推荐
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. <el-dialog title="请选择对当前运力的操作!" :visible.sync="centerDialogVisible" width="600px" center>
  25. <span slot="footer" class="dialog-footer">
  26. <el-button type="success" @click="changeDelivery(1)">推荐运力</el-button>
  27. <el-button type="danger" @click="changeDelivery(2)">屏蔽运力</el-button>
  28. <el-button type="primary" @click="changeDelivery(3)">重置运力</el-button>
  29. </span>
  30. </el-dialog>
  31. </div>
  32. </template>
  33. <script>
  34. import {
  35. getDeliveryFloorList,
  36. getConfig,
  37. updateConfig,
  38. } from "../../api/setting.js";
  39. export default {
  40. data() {
  41. return {
  42. form: "",
  43. list: [],
  44. billDeliveryIds: [], // 推荐运力ID
  45. shieldDeliveryIds: [], // 屏蔽运力ID
  46. centerDialogVisible: false,
  47. };
  48. },
  49. created() {
  50. this.getDeliveryFloorList();
  51. this.getConfig();
  52. },
  53. mounted() {},
  54. methods: {
  55. changeStatus(id) {
  56. this.id = id;
  57. this.centerDialogVisible = true;
  58. },
  59. changeDelivery(type) {
  60. console.log(2222);
  61. // 推荐该运力
  62. if (type === 1) {
  63. this.shieldDeliveryIds = this.shieldDeliveryIds.filter((v) => {
  64. return v !== String(this.id);
  65. });
  66. this.billDeliveryIds.push(String(this.id));
  67. this.billDeliveryIds = [...new Set(this.billDeliveryIds)];
  68. }
  69. // 屏蔽该运力
  70. if (type === 2) {
  71. this.billDeliveryIds = this.billDeliveryIds.filter((v) => {
  72. return v !== String(this.id);
  73. });
  74. this.shieldDeliveryIds.push(String(this.id));
  75. this.shieldDeliveryIds = [...new Set(this.shieldDeliveryIds)];
  76. }
  77. // 恢复为普通运力
  78. if (type === 3) {
  79. this.billDeliveryIds = this.billDeliveryIds.filter((v) => {
  80. return v !== String(this.id);
  81. });
  82. this.shieldDeliveryIds = this.shieldDeliveryIds.filter((v) => {
  83. return v !== String(this.id);
  84. });
  85. }
  86. this.updateConfig();
  87. },
  88. getDeliveryFloorList() {
  89. getDeliveryFloorList().then((res) => {
  90. if (res.code === 200) {
  91. // 电脑端暂时不支持货拉拉
  92. this.list = res.data.filter((v) => {
  93. return v.type !== 12;
  94. });
  95. } else {
  96. this.$message({
  97. type: "error",
  98. message: res.msg,
  99. });
  100. }
  101. });
  102. },
  103. getConfig() {
  104. getConfig().then((res) => {
  105. if (res.code === 200) {
  106. this.billDeliveryIds = res.data.billDeliveryIds
  107. ? res.data.billDeliveryIds.split(",")
  108. : [];
  109. this.shieldDeliveryIds = res.data.shieldDeliveryIds
  110. ? res.data.shieldDeliveryIds.split(",")
  111. : [];
  112. let a = new Set(this.shieldDeliveryIds);
  113. let b = new Set(this.billDeliveryIds);
  114. let difference = new Set([...a].filter((x) => !b.has(x)));
  115. this.shieldDeliveryIds = [...difference];
  116. } else {
  117. this.$message({
  118. type: "error",
  119. message: res.msg,
  120. });
  121. }
  122. this.centerDialogVisible = false;
  123. });
  124. },
  125. updateConfig() {
  126. let billDeliveryIds = this.billDeliveryIds.toString();
  127. let shieldDeliveryIds = this.shieldDeliveryIds.toString();
  128. updateConfig({ billDeliveryIds, shieldDeliveryIds }).then((res) => {
  129. if (res.code === 200) {
  130. this.$message({
  131. type: "success",
  132. message: "修改成功!",
  133. });
  134. } else {
  135. this.$message({
  136. type: "error",
  137. message: res.msg,
  138. });
  139. }
  140. this.getConfig();
  141. });
  142. },
  143. },
  144. };
  145. </script>
  146. <style lang="scss" scoped>
  147. .delivery-content {
  148. .recommend {
  149. background-color: #fff;
  150. margin-top: 10px;
  151. .title {
  152. font-size: 16px;
  153. font-family: PingFang SC;
  154. font-weight: 600;
  155. color: #333333;
  156. height: 55px;
  157. line-height: 55px;
  158. box-sizing: border-box;
  159. padding: 0 18px;
  160. border-bottom: 1px solid #eee;
  161. span:nth-child(2) {
  162. font-size: 14px;
  163. font-family: PingFang SC;
  164. font-weight: 400;
  165. color: #b1b1b1;
  166. }
  167. }
  168. .delivery-list {
  169. display: flex;
  170. flex-wrap: wrap;
  171. padding: 30px 18px 0;
  172. .item {
  173. position: relative;
  174. cursor: pointer;
  175. margin: 0 30px 30px 0;
  176. .mask {
  177. position: absolute;
  178. display: flex;
  179. align-items: center;
  180. justify-content: center;
  181. top: 0;
  182. left: 0;
  183. width: 129px;
  184. height: 40px;
  185. background: #999;
  186. font-size: 14px;
  187. border-radius: 25px;
  188. opacity: 0.8;
  189. }
  190. .mantle {
  191. color: #fff;
  192. }
  193. .recommend-delivery {
  194. color: red;
  195. }
  196. .icon {
  197. width: 129px;
  198. height: 40px;
  199. }
  200. }
  201. }
  202. }
  203. }
  204. </style>