deptSelect.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="mine">
  3. <scroll-view scroll-y class="body">
  4. <view class="bottom">
  5. <checkbox-group @change="checkboxChange" :value="optionData">
  6. <label class="litem-list" v-for="item in deptData" :key="item.value">
  7. <view>{{item.text}}</view>
  8. <checkbox :value="item.value" color="#49b856" :checked="item.checked" />
  9. </label>
  10. </checkbox-group>
  11. </view>
  12. </scroll-view>
  13. <view class="foot_common_btns">
  14. <button @click="goBackOrToList" type="default" class="cancelButton btn">返回</button>
  15. <button @click="submit" type="default" class="primaryButton btn">确认</button>
  16. </view>
  17. </view>
  18. </template>
  19. <script setup>
  20. import { ref, reactive } from 'vue'
  21. import { onLoad, onTabItemTap } from '@dcloudio/uni-app'
  22. import { api_incident_count, api_department, api_branch} from "@/http/api.js"
  23. import { defaultColor } from '@/static/js/theme.js'
  24. import { useSetTitle } from '@/share/useSetTitle.js'
  25. import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
  26. import { useLoginUserStore } from '@/stores/loginUser'
  27. import { useIncidentNumStore } from '@/stores/incidentNum'
  28. import { repositoryListSearchStore } from '@/stores/repositorySearch'
  29. import { useSetTabbar } from '@/share/useSetTabbar.js'
  30. import { useGoBack } from '@/share/useGoBack.js'
  31. useSetTitle();
  32. const loginUserStore = useLoginUserStore();
  33. const incidentNumStore = useIncidentNumStore();
  34. const { makePhoneCall } = useMakePhoneCall();
  35. const repositorySearchStore = repositoryListSearchStore();
  36. const { setTabbar } = useSetTabbar();
  37. const { goBack } = useGoBack();
  38. const deptData = ref([])
  39. const dataForm = reactive({
  40. dept: '',
  41. branch:''
  42. })
  43. const deptSelectData = ref(null)
  44. const deptSelectName = ref(null)
  45. const checkBox = ref([])
  46. const optionData = ref(null)
  47. const deptId = ref(null)
  48. // 是否提交
  49. const isSubmit = ref(false)
  50. const entranceType = ref(null)
  51. // 上一步或者返回列表
  52. function goBackOrToList(){
  53. goBack();
  54. }
  55. function checkboxChange (e) {
  56. var items = deptData.value;
  57. let values = e.detail.value;
  58. deptSelectName.value = []
  59. for (var i = 0, lenI = items.length; i < lenI; ++i) {
  60. const item = items[i]
  61. if(values.includes(item.value)){
  62. deptSelectName.value.push(item)
  63. }
  64. }
  65. }
  66. // 获取科室列表
  67. function getRepairTypes(){
  68. uni.showLoading({
  69. title: "加载中",
  70. mask: true,
  71. });
  72. let postData = {
  73. department: {
  74. hospital: Number(deptId.value),
  75. },
  76. idx:0,
  77. sum:9999
  78. }
  79. api_department(postData).then(res => {
  80. uni.hideLoading();
  81. res = res.list || [];
  82. deptData.value = res.map(v => ({
  83. text: v.dept,
  84. value: v.id+'',
  85. checked: false
  86. }));
  87. for(let i of deptData.value){
  88. for(let t of optionData.value){
  89. if(i.value == Number(t)){
  90. i.checked = true
  91. }
  92. }
  93. }
  94. if(optionData.value){
  95. checkBox.value = optionData.value
  96. }
  97. })
  98. }
  99. function submit(){
  100. let isId = null
  101. for(let x of deptSelectName.value){
  102. isId = deptData.value.find(i=>i.value == x.value)
  103. }
  104. if(!isId){
  105. deptSelectName.value = []
  106. uni.showToast({
  107. icon: 'none',
  108. title: '请先选择科室'
  109. });
  110. return
  111. }
  112. if(!deptSelectName.value){
  113. uni.showToast({
  114. icon: 'none',
  115. title: '请先选择科室'
  116. });
  117. return
  118. }
  119. let id = []
  120. let name = []
  121. for(let i of deptSelectName.value){
  122. id.push(i.value)
  123. name.push(i.text)
  124. }
  125. let data = {
  126. data:id,
  127. name:name
  128. }
  129. console.log(888,entranceType.value)
  130. if(entranceType.value=='home'){
  131. uni.reLaunch({
  132. url: '/pages/repair/config?data='+JSON.stringify(data)
  133. })
  134. }else{
  135. uni.navigateTo({
  136. url: `/pages/myRepair/myRepair?data=${JSON.stringify(data)}&type=2`
  137. })
  138. }
  139. }
  140. // 初始化
  141. // function onLoadFn(){
  142. // getRepairTypes()
  143. // }
  144. onLoad((option) => {
  145. console.log(123,option)
  146. let name = option.commonDeptName.split('/')
  147. if(option.data!='none'){
  148. let data = JSON.parse(option.data).split(',')
  149. optionData.value = data
  150. deptSelectName.value = []
  151. for(let i in optionData.value){
  152. deptSelectName.value.push({
  153. value:optionData.value[i],
  154. text:name[i]
  155. })
  156. }
  157. }
  158. deptId.value = option.deptId
  159. entranceType.value = option.type
  160. getRepairTypes();
  161. })
  162. // onTabItemTap(e => {
  163. // onLoadFn();
  164. // })
  165. </script>
  166. <style scoped>
  167. >>> .uni-data-tree-input{
  168. width: 100% !important;
  169. }
  170. >>> .input-value-border{
  171. border: none !important;
  172. }
  173. >>> .input-value{
  174. padding:0 !important;
  175. flex-direction: row-reverse !important;
  176. }
  177. >>> .selected-list{
  178. flex-direction: row-reverse !important;
  179. }
  180. >>> .arrow-area{
  181. display: none !important;
  182. }
  183. </style>
  184. <style lang="scss" scoped>
  185. .uni-checkbox-input:hover{
  186. border-color:#49b856;
  187. }
  188. .mine{
  189. display: flex;
  190. flex-direction: column;
  191. justify-content: space-between;
  192. background: #fff;
  193. .phone-filled{
  194. margin-right: 5rpx;
  195. }
  196. .newicon-xinjian2,
  197. .newicon-zhishiku{
  198. margin-right: 10rpx;
  199. }
  200. .body{
  201. height: 88vh;
  202. // padding: 0 30rpx;
  203. box-sizing: border-box;
  204. border-radius: 8rpx;
  205. .top{
  206. padding: 30rpx;
  207. background-color: #fff;
  208. .top_name{
  209. font-size: 28rpx;
  210. font-weight: bold;
  211. }
  212. .top_count{
  213. margin-top: 45rpx;
  214. display: flex;
  215. align-items: center;
  216. justify-content: space-between;
  217. .top_count_item{
  218. text-align: center;
  219. .name{
  220. color: #949494;
  221. font-size: 22rpx;
  222. }
  223. .value{
  224. font-size: 50rpx;
  225. font-weight: bold;
  226. margin-top: 15rpx;
  227. }
  228. }
  229. }
  230. }
  231. .bottom{
  232. background-color: #fff;
  233. margin-top: 15rpx;
  234. .litem-list{
  235. display: flex;
  236. justify-content: space-between;
  237. height: 70rpx;
  238. align-items: center;
  239. border-bottom: 1px solid #f5f5f5;
  240. padding: 0 20rpx;
  241. font-size: 28rpx;
  242. }
  243. .bottom_name{
  244. font-size: 26rpx;
  245. color: $uni-primary;
  246. padding: 21rpx 24rpx;
  247. }
  248. .bottom_list{
  249. .bottom_list_item{
  250. border-top: 1rpx solid #DEDEDE;
  251. padding: 30rpx 30rpx 30rpx 30rpx;
  252. display: flex;
  253. justify-content: space-between;
  254. align-items: center;
  255. font-size: 24rpx;
  256. position: relative;
  257. .value{
  258. max-width: 380rpx;
  259. color: #333;
  260. display: flex;
  261. align-items: center;
  262. text-align: justify;
  263. margin-right: 30rpx;
  264. }
  265. .no-mar{
  266. margin-right:0 !important;
  267. }
  268. .icon{
  269. position: absolute;
  270. right: 20rpx;
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. </style>