detail.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="main">
  3. <view class="title">{{ item.templateName }}</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="请输入" :disabled="item.state != 0" />
  14. <input v-if="item.input == '数字'" type="number" v-model="item.s_value" placeholder="请输入" :disabled="item.state != 0" />
  15. <textarea v-if="item.input == '多行文本'" v-model="item.s_value" placeholder="请输入" :disabled="item.state != 0" />
  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" @click="add()" v-if="item.state == 0">立即提交</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.item.state != 0) {
  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. item.s_value = op.check; //选中项
  57. this.$forceUpdate();
  58. },
  59. add() {
  60. let rule = [];
  61. let obj = {};
  62. this.item.op
  63. .filter((item) => item.ifnull == '必填')
  64. .forEach((item) => {
  65. rule.push({ name: item.name, checkType: 'notnull', errorMsg: '第' + (this.item.op.indexOf(item) + 1) + '项,' + item.name + '不能为空' });
  66. obj[item.name] = item.s_value;
  67. });
  68. if (!this.verify.check(obj, rule)) {
  69. uni.showModal({ content: this.verify.error, showCancel: false });
  70. return;
  71. }
  72. let data = JSON.parse(JSON.stringify(this.item));
  73. data.op = JSON.stringify(data.op);
  74. this.http.request({
  75. url: '/app/follow/push',
  76. data: data,
  77. method: 'POST',
  78. success: (res) => {
  79. uni.showModal({
  80. title: '提示',
  81. content: '感谢您的回访',
  82. showCancel: false,
  83. success: (res) => {
  84. uni.$emit('follow');
  85. uni.navigateBack();
  86. }
  87. });
  88. }
  89. });
  90. }
  91. }
  92. };
  93. </script>
  94. <style lang="scss">
  95. page {
  96. background-color: white;
  97. }
  98. .title {
  99. text-align: center;
  100. font-weight: bold;
  101. padding-bottom: 10px;
  102. }
  103. .item {
  104. .mtt {
  105. text-align: left;
  106. font-size: 16px;
  107. padding: 15px 0px 12px 0px;
  108. position: relative;
  109. color: $font-c;
  110. .ifnull {
  111. color: red;
  112. font-weight: bold;
  113. }
  114. .tm {
  115. padding-left: 0px;
  116. }
  117. .dx {
  118. font-size: 12px;
  119. color: #646464;
  120. }
  121. }
  122. input {
  123. background-color: $inp;
  124. border-radius: 5px;
  125. padding: 12px;
  126. font-size: 14px;
  127. }
  128. textarea {
  129. background-color: $inp;
  130. border-radius: 5px;
  131. width: 93%;
  132. padding: 12px;
  133. font-size: 14px;
  134. height: 70px;
  135. }
  136. .ops {
  137. margin-top: -5px;
  138. overflow: hidden;
  139. .op {
  140. padding: 9px;
  141. background-color: $inp;
  142. margin-top: 10px;
  143. font-size: 14px;
  144. border-radius: 3px;
  145. color: #656363;
  146. float: left;
  147. margin-right: 10px;
  148. &.active {
  149. background-color: $main-color;
  150. color: white;
  151. }
  152. }
  153. }
  154. }
  155. </style>