123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- <template>
- <view class="consumableList">
- <view class="head">
- <uni-search-bar v-model="dataInfo.keyWord" :placeholder="placeHolder" bgColor="#F8F8F8" @input="search" cancelButton="none" focus :radius="18" />
- </view>
- <view class="body" v-if="dataInfo.list.length">
- <view class="body_item ellipsis" v-for="data in dataInfo.list" :key="data.id" @click="clickItem(data)">
- {{data.dept}}
- </view>
- </view>
- <view class="zanwu" v-else>
- <text class="newicon newicon-zanwu"></text>
- </view>
- <view class="foot_common_btns">
- <button @click="goBackPage" type="default" class="primaryButton btn">返回</button>
- </view>
- </view>
- </template>
- <script setup>
- import { debounce } from 'lodash-es'
- import { ref, reactive} from 'vue'
- import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
- import { api_department, api_incidentDetail, api_addSummaryDoc } from "@/http/api.js"
- import { defaultColor } from '@/static/js/theme.js'
- import { useSetTitle } from '@/share/useSetTitle.js'
- import { useLoginUserStore } from '@/stores/loginUser'
- import { useIncidentBuildStore } from '@/stores/incidentBuild'
- import { useGoBack } from '@/share/useGoBack.js'
-
- useSetTitle();
- const loginUserStore = useLoginUserStore();
- const incidentBuildStore = useIncidentBuildStore();
- const { goBack } = useGoBack();
-
- // 主题颜色
- const primaryColor = ref(defaultColor)
-
- // placeHolder
- const placeHolder = ref('');
-
- const entranceType = ref(null);
-
- // 院区id
- const branchId = ref(null);
-
- // 数据
- const dataInfo = reactive({
- list: [],//工单列表
- idx: 0,//页码
- hasMore: true,//是否有更多数据
- incidentData: {},//事件对象
- keyWord: '',//搜索的关键词
- })
-
- // 搜索
- const search = debounce(getList.bind(null, 0), 500);
-
- // 获取列表信息
- function getList(idx){
- if(dataInfo.keyWord.trim() === ''){
- dataInfo.list = [];
- uni.stopPullDownRefresh();
- return;
- }
-
- uni.showLoading({
- title: "加载中",
- mask: true,
- });
-
- dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
- if(dataInfo.idx === 0){
- dataInfo.list = [];
- }
- let postData = {
- idx: dataInfo.idx,
- sum: 20,
- department: {
- hospital:{
- id:''
- },
- // branch: dataInfo.incidentData.branch,
- // searchType: 'quickStart',
- // selectType: 'pinyin_qs',
- dept: dataInfo.keyWord,
- }
- }
- if(entranceType.value=='repair' || entranceType.value=='config'){
- if(branchId.value){
- postData.department.hospital.id = branchId.value
- }
- }else{
- if(loginUserStore.loginUser.user.currentHospital.parent){
- postData.department.hospital.id = loginUserStore.loginUser.user.currentHospital.parent.id
- }else{
- postData.department.hospital.id = loginUserStore.loginUser.user.currentHospital.id
- }
- }
- api_department(postData).then(res => {
- uni.hideLoading();
- uni.stopPullDownRefresh();
- if(res.status == 200){
- let list = res.list || [];
- if(list.length){
- dataInfo.hasMore = true;
- dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
- }else{
- dataInfo.hasMore = false;
- }
- }else{
- uni.showToast({
- icon: 'none',
- title: res.msg || '请求数据失败!'
- });
- }
- })
- }
-
- function goBackPage(){
- // goBack()
- if(entranceType.value=='config'){
- uni.reLaunch({
- url: `/pages/repair/config?type=selectDept`
- })
- }else{
- goBack()
- }
- }
-
- // 点击
- function clickItem(data){
- if(entranceType.value=='repair'){
- let query = {
- department:null,
- departmentName:null,
- branch:branchId.value
- }
- let rapidRepNextData = uni.getStorageSync('rapidRepNext')
- if(rapidRepNextData){
- let parseData = JSON.parse(rapidRepNextData)
- query.department = data.id//报修科室
- query.departmentName = data.dept//报修科室
- let repairData = {
- ...parseData,
- ...query
- }
- uni.setStorageSync('rapidRepNext',JSON.stringify(repairData))
- }else{
- query.department = data.id//报修科室
- query.departmentName = data.dept//报修科室
- uni.setStorageSync('rapidRepNext',JSON.stringify(query))
- }
- uni.navigateTo({
- url: '/pages/repair/rapidRepNext'
- })
- }else if(entranceType.value=='config'){
- let query = {
- dept:null,
- departmentName:null,
- branch:branchId.value
- }
- let configNewData = uni.getStorageSync('configData')
- if(configNewData){
- let parseData = JSON.parse(configNewData)
- query.dept = data.id//报修科室
- query.departmentName = data.dept//报修科室
- // parseData.dataType = true
- let configData = {
- ...parseData,
- ...query
- }
- uni.setStorageSync('configData',JSON.stringify(configData))
- uni.reLaunch({
- url: `/pages/repair/config?type=selectDept`
- })
- }else{
- query.dept = data.id//报修科室
- query.departmentName = data.dept//报修科室
- uni.setStorageSync('configData',JSON.stringify(query))
- }
- }else{
- dataInfo.incidentData.department = data;
- incidentBuildStore.setIncidentBuildData(dataInfo.incidentData, incidentBuildStore.incidentBuild.type, incidentBuildStore.incidentBuild.sign);
- uni.navigateTo({
- url: '/pages/buildIncident/buildIncident'
- })
- }
- }
-
- onLoad((option) => {
- if(option.type){
- entranceType.value = option.type
- branchId.value = option.branchId
- }
- if(incidentBuildStore.incidentBuild.data){
- dataInfo.incidentData = incidentBuildStore.incidentBuild.data;
- }
- if(incidentBuildStore.incidentBuild.type === 'buildIncident' && incidentBuildStore.incidentBuild.sign === 'department'){
- placeHolder.value = '请搜索报修科室'
- }
- getList(0);
- })
-
- onPullDownRefresh(() => {
- getList(0)
- })
-
- onReachBottom(() => {
- dataInfo.idx += 1;
- if (dataInfo.hasMore) {
- getList(); // 当触底时加载更多数据
- }
- })
- </script>
- <style lang="scss" scoped>
- .consumableList{
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .head{
- height: 88rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 0 24rpx;
- position: fixed;
- z-index: 99;
- width: 100%;
- box-sizing: border-box;
- background: linear-gradient( 90deg, #58CF66 0%, #DDE9FC 100%);
- }
- .body{
- margin-bottom: 140rpx;
- margin-top: 88rpx;
- font-size: 26rpx;
- .body_item{
- border-bottom: 1rpx solid #DEDEDE;
- padding: 24rpx;
- }
- }
- .zanwu{
- margin-bottom: 140rpx;
- margin-top: 88rpx;
- display: flex;
- justify-content: center;
- .newicon-zanwu{
- font-size: 256rpx;
- color: #D6D6D6;
- margin-top: 140rpx;
- }
- }
- .foot_common_btns{
- position: fixed;
- left: 0;
- bottom: 0;
- background-color: #fff;
- }
- }
- </style>
|