You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

266 regels
5.3 KiB

  1. <template>
  2. <view class="box">
  3. <view class="conmsg" v-if="allList.length!=0">
  4. <view class="conmsg-msg">
  5. <view v-for="(item,index) in allList" :key="index">
  6. <view class="">
  7. <view class="conmsg-msg-lab" :class="{mustSe: item.level == 1 && item.mustSelected == 0 }"
  8. style="border: none;">
  9. <view class="conmsg-msg-lab-1">
  10. {{item.name}}
  11. </view>
  12. </view>
  13. <view class="con-msg-con"
  14. :style="{borderBottom:index==allList.length-1?'none':'1px solid #E0E0E0'}">
  15. <view v-for='(item1,i) in item.children' :key='i' @click="Edittag(item,item1,index,i)"
  16. :style="{border:item1.selected==0?'1px solid #0A6EE9':'1px solid #E0E0E0'}"
  17. class="chebox">
  18. {{item1.label}}
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="submit">
  26. <view class="btn" @click="submit">
  27. 确定
  28. </view>
  29. </view>
  30. <view class="" style="height: 220rpx;"></view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. allList: [],
  38. customerId: ''
  39. }
  40. },
  41. onLoad(e) {
  42. this.customerId = e.id;
  43. this.getListByType()
  44. },
  45. methods: {
  46. Edittag(item, item1, index, i) {
  47. if (this.allList[index].children[i].selected == 0) {
  48. this.allList[index].children[i].selected = 1;
  49. } else {
  50. this.allList[index].children[i].selected = 0;
  51. }
  52. this.$forceUpdate()
  53. },
  54. // 字典表接口
  55. getListByType() {
  56. this.$u.get("/matchKeywords/findManualCalibration", {
  57. customerId: this.customerId,
  58. type: 2
  59. })
  60. .then(res => {
  61. res.forEach(item1 => {
  62. item1.children.map(item => {
  63. if (item.isInterval == 0) {
  64. item.label = item.name + item.unit + '-' + item.endName + item
  65. .unit;
  66. } else {
  67. item.label = item.name
  68. }
  69. item.value = item.id;
  70. })
  71. })
  72. this.allList = res
  73. })
  74. },
  75. // 提交
  76. submit() {
  77. let param = {
  78. keywordIds: '',
  79. id: this.customerId,
  80. projectId: uni.getStorageSync('buildingID').id,
  81. }
  82. let str = []
  83. let indexs = 0; //
  84. try {
  85. this.allList.forEach(item => {
  86. if (item.mustSelected == 0) {
  87. if (item.children.findIndex(item => item.selected == 0) == -1) {
  88. throw new Error(item.name)
  89. }
  90. }
  91. item.children.map(item1 => {
  92. if (item1.selected == 0) {
  93. str.push(item1.keywordsId)
  94. }
  95. })
  96. })
  97. } catch (e) {
  98. console.log(e)
  99. uni.showToast({
  100. title: `${e.message}为必选项~`,
  101. icon: 'none',
  102. duration: 2000
  103. })
  104. return
  105. }
  106. str = str.join(',')
  107. param.keywordIds = str
  108. this.$u.post("matchKeywords/updateManualCalibration", param).then(res => {
  109. uni.showToast({
  110. title: '操作成功',
  111. icon: 'none',
  112. success: () => {
  113. let sdd = {
  114. keywordIds: this.customerId,
  115. id: this.customerId,
  116. bg: 0,
  117. speaker: 0
  118. }
  119. let pages = getCurrentPages() //获取当前页面栈的信息
  120. let prevPage = pages[pages.length - 2] //获取上一个页面
  121. prevPage.setData({ //把需要回传的值保存到上一个页面
  122. info: sdd
  123. });
  124. uni.navigateBack()
  125. }
  126. })
  127. })
  128. },
  129. }
  130. }
  131. </script>
  132. <style lang="scss" scoped>
  133. .box {
  134. width: 100%;
  135. height: 100%;
  136. background: #F8F8F8;
  137. overflow: hidden;
  138. }
  139. .conmsg {
  140. background: #FFFFFF;
  141. margin-top: 20rpx;
  142. .conmsg-title {
  143. height: 92rpx;
  144. line-height: 92rpx;
  145. font-weight: bold;
  146. padding: 0 30rpx;
  147. // font-weight: 500;
  148. color: #303030;
  149. font-size: 32rpx;
  150. border-bottom: 1px solid #E0E0E0;
  151. }
  152. .conmsg-msg {
  153. padding: 0 30rpx;
  154. .conmsg-msg-lab {
  155. position: relative;
  156. height: 102rpx;
  157. display: flex;
  158. font-size: 30rpx;
  159. font-weight: 400;
  160. color: #333333;
  161. border-bottom: 1px solid #E0E0E0;
  162. line-height: 102rpx;
  163. &.mustSe::before {
  164. content: '*';
  165. color: red;
  166. position: absolute;
  167. left: -10rpx;
  168. right: -10rpx;
  169. z-index: 10;
  170. }
  171. .conmsg-msg-lab-1 {
  172. display: flex;
  173. min-width: 136rpx;
  174. .star {
  175. color: #E7483C;
  176. line-height: 108rpx;
  177. }
  178. }
  179. .conmsg-msg-lab-inp {
  180. margin-top: 30rpx;
  181. margin-left: 44rpx;
  182. }
  183. .conmsg-msg-lab-img {
  184. width: 14rpx;
  185. height: 30rpx;
  186. margin-top: 6rpx;
  187. margin-left: auto;
  188. image {
  189. width: 100%;
  190. height: 100%;
  191. }
  192. }
  193. }
  194. }
  195. }
  196. .submit {
  197. position: fixed;
  198. bottom: 20rpx;
  199. left: 20rpx;
  200. height: 120rpx;
  201. background: #FFFFFF;
  202. .btn {
  203. // margin: 60rpx auto;
  204. text-align: center;
  205. width: 690rpx;
  206. height: 88rpx;
  207. background: #2671E2;
  208. border-radius: 8rpx;
  209. font-size: 32tpx;
  210. font-weight: 400;
  211. color: #FFFFFF;
  212. line-height: 88rpx;
  213. }
  214. }
  215. .con-msg-con {
  216. display: flex;
  217. flex-wrap: wrap;
  218. // justify-content: space-around;
  219. border-bottom: 1px solid #E0E0E0;
  220. padding-bottom: 16rpx;
  221. .chebox {
  222. // width: 20%;
  223. height: 60rpx;
  224. line-height: 60rpx;
  225. // margin: 10rpx 0;
  226. margin-bottom: 25rpx;
  227. margin-right: 20rpx;
  228. border: 1px solid #E0E0E0;
  229. box-sizing: border-box;
  230. padding: 0 10rpx;
  231. }
  232. }
  233. .sexchose {
  234. width: 120rpx;
  235. height: 60rpx;
  236. background: #FFFFFF;
  237. border-radius: 4rpx;
  238. border: 1px solid #E0E0E0;
  239. text-align: center;
  240. line-height: 60rpx;
  241. margin-right: 20rpx;
  242. }
  243. </style>