voiceSetting.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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="open">[时长设置]</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="自动配送设置" :visible.sync="centerDialogVisible" width="800px" center>
  58. <el-input placeholder="请输入自动配送时长" v-model="input" clearable>
  59. </el-input>
  60. <div class="delivery-list">
  61. <div class="delivery" v-for="(v,i) in deliveryList" :key="i">{{v.name}}</div>
  62. </div>
  63. <span slot="footer" class="dialog-footer">
  64. <el-button size="mideum" @click="centerDialogVisible = false">取 消</el-button>
  65. <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  66. </span>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. import {
  72. getConfig,
  73. updateConfig,
  74. queryPushMessageStatus,
  75. updateSavePushMessageStatus,
  76. } from "../../api/setting.js";
  77. import { floorListDelivery } from '../../api/shop.js'
  78. export default {
  79. data() {
  80. return {
  81. voiceList: [],
  82. openAutodelivery: 0,
  83. openAutoorder: 0,
  84. openPrintSwitch: 0,
  85. input: 300,
  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. floorListDelivery(){
  100. floorListDelivery().then(res=>{
  101. if(res.code === 200){
  102. this.deliveryList = res.data
  103. }else{
  104. this.$message({
  105. type: 'error',
  106. message: res.msg
  107. })
  108. }
  109. })
  110. },
  111. changeMessageStatus() {
  112. this.voiceList = this.voiceList.map((v) => {
  113. v.msasterSwitch = this.msasterSwitch;
  114. return v;
  115. });
  116. this.updateSavePushMessageStatus();
  117. },
  118. getConfig() {
  119. getConfig().then((res) => {
  120. if (res.code === 200) {
  121. this.autodeliveryOrderTime = res.data.autodeliveryOrderTime / 60;
  122. this.openAutodelivery = res.data.openAutodelivery;
  123. this.openAutoorder = res.data.openAutoorder;
  124. this.openPrintSwitch = res.data.openPrintSwitch;
  125. this.autodeliveryIds = res.data.autodeliveryIds.split(',')
  126. } else {
  127. this.$message({
  128. type: "error",
  129. message: res.msg,
  130. });
  131. }
  132. });
  133. },
  134. queryPushMessageStatus() {
  135. queryPushMessageStatus().then((res) => {
  136. if (res.code === 200) {
  137. this.voiceList = res.data;
  138. let msasterSwitchList = res.data.map((v) => {
  139. return v.msasterSwitch;
  140. });
  141. let msasterSwitch = [...new Set(msasterSwitchList)];
  142. this.msasterSwitch =
  143. msasterSwitch.length === 1 && msasterSwitch[0] === 1 ? 1 : 0;
  144. } else {
  145. this.$message({
  146. type: "error",
  147. message: res.msg,
  148. });
  149. }
  150. });
  151. },
  152. updateSavePushMessageStatus() {
  153. updateSavePushMessageStatus({ orderPushMessages: this.voiceList }).then(
  154. (res) => {
  155. if (res.code === 200) {
  156. this.$message({
  157. type: "success",
  158. message: "修改成功!",
  159. });
  160. this.queryPushMessageStatus();
  161. } else {
  162. this.$message({
  163. type: "error",
  164. message: res.msg,
  165. });
  166. }
  167. }
  168. );
  169. },
  170. autodelivery() {
  171. if (this.openAutodelivery === 1) {
  172. this.centerDialogVisible = true;
  173. }
  174. },
  175. updateConfig() {
  176. let params = {};
  177. if (time) {
  178. params = {
  179. autodeliveryOrderTime: time * 60,
  180. openAutodelivery: this.openAutodelivery,
  181. openAutoorder: this.openAutoorder,
  182. openPrintSwitch: this.openPrintSwitch,
  183. };
  184. } else {
  185. params = {
  186. openAutodelivery: this.openAutodelivery,
  187. openAutoorder: this.openAutoorder,
  188. openPrintSwitch: this.openPrintSwitch,
  189. };
  190. }
  191. updateConfig(params).then((res) => {
  192. if (res.code === 200) {
  193. this.$message({
  194. type: "success",
  195. message: "修改成功!",
  196. });
  197. this.getConfig();
  198. } else {
  199. this.$message({
  200. type: "error",
  201. message: res.msg,
  202. });
  203. }
  204. });
  205. },
  206. open() {
  207. this.$prompt("请设置时长(分钟)", "开启自动配送", {
  208. confirmButtonText: "确定",
  209. cancelButtonText: "取消",
  210. inputValue: this.autodeliveryOrderTime,
  211. })
  212. .then(({ value }) => {
  213. this.updateConfig(value);
  214. })
  215. .catch(() => {
  216. this.$message({
  217. type: "info",
  218. message: "取消输入",
  219. });
  220. });
  221. },
  222. },
  223. };
  224. </script>
  225. <style lang="scss" scoped>
  226. .voice {
  227. .top-set {
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: center;
  231. padding: 20px;
  232. background-color: #fff;
  233. .t-left {
  234. font-size: 16px;
  235. font-family: PingFang SC;
  236. font-weight: 600;
  237. color: #333333;
  238. span {
  239. cursor: pointer;
  240. font-size: 14px;
  241. font-family: PingFang SC;
  242. font-weight: 400;
  243. color: #175199;
  244. }
  245. }
  246. .t-right {
  247. font-size: 14px;
  248. font-family: PingFang SC;
  249. font-weight: 400;
  250. color: #b1b1b1;
  251. }
  252. }
  253. .voice-content {
  254. margin-top: 10px;
  255. .voice-list {
  256. background-color: #fff;
  257. .item {
  258. display: flex;
  259. justify-content: space-between;
  260. align-items: center;
  261. padding: 17px 22px 19px 18px;
  262. .left {
  263. display: flex;
  264. align-items: center;
  265. .voice-icon {
  266. width: 15px;
  267. height: 12px;
  268. margin-right: 4px;
  269. margin-top: 2px;
  270. }
  271. span {
  272. font-size: 14px;
  273. font-family: PingFang SC;
  274. font-weight: 400;
  275. color: #333333;
  276. }
  277. }
  278. }
  279. }
  280. }
  281. .delivery-list {
  282. display: flex;
  283. flex-wrap: wrap;
  284. margin-top: 20px;
  285. .delivery {
  286. margin: 0 20px 20px 0;
  287. width: 100px;
  288. height: 30px;
  289. line-height: 30px;
  290. text-align: center;
  291. border-radius: 25px;
  292. border: 1px solid #999;
  293. color: #999999;
  294. cursor: pointer;
  295. }
  296. }
  297. }
  298. </style>