123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- <template>
- <div class="voice">
- <div class="top-set">
- <div class="t-left">
- 自动接单
- </div>
- <div class="t-right">
- <el-switch @change="updateConfig" v-model="openAutoorder" :active-value="1" :inactive-value="0" />
- </div>
- </div>
- <div class="top-set">
- <div class="t-left">
- 自动配送(暂不支持预约单)
- <span @click="centerDialogVisible = true">[时长设置]</span>
- </div>
- <div class="t-right">
- <span>默认下单{{autodeliveryOrderTime}}分钟后</span>
- <el-switch @change="autodelivery" v-model="openAutodelivery" :active-value="1" :inactive-value="0" />
- </div>
- </div>
- <div class="top-set">
- <div class="t-left">
- 自动打印
- <span>(开启后将为您自动打印小票)</span>
- </div>
- <div class="t-right">
- <el-switch @change="updateConfig" v-model="openPrintSwitch" :active-value="1" :inactive-value="0" />
- </div>
- </div>
- <div class="voice-content">
- <div class="top-set" style="border-bottom: 1px solid #eee;">
- <div class="t-left">
- 语音播报
- </div>
- <div class="t-right">
- <span>一键开启</span>
- <el-switch @change="changeMessageStatus" v-model="msasterSwitch" :active-value="1" :inactive-value="0" />
- </div>
- </div>
- <div class="voice-list">
- <el-row>
- <el-col :span="8" v-for="(item, index) in voiceList" :key="index">
- <div class="item">
- <div class="left">
- <img src="../../../static/image/voice-icon.png" class="voice-icon" />
- <span>{{ item.name }}</span>
- </div>
- <div class="right">
- <el-switch @change="updateSavePushMessageStatus" v-model="item.msasterSwitch" :active-value="1" :inactive-value="0" />
- </div>
- </div>
- </el-col>
- </el-row>
- </div>
- </div>
- <!-- // 选择自动配送运力 -->
- <el-dialog title="自动配送设置" @close="cancel" :visible.sync="centerDialogVisible" width="800px" center>
- <el-input placeholder="请输入自动配送时长" v-model="autodeliveryOrderTime" clearable>
- <template slot="append">分钟</template>
- </el-input>
- <div class="delivery-list">
- <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>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button size="medium" @click="cancel">取 消</el-button>
- <el-button size='medium' type="primary" @click="confirm">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- getConfig,
- updateConfig,
- queryPushMessageStatus,
- updateSavePushMessageStatus,
- } from "../../api/setting.js";
- import { floorListDelivery } from "../../api/shop.js";
- export default {
- data() {
- return {
- voiceList: [],
- openAutodelivery: 0,
- openAutoorder: 0,
- openPrintSwitch: 0,
- autodeliveryOrderTime: 0,
- msasterSwitch: 0,
- centerDialogVisible: false,
- autodeliveryIds: [],
- deliveryList: [], // 运力列表
- };
- },
- created() {
- this.getConfig();
- this.queryPushMessageStatus();
- this.floorListDelivery();
- },
- methods: {
- cancel() {
- this.centerDialogVisible = false;
- this.openAutodelivery = 0;
- },
- confirm() {
- if (!this.autodeliveryIds.length) {
- return this.$message({
- type: "error",
- message: "开启自动配送必须选择至少一个运力平台!",
- });
- }
- this.centerDialogVisible = true;
- this.updateConfig();
- },
- chooseDelivery(deliveryId) {
- let id = String(deliveryId);
- if (this.autodeliveryIds.includes(id)) {
- this.autodeliveryIds = this.autodeliveryIds.filter((v) => {
- return v !== id;
- });
- } else {
- this.autodeliveryIds.push(id);
- }
- },
- floorListDelivery() {
- floorListDelivery().then((res) => {
- if (res.code === 200) {
- this.deliveryList = res.data;
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- },
- changeMessageStatus() {
- this.voiceList = this.voiceList.map((v) => {
- v.msasterSwitch = this.msasterSwitch;
- return v;
- });
- this.updateSavePushMessageStatus();
- },
- getConfig() {
- this.centerDialogVisible = false;
- getConfig().then((res) => {
- if (res.code === 200) {
- this.autodeliveryOrderTime = res.data.autodeliveryOrderTime / 60;
- this.openAutodelivery = res.data.openAutodelivery;
- this.openAutoorder = res.data.openAutoorder;
- this.openPrintSwitch = res.data.openPrintSwitch;
- this.autodeliveryIds = res.data.autodeliveryIds ? res.data.autodeliveryIds.split(",") : [];
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- },
- queryPushMessageStatus() {
- queryPushMessageStatus().then((res) => {
- if (res.code === 200) {
- this.voiceList = res.data;
- let msasterSwitchList = res.data.map((v) => {
- return v.msasterSwitch;
- });
- let msasterSwitch = [...new Set(msasterSwitchList)];
- this.msasterSwitch =
- msasterSwitch.length === 1 && msasterSwitch[0] === 1 ? 1 : 0;
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- },
- updateSavePushMessageStatus() {
- updateSavePushMessageStatus({ orderPushMessages: this.voiceList }).then(
- (res) => {
- if (res.code === 200) {
- this.$message({
- type: "success",
- message: "修改成功!",
- });
- this.queryPushMessageStatus();
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- }
- );
- },
- autodelivery() {
- if (this.openAutodelivery === 1) {
- this.centerDialogVisible = true;
- } else {
- this.updateConfig();
- }
- },
- updateConfig() {
- let params = {
- autodeliveryOrderTime: this.autodeliveryOrderTime * 60,
- autodeliveryIds: this.autodeliveryIds.toString(),
- openAutodelivery: this.openAutodelivery,
- openAutoorder: this.openAutoorder,
- openPrintSwitch: this.openPrintSwitch,
- };
- updateConfig(params).then((res) => {
- if (res.code === 200) {
- this.$message({
- type: "success",
- message: "修改成功!",
- });
- this.getConfig();
- } else {
- this.$message({
- type: "error",
- message: res.msg,
- });
- }
- });
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .voice {
- .top-set {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20px;
- background-color: #fff;
- .t-left {
- font-size: 16px;
- font-family: PingFang SC;
- font-weight: 600;
- color: #333333;
- span {
- cursor: pointer;
- font-size: 14px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #175199;
- }
- }
- .t-right {
- font-size: 14px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #b1b1b1;
- }
- }
- .voice-content {
- margin-top: 10px;
- .voice-list {
- background-color: #fff;
- .item {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 17px 22px 19px 18px;
- .left {
- display: flex;
- align-items: center;
- .voice-icon {
- width: 15px;
- height: 12px;
- margin-right: 4px;
- margin-top: 2px;
- }
- span {
- font-size: 14px;
- font-family: PingFang SC;
- font-weight: 400;
- color: #333333;
- }
- }
- }
- }
- }
- .delivery-list {
- display: flex;
- flex-wrap: wrap;
- margin-top: 20px;
- .delivery {
- margin: 0 20px 20px 0;
- width: 100px;
- height: 30px;
- line-height: 30px;
- text-align: center;
- border-radius: 25px;
- border: 1px solid #999;
- color: #999999;
- cursor: pointer;
- }
- .active {
- border: 1px solid #fc7200;
- color: #fff;
- background: #fc7200;
- }
- }
- }
- </style>
|