preference.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <div id="">
  3. <el-dialog
  4. :visible.sync="dialogVisible"
  5. width="628px"
  6. :show-close="false"
  7. :close-on-click-modal="false"
  8. >
  9. <div slot="title" class="hearders">
  10. <div class="leftTitle">配置优选</div>
  11. <div class="rightBoxs">
  12. <img
  13. src="@/assets/images/Close@2x.png"
  14. alt=""
  15. @click="dialogVisible = false"
  16. />
  17. </div>
  18. </div>
  19. <el-transfer
  20. :titles="['未选', '已选']"
  21. v-model="value"
  22. :data="transferData"
  23. :props="{
  24. key: 'id',
  25. label: 'name',
  26. }"
  27. ></el-transfer>
  28. <span slot="footer" class="dialog-footer">
  29. <el-button @click="close">取 消</el-button>
  30. <el-button type="primary" @click="submit">确 定</el-button>
  31. </span>
  32. </el-dialog>
  33. </div>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. transferData: [],
  40. value: [],
  41. dialogVisible: false,
  42. };
  43. },
  44. methods: {
  45. openBoxs(array) {
  46. let value = [];
  47. this.transferData = array.map((i) => {
  48. if (i.firstChoiceStatus == 1) {
  49. value.push(i.id);
  50. }
  51. i.disabled = i.type == 2 ? false : true;
  52. return i;
  53. });
  54. this.value = value;
  55. this.dialogVisible = true;
  56. },
  57. close() {
  58. this.dialogVisible = false;
  59. },
  60. submit() {
  61. let transferData = JSON.parse(JSON.stringify(this.transferData));
  62. transferData.forEach((i) => {
  63. delete i.disabled;
  64. if (this.value.includes(i.id)) {
  65. i.firstChoiceStatus = 1;
  66. } else {
  67. i.firstChoiceStatus = 0;
  68. }
  69. });
  70. this.$emit("update:tableDataInfos", transferData);
  71. this.close();
  72. },
  73. },
  74. };
  75. </script>
  76. <style lang="scss" scoped></style>