deliverySetting.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <div class="delivery-setting">
  3. <div class="model">
  4. <div class="title">接单设置</div>
  5. <div class="list">
  6. <div class="item" v-for="(v,i) in list3" :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. <el-switch @change="change(v)" v-model="v.value" :active-value="1" :inactive-value="0" active-color="#FC7200" inactive-color="#999" />
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. <div class="model">
  20. <div class="title">自动发单设置</div>
  21. <div class="list">
  22. <div class="item" v-for="(v,i) in list" :key=i>
  23. <div class="left">
  24. <div class="left-top">
  25. <div class="name">{{v.name}}</div>
  26. <div @click="setTime(v,i)" class="set-tips">{{v.setContent}}</div>
  27. </div>
  28. <div class="left-bot">{{v.tips}}</div>
  29. </div>
  30. <div class="right">
  31. <div v-if="!i" :class="['time', v.value ? '' : 'time1']">顾客下单{{v.time}}分钟后</div>
  32. <div v-else :class="['time', v.value ? '' : 'time1']">期望送达前{{v.time}}分钟</div>
  33. <el-switch @change="change(v)" v-model="v.value" :active-value="1" :inactive-value="0" active-color="#FC7200" inactive-color="#999" />
  34. </div>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="model">
  39. <div class="title">配送信息同步设置</div>
  40. <div class="list">
  41. <div class="item">
  42. <div class="left">
  43. <div class="left-top">
  44. <div class="name">同步商品图片</div>
  45. </div>
  46. <div class="left-bot">同步后显示最新的商品图片,7天内只可以同步一次,如遇特殊情况可联系客服。</div>
  47. </div>
  48. <div class="right">
  49. <img @click="syncFoodImg" class="img" src="../../../static/image/update.png" alt="">
  50. </div>
  51. </div>
  52. <div class="item" v-for="(v,i) in list2" :key=i>
  53. <div class="left">
  54. <div class="left-top">
  55. <div class="name">{{v.name}}</div>
  56. </div>
  57. <div class="left-bot">{{v.tips}}</div>
  58. </div>
  59. <div class="right">
  60. <el-switch @change="change(v)" v-model="v.value" :active-value="1" :inactive-value="0" active-color="#FC7200" inactive-color="#999" />
  61. </div>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="model">
  66. <div class="title">运力设置<span class="tips">(推荐的运力在聚合发单时会置顶展示,屏蔽的运力在发单时将不进行计价)</span></div>
  67. <div class="list">
  68. <div class="item" v-for="(v,i) in deliveryList" :key=i>
  69. <div class="left">
  70. <div class="left-top">
  71. <div class="name">{{v.name}}</div>
  72. </div>
  73. <div class="left-bot">{{v.tips}}</div>
  74. </div>
  75. <div class="right">
  76. <div class="con" @click="changeDelivery(v,3)" v-if="billDeliveryIds.includes(String(v.deliveryId))">取消推荐</div>
  77. <div class="con con1" @click="changeDelivery(v,2)" v-if="billDeliveryIds.includes(String(v.deliveryId)) || !shieldDeliveryIds.includes(String(v.deliveryId))">屏蔽</div>
  78. <div class="con con1" @click="changeDelivery(v,3)" v-if="shieldDeliveryIds.includes(String(v.deliveryId))">取消屏蔽</div>
  79. <div class="con" @click="changeDelivery(v,1)" v-if="shieldDeliveryIds.includes(String(v.deliveryId)) || !billDeliveryIds.includes(String(v.deliveryId))">推荐</div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <el-dialog :title="!curIndex ? '即时单自动发单时间设置' : '预定单自动发单时间设置'" @close="centerDialogVisible=false" :visible.sync="centerDialogVisible" width="400px" center>
  85. <el-form label-width="120px">
  86. <el-form-item :label="!curIndex ? '顾客下单' : '期望送达前'">
  87. <el-input size="small" class="auto-time" v-model="time" clearable>
  88. <template slot="append">分钟{{curIndex ? '' : '后'}}</template>
  89. </el-input>
  90. </el-form-item>
  91. </el-form>
  92. <span slot="footer" class="dialog-footer">
  93. <el-button size="medium" @click="centerDialogVisible=false">取 消</el-button>
  94. <el-button size='medium' type="primary" @click="confirm">确 定</el-button>
  95. </span>
  96. </el-dialog>
  97. </div>
  98. </template>
  99. <script>
  100. import {
  101. getDeliveryFloorList,
  102. getConfig,
  103. updateConfig,
  104. syncFoodImg,
  105. } from "../../api/setting.js";
  106. export default {
  107. name: "deliverySetting",
  108. data() {
  109. return {
  110. list: [
  111. {
  112. name: "自动发单",
  113. setContent: "设置时长",
  114. value: 1,
  115. field: "openAutodelivery",
  116. tips: "非冲突绑定模式,不支持自动发单",
  117. time: 0,
  118. },
  119. {
  120. name: "预约单自动发单",
  121. setContent: "设置时长",
  122. value: 1,
  123. field: "openBookingAutodelivery",
  124. tips: "设置的时长为预约单期望送达前多长时间自动呼叫配送",
  125. time: 0,
  126. },
  127. ],
  128. list2: [
  129. {
  130. name: "订单详情显示出商品图片",
  131. value: 1,
  132. field: "showFoodImg",
  133. tips: "在订单详情的商品显示图片,方便制作时确认",
  134. },
  135. {
  136. name: "同步订单商品给骑手",
  137. value: 1,
  138. field: "syncGoodsDetailToDelivery",
  139. tips: "关闭后骑手将看不到商品详情",
  140. },
  141. ],
  142. list3: [
  143. {
  144. name: "自动接单",
  145. value: 1,
  146. field: "openAutoorder",
  147. tips: "非冲突绑定模式,不支持自动接单",
  148. },
  149. ],
  150. billDeliveryIds: [], // 推荐运力
  151. shieldDeliveryIds: [], // 屏蔽运力
  152. deliveryList: [],
  153. centerDialogVisible: false,
  154. curIndex: 0,
  155. time: 0,
  156. };
  157. },
  158. // 监听属性 类似于data概念
  159. computed: {},
  160. // 监控data中的数据变化
  161. watch: {},
  162. // 生命周期 - 创建完成(可以访问当前this实例)
  163. created() {
  164. this.getDelivery();
  165. this.getConfig();
  166. },
  167. // 生命周期 - 挂载完成(可以访问DOM元素)
  168. mounted() {},
  169. // 生命周期 - 创建之前
  170. beforeCreate() {},
  171. // 生命周期 - 挂载之前
  172. beforeMount() {},
  173. // 生命周期 - 更新之前
  174. beforeUpdate() {},
  175. // 生命周期 - 更新之后
  176. updated() {},
  177. // 生命周期 - 销毁之前
  178. beforeDestroy() {},
  179. // 生命周期 - 销毁完成
  180. destroyed() {},
  181. // 如果页面有keep-alive缓存功能,这个函数会触发
  182. activated() {},
  183. // 方法集合
  184. methods: {
  185. changeDelivery(v, type) {
  186. let id = v.deliveryId;
  187. // 推荐该运力
  188. if (type === 1) {
  189. this.shieldDeliveryIds = this.shieldDeliveryIds.filter((v) => {
  190. return v !== String(id);
  191. });
  192. this.billDeliveryIds.push(String(id));
  193. this.billDeliveryIds = [...new Set(this.billDeliveryIds)];
  194. }
  195. // 屏蔽该运力
  196. if (type === 2) {
  197. this.billDeliveryIds = this.billDeliveryIds.filter((v) => {
  198. return v !== String(id);
  199. });
  200. this.shieldDeliveryIds.push(String(id));
  201. this.shieldDeliveryIds = [...new Set(this.shieldDeliveryIds)];
  202. }
  203. // 恢复为普通运力
  204. if (type === 3) {
  205. this.billDeliveryIds = this.billDeliveryIds.filter((v) => {
  206. return v !== String(id);
  207. });
  208. this.shieldDeliveryIds = this.shieldDeliveryIds.filter((v) => {
  209. return v !== String(id);
  210. });
  211. }
  212. let data = {
  213. billDeliveryIds: String(this.billDeliveryIds),
  214. shieldDeliveryIds: String(this.shieldDeliveryIds),
  215. };
  216. this.updateConfig(data);
  217. },
  218. confirm() {
  219. let data = {};
  220. if (!this.curIndex) {
  221. data = { autodeliveryOrderTime: this.time * 60 };
  222. } else {
  223. data = { bookingAutodeliveryOrderTime: this.time * 60 };
  224. }
  225. this.updateConfig(data);
  226. },
  227. setTime(v, i) {
  228. if (!v.value) {
  229. return this.$message({
  230. message: "请开启后再设置时间!",
  231. type: "warning",
  232. });
  233. }
  234. this.curIndex = i;
  235. this.time = v.time;
  236. this.centerDialogVisible = true;
  237. },
  238. change(e) {
  239. let data = { [e.field]: e.value };
  240. this.updateConfig(data);
  241. },
  242. getDelivery() {
  243. getDeliveryFloorList().then((res) => {
  244. console.log("返回的运力:", res);
  245. if (res.code === 200) {
  246. // 电脑端暂时不支持货拉拉
  247. this.deliveryList = res.data.filter((v) => {
  248. return v.type !== 12;
  249. });
  250. } else {
  251. this.$message({
  252. type: "error",
  253. message: res.msg,
  254. });
  255. }
  256. });
  257. },
  258. getConfig() {
  259. getConfig().then((res) => {
  260. if (res.code === 200) {
  261. this.billDeliveryIds = res.data.billDeliveryIds
  262. ? res.data.billDeliveryIds.split(",")
  263. : [];
  264. this.shieldDeliveryIds = res.data.shieldDeliveryIds
  265. ? res.data.shieldDeliveryIds.split(",")
  266. : [];
  267. this.list[0].time = res.data.autodeliveryOrderTime / 60;
  268. this.list[1].time = res.data.bookingAutodeliveryOrderTime / 60;
  269. this.list = this.list.map((v) => {
  270. v.value = res.data[v.field];
  271. return v;
  272. });
  273. this.list2 = this.list2.map((v) => {
  274. v.value = res.data[v.field];
  275. return v;
  276. });
  277. this.list3 = this.list3.map((v) => {
  278. v.value = res.data[v.field];
  279. return v;
  280. });
  281. } else {
  282. this.$message({
  283. type: "error",
  284. message: res.msg,
  285. });
  286. }
  287. this.centerDialogVisible = false;
  288. });
  289. },
  290. updateConfig(data) {
  291. updateConfig(data).then((res) => {
  292. if (res.code !== 200) {
  293. this.$message({
  294. type: "error",
  295. message: res.msg,
  296. });
  297. }
  298. this.getConfig();
  299. });
  300. },
  301. syncFoodImg() {
  302. syncFoodImg().then((res) => {
  303. if (res.code === 200) {
  304. this.$message({
  305. type: "success",
  306. message: "正在同步!",
  307. });
  308. } else {
  309. this.$message({
  310. type: "error",
  311. message: res.msg,
  312. });
  313. }
  314. });
  315. },
  316. },
  317. };
  318. </script>
  319. <style lang="scss" scoped type="text/css">
  320. /deep/ .el-button--default:hover {
  321. background-color: rgba(252, 114, 0, 0.2);
  322. border-color: rgba(252, 114, 0, 0.2);
  323. color: #fc7200;
  324. }
  325. /deep/ .el-button--primary {
  326. background-color: #fc7200;
  327. border-color: #fc7200;
  328. }
  329. .model {
  330. .title {
  331. position: relative;
  332. font-size: 16px;
  333. font-weight: bold;
  334. line-height: 22px;
  335. color: #333333;
  336. padding-left: 10px;
  337. margin-top: 24px;
  338. .tips {
  339. font-size: 14px;
  340. font-weight: 400;
  341. line-height: 22px;
  342. color: #999999;
  343. }
  344. }
  345. .title::before {
  346. width: 3px;
  347. height: 16px;
  348. background: #fc7200;
  349. border-radius: 2px;
  350. content: "";
  351. position: absolute;
  352. top: 2px;
  353. left: 0;
  354. }
  355. .list {
  356. .item {
  357. display: flex;
  358. justify-content: space-between;
  359. align-items: center;
  360. background: #ffffff;
  361. margin-top: 10px;
  362. padding: 16px 20px;
  363. .left {
  364. display: flex;
  365. flex-direction: column;
  366. font-size: 14px;
  367. font-weight: bold;
  368. line-height: 20px;
  369. color: #000000;
  370. .left-top {
  371. display: flex;
  372. align-items: center;
  373. .set-tips {
  374. font-weight: 400;
  375. color: #fc7200;
  376. margin-left: 10px;
  377. cursor: pointer;
  378. }
  379. }
  380. .left-bot {
  381. margin-top: 2px;
  382. font-size: 12px;
  383. font-weight: 400;
  384. line-height: 17px;
  385. color: #999999;
  386. }
  387. }
  388. .right {
  389. display: flex;
  390. align-items: center;
  391. .time {
  392. font-size: 12px;
  393. font-family: PingFang SC;
  394. font-weight: 400;
  395. line-height: 17px;
  396. color: #333333;
  397. margin-right: 20px;
  398. }
  399. .time1 {
  400. color: #999999;
  401. }
  402. .con {
  403. font-size: 14px;
  404. font-weight: 400;
  405. line-height: 20px;
  406. color: #fc7200;
  407. padding-left: 20px;
  408. cursor: pointer;
  409. }
  410. .con1 {
  411. color: #999999;
  412. }
  413. .img {
  414. width: 20px;
  415. height: 20px;
  416. cursor: pointer;
  417. }
  418. }
  419. }
  420. }
  421. }
  422. </style>