Newer
Older
smartKitchenFront / src / components / mycomponent / dialog / move / massageAddDialog.vue
liuyangyingjie on 26 Oct 2022 4 KB first commit
<template>
  <el-dialog
    :title="title"
    width="520px"
    :visible.sync="isShowInfo"
    append-to-body
    @close="close"
  >
    <!-- <dialog-header title="新增消息通知" @close="close"></dialog-header> -->
    <div class="brandDialog">
      <div class="inputContent">
        <div class="inputBox">
          <red-star />
          <input-vue
            title="消息标题"
            placeholder="请输入标题"
            width="300px"
            class="inputWidth"
            style="justify-content: space-between"
            v-model="massageInfo.messageTitle"
          ></input-vue>
        </div>
        <div class="inputBox">
          <red-star />
          <input-vue
            title="消息内容"
            class="inputWidth"
            style="justify-content: space-between"
          >
            <el-input
              style="width: 300px"
              type="textarea"
              :rows="3"
              placeholder="请输入内容"
              v-model="massageInfo.messageContent"
            >
            </el-input>
          </input-vue>
        </div>
        <div class="inputBox" style="align-items: baseline">
          <red-star />
          <input-vue
            title="目标用户"
            placeholder=""
            width="300px"
            class="inputWidth"
            style="justify-content: space-between; align-items: baseline"
          >
            <div style="width: 100%; padding-left: 58px">
              <div style="margin-top: 10px">
                <el-radio :label="1" v-model="massageInfo.userFlag"
                  >全部用户</el-radio
                >
              </div>
              {{checkList}}
              <div style="margin-top: 10px">
                <el-radio :label="0" v-model="massageInfo.userFlag"
                  >标签用户</el-radio
                >
                <div style="height: 80px; overflow: auto ;margin-top: 10px" v-if="massageInfo.userFlag==0">
                  <el-checkbox-group v-model="checkList"  :max="5"  >
                    <el-checkbox
                      v-for="item in ProvinceList"
                      :key="item.id"
                      :label="item.areaName"
                    ></el-checkbox>
                  </el-checkbox-group>
                </div>
              </div>
            </div>
          </input-vue>
        </div>
      </div>
      <div class="btnBox">
        <el-button type="primary" class="save" @click="save">确定</el-button>
        <el-button type="info" class="close" @click="close">取消</el-button>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import InputVue from "../../input/inputVue.vue";
import DialogHeader from "../dialogHeader.vue";
import RedStar from "../../redStar.vue";
import InputNumber from "../../input/inputNumber.vue";
import { add } from "../../../../api/move/message";
import { order_area } from "../../../../api/order/order";
export default {
  components: {
    DialogHeader,
    RedStar,
    InputVue,
    InputNumber,
  },
  props: {
    dataInfo: {},
    isShowInfo: {
      type: Boolean,
      default: true,
    },
    title: "",
  },
  mounted() {
    order_area("pid=0").then((res) => {
      console.log(res);
      this.ProvinceList = res;
    });
  },
  data() {
    return {
      checkList: [],
      ProvinceList: [],
      massageInfo: {
        messageTitle: "",
        messageContent: "",
        userFlag: 1,
        provinceList: [],
      },
    };
  },
  methods: {
    close() {
      this.$emit("close");
    },
    save() {
      if (this.title == "消息推送新增") {
         const temp = {...this.massageInfo }
         if(this.massageInfo.userFlag==0){
          temp.provinceList = this.checkList
         }
        add(temp).then((res) => {
          if (res != "") {
            this.$message.success("新增成功");
            this.close();
            this.massageInfo = {
              messageTitle: "",
              messageContent: "",
              userFlag: 1,
              provinceList: [],
            };
          }
        });
      }
    },

  },
};
</script>

<style lang="scss" scoped>
.brandDialog {
  width: 500px;
  .inputContent {
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    .inputBox {
      width: 100%;
      display: flex;
      align-items: center;
    }
  }
  .btnBox {
    padding: 30px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-evenly;

    .save,
    .close {
      width: 100px;
    }
  }
}
</style>