shuyouGameTaskName-select.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <!--
  2. * @Author: YKH
  3. * @Date: 2022-09-05 20:50:57
  4. * @LastEditTime: 2022-09-16 23:31:58
  5. * @Description: file content
  6. * @FilePath: \cool-admin-3.x\cool-admin-vue-vue3-ts-vite\src\cool\modules\shuyou\components\shuyouGameTaskName-select.vue
  7. -->
  8. <template>
  9. <!-- <el-select v-model="value" v-bind="props" filterable multiple @change="onChange">
  10. <el-option v-for="(item, index) in list" :key="index" :value="item.id" :label="item.id+' [ '+item.task_name+' ] '" />
  11. </el-select> -->
  12. <el-select v-model="value" v-bind="props" filterable multiple @change="onChange"
  13. placeholder="可搜索">
  14. <el-option v-for="(item, index) in list" :key="index" :value="item.id"
  15. :label="item.id" />
  16. </el-select>
  17. </template>
  18. <script lang="ts">
  19. import { defineComponent, inject, onMounted, ref, watch } from "vue";
  20. // import { isArray } from "/@/core/utils";
  21. export default defineComponent({
  22. name: "shuyouGameTaskNameselect",
  23. props: {
  24. modelValue: [String, Number, Array],
  25. props: Object
  26. },
  27. emits: ["update:modelValue"],
  28. setup(props, { emit }) {
  29. // 请求服务
  30. const service = inject<any>("service");
  31. // 数据列表
  32. const list = ref<any[]>([]);
  33. // 绑定值
  34. const value = ref<any>();
  35. // 绑定值回调
  36. function onChange(val: any) {
  37. emit("update:modelValue", val);
  38. }
  39. // 解析值
  40. watch(
  41. () => props.modelValue,
  42. (val: any) => {
  43. value.value = val //(isArray(val) ? val : [val]).filter(Boolean);
  44. },
  45. {
  46. immediate: true
  47. }
  48. );
  49. onMounted(async () => {
  50. let aa = await service.shuyouGameTask.taskList()
  51. list.value = aa.data;
  52. // console.log(list.value)
  53. });
  54. return {
  55. list,
  56. value,
  57. onChange
  58. };
  59. }
  60. });
  61. </script>