detail.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="main">
  3. <view class="title">{{ item.title }}</view>
  4. <u-divider text="开始"></u-divider>
  5. <view class="item" v-for="(item, index) in item.op" :key="item.name">
  6. <view class="mtt">
  7. <text class="ifnull" v-if="item.ifnull == '必填'">*</text>
  8. <text class="index">{{ index + 1 }}、</text>
  9. <text class="tm">{{ item.name }}</text>
  10. <text class="dx">({{ item.input }})</text>
  11. </view>
  12. <view class="mts">
  13. <input v-if="item.input == '填空'" v-model="item.s_value" placeholder="请输入" />
  14. <input v-if="item.input == '数字'" type="number" v-model="item.s_value" placeholder="请输入" :disabled="look ? true : false" />
  15. <textarea v-if="item.input == '多行文本'" v-model="item.s_value" placeholder="请输入" />
  16. <view class="ops" v-if="item.input == '单选' || item.input == '多选' || item.input == '判断'">
  17. <view v-for="(op, i) in item.selects" :key="op.name">
  18. <view class="op" :class="{ active: op.check }" @click="check(item, op)">{{ op.name }}</view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <u-divider text="结束"></u-divider>
  24. <button class="btn">立即提交</button>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. look: false,
  32. item: {}
  33. };
  34. },
  35. onLoad(e) {
  36. this.http.request({
  37. url: '/app/follow/detail/' + e.id,
  38. success: (res) => {
  39. this.item = res.data.data;
  40. this.item.op = JSON.parse(this.item.op);
  41. }
  42. });
  43. },
  44. methods: {
  45. //单选或多选
  46. check(item, op) {
  47. if (this.look) {
  48. return;
  49. }
  50. if (item.input == '单选' || item.input == '判断') {
  51. item.selects.forEach((i) => (i.check = false));
  52. op.check = true;
  53. } else {
  54. op.check = !op.check;
  55. }
  56. this.$forceUpdate();
  57. },
  58. add() {
  59. let rule = [];
  60. let obj = {};
  61. this.item.op
  62. .filter((item) => item.ifnull == '必填')
  63. .forEach((item) => {
  64. rule.push({ name: item.name, checkType: 'notnull', errorMsg: '第' + (this.item.op.indexOf(item) + 1) + '项,' + item.name + '不能为空' });
  65. obj[item.name] = item.s_value;
  66. });
  67. if (!this.verify.check(obj, rule)) {
  68. uni.showModal({ content: this.verify.error, showCancel: false });
  69. return;
  70. }
  71. }
  72. }
  73. };
  74. </script>
  75. <style lang="scss">
  76. page {
  77. background-color: white;
  78. }
  79. .title {
  80. text-align: center;
  81. }
  82. .item {
  83. .mtt {
  84. text-align: left;
  85. font-size: 16px;
  86. padding: 15px 0px 12px 0px;
  87. position: relative;
  88. color: $font-c;
  89. .ifnull {
  90. color: red;
  91. font-weight: bold;
  92. }
  93. .tm {
  94. padding-left: 0px;
  95. }
  96. .dx {
  97. font-size: 12px;
  98. color: #646464;
  99. }
  100. }
  101. input {
  102. background-color: $inp;
  103. border-radius: 5px;
  104. padding: 12px;
  105. font-size: 14px;
  106. }
  107. textarea {
  108. background-color: $inp;
  109. border-radius: 5px;
  110. width: 93%;
  111. padding: 12px;
  112. font-size: 14px;
  113. height: 70px;
  114. }
  115. .ops {
  116. margin-top: -5px;
  117. overflow: hidden;
  118. .op {
  119. padding: 9px;
  120. background-color: $inp;
  121. margin-top: 10px;
  122. font-size: 14px;
  123. border-radius: 3px;
  124. color: #656363;
  125. float: left;
  126. margin-right: 10px;
  127. &.active {
  128. background-color: $main-color;
  129. color: white;
  130. }
  131. }
  132. }
  133. }
  134. </style>