voiceSetting.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div class="voice">
  3. <div class="top-set">
  4. <div class="t-left">
  5. 自动接单
  6. </div>
  7. <div class="t-right">
  8. <el-switch @change="updateConfig" v-model="openAutoorder" :active-value="1" :inactive-value="0" />
  9. </div>
  10. </div>
  11. <div class="top-set">
  12. <div class="t-left">
  13. 自动配送(暂不支持预约单)
  14. <span @click="centerDialogVisible = true">[时长设置]</span>
  15. </div>
  16. <div class="t-right">
  17. <span>默认下单{{autodeliveryOrderTime}}分钟后</span>
  18. <el-switch @change="autodelivery" v-model="openAutodelivery" :active-value="1" :inactive-value="0" />
  19. </div>
  20. </div>
  21. <div class="top-set">
  22. <div class="t-left">
  23. 自动打印
  24. <span>(开启后将为您自动打印小票)</span>
  25. </div>
  26. <div class="t-right">
  27. <el-switch @change="updateConfig" v-model="openPrintSwitch" :active-value="1" :inactive-value="0" />
  28. </div>
  29. </div>
  30. <div class="voice-content">
  31. <div class="top-set" style="border-bottom: 1px solid #eee;">
  32. <div class="t-left">
  33. 语音播报
  34. </div>
  35. <div class="t-right">
  36. <span>一键开启</span>
  37. <el-switch @change="changeMessageStatus" v-model="msasterSwitch" :active-value="1" :inactive-value="0" />
  38. </div>
  39. </div>
  40. <div class="voice-list">
  41. <el-row>
  42. <el-col :span="8" v-for="(item, index) in voiceList" :key="index">
  43. <div class="item">
  44. <div class="left">
  45. <img src="../../../static/image/voice-icon.png" class="voice-icon" />
  46. <span>{{ item.name }}</span>
  47. </div>
  48. <div class="right">
  49. <el-switch @change="updateSavePushMessageStatus" v-model="item.msasterSwitch" :active-value="1" :inactive-value="0" />
  50. </div>
  51. </div>
  52. </el-col>
  53. </el-row>
  54. </div>
  55. </div>
  56. <!-- // 选择自动配送运力 -->
  57. <el-dialog title="自动配送设置" @close="cancel" :visible.sync="centerDialogVisible" width="800px" center>
  58. <el-input placeholder="请输入自动配送时长" v-model="autodeliveryOrderTime" clearable>
  59. <template slot="append">分钟</template>
  60. </el-input>
  61. <div class="delivery-list">
  62. <div @click="chooseDelivery(v.deliveryId)" :class="autodeliveryIds.includes(String(v.deliveryId)) ? 'delivery active' : 'delivery'" v-for="(v,i) in deliveryList" :key="i">{{v.name}}</div>
  63. </div>
  64. <span slot="footer" class="dialog-footer">
  65. <el-button size="medium" @click="cancel">取 消</el-button>
  66. <el-button size='medium' type="primary" @click="confirm">确 定</el-button>
  67. </span>
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import {
  73. getConfig,
  74. updateConfig,
  75. queryPushMessageStatus,
  76. updateSavePushMessageStatus,
  77. } from "../../api/setting.js";
  78. import { floorListDelivery } from "../../api/shop.js";
  79. export default {
  80. data() {
  81. return {
  82. voiceList: [],
  83. openAutodelivery: 0,
  84. openAutoorder: 0,
  85. openPrintSwitch: 0,
  86. autodeliveryOrderTime: 0,
  87. msasterSwitch: 0,
  88. centerDialogVisible: false,
  89. autodeliveryIds: [],
  90. deliveryList: [], // 运力列表
  91. };
  92. },
  93. created() {
  94. this.getConfig();
  95. this.queryPushMessageStatus();
  96. this.floorListDelivery();
  97. },
  98. methods: {
  99. cancel() {
  100. this.centerDialogVisible = false;
  101. this.openAutodelivery = 0;
  102. },
  103. confirm() {
  104. if (!this.autodeliveryIds.length) {
  105. return this.$message({
  106. type: "error",
  107. message: "开启自动配送必须选择至少一个运力平台!",
  108. });
  109. }
  110. this.centerDialogVisible = true;
  111. this.updateConfig();
  112. },
  113. chooseDelivery(deliveryId) {
  114. let id = String(deliveryId);
  115. if (this.autodeliveryIds.includes(id)) {
  116. this.autodeliveryIds = this.autodeliveryIds.filter((v) => {
  117. return v !== id;
  118. });
  119. } else {
  120. this.autodeliveryIds.push(id);
  121. }
  122. },
  123. floorListDelivery() {
  124. floorListDelivery().then((res) => {
  125. if (res.code === 200) {
  126. this.deliveryList = res.data;
  127. } else {
  128. this.$message({
  129. type: "error",
  130. message: res.msg,
  131. });
  132. }
  133. });
  134. },
  135. changeMessageStatus() {
  136. this.voiceList = this.voiceList.map((v) => {
  137. v.msasterSwitch = this.msasterSwitch;
  138. return v;
  139. });
  140. this.updateSavePushMessageStatus();
  141. },
  142. getConfig() {
  143. this.centerDialogVisible = false;
  144. getConfig().then((res) => {
  145. if (res.code === 200) {
  146. this.autodeliveryOrderTime = res.data.autodeliveryOrderTime / 60;
  147. this.openAutodelivery = res.data.openAutodelivery;
  148. this.openAutoorder = res.data.openAutoorder;
  149. this.openPrintSwitch = res.data.openPrintSwitch;
  150. this.autodeliveryIds = res.data.autodeliveryIds ? res.data.autodeliveryIds.split(",") : [];
  151. } else {
  152. this.$message({
  153. type: "error",
  154. message: res.msg,
  155. });
  156. }
  157. });
  158. },
  159. queryPushMessageStatus() {
  160. queryPushMessageStatus().then((res) => {
  161. if (res.code === 200) {
  162. this.voiceList = res.data;
  163. let msasterSwitchList = res.data.map((v) => {
  164. return v.msasterSwitch;
  165. });
  166. let msasterSwitch = [...new Set(msasterSwitchList)];
  167. this.msasterSwitch =
  168. msasterSwitch.length === 1 && msasterSwitch[0] === 1 ? 1 : 0;
  169. } else {
  170. this.$message({
  171. type: "error",
  172. message: res.msg,
  173. });
  174. }
  175. });
  176. },
  177. updateSavePushMessageStatus() {
  178. updateSavePushMessageStatus({ orderPushMessages: this.voiceList }).then(
  179. (res) => {
  180. if (res.code === 200) {
  181. this.$message({
  182. type: "success",
  183. message: "修改成功!",
  184. });
  185. this.queryPushMessageStatus();
  186. } else {
  187. this.$message({
  188. type: "error",
  189. message: res.msg,
  190. });
  191. }
  192. }
  193. );
  194. },
  195. autodelivery() {
  196. if (this.openAutodelivery === 1) {
  197. this.centerDialogVisible = true;
  198. } else {
  199. this.updateConfig();
  200. }
  201. },
  202. updateConfig() {
  203. let params = {
  204. autodeliveryOrderTime: this.autodeliveryOrderTime * 60,
  205. autodeliveryIds: this.autodeliveryIds.toString(),
  206. openAutodelivery: this.openAutodelivery,
  207. openAutoorder: this.openAutoorder,
  208. openPrintSwitch: this.openPrintSwitch,
  209. };
  210. updateConfig(params).then((res) => {
  211. if (res.code === 200) {
  212. this.$message({
  213. type: "success",
  214. message: "修改成功!",
  215. });
  216. this.getConfig();
  217. } else {
  218. this.$message({
  219. type: "error",
  220. message: res.msg,
  221. });
  222. }
  223. });
  224. },
  225. },
  226. };
  227. </script>
  228. <style lang="scss" scoped>
  229. .voice {
  230. .top-set {
  231. display: flex;
  232. justify-content: space-between;
  233. align-items: center;
  234. padding: 20px;
  235. background-color: #fff;
  236. .t-left {
  237. font-size: 16px;
  238. font-family: PingFang SC;
  239. font-weight: 600;
  240. color: #333333;
  241. span {
  242. cursor: pointer;
  243. font-size: 14px;
  244. font-family: PingFang SC;
  245. font-weight: 400;
  246. color: #175199;
  247. }
  248. }
  249. .t-right {
  250. font-size: 14px;
  251. font-family: PingFang SC;
  252. font-weight: 400;
  253. color: #b1b1b1;
  254. }
  255. }
  256. .voice-content {
  257. margin-top: 10px;
  258. .voice-list {
  259. background-color: #fff;
  260. .item {
  261. display: flex;
  262. justify-content: space-between;
  263. align-items: center;
  264. padding: 17px 22px 19px 18px;
  265. .left {
  266. display: flex;
  267. align-items: center;
  268. .voice-icon {
  269. width: 15px;
  270. height: 12px;
  271. margin-right: 4px;
  272. margin-top: 2px;
  273. }
  274. span {
  275. font-size: 14px;
  276. font-family: PingFang SC;
  277. font-weight: 400;
  278. color: #333333;
  279. }
  280. }
  281. }
  282. }
  283. }
  284. .delivery-list {
  285. display: flex;
  286. flex-wrap: wrap;
  287. margin-top: 20px;
  288. .delivery {
  289. margin: 0 20px 20px 0;
  290. width: 100px;
  291. height: 30px;
  292. line-height: 30px;
  293. text-align: center;
  294. border-radius: 25px;
  295. border: 1px solid #999;
  296. color: #999999;
  297. cursor: pointer;
  298. }
  299. .active {
  300. border: 1px solid #fc7200;
  301. color: #fff;
  302. background: #fc7200;
  303. }
  304. }
  305. }
  306. </style>