checkStandardSelect.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="wrap">
  3. <page-nav :desc="desc" :title="title"></page-nav>
  4. <view class="container">
  5. <uni-list>
  6. <uni-list-item v-for="(item, index) in dictList" :key="index">
  7. <template v-slot:body>
  8. <image slot="icon" class="u-cell-icon" :src="getIcon('cell')" mode="widthFix"></image>
  9. <view @click="selectItem(item)">
  10. <text>{{item.dictValue}}</text>
  11. </view>
  12. </template>
  13. </uni-list-item>
  14. </uni-list>
  15. </view>
  16. <!-- <view class="list-wrap">
  17. <u-cell-group title-bg-color="rgb(243, 244, 246)" :title="item.groupName" v-for="(item, index) in dictList"
  18. :key="index">
  19. <u-cell-item :titleStyle="{fontWeight: 500}" @click="selectItem(item1)" :title="item1.dictValue"
  20. v-for="(item1, index1) in item.list" :key="index1">
  21. <image slot="icon" class="u-cell-icon" :src="getIcon('cell')" mode="widthFix"></image>
  22. </u-cell-item>
  23. </u-cell-group>
  24. </view> -->
  25. <u-gap height="70"></u-gap>
  26. </view>
  27. </template>
  28. <script>
  29. import pageNav from '@/components/page-nav/page-nav.vue';
  30. import http from '@/http/api.js'
  31. export default {
  32. components: {
  33. pageNav
  34. },
  35. onLoad(option) {
  36. let dictId = option.id;
  37. // let dictList = {};
  38. // dictList['groupName'] = '列表信息';
  39. var list = [];
  40. http.request({
  41. url: '/galaxy-system/dict-biz/list?parentId=' + dictId,
  42. method: 'GET'
  43. }).then(res => {
  44. console.log(res.data)
  45. if (res.data != null) {
  46. const dictLength = res.data['length'];
  47. for (var i = 0; i < dictLength; i++) {
  48. let dict = res.data['' + i];
  49. list.push(dict);
  50. }
  51. }
  52. }).catch(err => {
  53. console.log(err)
  54. })
  55. // dictList['list'] = list;
  56. this.dictList = list;
  57. },
  58. data() {
  59. return {
  60. dictList: [],
  61. title: '选择问题隐患标签',
  62. desc: ''
  63. }
  64. },
  65. computed: {
  66. getIcon() {
  67. return path => {
  68. return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
  69. }
  70. },
  71. },
  72. onShow() {
  73. uni.setNavigationBarTitle({
  74. title: ""
  75. });
  76. },
  77. created() {
  78. },
  79. methods: {
  80. selectItem(dict) {
  81. const that = this;
  82. const parentId = dict['id'];
  83. uni.showLoading({
  84. title: '处理中'
  85. });
  86. http.request({
  87. url: '/galaxy-system/dict-biz/list',
  88. method: 'GET',
  89. params: {
  90. parentId
  91. }
  92. }).then(res => {
  93. uni.hideLoading()
  94. if (res.data != null) {
  95. const dictLength = res.data['length'];
  96. if (dictLength > 0) {
  97. let basisDict = res.data[0];
  98. var subDict = {
  99. id: basisDict['id'],
  100. dictKey: basisDict['dictKey'],
  101. dictValue: basisDict['dictValue'],
  102. };
  103. uni.$emit("handClickStandardSelect", {
  104. id: dict['id'],
  105. dictKey: dict['dictKey'],
  106. dictValue: dict['dictValue'],
  107. subDict: subDict
  108. });
  109. uni.navigateBack();
  110. } else {
  111. var subDict = {
  112. id: '',
  113. dictKey: '',
  114. dictValue: '',
  115. };
  116. uni.$emit("handClickStandardSelect", {
  117. id: dict['id'],
  118. dictKey: dict['dictKey'],
  119. dictValue: dict['dictValue'],
  120. subDict: subDict
  121. });
  122. uni.navigateBack();
  123. // uni.showModal({
  124. // content: '此标准下没有依据!',
  125. // showCancel: false
  126. // });
  127. }
  128. } else {
  129. // uni.showModal({
  130. // content: '此标准下没有依据!',
  131. // showCancel: false
  132. // });
  133. var subDict = {
  134. id: '',
  135. dictKey: '',
  136. dictValue: '',
  137. };
  138. uni.$emit("handClickStandardSelect", {
  139. id: dict['id'],
  140. dictKey: dict['dictKey'],
  141. dictValue: dict['dictValue'],
  142. subDict: subDict
  143. });
  144. uni.navigateBack();
  145. }
  146. }).catch(err => {
  147. uni.hideLoading()
  148. console.log(err)
  149. })
  150. },
  151. }
  152. }
  153. </script>
  154. <style>
  155. /* page {
  156. background-color: rgb(240, 242, 244);
  157. } */
  158. </style>
  159. <style lang="scss" scoped>
  160. .u-cell-icon {
  161. width: 36rpx;
  162. height: 36rpx;
  163. margin-right: 8rpx;
  164. }
  165. .slot-box {
  166. /* #ifndef APP-NVUE */
  167. display: flex;
  168. /* #endif */
  169. flex-direction: row;
  170. align-items: center;
  171. }
  172. .slot-image {
  173. /* #ifndef APP-NVUE */
  174. display: block;
  175. /* #endif */
  176. margin-right: 10px;
  177. width: 30px;
  178. height: 30px;
  179. }
  180. .slot-text {
  181. flex: 1;
  182. font-size: 14px;
  183. color: #4cd964;
  184. margin-right: 10px;
  185. }
  186. </style>