邃芒慧影管理端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 

87 rindas
2.0 KiB

  1. <template>
  2. <div>
  3. <el-checkbox-group v-model="checkboxGroup" size="small" class="checkbox">
  4. <el-checkbox v-for="(item, index) in tableData" :key="index" :label="item.id" border>
  5. <img :src="item.coverImg" width="50" />
  6. <p>{{ item.title }}</p>
  7. </el-checkbox>
  8. </el-checkbox-group>
  9. <div style="margin-top: 20px">
  10. <el-button @click="handleClose"
  11. >{{ $t('personMould.cancel') }}</el-button
  12. >
  13. <el-button type="primary" @click="addModel()">{{ $t('personMould.confirm') }}</el-button>
  14. </div>
  15. </div>
  16. </template>
  17. <script setup>
  18. import { ref } from 'vue'
  19. import { voiceMouldListApi, userVoiceIdListApi, associatedUserVoicesApi } from '@/apis/userManage.js'
  20. import dayjs from "dayjs";
  21. const emit = defineEmits(["close"]);
  22. const props = defineProps({
  23. serviceId: {
  24. required: true,
  25. }
  26. });
  27. const getDate = (val) => {
  28. return dayjs(val).format("YYYY-MM-DD");
  29. };
  30. const checkboxGroup = ref([])
  31. const total = ref(0);
  32. const tableData = ref([]);
  33. const modelAllListFunc = async () => {
  34. try {
  35. const res = await voiceMouldListApi(1, 10000);
  36. const modelIds = await userVoiceIdListApi(props.serviceId);
  37. tableData.value = res.data.list;
  38. total.value = res.data.total * 1;
  39. setTimeout(()=> {
  40. if(modelIds.data && modelIds.data.length > 0) {
  41. modelIds.data.forEach((item) => {
  42. checkboxGroup.value.push(item)
  43. })
  44. }
  45. }, 500)
  46. } catch (error) {
  47. console.log(error, "err");
  48. }
  49. };
  50. const addModel = async () => {
  51. const data = {
  52. mouldIds: checkboxGroup.value,
  53. cUserId: props.serviceId
  54. }
  55. const res = await associatedUserVoicesApi(data);
  56. if(res.code === 200) {
  57. ElMessage.success("关联成功!");
  58. handleClose()
  59. }
  60. };
  61. function handleClose() {
  62. emit("close");
  63. }
  64. onMounted(() => {
  65. modelAllListFunc(1, 10);
  66. });
  67. </script>
  68. <style lang="scss" scoped>
  69. .checkbox {
  70. max-height: 500px;
  71. overflow: auto;
  72. :deep .el-checkbox.el-checkbox--small {
  73. width: 110px;
  74. height:110px;
  75. margin-bottom: 10px;
  76. }
  77. }
  78. </style>