thr.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div id="thr">
  3. <el-row>
  4. <el-col :span="24" class="main">
  5. <el-form :model="form" :rules="rules" ref="form" label-width="90px">
  6. <el-col :span="24" class="thrList" v-for="(i, index) in question" :key="`thr${index}`">
  7. <el-col :span="2" class="label">
  8. {{ i.label }}
  9. </el-col>
  10. <el-col :span="21" class="select">
  11. <el-col :span="4" class="chiList" v-for="(f, index) in i.children" :key="`children${index}`">
  12. <el-col :span="24" class="chi_label">
  13. {{ f.label }}
  14. </el-col>
  15. <el-col :span="24" class="chi_select">
  16. <el-select v-model="form[f.model]" :disabled="disabled[f.model]" @change="toChange">
  17. <el-option v-for="(item, index) in getList(f.list)" :key="index" :value="item" :label="item"></el-option>
  18. </el-select>
  19. </el-col>
  20. </el-col>
  21. </el-col>
  22. </el-col>
  23. </el-form>
  24. </el-col>
  25. </el-row>
  26. </div>
  27. </template>
  28. <script>
  29. const _ = require('lodash');
  30. import { three } from '../fields.js';
  31. import * as select from '../select.js';
  32. import { mapState, createNamespacedHelpers } from 'vuex';
  33. export default {
  34. name: 'thr',
  35. props: {
  36. form: { type: Object },
  37. rules: { type: Object },
  38. },
  39. model: {
  40. prop: 'form',
  41. event: 'change',
  42. },
  43. components: {},
  44. data: function() {
  45. return {
  46. disabled: {},
  47. question: three,
  48. };
  49. },
  50. created() {},
  51. methods: {
  52. // 获取列表
  53. getList(type) {
  54. return select[type];
  55. },
  56. // 修改disabled
  57. toChange() {
  58. const d1 = _.get(this.form, 'charge');
  59. const d2 = _.get(this.form, 'gnum');
  60. let obj = {};
  61. if (d1 === '无技术团队') {
  62. const r = three.find(f => f.model === 'group');
  63. if (r) {
  64. const { children } = r;
  65. const keys = _.drop(children, 1).map(i => i.model);
  66. for (const key of keys) {
  67. obj[key] = true;
  68. }
  69. }
  70. }
  71. if (d2 === '无顾问团队') {
  72. const r = three.find(f => f.model === 'gw_group');
  73. if (r) {
  74. const { children } = r;
  75. const keys = _.drop(children, 1).map(i => i.model);
  76. for (const key of keys) {
  77. obj[key] = true;
  78. }
  79. }
  80. }
  81. this.$set(this, `disabled`, obj);
  82. },
  83. },
  84. computed: {
  85. ...mapState(['user']),
  86. },
  87. metaInfo() {
  88. return { title: this.$route.meta.title };
  89. },
  90. watch: {
  91. test: {
  92. deep: true,
  93. immediate: true,
  94. handler(val) {},
  95. },
  96. },
  97. };
  98. </script>
  99. <style lang="less" scoped>
  100. .main {
  101. .thrList {
  102. padding: 10px 0;
  103. border-bottom: 1px solid #ccc;
  104. .label {
  105. font-size: 14px;
  106. color: #606266;
  107. margin: 0 7px 0 0;
  108. padding: 5px 0;
  109. }
  110. .select {
  111. width: 90.8%;
  112. .chiList {
  113. width: 15.6%;
  114. margin: 0 10px 0 0;
  115. .chi_label {
  116. text-align: center;
  117. font-size: 14px;
  118. color: #606266;
  119. padding: 5px 0;
  120. }
  121. }
  122. .chiList:last-child {
  123. margin: 0;
  124. }
  125. }
  126. }
  127. .thrList:last-child {
  128. border-bottom: none;
  129. }
  130. }
  131. </style>