detail.vue 3.8 KB

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