1
0

detail.vue 3.7 KB

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