peopleManage.vue 6.71 KB
<template>
    <el-card class="container">
      <div class="title">
        <div
          class="add_btn"
          @click="addPeople"
        >
          {{ languageFormat(language, "新增", "Add") }}
        </div>
        {{ languageFormat(language, "观影人管理", "Viewers") }}
      </div>
      <div class="content">
        <div class="people_box">
          <div
            v-for="(it, index) in cousList"
            :key="index"
            class="people_item"
          >
            <div class="name">{{ it.name }}</div>
            <div class="idcard">
              {{ languageFormat(language, "证件号", "Identity Card") }}{{
                it.idCard
              }}
            </div>
            <div class="btn" @click="deletePeople(it.id)">
              {{ languageFormat(language, "删除", "delete") }}
            </div>
          </div>
        </div>
      </div>

      <el-dialog
        v-model="show"
        center
        title="新增观影人"
        width="700"
      >
        <el-form ref="formRef" :model="form" :rules="rules" label-width="80px" size="large" style="margin: 80px">
          <el-form-item label="姓名" required prop="name">
            <el-input v-model="form.name" size=""></el-input>
          </el-form-item>
          <el-form-item label="证件号" required prop="idCard">
            <el-input v-model="form.idCard"></el-input>
          </el-form-item>
        </el-form>

        <br>
        <br>
        <span slot="footer" class="dialog-footer">
        <div style="text-align: center">
          <el-button class="can_pay" @click="show = false">取 消</el-button>
          <el-button class="pay" type="primary" @click="submit">确 定</el-button>
        </div>
      </span>
        <br>
        <br>
        <br>
      </el-dialog>
    </el-card>

</template>


<script setup>
import {reactive, ref} from "vue";
import {customerListApi,aadCustomer,delCustomer} from '@/apiPc/booking'

import {deleteViewPeople, viewPeopleList} from "@/viewsPc/seat/api/index.js";
import {ElMessageBox, ElMessage} from "element-plus";
import {languageFormat} from "@/viewsPc/seat/utils/language.js";
import {useStorage} from "@vueuse/core/index";

const language = useStorage("language", 0);

const audience = reactive({
  data: [],
  fetchData() {
    viewPeopleList().then((res) => {
      audience.data = res.data;
    });
  },

  deletePeople(id) {
    ElMessageBox.confirm(
        languageFormat(
          language.value,
          "确认删除该观看人吗?",
          "Are you sure to delete this viewer?"
        ),
        languageFormat(language.value, "提示", "Reminder"),
        {
          confirmButtonText: languageFormat(language.value, "确认", "confirm"),
          cancelButtonText: languageFormat(language.value, "取消", "cancel"),
          type: "warning",
          draggable: true,
        }
      )
      .then(() => {
        deleteViewPeople({id}).then(() => {
          audience.fetchData();
          ElMessage({
            type: "success",
            message: languageFormat(
              language.value,
              "操作成功",
              "Operate successfully"
            ),
          });
        });
      })
      .catch(() => {
      });
  },
});

const cousList = ref([])
const show = ref(false)
const form = ref({})
const formRef = ref(null)
const rules = ref({
  name: [
    {required: true, message: "请输入姓名", trigger: "blur"},
  ],
  idCard: [
    {required: true, message: "请输入证件号", trigger: "blur"},
  ],
})

customerList()
async function customerList() {
  const res = await customerListApi()
  // cousList.value = res.rows
  cousList.value = [{},{}]
}

function addPeople() {
  show.value = true
  formRef.value?.resetFields()
}

function submit() {
  formRef.value.validate((valid) => {
    if (valid) {
      console.log(form.value);
      aadCustomer(form.value).then(res=>{
        show.value = false
        customerList()
        ElMessage.success('添加成功')
      })
    } else {
      return ElMessage.waiting('请完善信息')
    }
  })
}

async function deletePeople(v){
  const res =await delCustomer(v.id)
  if(res.code===200){
    ElMessage.success('删除成功')
    await customerList()
  }
}
</script>


<style lang="scss" scoped>
div {
  box-sizing: border-box;
}

:deep(.el-dialog) {
  padding: 0;

  .el-dialog__header {
    height: 50px;
    line-height: 50px;
    background: linear-gradient(270deg, #493ceb 0%, #8623fc 100%);

    .el-dialog__title {
      color: #fff;
    }
  }
}

.pay {
  width: 200px;
  height: 40px;
  background: linear-gradient(270deg, #493ceb 0%, #8623fc 100%);
  border-radius: 20px;
  font-weight: 500;
  font-size: 16px;
  color: #ffffff;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
}

.can_pay {
  width: 200px;
  height: 40px;
  background: #f6f6f6;
  border-radius: 20px;
  font-weight: 500;
  font-size: 16px;
  color: #999;
  line-height: 40px;
  text-align: center;
  box-sizing: border-box;
  cursor: pointer;
}

.container {
  //padding: 20px 0;
  //:deep(.el-card__body){
  //  padding: 0;
  //}
  width: 1200px;
  margin: 20px auto;

  .title {
    position: relative;
    padding: 11px;
    text-align: center;
    background: linear-gradient(270deg, #493ceb 0%, #8623fc 100%);
    font-size: 18px;
    color: #ffffff;

    .add_btn {
      position: absolute;
      left: 20px;
      top: 50%;
      transform: translateY(-50%);
      width: 68px;
      height: 24px;
      border-radius: 12px;
      border: 1px solid #ffffff;
      font-weight: 400;
      font-size: 12px;
      color: #ffffff;
      text-align: center;
      line-height: 24px;
      box-sizing: border-box;
      user-select: none;
      cursor: pointer;
    }
  }

  .content {
    min-height: 590px;
    background-color: #fff;
    box-shadow: 0px 0px 46px 0px rgba(1, 16, 64, 0.08);
    padding: 20px;

    .people_box {
      display: flex;
      flex-wrap: wrap;
      gap: 20px;

      .people_item {
        width: 275px;
        height: 137px;
        background: #ffffff;
        border: 1px solid #dcdfe6;
        padding: 16px;

        .name {
          font-weight: 600;
          font-size: 16px;
          color: #2d373f;
          line-height: 22px;
        }

        .idcard {
          font-size: 16px;
          color: #95a1a6;
          line-height: 22px;
          margin-top: 12px;
          margin-bottom: 17px;
        }

        .btn {
          width: 69px;
          height: 32px;
          background: #e7e6ff;
          font-weight: 400;
          font-size: 16px;
          color: #493ceb;
          line-height: 32px;
          text-align: center;
          cursor: pointer;
          user-select: none;
        }
      }
    }
  }
}

@media screen and (max-width: 768px) {
  .container {
    width: 100%;
  }
}
</style>